-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(l2): prover comparison benchmarks #1221
Merged
Merged
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6dc7653
added bench crate and makefile rules
xqft 588d9bf
rename binaries
xqft 3fbfb78
Merge branch 'main' into l2/comparison_bench
xqft d31d83f
add Prove command
xqft 0f18fea
Merge branch 'main' into l2/comparison_bench
xqft eb9e1e4
fix Prove cmd
xqft 17c6fd0
added gas consumption stdout to zkvm program
xqft 9b245c8
remove bench crate
xqft 8331368
remove bench crate from Cargo.toml
xqft 02bb9a9
add commands for comparison to Makefile
xqft cceadd3
add rsp input cache
xqft a001efc
add .gitignore
xqft b41fe04
Merge branch 'main' into l2/comparison_bench
xqft f4524e2
disable dev mode
xqft 2e327e4
fix stdout redirect
xqft 8619d1e
ignore git clone error
xqft 6fbbcba
fix stdout
xqft 577db3a
Merge branch 'main' into l2/comparison_bench
xqft a054edf
Merge branch 'main' into l2/comparison_bench
xqft dc099a8
Merge branch 'main' into l2/comparison_bench
jrchatruc 67da075
Merge branch 'main' into l2/comparison_bench
jrchatruc 975378c
fix clippy
xqft 894a512
Merge branch 'main' into l2/comparison_bench
xqft e4c5ad3
Update prover.rs
xqft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 2>&1 | ||
@echo "" | ||
@echo "ethrex_l2 times (L2 block, 25 MGas):" | ||
@RISC0_DEV_MODE=1 time $(ETHREX_L2_BIN) prove \ | ||
--genesis $(GENESIS_FILE) \ | ||
--chain $(CHAIN_FILE) \ | ||
--block-number 2 \ | ||
> /dev/null 2>&1 | ||
|
||
$(ETHREX_L2_BIN): | ||
CARGO_TARGET_DIR=target cargo build -r --manifest-path $(ROOT_DIRECTORY)/Cargo.toml --bin ethrex_l2 --features "build_zkvm,gpu" | ||
|
||
$(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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
RISC0_DEV_MODE=0
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! good catch, thanks!!