Skip to content

Commit ce1a983

Browse files
committed
add l2 prestate
1 parent 1a43b24 commit ce1a983

File tree

8 files changed

+16
-48
lines changed

8 files changed

+16
-48
lines changed

.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[target.'cfg(target_os="macos")']
2-
rustflags = ["-C", "link-args=-framework CoreFoundation -framework Security"]
2+
rustflags = ["-C", "link-args=-framework CoreFoundation -framework Security -framework CoreServices"]
33
[net]
44
git-fetch-with-cli = true
55
[env]

bus-mapping/src/circuit_input_builder/access.rs

+1-33
Original file line numberDiff line numberDiff line change
@@ -104,46 +104,14 @@ impl AccessSet {
104104
self.code.extend(other.code.drain());
105105
}
106106

107-
#[cfg(not(feature = "scroll"))]
108107
pub(crate) fn from_geth_data(geth_data: &GethData) -> Self {
109108
let mut access_set = AccessSet::default();
110109
access_set.add_account(geth_data.eth_block.author.unwrap());
111110
for trace in geth_data.geth_traces.iter() {
112-
access_set.extend_from_traces(trace.prestate.as_ref().unwrap());
111+
access_set.extend_from_traces(&trace.prestate);
113112
}
114113
access_set
115114
}
116-
117-
#[cfg(feature = "scroll")]
118-
pub(crate) fn from_geth_data(geth_data: &GethData) -> Self {
119-
let mut access_set = AccessSet::default();
120-
access_set.add_account(geth_data.eth_block.author.unwrap());
121-
for (addr, storage) in geth_data.block_trace.storage_trace.storage_proofs.iter() {
122-
log::info!("add addr {:?} to access_set", addr);
123-
access_set.add_account(*addr);
124-
access_set.add_code(*addr);
125-
for key in storage.keys() {
126-
log::info!("add addr {:?} key {:?} to access_set", addr, key);
127-
access_set.add_storage(*addr, *key);
128-
}
129-
}
130-
if let Some(ref proofs) = geth_data.block_trace.storage_trace.proofs {
131-
for addr in proofs.keys() {
132-
log::info!("add addr {:?} to access_set", addr);
133-
access_set.add_account(*addr);
134-
access_set.add_code(*addr);
135-
}
136-
}
137-
access_set
138-
}
139-
}
140-
141-
impl From<Vec<Access>> for AccessSet {
142-
fn from(list: Vec<Access>) -> Self {
143-
let mut access_set = AccessSet::default();
144-
access_set.extend_from_access(list);
145-
access_set
146-
}
147115
}
148116

149117
/// Source of the code in the EVM execution.

eth-types/src/geth_types.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Types needed for generating Ethereum traces
22
3-
#[cfg(feature = "scroll")]
4-
use crate::l2_types::BlockTrace;
53
use crate::{
64
sign_types::{biguint_to_32bytes_le, ct_option_ok_or, recover_pk2, SignData, SECP256K1_Q},
75
AccessList, Address, Block, Bytes, Error, GethExecTrace, Hash, ToBigEndian, ToLittleEndian,
@@ -383,9 +381,6 @@ pub struct GethData {
383381
pub geth_traces: Vec<GethExecTrace>,
384382
/// Accounts
385383
pub accounts: Vec<Account>,
386-
/// block trace
387-
#[cfg(feature = "scroll")]
388-
pub block_trace: BlockTrace,
389384
}
390385
/*
391386
impl GethData {

eth-types/src/l2_types.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use crate::{
44
evm_types::{Gas, GasCost, OpcodeId, ProgramCounter},
5-
Block, GethCallTrace, GethExecError, GethExecStep, GethExecTrace, Hash, Transaction, Word,
6-
H256,
5+
Block, GethCallTrace, GethExecError, GethExecStep, GethExecTrace, GethPrestateTrace, Hash,
6+
Transaction, Word, H256,
77
};
88
use ethers_core::types::{Address, Bytes, U256, U64};
99
use serde::{Deserialize, Serialize};
@@ -208,6 +208,8 @@ pub struct ExecutionResult {
208208
/// callTrace
209209
#[serde(rename = "callTrace")]
210210
pub call_trace: GethCallTrace,
211+
/// prestate
212+
pub prestate: HashMap<Address, GethPrestateTrace>,
211213
}
212214

213215
impl From<ExecutionResult> for GethExecTrace {
@@ -220,7 +222,7 @@ impl From<ExecutionResult> for GethExecTrace {
220222
return_value: e.return_value,
221223
struct_logs,
222224
account_after: e.account_after,
223-
prestate: None,
225+
prestate: e.prestate,
224226
call_trace: e.call_trace,
225227
}
226228
}

eth-types/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ pub struct GethExecTrace {
687687
/// Only viable for scroll mode
688688
pub account_after: Vec<crate::l2_types::AccountProofWrapper>,
689689
/// prestate trace
690-
pub prestate: Option<HashMap<Address, GethPrestateTrace>>,
690+
pub prestate: HashMap<Address, GethPrestateTrace>,
691691
/// call trace
692692
#[serde(rename = "callTrace")]
693693
pub call_trace: GethCallTrace,
@@ -870,6 +870,7 @@ mod tests {
870870
]
871871
}
872872
],
873+
"prestate": {},
873874
"callTrace": {
874875
"calls": [],
875876
"error": null,
@@ -957,7 +958,7 @@ mod tests {
957958
]),
958959
}
959960
],
960-
prestate: None,
961+
prestate: HashMap::new(),
961962
call_trace: GethCallTrace {
962963
calls: Vec::new(),
963964
error: None,

geth-utils/l2geth/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/imdario/mergo v0.3.16
7-
github.com/scroll-tech/go-ethereum v1.10.14-0.20231108100028-cb76ecd42bf7
7+
github.com/scroll-tech/go-ethereum v1.10.14-0.20231127063850-acaa268ff676
88
)
99

1010
require (

geth-utils/l2geth/go.sum

+5-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ github.com/scroll-tech/go-ethereum v1.10.14-0.20230901060443-e1eebd17067c h1:GuA
137137
github.com/scroll-tech/go-ethereum v1.10.14-0.20230901060443-e1eebd17067c/go.mod h1:DiN3p2inoXOxGffxSswDKqWjQ7bU+Mp0c9v0XQXKmaA=
138138
github.com/scroll-tech/go-ethereum v1.10.14-0.20230919024151-fa0be69a3fb9 h1:QiqH+ZGNNzMcKy21VGX6XYg81DXE+/9j1Ik7owm13hs=
139139
github.com/scroll-tech/go-ethereum v1.10.14-0.20230919024151-fa0be69a3fb9/go.mod h1:DiN3p2inoXOxGffxSswDKqWjQ7bU+Mp0c9v0XQXKmaA=
140+
github.com/scroll-tech/go-ethereum v1.10.14-0.20231127055938-52511afb103f h1:rWae0zTgyQg41TnbUl1u8QC5VDfN8FA4WTMn7UTkUKo=
141+
github.com/scroll-tech/go-ethereum v1.10.14-0.20231127055938-52511afb103f/go.mod h1:4HrFcoStbViFVy/9l/rvKl1XmizVAaPdgqI8v0U8hOc=
142+
github.com/scroll-tech/go-ethereum v1.10.14-0.20231127063850-acaa268ff676 h1:/xCHeje6y3nv+cn4Qsm24fwOGT3VLOfzdsPe6/bK4SY=
143+
github.com/scroll-tech/go-ethereum v1.10.14-0.20231127063850-acaa268ff676/go.mod h1:4HrFcoStbViFVy/9l/rvKl1XmizVAaPdgqI8v0U8hOc=
140144
github.com/scroll-tech/zktrie v0.6.0 h1:xLrMAO31Yo2BiPg1jtYKzcjpEFnXy8acbB7iIsyshPs=
141145
github.com/scroll-tech/zktrie v0.6.0/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=
142146
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=
243247
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
244248
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
245249
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
246-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
250+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

mock/src/test_ctx.rs

-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ impl<const NACC: usize, const NTX: usize> From<TestContext<NACC, NTX>> for GethD
108108
eth_block: ctx.eth_block,
109109
geth_traces: ctx.geth_traces.to_vec(),
110110
accounts: ctx.accounts.into(),
111-
#[cfg(feature = "scroll")]
112-
block_trace: ctx.block_trace,
113111
}
114112
}
115113
}

0 commit comments

Comments
 (0)