-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(l2): prover comparison benchmarks (#1221)
**Motivation** To compare the L2 prover performance with rsp. **Description** - adds a `prove` command to the L2 CLI to prove a block from genesis and chain files - adds a cache for rsp containing a L1 mainnet block - adds some rules to the prover's Makefile to run the comparison (rsp proving a 24 MGas mainnet block, ethrex proving a 25 MGas L2 block) --------- Co-authored-by: Javier Rodríguez Chatruc <49622509+jrchatruc@users.noreply.github.com>
- Loading branch information
Showing
13 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use clap::Args; | ||
use ethrex_l2::utils::test_data_io::{generate_program_input, read_chain_file, read_genesis_file}; | ||
use ethrex_prover_lib::prover::Prover; | ||
|
||
#[derive(Args)] | ||
pub(crate) struct Command { | ||
#[clap( | ||
short = 'g', | ||
long = "genesis", | ||
help = "Path to the file containing the genesis block." | ||
)] | ||
genesis: String, | ||
#[clap( | ||
short = 'c', | ||
long = "chain", | ||
help = "Path to the file containing the test chain." | ||
)] | ||
chain: String, | ||
#[clap( | ||
short = 'n', | ||
long = "block-number", | ||
help = "Number of the block in the test chain to prove." | ||
)] | ||
block_number: usize, | ||
} | ||
|
||
impl Command { | ||
pub fn run(self) -> eyre::Result<()> { | ||
let genesis = read_genesis_file(&self.genesis); | ||
let chain = read_chain_file(&self.chain); | ||
let program_input = generate_program_input(genesis, chain, self.block_number)?; | ||
|
||
let mut prover = Prover::new(); | ||
prover.prove(program_input).expect("proving failed"); | ||
println!( | ||
"Total gas consumption: {}", | ||
prover | ||
.get_gas() | ||
.expect("failed to deserialize gas consumption") | ||
); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rsp/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
.PHONY: perf_test_proving perf_gpu rsp_comparison | ||
|
||
ROOT_DIRECTORY := ../../.. | ||
|
||
RISC0_DEV_MODE?=1 | ||
RUST_LOG?="info" | ||
perf_test_proving: | ||
@echo "Using RISC0_DEV_MODE: ${RISC0_DEV_MODE}" | ||
RISC0_DEV_MODE=${RISC0_DEV_MODE} RUST_LOG=${RUST_LOG} cargo test --release --test perf_zkvm --features build_zkvm -- --show-output | ||
.PHONY: perf_test_proving | ||
|
||
perf_gpu: | ||
RUSTFLAGS="-C target-cpu=native" RISC0_DEV_MODE=0 RUST_LOG="debug" cargo test --release --test perf_zkvm --features "build_zkvm,gpu" -- --show-output | ||
.PHONY: perf_gpu | ||
|
||
# L2 Prover comparison with rsp. Uses GPU by default. | ||
|
||
ETHREX_L2_BIN := ./target/release/ethrex_l2 | ||
RSP_BIN := ./target/release/rsp | ||
|
||
GENESIS_FILE := $(ROOT_DIRECTORY)/test_data/genesis-l2-old.json | ||
CHAIN_FILE := $(ROOT_DIRECTORY)/test_data/l2-loadtest.rlp | ||
RSP_CACHE := $(ROOT_DIRECTORY)/test_data/rsp | ||
|
||
rsp_comparison: $(ETHREX_L2_BIN) $(RSP_BIN) | ||
@echo "rsp times (L1 Mainnet block, 24 MGas):" | ||
@time $(RSP_BIN) --prove \ | ||
--chain-id 1 \ | ||
--block-number 21272632 \ | ||
--cache-dir $(RSP_CACHE) \ | ||
>/dev/null | ||
@echo "" | ||
@echo "ethrex_l2 times (L2 block, 25 MGas):" | ||
@RISC0_DEV_MODE=false time $(ETHREX_L2_BIN) prove \ | ||
--genesis $(GENESIS_FILE) \ | ||
--chain $(CHAIN_FILE) \ | ||
--block-number 2 \ | ||
>/dev/null | ||
|
||
$(ETHREX_L2_BIN): | ||
CARGO_TARGET_DIR=target cargo build -r --manifest-path $(ROOT_DIRECTORY)/Cargo.toml --bin ethrex_l2 --features "build_zkvm,gpu,disable-dev-mode" | ||
|
||
$(RSP_BIN): | ||
- git clone https://github.com/succinctlabs/rsp.git | ||
cd rsp; \ | ||
CARGO_TARGET_DIR=../target cargo build -r --bin rsp --features cuda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use ethrex_blockchain::error::ChainError; | ||
use ethrex_storage::error::StoreError; | ||
use ethrex_vm::errors::ExecutionDBError; | ||
use keccak_hash::H256; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum ProverInputError { | ||
#[error("Invalid block number: {0}")] | ||
InvalidBlockNumber(usize), | ||
#[error("Invalid parent block: {0}")] | ||
InvalidParentBlock(H256), | ||
#[error("Store error: {0}")] | ||
StoreError(#[from] StoreError), | ||
#[error("Chain error: {0}")] | ||
ChainError(#[from] ChainError), | ||
#[error("ExecutionDB error: {0}")] | ||
ExecutionDBError(#[from] ExecutionDBError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pub mod db; | ||
mod errors; | ||
pub mod errors; | ||
pub mod execution_db; | ||
mod execution_result; | ||
#[cfg(feature = "l2")] | ||
|
Binary file not shown.