arkworks-rs / std Goto Github PK
View Code? Open in Web Editor NEWA standard library wrapper for use in the `arkworks` ecosystem
Home Page: https://www.arkworks.rs
License: Apache License 2.0
A standard library wrapper for use in the `arkworks` ecosystem
Home Page: https://www.arkworks.rs
License: Apache License 2.0
It would be nice if WASM tooling could be added. Short of creating a full webapp, it would be cool if people could simply benchmark performance on their browser. This is related to arkworks-rs/algebra#79 , and the WebGPU benchmarks in browser mode can also be added there.
WASM-specific optimisations may also have to be considered under given compilation options.
I have to investigate how to integrate WebGPU into a WASM compilation pipeline. I don't think it's too hard.
Currently, there is a lot of ambiguity in the naming, requiring downstream user to check the original def to get confirmation of what it does. This makes it much clearer.
There is also precedent in the naming in usize methods, for the function next_power_of_two
.
When the std
feature is on, algebra_core
chooses to reexport the std::io
library instead of using its own io
package. However, some of the implementation in the io
package is inconsistent with the std::io
library. It might cause some confusion and user has to handle both cases when inconsistency happens.
For example, when user tries to use the Error struct in the io
package, when in no_std
mode, it is fine to return Err(algebra_core::io::Error)
, while when the std
feature is on it won't compile.
It is because the IO Error implemented by algebra_core is
pub struct Error;
while Error in std::io is
pub struct Error {
repr: Repr,
}
It might be better to make algebra_core::io
more consistent to the standard library, or just use the io
package instead of reexporting std::io
package regardless of whether std
feature is on or off to avoid confusion.
This is related to a number of dependabot's pledges petitions to bump up the version of rand.
arkworks-rs/nonnative#22
arkworks-rs/r1cs-std#31
#15
arkworks-rs/gm17#8
arkworks-rs/algebra#151
arkworks-rs/groth16#19
It would be easy if all these repos use ark_std::rand:...
for the needed traits.
In addition, it would be great if we can handle the rand_xorshift
in r1cs_std
and algebra
as well. If we are likely to keep them, it may be useful to import them here as well (since a majority of the repos would use algebra
anyway).
ark_std::error
replaces core::error
when not using std, but it winds up woefully inferior to the core::error
behind #[feature(error_in_core)]
. In particular ark_std::error::Error
should've the downcast*
methods on core::error::Error
.
We should probably copy core::error
to ark_std::error
. Ain't much relevant in the real std::error
anymore. If possible, we should detect #[feature(error_in_core)]
or even nightly, so as to not replace core::error
then.
Interestingly, there were never std::io
references in std::error
per se. It appears backtrace messed up moving std::error
to core::error
, but I've no idea why backtrace cannot work with just alloc, or be placed into an extension trait, or whatever.
We should add a method either on UniformRand or on a trait thats auto-derivable for traits with UniformRand and Zero, in order to sample non-zero elements
Originally posted by @ValarDragon in arkworks-rs/groth16#16 (comment)
It seems that ark-std does not compile in no_std, here's the error:
Compiling ark-std v0.1.0 (https://github.com/arkworks-rs/utils/#423b772d)
error[E0432]: unresolved import `alloc::sync`
Error: --> /cargo/git/checkouts/utils-540e2bc5e2565ace/423b772/std/src/lib.rs:35:20
|
35 | pub use alloc::sync::*;
| ^^^^ could not find `sync` in `alloc`
Use web_worker
to create a new rayon::ThreadPool
to enable parallelization on wasm
.
The wasm
app will need a initialization for the global ThreadPool, so probably something like this:
fn set_global_pool_to_web_workers() {
let concurrency = match web_sys::window() {
Some(window) => window.navigator().hardware_concurrency() as usize,
None => {
console_log!("Failed to get hardware concurrency from window. This function is only available in the main browser thread.");
2
}
};
let worker_pool = pool::WorkerPool::new(concurrency);
rayon::ThreadPoolBuilder::new()
.num_threads(concurrency)
.spawn_handler(|thread| Ok(pool.run(|| thread.run()).unwrap()))
.build()?;
}
cc @kobigurk @howardwu, this is of interest for speeding up proving and setup ceremonies in the browser.
Note that this repo we still have the old README from Zexe, and it might be useful to draft a new PR.
Are we migrating to the new trace crate, or has it been completed already, perhaps?
UniformRand
can be replaced by the providers in rand
to reduce code complexity
The base field types need to implement Standard: Distribution<T>
as RNG requirement. Example:
This is superseded by CryptoRng that wraps cryptographic requirements without requiring concrete implementations in T
.
UniformRand
by RngCore + CryptoRng
UniformRand
I find an issue in my program.
I am trying to spawn thread to run some tasks and the tasks call start_timer and then panic before end_timer. It is normal in my program so I just handle the panic error from thread and try to do other tasks in new spawn threads.
After panic happens some times, my program hang at busy print dot infinitely.
I cannot stable reproduce it but after reviewing the code, I think it is very probably because of the overflow issue when global static INDENT_NUM exceed some number and makes this indent_amount exceed 75 and cause the issue.
https://docs.rs/ark-std/latest/src/ark_std/perf_trace.rs.html#125
After each panic of my spawn thread, I can see more and more dots before Start: and End: logging in my programe and finally if it exceed 75 and the next time when I call a end_timer will trigger the infinitely printing of dot.
I think it would be nice to have a feature that when activated, will print out the timings for various sub-procedures. A nice standardised format for printing the name of the function and the line numbers could be nice.
When the feature is not activated, this code is not compiled.
The thing I find most annoying is uninstrumenting code, only to discover I want to look at some sub function timings, and I have to reinstrument the code...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.