From ce1a983aef72e37badc9aa836b51ef27d1cb81dc Mon Sep 17 00:00:00 2001 From: lightsing Date: Mon, 27 Nov 2023 14:04:06 +0800 Subject: [PATCH] add l2 prestate --- .cargo/config.toml | 2 +- .../src/circuit_input_builder/access.rs | 34 +------------------ eth-types/src/geth_types.rs | 5 --- eth-types/src/l2_types.rs | 8 +++-- eth-types/src/lib.rs | 5 +-- geth-utils/l2geth/go.mod | 2 +- geth-utils/l2geth/go.sum | 6 +++- mock/src/test_ctx.rs | 2 -- 8 files changed, 16 insertions(+), 48 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index bd0f7448f4..361bd30ffa 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,5 @@ [target.'cfg(target_os="macos")'] -rustflags = ["-C", "link-args=-framework CoreFoundation -framework Security"] +rustflags = ["-C", "link-args=-framework CoreFoundation -framework Security -framework CoreServices"] [net] git-fetch-with-cli = true [env] diff --git a/bus-mapping/src/circuit_input_builder/access.rs b/bus-mapping/src/circuit_input_builder/access.rs index b9012dff66..81c0bce479 100644 --- a/bus-mapping/src/circuit_input_builder/access.rs +++ b/bus-mapping/src/circuit_input_builder/access.rs @@ -104,46 +104,14 @@ impl AccessSet { self.code.extend(other.code.drain()); } - #[cfg(not(feature = "scroll"))] pub(crate) fn from_geth_data(geth_data: &GethData) -> Self { let mut access_set = AccessSet::default(); access_set.add_account(geth_data.eth_block.author.unwrap()); for trace in geth_data.geth_traces.iter() { - access_set.extend_from_traces(trace.prestate.as_ref().unwrap()); + access_set.extend_from_traces(&trace.prestate); } access_set } - - #[cfg(feature = "scroll")] - pub(crate) fn from_geth_data(geth_data: &GethData) -> Self { - let mut access_set = AccessSet::default(); - access_set.add_account(geth_data.eth_block.author.unwrap()); - for (addr, storage) in geth_data.block_trace.storage_trace.storage_proofs.iter() { - log::info!("add addr {:?} to access_set", addr); - access_set.add_account(*addr); - access_set.add_code(*addr); - for key in storage.keys() { - log::info!("add addr {:?} key {:?} to access_set", addr, key); - access_set.add_storage(*addr, *key); - } - } - if let Some(ref proofs) = geth_data.block_trace.storage_trace.proofs { - for addr in proofs.keys() { - log::info!("add addr {:?} to access_set", addr); - access_set.add_account(*addr); - access_set.add_code(*addr); - } - } - access_set - } -} - -impl From> for AccessSet { - fn from(list: Vec) -> Self { - let mut access_set = AccessSet::default(); - access_set.extend_from_access(list); - access_set - } } /// Source of the code in the EVM execution. diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index e135374bb7..e0ee50ead5 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -1,7 +1,5 @@ //! Types needed for generating Ethereum traces -#[cfg(feature = "scroll")] -use crate::l2_types::BlockTrace; use crate::{ sign_types::{biguint_to_32bytes_le, ct_option_ok_or, recover_pk2, SignData, SECP256K1_Q}, AccessList, Address, Block, Bytes, Error, GethExecTrace, Hash, ToBigEndian, ToLittleEndian, @@ -383,9 +381,6 @@ pub struct GethData { pub geth_traces: Vec, /// Accounts pub accounts: Vec, - /// block trace - #[cfg(feature = "scroll")] - pub block_trace: BlockTrace, } /* impl GethData { diff --git a/eth-types/src/l2_types.rs b/eth-types/src/l2_types.rs index daf804df2e..b5f7861f51 100644 --- a/eth-types/src/l2_types.rs +++ b/eth-types/src/l2_types.rs @@ -2,8 +2,8 @@ use crate::{ evm_types::{Gas, GasCost, OpcodeId, ProgramCounter}, - Block, GethCallTrace, GethExecError, GethExecStep, GethExecTrace, Hash, Transaction, Word, - H256, + Block, GethCallTrace, GethExecError, GethExecStep, GethExecTrace, GethPrestateTrace, Hash, + Transaction, Word, H256, }; use ethers_core::types::{Address, Bytes, U256, U64}; use serde::{Deserialize, Serialize}; @@ -208,6 +208,8 @@ pub struct ExecutionResult { /// callTrace #[serde(rename = "callTrace")] pub call_trace: GethCallTrace, + /// prestate + pub prestate: HashMap, } impl From for GethExecTrace { @@ -220,7 +222,7 @@ impl From for GethExecTrace { return_value: e.return_value, struct_logs, account_after: e.account_after, - prestate: None, + prestate: e.prestate, call_trace: e.call_trace, } } diff --git a/eth-types/src/lib.rs b/eth-types/src/lib.rs index dfb4a6f9a8..64a5a18957 100644 --- a/eth-types/src/lib.rs +++ b/eth-types/src/lib.rs @@ -687,7 +687,7 @@ pub struct GethExecTrace { /// Only viable for scroll mode pub account_after: Vec, /// prestate trace - pub prestate: Option>, + pub prestate: HashMap, /// call trace #[serde(rename = "callTrace")] pub call_trace: GethCallTrace, @@ -870,6 +870,7 @@ mod tests { ] } ], + "prestate": {}, "callTrace": { "calls": [], "error": null, @@ -957,7 +958,7 @@ mod tests { ]), } ], - prestate: None, + prestate: HashMap::new(), call_trace: GethCallTrace { calls: Vec::new(), error: None, diff --git a/geth-utils/l2geth/go.mod b/geth-utils/l2geth/go.mod index 0633560d84..2a867df538 100644 --- a/geth-utils/l2geth/go.mod +++ b/geth-utils/l2geth/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/imdario/mergo v0.3.16 - github.com/scroll-tech/go-ethereum v1.10.14-0.20231108100028-cb76ecd42bf7 + github.com/scroll-tech/go-ethereum v1.10.14-0.20231127063850-acaa268ff676 ) require ( diff --git a/geth-utils/l2geth/go.sum b/geth-utils/l2geth/go.sum index dcf427247a..ac60be73ad 100644 --- a/geth-utils/l2geth/go.sum +++ b/geth-utils/l2geth/go.sum @@ -137,6 +137,10 @@ github.com/scroll-tech/go-ethereum v1.10.14-0.20230901060443-e1eebd17067c h1:GuA github.com/scroll-tech/go-ethereum v1.10.14-0.20230901060443-e1eebd17067c/go.mod h1:DiN3p2inoXOxGffxSswDKqWjQ7bU+Mp0c9v0XQXKmaA= github.com/scroll-tech/go-ethereum v1.10.14-0.20230919024151-fa0be69a3fb9 h1:QiqH+ZGNNzMcKy21VGX6XYg81DXE+/9j1Ik7owm13hs= github.com/scroll-tech/go-ethereum v1.10.14-0.20230919024151-fa0be69a3fb9/go.mod h1:DiN3p2inoXOxGffxSswDKqWjQ7bU+Mp0c9v0XQXKmaA= +github.com/scroll-tech/go-ethereum v1.10.14-0.20231127055938-52511afb103f h1:rWae0zTgyQg41TnbUl1u8QC5VDfN8FA4WTMn7UTkUKo= +github.com/scroll-tech/go-ethereum v1.10.14-0.20231127055938-52511afb103f/go.mod h1:4HrFcoStbViFVy/9l/rvKl1XmizVAaPdgqI8v0U8hOc= +github.com/scroll-tech/go-ethereum v1.10.14-0.20231127063850-acaa268ff676 h1:/xCHeje6y3nv+cn4Qsm24fwOGT3VLOfzdsPe6/bK4SY= +github.com/scroll-tech/go-ethereum v1.10.14-0.20231127063850-acaa268ff676/go.mod h1:4HrFcoStbViFVy/9l/rvKl1XmizVAaPdgqI8v0U8hOc= github.com/scroll-tech/zktrie v0.6.0 h1:xLrMAO31Yo2BiPg1jtYKzcjpEFnXy8acbB7iIsyshPs= github.com/scroll-tech/zktrie v0.6.0/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= @@ -243,4 +247,4 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= \ No newline at end of file +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/mock/src/test_ctx.rs b/mock/src/test_ctx.rs index 8106222723..472e983e60 100644 --- a/mock/src/test_ctx.rs +++ b/mock/src/test_ctx.rs @@ -108,8 +108,6 @@ impl From> for GethD eth_block: ctx.eth_block, geth_traces: ctx.geth_traces.to_vec(), accounts: ctx.accounts.into(), - #[cfg(feature = "scroll")] - block_trace: ctx.block_trace, } } }