Skip to content

Commit

Permalink
running...
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Jun 7, 2024
1 parent 8f77094 commit e703d47
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ prover/tests/traces/bridge/*.proof

# ignore local logs
*.log
outputs
*.sh

# ignore local parameters
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

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

10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ make download-setup -e degree=DEGREE params_dir=PARAMS_DIR
And there are other tests:
- `make test-inner-prove` could be used to test the first-level circuit.
- `make test-batch-prove` could be used to test the final two levels.
- `make test-batches-with-each-chunk-num-prove` could be used to test batch proving with different chunk numbers.

### Binaries

Expand All @@ -45,17 +44,12 @@ Could use the following command to run binaries locally.
Run zkevm prover to generate chunk proof (work directory is `./integration`)
```shell
# Params file should be located in `./integration/params`.
cargo run --release --bin chain_prover -- --params=params --trace=tests/extra_traces/batch_34700/chunk_1236462/block_4176564.json
cargo run --release --bin trace_prover -- --params=params --trace=tests/extra_traces/batch_34700/chunk_1236462/block_4176564.json
```

### Dockers

- `docker/chunk-prover` is used to build and run GPU chunk-prover.
- `docker/mock-testnet` is used to build and run GPU mock-testnet (inner-prove or chunk-prove).

### Verifier Contract

Both YUL and bytecode of verifier contract could be generated when running aggregation tests (`make test-e2e-prove`). After running aggregation tests, a new folder is created in `integration` folder of scroll-prover and named like `integration/outputs/agg_tests_*`. It contains below files:
Both YUL and bytecode of verifier contract could be generated when running aggregation tests (`make test-e2e-prove`). After running aggregation tests, a new folder is created in `integration` folder of scroll-prover and named like `integration/outputs/e2e_tests_*`. It contains below files:

- Chunk protocol: `chunk_chunk_0.protocol`
- Chunk VK: `vk_chunk_0.vkey`
Expand Down
32 changes: 16 additions & 16 deletions bin/src/chain_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,45 @@ const DEFAULT_END_BATCH: i64 = i64::MAX;

#[tokio::main]
async fn main() {
init_env_and_log("mock_testnet");
init_env_and_log("chain_prover");

log::info!("mock-testnet: BEGIN");
log::info!("chain_prover: BEGIN");

let setting = Setting::new();
log::info!("mock-testnet: setting = {setting:?}");
log::info!("chain_prover: setting = {setting:?}");

prepare_circuit_capacity_checker();
log::info!("mock-testnet: prepared ccc");
log::info!("chain_prover: prepared ccc");

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

for batch_id in setting.begin_batch..=setting.end_batch {
let chunks = rollupscan
.get_chunk_info_by_batch_index(batch_id)
.await
.unwrap_or_else(|e| {
panic!("mock-testnet: failed to request rollupscan chunks API for batch-{batch_id}: {e}")
panic!("chain_prover: failed to request rollupscan chunks API for batch-{batch_id}: {e}")
});

if chunks.is_none() {
log::warn!("mock-testnet: no chunks in batch-{batch_id}");
log::warn!("chain_prover: no chunks in batch-{batch_id}");
continue;
}

let mut chunk_proofs = vec![];
for chunk in chunks.unwrap() {
let chunk_id = chunk.index;
log::info!("mock-testnet: handling chunk {:?}", chunk_id);
log::info!("chain_prover: handling chunk {:?}", chunk_id);

let mut block_traces: Vec<BlockTrace> = vec![];
for block_num in chunk.start_block_number..=chunk.end_block_number {
let trace = l2geth
.get_block_trace_by_num(block_num)
.await
.unwrap_or_else(|e| {
panic!("mock-testnet: failed to request l2geth block-trace API for batch-{batch_id} chunk-{chunk_id} block-{block_num}: {e}")
panic!("chain_prover: failed to request l2geth block-trace API for batch-{batch_id} chunk-{chunk_id} block-{block_num}: {e}")
});

block_traces.push(trace);
Expand All @@ -62,7 +62,7 @@ async fn main() {
let witness_block = match build_block(&block_traces, batch_id, chunk_id) {
Ok(block) => block,
Err(e) => {
log::error!("mock-testnet: building block failed {e:?}");
log::error!("chain_prover: building block failed {e:?}");
continue;
}
};
Expand All @@ -71,7 +71,7 @@ async fn main() {
}

let chunk_proof = prove_utils::prove_chunk(
&format!("mock-testnet: batch-{batch_id} chunk-{chunk_id}"),
&format!("chain_prover: batch-{batch_id} chunk-{chunk_id}"),
&witness_block,
);

Expand All @@ -81,10 +81,10 @@ async fn main() {
}

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

log::info!("mock-testnet: END");
log::info!("chain_prover: END");
}

fn build_block(block_traces: &[BlockTrace], batch_id: i64, chunk_id: i64) -> Result<WitnessBlock> {
Expand All @@ -104,7 +104,7 @@ struct Setting {
impl Setting {
pub fn new() -> Self {
let l2geth_api_url =
env::var("L2GETH_API_URL").expect("mock-testnet: Must set env L2GETH_API_URL");
env::var("L2GETH_API_URL").expect("chain_prover: Must set env L2GETH_API_URL");
let rollupscan_api_url = env::var("ROLLUPSCAN_API_URL");
let rollupscan_api_url =
rollupscan_api_url.unwrap_or_else(|_| "http://10.0.3.119:8560/api/chunks".to_string());
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions docker/mock-testnet/gpu/run.sh

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
chunk_prover:
image: {DOCKER_IMAGE}
runtime: nvidia
container_name: chunk-prover-gpu
container_name: trace-prover-gpu
environment:
- CHAIN_ID={CHAIN_ID}
volumes:
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn test_capacity_checker() {

let block_traces = load_chunk_for_test().1;

let full = false;
let full = true;
let batch_id = 0;
let chunk_id = 0;
let avg_each_tx_time = if full {
Expand Down

0 comments on commit e703d47

Please sign in to comment.