Skip to content

Commit d048f8d

Browse files
authored
chore: upgrade reth (#137)
* chore: upgrade reth * fix precompile * rename to bn254 * upgrade * remove legacy compat test
1 parent 6915dee commit d048f8d

File tree

23 files changed

+642
-1291
lines changed

23 files changed

+642
-1291
lines changed

Cargo.lock

Lines changed: 447 additions & 551 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ repository = "https://github.com/scroll-tech/stateless-block-verifier"
2323

2424
[workspace.dependencies]
2525
# https://github.com/alloy-rs/alloy
26-
alloy = { version = "1.0", default-features = false }
27-
alloy-consensus = { version = "1.0", default-features = false }
28-
alloy-eips = { version = "1.0", default-features = false }
29-
alloy-network = { version = "1.0", default-features = false }
30-
alloy-provider = { version = "1.0", default-features = false }
31-
alloy-rpc-client = { version = "1.0", default-features = false }
32-
alloy-rpc-types-eth = { version = "1.0", default-features = false }
33-
alloy-rpc-types-debug = { version = "1.0", default-features = false }
34-
alloy-serde = { version = "1.0", default-features = false }
35-
alloy-transport = { version = "1.0", default-features = false }
26+
alloy = { version = "1.0.30", default-features = false }
27+
alloy-consensus = { version = "1.0.30", default-features = false }
28+
alloy-eips = { version = "1.0.30", default-features = false }
29+
alloy-network = { version = "1.0.30", default-features = false }
30+
alloy-provider = { version = "1.0.30", default-features = false }
31+
alloy-rpc-client = { version = "1.0.30", default-features = false }
32+
alloy-rpc-types-eth = { version = "1.0.30", default-features = false }
33+
alloy-rpc-types-debug = { version = "1.0.30", default-features = false }
34+
alloy-serde = { version = "1.0.30", default-features = false }
35+
alloy-transport = { version = "1.0.30", default-features = false }
3636
# https://github.com/alloy-rs/rlp
37-
alloy-rlp = { version = "0.3", default-features = false }
37+
alloy-rlp = { version = "0.3.10", default-features = false }
3838
# https://github.com/alloy-rs/trie
39-
alloy-trie = { version = "0.9", default-features = false }
39+
alloy-trie = { version = "0.9.1", default-features = false }
4040
# https://github.com/alloy-rs/core
41-
alloy-primitives = { version = "1.3", default-features = false, features = ["map-hashbrown", "map-fxhash"] }
41+
alloy-primitives = { version = "1.3.1", default-features = false, features = ["map-hashbrown", "map-fxhash"] }
4242
# https://github.com/alloy-rs/evm
43-
alloy-evm = { version = "0.17", default-features = false }
43+
alloy-evm = { version = "0.20.1", default-features = false }
4444

4545
revm-scroll = { git = "https://github.com/scroll-tech/scroll-revm", default-features = false }
4646

@@ -83,7 +83,6 @@ scroll-alloy-network = { git = "https://github.com/scroll-tech/reth", branch = "
8383
#scroll-alloy-network = { path = "../reth/crates/scroll/alloy/network", default-features = false }
8484

8585
openvm-ecc-guest = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.0" }
86-
openvm-keccak256 = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.0" }
8786
openvm-sha2 = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.0" }
8887
openvm-pairing = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.0" }
8988
openvm-k256 = { package = "k256", git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.0" }
@@ -94,13 +93,11 @@ async-trait = "0.1"
9493
auto_impl = "1.2"
9594
console = "0.16"
9695
futures = "0.3"
97-
hashbrown = { version = "0.15", default-features = false }
9896
indicatif = "0.18"
9997
itertools = "0.14"
10098
rkyv = "0.8"
10199
rustc-hash = "2.1"
102100
thiserror = "2.0"
103-
tiny-keccak = "2.0"
104101
url = ">=2.5.3"
105102
rstest = "0.26"
106103
cfg-if = "1.0"
Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
use crate::{EvmDatabase, VerificationError};
22
use sbv_kv::KeyValueStoreGet;
3-
use sbv_precompile::PrecompileProvider;
43
use sbv_primitives::{
54
B256, Bytes,
65
chainspec::ChainSpec,
76
types::{
8-
evm::precompiles::PrecompilesMap,
97
reth::{
10-
evm::{
11-
ConfigureEvm, Database, EthEvm, EthEvmConfig, EvmEnv, EvmFactory,
12-
eth::EthEvmContext,
13-
execute::Executor,
14-
revm::{
15-
Context, Inspector, MainBuilder, MainContext,
16-
context::{
17-
BlockEnv, CfgEnv, TxEnv,
18-
result::{EVMError, HaltReason},
19-
},
20-
inspector::NoOpInspector,
21-
},
22-
},
8+
evm::{ConfigureEvm, EthEvmConfig, execute::Executor},
239
execution_types::BlockExecutionOutput,
2410
primitives::{Block, Receipt, RecoveredBlock},
2511
},
26-
revm::{SpecId, database::CacheDB, precompile::PrecompileSpecId},
12+
revm::database::CacheDB,
2713
},
2814
};
2915
use std::sync::Arc;
3016

31-
/// Ethereum-related EVM configuration with [`SbvEthEvmFactory`] as the factory.
32-
pub type EvmConfig = EthEvmConfig<ChainSpec, SbvEthEvmFactory>;
33-
3417
/// EVM executor that handles the block.
3518
#[derive(Debug)]
3619
pub struct EvmExecutor<'a, CodeDb, BlockHashProvider> {
@@ -59,7 +42,7 @@ impl<CodeDb: KeyValueStoreGet<B256, Bytes>, BlockHashProvider: KeyValueStoreGet<
5942
{
6043
/// Handle the block with the given witness
6144
pub fn execute(self) -> Result<BlockExecutionOutput<Receipt>, VerificationError> {
62-
let provider = EvmConfig::new_with_evm_factory(self.chain_spec.clone(), SbvEthEvmFactory);
45+
let provider = EthEvmConfig::new(self.chain_spec.clone());
6346

6447
let output = cycle_track!(
6548
provider.executor(CacheDB::new(self.db)).execute(self.block),
@@ -69,53 +52,3 @@ impl<CodeDb: KeyValueStoreGet<B256, Bytes>, BlockHashProvider: KeyValueStoreGet<
6952
Ok(output)
7053
}
7154
}
72-
73-
/// Factory producing [`EthEvm`].
74-
#[derive(Debug, Default, Clone, Copy)]
75-
#[non_exhaustive]
76-
pub struct SbvEthEvmFactory;
77-
78-
impl EvmFactory for SbvEthEvmFactory {
79-
type Evm<DB: Database, I: Inspector<EthEvmContext<DB>>> = EthEvm<DB, I, Self::Precompiles>;
80-
type Context<DB: Database> = Context<BlockEnv, TxEnv, CfgEnv, DB>;
81-
type Tx = TxEnv;
82-
type Error<DBError: core::error::Error + Send + Sync + 'static> = EVMError<DBError>;
83-
type HaltReason = HaltReason;
84-
type Spec = SpecId;
85-
type Precompiles = PrecompilesMap;
86-
87-
fn create_evm<DB: Database>(&self, db: DB, input: EvmEnv) -> Self::Evm<DB, NoOpInspector> {
88-
let spec_id = input.cfg_env.spec;
89-
EthEvm::new(
90-
Context::mainnet()
91-
.with_block(input.block_env)
92-
.with_cfg(input.cfg_env)
93-
.with_db(db)
94-
.build_mainnet_with_inspector(NoOpInspector {})
95-
.with_precompiles(PrecompileProvider::with_spec(
96-
PrecompileSpecId::from_spec_id(spec_id),
97-
)),
98-
false,
99-
)
100-
}
101-
102-
fn create_evm_with_inspector<DB: Database, I: Inspector<Self::Context<DB>>>(
103-
&self,
104-
db: DB,
105-
input: EvmEnv,
106-
inspector: I,
107-
) -> Self::Evm<DB, I> {
108-
let spec_id = input.cfg_env.spec;
109-
EthEvm::new(
110-
Context::mainnet()
111-
.with_block(input.block_env)
112-
.with_cfg(input.cfg_env)
113-
.with_db(db)
114-
.build_mainnet_with_inspector(inspector)
115-
.with_precompiles(PrecompileProvider::with_spec(
116-
PrecompileSpecId::from_spec_id(spec_id),
117-
)),
118-
true,
119-
)
120-
}
121-
}

crates/core/src/executor/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#[cfg(not(feature = "scroll"))]
22
mod ethereum;
33
#[cfg(not(feature = "scroll"))]
4-
pub use ethereum::{EvmConfig, EvmExecutor, SbvEthEvmFactory};
4+
pub use ethereum::EvmExecutor;
55

66
#[cfg(feature = "scroll")]
77
mod scroll;
88
#[cfg(feature = "scroll")]
9-
pub use scroll::{EvmConfig, EvmExecutor};
9+
pub use scroll::EvmExecutor;

crates/core/src/executor/scroll.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@ use sbv_primitives::{
55
chainspec::ChainSpec,
66
types::{
77
reth::{
8-
evm::{ConfigureEvm, EthEvmConfig, RethReceiptBuilder},
8+
evm::{ConfigureEvm, EthEvmConfig},
99
execution_types::BlockExecutionOutput,
10-
primitives::{Block, EthPrimitives, Receipt, RecoveredBlock},
10+
primitives::{Block, Receipt, RecoveredBlock},
1111
},
1212
revm::database::CacheDB,
1313
},
1414
};
1515
use std::sync::Arc;
1616

17-
/// Ethereum-related EVM configuration.
18-
pub type EvmConfig =
19-
EthEvmConfig<ChainSpec, EthPrimitives, RethReceiptBuilder, sbv_precompile::PrecompileProvider>;
20-
2117
/// EVM executor that handles the block.
2218
#[derive(Debug)]
2319
pub struct EvmExecutor<'a, CodeDb, BlockHashProvider, CompressionRatios> {
@@ -60,7 +56,7 @@ impl<
6056
revm::database::{State, states::bundle_state::BundleRetention},
6157
};
6258

63-
let provider = EvmConfig::new(self.chain_spec.clone(), Default::default());
59+
let provider = EthEvmConfig::scroll(self.chain_spec.clone());
6460
let factory = provider.block_executor_factory();
6561

6662
let mut db = State::builder()

crates/core/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ mod error;
1414
pub use error::VerificationError;
1515

1616
mod executor;
17-
#[cfg(not(feature = "scroll"))]
18-
pub use executor::SbvEthEvmFactory;
19-
pub use executor::{EvmConfig, EvmExecutor};
17+
pub use executor::EvmExecutor;
2018

2119
pub mod verifier;
2220

crates/core/src/witness.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -237,55 +237,3 @@ impl BlockWitnessChunkExt for [BlockWitness] {
237237
.all(|(a, b)| a.header.state_root == b.prev_state_root)
238238
}
239239
}
240-
241-
#[cfg(test)]
242-
#[cfg(feature = "scroll")]
243-
mod tests {
244-
use super::*;
245-
use std::{collections::BTreeSet, ffi::OsStr, path::PathBuf};
246-
247-
#[rstest::rstest]
248-
fn serde_scroll_blocks_roundtrip(
249-
#[files("../../testdata/scroll_witness/**/*.json")]
250-
#[mode = path]
251-
path: PathBuf,
252-
) {
253-
let file_content = std::fs::read_to_string(path).unwrap();
254-
let witness: BlockWitness = serde_json::from_str(&file_content).unwrap();
255-
let serialized = serde_json::to_string(&witness).unwrap();
256-
let deserialized: BlockWitness = serde_json::from_str(&serialized).unwrap();
257-
assert_eq!(witness, deserialized);
258-
}
259-
260-
#[rstest::rstest]
261-
fn serde_scroll_blocks_legacy_compatibility(
262-
#[files("../../testdata/scroll_witness/**/*.json")]
263-
#[mode = path]
264-
path: PathBuf,
265-
) {
266-
let file_content = std::fs::read_to_string(&path).unwrap();
267-
let witness: BlockWitness = serde_json::from_str(&file_content).unwrap();
268-
269-
let base_dir = path
270-
.ancestors()
271-
.find(|p| p.file_name().unwrap() == OsStr::new("testdata"))
272-
.unwrap();
273-
let filename = path.file_name().unwrap();
274-
let harfork = path.parent().unwrap().file_name().unwrap();
275-
let legacy_path = base_dir
276-
.join("legacy")
277-
.join("scroll_witness")
278-
.join(harfork)
279-
.join(filename);
280-
let legacy_content = std::fs::read_to_string(legacy_path).unwrap();
281-
let mut legacy_witness: sbv_primitives::legacy_types::BlockWitness =
282-
serde_json::from_str(&legacy_content).unwrap();
283-
legacy_witness.states = Vec::from_iter(BTreeSet::from_iter(legacy_witness.states));
284-
legacy_witness.codes = Vec::from_iter(BTreeSet::from_iter(legacy_witness.codes));
285-
286-
let mut legacy_converted = witness.into_legacy();
287-
legacy_converted.states = Vec::from_iter(BTreeSet::from_iter(legacy_converted.states));
288-
legacy_converted.codes = Vec::from_iter(BTreeSet::from_iter(legacy_converted.codes));
289-
assert_eq!(legacy_converted, legacy_witness);
290-
}
291-
}

crates/kv/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ workspace = true
1313

1414
[dependencies]
1515
auto_impl.workspace = true
16-
hashbrown = { workspace = true, features = [
17-
"rayon",
18-
] } # reth use rayon::IntoParallelIterator
16+
alloy-primitives.workspace = true
1917
rustc-hash.workspace = true

crates/kv/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ use auto_impl::auto_impl;
44
use std::{borrow::Borrow, hash::Hash};
55

66
mod imps;
7-
pub use hashbrown;
87
pub use imps::{nohash, null};
98

109
/// HashMap
11-
pub type HashMap<K, V, S = rustc_hash::FxBuildHasher> = hashbrown::HashMap<K, V, S>;
10+
pub type HashMap<K, V, S = rustc_hash::FxBuildHasher> = alloy_primitives::map::HashMap<K, V, S>;
1211
/// HashSet
13-
pub type HashSet<V, S = rustc_hash::FxBuildHasher> = hashbrown::HashSet<V, S>;
12+
pub type HashSet<V, S = rustc_hash::FxBuildHasher> = alloy_primitives::map::HashSet<V, S>;
1413

1514
/// Key-Value store insert trait
1615
#[auto_impl(&mut, Box)]

crates/precompile/Cargo.toml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ repository.workspace = true
1212
sbv-primitives = { workspace = true, features = ["evm-types", "revm-types"] }
1313

1414
openvm-ecc-guest = { workspace = true, optional = true }
15-
openvm-keccak256 = { workspace = true, optional = true }
1615
openvm-k256 = { workspace = true, optional = true }
1716
openvm-sha2 = { workspace = true, optional = true }
1817
openvm-pairing = { workspace = true, optional = true }
@@ -31,41 +30,32 @@ scroll = [
3130
]
3231
scroll-openvm = [
3332
"scroll",
34-
"openvm-bn128",
33+
"openvm-bn254",
3534
"openvm-sha256"
3635
]
3736
ethereum-openvm = [
38-
"openvm-bn128",
37+
"openvm-bn254",
3938
"openvm-kzg",
4039
"openvm-secp256k1",
4140
"openvm-sha256",
4241
]
4342

44-
bn128 = [] # marker, won't be used in dependencies
45-
openvm-bn128 = [
46-
"bn128",
43+
openvm-bn254 = [
4744
"dep:openvm-ecc-guest",
4845
"dep:openvm-pairing",
4946
"openvm-pairing/bn254",
5047
]
5148

52-
kzg = [] # marker, won't be used in dependencies
5349
openvm-kzg = [
54-
"kzg",
5550
"dep:openvm-kzg",
5651
]
5752

58-
secp256k1 = [] # marker, won't be used in dependencies
5953
openvm-secp256k1 = [
60-
"secp256k1",
6154
"dep:openvm-ecc-guest",
62-
"dep:openvm-keccak256",
6355
"dep:openvm-k256",
6456
]
6557

66-
sha256 = []
6758
openvm-sha256 = [
68-
"sha256",
6959
"dep:openvm-sha2"
7060
]
7161

0 commit comments

Comments
 (0)