Skip to content

Commit

Permalink
bin refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Jun 7, 2024
1 parent f7a7652 commit 8f77094
Show file tree
Hide file tree
Showing 23 changed files with 161 additions and 229 deletions.
29 changes: 14 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ serde_json = "1.0"
tokio = { version = "1.32", features = ["full"] }

halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.11.0rc8", default-features = false, features = ["parallel_syn", "scroll"] }
zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag ="v0.11.0rc8", default-features = false, features = ["parallel_syn", "scroll"] }
prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "refactor/witness-building", default-features = false, features = ["parallel_syn", "scroll"] }
integration = { path = "integration" }

[patch.crates-io]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test: ## Run tests for all the workspace members
@cargo test --release -p integration --test unit_tests

mock:
@cargo test --features prove_verify --release test_mock_prove -- --exact --nocapture
@cargo test --release -p integration --test mock_tests test_mock_prove -- --exact --nocapture

mock-testnet:
@cargo run --bin mock_testnet --release
Expand Down
22 changes: 1 addition & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,8 @@ Could use the following command to run binaries locally.

Run zkevm prover to generate chunk proof (work directory is `./integration`)
```shell
cargo build --release --bin zkevm_prove

./target/release/zkevm_prove --help
```
Could specify arguments as
```shell
# Proof data will be saved to `./integration/proof_data`.
export OUTPUT_DIR="proof_data"

# Params file should be located in `./integration/params`.
cargo run --release --bin zkevm_prove -- --params=params --trace=tests/extra_traces/new.json
```

Run zkevm verifier to verify chunk proof (work directory is `./integration`)
```shell
cargo build --release --bin zkevm_verify

./target/release/zkevm_verify --help
```
Could specify arguments as
```shell
cargo run --release --bin zkevm_verify -- --params=params --proof=proof_data
cargo run --release --bin chain_prover -- --params=params --trace=tests/extra_traces/batch_34700/chunk_1236462/block_4176564.json
```

### Dockers
Expand Down
12 changes: 4 additions & 8 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ prover.workspace = true
integration.workspace = true

[[bin]]
name = "zkevm_prove"
path = "src/zkevm_prove.rs"
name = "trace_prover"
path = "src/trace_prover.rs"

[[bin]]
name = "zkevm_verify"
path = "src/zkevm_verify.rs"

[[bin]]
name = "mock_testnet"
path = "src/mock_testnet.rs"
name = "chain_prover"
path = "src/chain_prover.rs"

[features]
default = []
Expand Down
14 changes: 7 additions & 7 deletions bin/src/mock_testnet.rs → bin/src/chain_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use prover::{
};
use std::env;

mod l2geth;
mod prove;
mod rollupscan;
mod l2geth_client;
mod prove_utils;
mod rollupscan_client;

const DEFAULT_BEGIN_BATCH: i64 = 1;
const DEFAULT_END_BATCH: i64 = i64::MAX;
Expand All @@ -25,9 +25,9 @@ async fn main() {
prepare_circuit_capacity_checker();
log::info!("mock-testnet: prepared ccc");

let l2geth = l2geth::Client::new("mock-testnet", &setting.l2geth_api_url)
let l2geth = l2geth_client::Client::new("mock-testnet", &setting.l2geth_api_url)
.unwrap_or_else(|e| panic!("mock-testnet: failed to initialize ethers Provider: {e}"));
let rollupscan = rollupscan::Client::new("mock-testnet", &setting.rollupscan_api_url);
let rollupscan = rollupscan_client::Client::new("mock-testnet", &setting.rollupscan_api_url);

for batch_id in setting.begin_batch..=setting.end_batch {
let chunks = rollupscan
Expand Down Expand Up @@ -70,7 +70,7 @@ async fn main() {
continue;
}

let chunk_proof = prove::prove_chunk(
let chunk_proof = prove_utils::prove_chunk(
&format!("mock-testnet: batch-{batch_id} chunk-{chunk_id}"),
&witness_block,
);
Expand All @@ -81,7 +81,7 @@ async fn main() {
}

#[cfg(feature = "batch-prove")]
prove::prove_batch(&format!("mock-testnet: batch-{batch_id}"), chunk_proofs);
prove_utils::prove_batch(&format!("mock-testnet: batch-{batch_id}"), chunk_proofs);
}

log::info!("mock-testnet: END");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions bin/src/trace_prover.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use clap::Parser;
use integration::test_util::prove_and_verify_chunk;
use prover::utils::init_env_and_log;
use std::env;

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
/// Get params dir path.
#[clap(short, long = "params", default_value = "params")]
params_path: String,
/// Get asserts dir path.
#[clap(short, long = "assets", default_value = "test_assets")]
assets_path: String,
/// Get BlockTrace from file or dir.
#[clap(
short,
long = "trace",
default_value = "tests/extra_traces/batch_34700/chunk_1236462/block_4176564.json"
)]
trace_path: String,
}

fn main() {
// Layer config files are located in `./integration/configs`.
env::set_current_dir("./integration").unwrap();
let output_dir = init_env_and_log("trace_prover");
log::info!("Initialized ENV and created output-dir {output_dir}");

let args = Args::parse();
prove_and_verify_chunk(
&args.trace_path,
Some("test"),
&args.params_path,
&args.assets_path,
&output_dir,
);
}
64 changes: 0 additions & 64 deletions bin/src/zkevm_prove.rs

This file was deleted.

32 changes: 0 additions & 32 deletions bin/src/zkevm_verify.rs

This file was deleted.

Loading

0 comments on commit 8f77094

Please sign in to comment.