ZKsync OS is a state transition function implementation that enables multiple execution environments (EVM, EraVM, Wasm, etc.) to operate within a unified ecosystem. It is implemented in Rust and compiled into a RISC-V binary, which can later be proven using ZKsync Airbender.
The most recent documentation can be found here:
Run the following commands to prepare your environment (only needed once):
rustup target add riscv32i-unknown-none-elf
cargo install cargo-binutils && rustup component add llvm-tools-previewZKsync OS is built for two targets:
- Your host platform, used by the sequencer to execute blocks/batches.
- RISC-V, used to produce a binary that is later proved by a RISC-V prover (Airbender).
cargo build --workspaceTo build RISC-V binaries in a reproducible way, use the following command (requires Docker):
./zksync_os/reproduce/reproduce.shNavigate to the zksync_os directory and run:
./dump_bin.sh --type for-testsFor other build modes, check zksync_os/dump_bin.sh.
Build zksync_os first for tests that execute the proof-running path:
cd zksync_os && ./dump_bin.sh --type for-testsRun workspace tests:
cargo test --workspaceNote: cargo test --workspace does not include directories excluded in root Cargo.toml (for example zksync_os, tests/fuzzer, tests/evm_tester, tests/instances/eth_runner).
Integration tests are mainly organized in tests/instances/ using the rig in tests/rig/.
Examples:
cargo test -p transactions -- --nocapture
cargo test -p precompiles -- --nocaptureUnit tests are organized in corresponding modules.
By default, many tests execute the RISC-V simulator to validate the behavior of the RISC-V-compiled ZKsync OS binary, but they do not generate full proofs. You can run proving by enabling the e2e_proving feature while running tests, for example:
cargo test --features e2e_proving -p transactions -- --nocaptureAlternatively, you can prove tests manually using this guide: Proving tests with CLI.
The repository also contains the EVM tester setup in tests/evm_tester.
Prepare fixtures once:
cd tests/evm_tester && ./download_ethereum_fixtures.shRun the tester:
cd tests/evm_tester && cargo run --bin evm-tester --release --features zksync_os_forward_system/no_printZKsync OS is distributed under the terms of either
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/blog/license/mit/)
at your option.
