We recommend to use nix for installing the correct version of rust and additional libraries:
> curl -L https://nixos.org/nix/install | sh
> . ~/.nix-profile/etc/profile.d/nix.sh
> nix-shell
> cargo build
To avoid manually activating the nix shell each time the direnv shell extension can be used to activate the environment when entering the local directory with the checkout of this repo. Note that direnv needs to be installed first, and to be hooked into the shell to function.
To allow direnv
for this repo run
direnv allow
from within the local checkout of this repo.
The pre-commit hooks are installed via the nix shell. To run them on all files use
> pre-commit run --all-files
> cargo test --release
Note that by default the release mode does not check integers overflow. In order to enforce this check run:
> ./scripts/run_tests.sh
We use grcov for test coverage
> ./scripts/test_coverage.sh
> cargo doc --open
To format your code run
> cargo fmt
- To update the nix packages run
./nix/update-nix
. - To update the rust overlay run
./nix/update-rust-overlay
.
To use the updates enter a new nix-shell
.
Refer to the nix/vagrant directory.
Currently, a benchmark for verifying Merkle paths is implemented.
The additional flags allow using assembly implementation of square_in_place
and mul_assign
within arkworks:
> RUSTFLAGS='-Ctarget-cpu=native -Ctarget-feature=+bmi2,+adx' cargo bench --bench=merkle_path
For benchmark, run:
RAYON_NUM_THREADS=N cargo bench
where N is the number of threads you want to use (N = 1 for single-thread).
A sample benchmark result is available under bench.md
.