diff --git a/Cargo.lock b/Cargo.lock index 53b09cd8..940f73bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "aggregator" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "ark-std 0.3.0", "bitstream-io", @@ -605,7 +605,7 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "bus-mapping" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "eth-types", "ethers-core", @@ -1303,7 +1303,7 @@ dependencies = [ [[package]] name = "eth-types" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "base64 0.13.1", "ethers-core", @@ -1460,7 +1460,7 @@ dependencies = [ [[package]] name = "external-tracer" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "eth-types", "geth-utils", @@ -1642,7 +1642,7 @@ dependencies = [ [[package]] name = "gadgets" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "eth-types", "halo2_proofs", @@ -1665,7 +1665,7 @@ dependencies = [ [[package]] name = "geth-utils" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "env_logger", "gobuild", @@ -2495,7 +2495,7 @@ dependencies = [ [[package]] name = "mock" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "eth-types", "ethers-core", @@ -2510,7 +2510,7 @@ dependencies = [ [[package]] name = "mpt-zktrie" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "eth-types", "halo2curves", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "prover" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "aggregator", "anyhow", @@ -4975,7 +4975,7 @@ dependencies = [ [[package]] name = "zkevm-circuits" version = "0.11.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#5e24350809970eb94d666ba57e7b40119112b60e" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=v0.11#fc2d62fa6e7dc9d6278c09fd65edae8938498511" dependencies = [ "array-init", "bus-mapping", diff --git a/Makefile b/Makefile index 40187999..a511b005 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ CHAIN_ID ?= 534352 export CHAIN_ID RUST_MIN_STACK ?= 16777216 export RUST_MIN_STACK +RUST_BACKTRACE=1 +export RUST_BACKTRACE help: ## Display this help screen @grep -h \ diff --git a/bin/src/chain_prover.rs b/bin/src/chain_prover.rs index 7690e5a7..b07f6c84 100644 --- a/bin/src/chain_prover.rs +++ b/bin/src/chain_prover.rs @@ -103,6 +103,7 @@ impl BatchBuilder { struct ChunkBuilder { traces: Vec, acc_row_usage_normalized: RowUsage, + block_limit: Option, } /// Same with production "chunk proposer" @@ -111,9 +112,22 @@ impl ChunkBuilder { Self { traces: Vec::new(), acc_row_usage_normalized: RowUsage::default(), + block_limit: None, } } pub fn add(&mut self, trace: BlockTrace) -> Option> { + // Condition1: block num + if let Some(block_limit) = self.block_limit { + if self.traces.len() + 1 == block_limit { + // build chunk + let mut chunk = self.traces.clone(); + chunk.push(trace.clone()); + self.traces.clear(); + return Some(chunk); + } + } + + // Condition2: ccc let ccc_result = { let mut checker = CircuitCapacityChecker::new(); checker.set_light_mode(false); @@ -137,6 +151,10 @@ impl ChunkBuilder { // Construct chunk myself async fn prove_by_block(l2geth: &l2geth_client::Client, begin_block: i64, end_block: i64) { let mut chunk_builder = ChunkBuilder::new(); + let force_curie = true; + if force_curie { + chunk_builder.block_limit = Some(1); + } let mut batch_builder = BatchBuilder::new(); let (begin_block, end_block) = if begin_block == 0 && end_block == 0 { // Blocks within last 24 hours @@ -150,7 +168,7 @@ async fn prove_by_block(l2geth: &l2geth_client::Client, begin_block: i64, end_bl let mut batch_begin_block = begin_block; for block_num in begin_block..=end_block { let trace = l2geth - .get_block_trace_by_num(block_num) + .get_block_trace_by_num(block_num, force_curie) .await .unwrap_or_else(|e| { panic!("chain_prover: failed to request l2geth block-trace API for block-{block_num}: {e}") @@ -263,7 +281,7 @@ async fn prove_by_batch( let mut block_traces: Vec = vec![]; for block_num in chunk.start_block_number..=chunk.end_block_number { let trace = l2geth - .get_block_trace_by_num(block_num) + .get_block_trace_by_num(block_num, false) .await .unwrap_or_else(|e| { panic!("chain_prover: failed to request l2geth block-trace API for batch-{batch_id} chunk-{chunk_id} block-{block_num}: {e}") diff --git a/bin/src/l2geth_client.rs b/bin/src/l2geth_client.rs index f6313e67..4adddf16 100644 --- a/bin/src/l2geth_client.rs +++ b/bin/src/l2geth_client.rs @@ -1,6 +1,7 @@ use anyhow::Result; use ethers_providers::{Http, Middleware, Provider}; use prover::BlockTrace; +use serde::Serialize; pub struct Client { id: String, @@ -21,17 +22,42 @@ impl Client { Ok(self.provider.get_block_number().await?.as_u64()) } - pub async fn get_block_trace_by_num(&self, block_num: i64) -> Result { + // when override_curie == true, + // we will force curie hard fork when tracing + pub async fn get_block_trace_by_num( + &self, + block_num: i64, + override_curie: bool, + ) -> Result { log::info!("{}: requesting trace of block {}", self.id, block_num); + let params = if override_curie { + // curl -s -H 'Content-Type: application/json' -X POST --data + // '{"jsonrpc":"2.0","method":"scroll_getBlockTraceByNumberOrHash", + // "params": ["0x485490", {"overrides": {"curieBlock":1}}], "id": 99}' + // 127.0.0.1:8545 + #[derive(Serialize)] + struct ChainConfig { + #[serde(rename = "curieBlock")] + curie_block: usize, + } + #[derive(Serialize)] + struct TraceConfig { + overrides: ChainConfig, + } + let override_param = TraceConfig { + overrides: ChainConfig { + curie_block: 1, // any small value could be ok + }, + }; + serde_json::json!([format!("{block_num:#x}"), override_param]) + } else { + serde_json::json!([format!("{block_num:#x}")]) + }; let trace = self .provider - .request( - "scroll_getBlockTraceByNumberOrHash", - [format!("{block_num:#x}")], - ) + .request("scroll_getBlockTraceByNumberOrHash", params) .await?; - Ok(trace) } }