Skip to content

Commit 34cd296

Browse files
lightsinglispcroynalnaruto
authored
feat: Euclid V2 (#87)
* feat: add EIP-7702 tx support (#85) * upgrade * upgrade * Update Cargo.toml * change branches * remove poseidon field * fix scroll types * trailing lf * feat: dump utils (#83) * provide utils lib * clippy * unify imports * fix * style fix * add EIP-7702 tx support * upgrade reth --------- Co-authored-by: Zhang Zhuo <[email protected]> * feat: msg queue hash (#84) * upgrade * upgrade * Update Cargo.toml * change branches * remove poseidon field * fix scroll types * trailing lf * feat: dump utils (#83) * provide utils lib * clippy * unify imports * fix * style fix * impl msg queue hash * remove legacy test * move chunk into primitives and impl EuclidV2 * set prev_msg_queue_hash * use is_l1_message * feat: num l1 msgs in scroll block * fix: usize instead of u64 for num txs * chore: clippy fix remove unused import * apply suggestion --------- Co-authored-by: Zhang Zhuo <[email protected]> Co-authored-by: Rohit Narurkar <[email protected]> * fix Eip7702 signature * chore: update reth dep * fix bytecode construct * upgrade to fix * add euclid v2 test cases * fix cli * remove unused * impl is_euclid_v2 in chunk * clippy * fix ChunkInfo * fix chunk mode * refactor * refactor --------- Co-authored-by: Zhang Zhuo <[email protected]> Co-authored-by: Rohit Narurkar <[email protected]>
1 parent 43938a8 commit 34cd296

File tree

25 files changed

+1706
-252
lines changed

25 files changed

+1706
-252
lines changed

Cargo.lock

+50-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+24-37
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,25 @@ alloy-trie = { version = "0.7", default-features = false }
3838
# https://github.com/alloy-rs/core
3939
alloy-primitives = { version = "0.8", default-features = false, features = ["map-hashbrown", "map-fxhash", "rkyv"] }
4040

41-
reth-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
42-
reth-evm = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
43-
reth-evm-ethereum = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
44-
reth-ethereum-forks = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
45-
reth-execution-types = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
46-
reth-primitives = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
47-
reth-primitives-traits = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
48-
reth-storage-errors = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
49-
reth-trie = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
50-
reth-trie-sparse = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
51-
52-
reth-scroll-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
53-
reth-scroll-evm = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
54-
reth-scroll-forks = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
55-
reth-scroll-primitives = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
56-
57-
scroll-alloy-consensus = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
58-
scroll-alloy-primitives = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
59-
scroll-alloy-rpc-types = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
60-
scroll-alloy-network = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
61-
62-
#reth-chainspec = { path = "../reth/crates/chainspec", default-features = false }
63-
#reth-evm = { path = "../reth/crates/evm/", default-features = false }
64-
#reth-evm-ethereum = { path = "../reth/crates/ethereum/evm", default-features = false }
65-
#reth-execution-types = { path = "../reth/crates/evm/execution-types", default-features = false }
66-
#reth-primitives = { path = "../reth/crates/primitives", default-features = false }
67-
#reth-scroll-chainspec = { path = "../reth/crates/scroll/chainspec", default-features = false }
68-
#reth-scroll-evm = { path = "../reth/crates/scroll/evm", default-features = false }
69-
#reth-scroll-primitives = { path = "../reth/crates/scroll/primitives", default-features = false }
70-
#reth-storage-errors = { path = "../reth/crates/storage/errors", default-features = false }
71-
#reth-trie = { path = "../reth/crates/trie/trie", default-features = false }
72-
#reth-trie-sparse = { path = "../reth/crates/trie/sparse", default-features = false }
41+
reth-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
42+
reth-evm = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
43+
reth-evm-ethereum = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
44+
reth-ethereum-forks = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
45+
reth-execution-types = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
46+
reth-primitives = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
47+
reth-primitives-traits = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
48+
reth-storage-errors = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
49+
reth-trie = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
50+
reth-trie-sparse = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
51+
52+
reth-scroll-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
53+
reth-scroll-evm = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
54+
reth-scroll-forks = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
55+
reth-scroll-primitives = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
56+
57+
scroll-alloy-consensus = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
58+
scroll-alloy-rpc-types = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
59+
scroll-alloy-network = { git = "https://github.com/scroll-tech/reth", branch = "feat/euclid-v2", default-features = false }
7360

7461
async-trait = "0.1"
7562
auto_impl = "1.2"
@@ -120,7 +107,7 @@ sbv-utils = { path = "crates/utils" }
120107

121108
[workspace.dependencies.revm]
122109
git = "https://github.com/scroll-tech/revm"
123-
branch = "scroll-evm-executor/v55"
110+
branch = "scroll-evm-executor/feat/v55/euclid-v2"
124111
default-features = false
125112
features = ["std"]
126113

@@ -134,10 +121,10 @@ ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.12.3" }
134121

135122
alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch = "v0.8.18" }
136123

137-
revm = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
138-
revm-interpreter = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
139-
revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
140-
revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v55" }
124+
revm = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/feat/v55/euclid-v2" }
125+
revm-interpreter = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/feat/v55/euclid-v2" }
126+
revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/feat/v55/euclid-v2" }
127+
revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/feat/v55/euclid-v2" }
141128

142129
# for local development
143130
# [patch."https://github.com/scroll-tech/revm"]

crates/bin/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ workspace = true
1515
[dependencies]
1616
anyhow.workspace = true
1717
clap = { workspace = true, features = ["derive"] }
18-
futures.workspace = true
1918
serde = { workspace = true, features = ["derive"] }
2019
serde_json.workspace = true
2120
serde_path_to_error.workspace = true

crates/bin/src/commands/run_file.rs

+28-15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ pub struct RunFileCommand {
1313
#[cfg(feature = "scroll")]
1414
#[arg(short, long)]
1515
chunk_mode: bool,
16+
#[cfg(feature = "scroll")]
17+
#[arg(long)]
18+
prev_msg_queue_hash: Option<sbv::primitives::B256>,
1619
}
1720

1821
impl RunFileCommand {
@@ -42,13 +45,13 @@ impl RunFileCommand {
4245
fn run_chunk(self) -> anyhow::Result<()> {
4346
use anyhow::bail;
4447
use sbv::{
45-
core::{ChunkInfo, EvmDatabase, EvmExecutor},
48+
core::{EvmDatabase, EvmExecutor},
4649
kv::{nohash::NoHashMap, null::NullProvider},
4750
primitives::{
4851
BlockWitness as _,
49-
chainspec::{Chain, get_chain_spec},
50-
ext::{BlockWitnessChunkExt, BlockWitnessExt, TxBytesHashExt},
51-
types::BlockWitness,
52+
chainspec::{Chain, get_chain_spec_or_build},
53+
ext::{BlockWitnessChunkExt, BlockWitnessExt},
54+
types::{BlockWitness, ChunkInfoBuilder},
5255
},
5356
trie::BlockWitnessTrieExt,
5457
};
@@ -71,18 +74,32 @@ impl RunFileCommand {
7174
.iter()
7275
.map(|w| w.build_reth_block())
7376
.collect::<Result<Vec<_>, _>>()?;
74-
let chunk_info =
75-
ChunkInfo::from_blocks(witnesses[0].chain_id, witnesses[0].pre_state_root, &blocks);
7677

77-
let chain_spec = get_chain_spec(Chain::from_id(chunk_info.chain_id())).unwrap();
78+
let chain_spec = get_chain_spec_or_build(Chain::from_id(witnesses.chain_id()), |_spec| {
79+
#[cfg(feature = "scroll")]
80+
{
81+
use sbv::primitives::hardforks::{ForkCondition, ScrollHardfork};
82+
_spec
83+
.inner
84+
.hardforks
85+
.insert(ScrollHardfork::EuclidV2, ForkCondition::Timestamp(0));
86+
}
87+
});
88+
89+
let mut chunk_info_builder =
90+
ChunkInfoBuilder::new(&chain_spec, witnesses.prev_state_root(), &blocks);
91+
if let Some(prev_msg_queue_hash) = self.prev_msg_queue_hash {
92+
chunk_info_builder.set_prev_msg_queue_hash(prev_msg_queue_hash);
93+
}
94+
7895
let mut code_db = NoHashMap::default();
7996
witnesses.import_codes(&mut code_db);
8097
let mut nodes_provider = NoHashMap::default();
8198
witnesses.import_nodes(&mut nodes_provider)?;
8299

83100
let mut db = EvmDatabase::new_from_root(
84101
&code_db,
85-
chunk_info.prev_state_root(),
102+
chunk_info_builder.prev_state_root(),
86103
&nodes_provider,
87104
&NullProvider,
88105
)?;
@@ -91,16 +108,12 @@ impl RunFileCommand {
91108
db.update(&nodes_provider, output.state.state.iter())?;
92109
}
93110
let post_state_root = db.commit_changes();
94-
if post_state_root != chunk_info.post_state_root() {
111+
if post_state_root != chunk_info_builder.post_state_root() {
95112
bail!("post state root mismatch");
96113
}
97114

98-
let withdraw_root = db.withdraw_root()?;
99-
let tx_bytes_hash = blocks
100-
.iter()
101-
.flat_map(|b| b.body().transactions.iter())
102-
.tx_bytes_hash();
103-
let _public_input_hash = chunk_info.public_input_hash(&withdraw_root, &tx_bytes_hash);
115+
let chunk_info = chunk_info_builder.build(db.withdraw_root()?);
116+
let _public_input_hash = chunk_info.pi_hash();
104117
dev_info!("[chunk mode] public input hash: {_public_input_hash:?}");
105118

106119
Ok(())

crates/bin/src/utils.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use sbv::{
33
kv::nohash::NoHashMap,
44
primitives::{
55
BlockWitness,
6-
chainspec::{Chain, get_chain_spec},
6+
chainspec::{Chain, get_chain_spec_or_build},
77
ext::BlockWitnessExt,
88
},
99
trie::BlockWitnessTrieExt,
@@ -30,7 +30,16 @@ fn verify_inner<T: BlockWitness + BlockWitnessTrieExt + BlockWitnessExt>(
3030
.build()
3131
.unwrap();
3232

33-
let chain_spec = get_chain_spec(Chain::from_id(witness.chain_id())).unwrap();
33+
let chain_spec = get_chain_spec_or_build(Chain::from_id(witness.chain_id()), |_spec| {
34+
#[cfg(feature = "scroll")]
35+
{
36+
use sbv::primitives::hardforks::{ForkCondition, ScrollHardfork};
37+
_spec
38+
.inner
39+
.hardforks
40+
.insert(ScrollHardfork::EuclidV2, ForkCondition::Timestamp(0));
41+
}
42+
});
3443

3544
let mut code_db = NoHashMap::default();
3645
witness.import_codes(&mut code_db);

crates/core/Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ reth-evm-ethereum.workspace = true
1818
reth-execution-types.workspace = true
1919
reth-scroll-evm = { workspace = true, optional = true }
2020
reth-storage-errors.workspace = true
21-
serde.workspace = true
22-
serde_json.workspace = true
21+
2322
thiserror.workspace = true
24-
tiny-keccak.workspace = true
2523

2624
sbv-primitives.workspace = true
2725
sbv-helpers.workspace = true
@@ -30,8 +28,6 @@ sbv-trie.workspace = true
3028

3129
[dev-dependencies]
3230
ctor.workspace = true
33-
serde.workspace = true
34-
serde_json.workspace = true
3531
tracing.workspace = true
3632
tracing-subscriber.workspace = true
3733

crates/core/src/chunk.rs

-119
This file was deleted.

crates/core/src/database.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ impl<
5757
nodes_provider: NodesProvider,
5858
block_hashes: BlockHashProvider,
5959
) -> Result<Self> {
60+
dev_trace!("open trie from root {:?}", state_root_before);
61+
6062
let state = cycle_track!(
6163
PartialStateTrie::open(&nodes_provider, state_root_before),
6264
"PartialStateTrie::open"
@@ -110,7 +112,7 @@ impl<
110112
.code_db
111113
.get(&hash)
112114
.cloned()
113-
.map(Bytecode::new_legacy)
115+
.map(Bytecode::new_raw)
114116
.map(to_analysed);
115117
code_cache.insert(hash, code.clone());
116118
code

crates/core/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
extern crate sbv_helpers;
55
extern crate core;
66

7-
#[cfg(feature = "scroll")]
8-
mod chunk;
9-
#[cfg(feature = "scroll")]
10-
pub use chunk::ChunkInfo;
11-
127
mod database;
138
pub use database::{DatabaseError, DatabaseRef, EvmDatabase};
149

0 commit comments

Comments
 (0)