consenzero
is a Proof of Concept of integrating zkVM with the current Ethereum Consensus layer. It will leverage lighthouse and RISC Zero.
- The "host" program 👷 - Retrieves the beacon state and beacon block from wild, feeds them to the guest to prove the state transition and broadcasts the receipt to the attester program.
- The "guest" program 📜 - Contains the actual beacon state transition function (STF) to be compiled into an ELF for 1) the host to prove and 2) the attester to verify the state transition.
- The "attester" program 🕵️ - Listens for a broadcasted receipt, verifies that the receipt is valid (follows the expected state transition function defined in the ELF), progresses its internal beacon state, and announces the receipt's validity.
- The host 👷 retrieves a beacon state at a specific slot number (simulates a sync'ed client).
- The host 👷 initializes the guest 📜 with the retrieved beacon state.
- The host 👷 listens for a beacon block broadcast (simulates block building).
- The host 👷 submits the newly broadcasted block to the guest 📜 to prove (simulates block sealing).
- The guest 📜 returns a receipt to the host 👷.
- The host 👷 broadcasts the receipt to the attester 🕵️ (simulates a block proposal)..
- The attester 🕵️ verifies the receipt, progresses its beacon state, and announces the receipt's validity (simulates block attestation).
consenzero
├── Cargo.toml
├── host
│ ├── Cargo.toml
│ └── src
│ └── main.rs <-- [Host code goes here]
└── methods
├── Cargo.toml
├── build.rs
├── guest
│ ├── Cargo.toml
│ └── src
│ └── method_name.rs <-- [Guest code goes here]
└── src
└── lib.rs
First, make sure [rustup] is installed. The
[rust-toolchain.toml
][rust-toolchain] file will be used by cargo
to
automatically install the correct version.
To build all methods and execute the method within the zkVM, run the following command:
cargo run -- --slot-number <SLOT_NUMBER>
This is an empty template, and so there is no expected output (until you modify the code).
During development, faster iteration upon code changes can be achieved by leveraging [dev-mode], we strongly suggest activating it during your early development phase. Furthermore, you might want to get insights into the execution statistics of your project, and this can be achieved by specifying the environment variable RUST_LOG="[executor]=info"
before running your project.
Put together, the command to run your project in development mode while getting execution statistics is:
RUST_LOG="[executor]=info" RISC0_DEV_MODE=1 cargo run -- --slot-number <SLOT_NUMBER>
Once you've reached a point where you're ready to generate real proofs, you can do so by setting RISC0_DEV_MODE=0. Generating proofs locally would be achieved by running the following:
RISC0_DEV_MODE=0 cargo run --release -- --slot-number <SLOT_NUMBER>
To gain insights into your application's performance, you can obtain executor statistics by setting the RUST_LOG environment variable to info.
Setting this filter will print statistics about the execution before proof generation, so you can understand how computationally expensive your application is. Since the statistics concern only the executor phase, it is recommended to run your application in dev-mode to avoid the overhead of proof generation:
RISC0_DEV_MODE=1 RUST_LOG=info cargo run --release -- --slot-number <SLOT_NUMBER>
The statistics include:
- Total Cycles
- Session Cycle
- Segments Count
- Execution time