Skip to content

WIP: upgrade reth/revm #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,957 changes: 1,041 additions & 916 deletions Cargo.lock

Large diffs are not rendered by default.

152 changes: 75 additions & 77 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,44 @@ repository = "https://github.com/scroll-tech/stateless-block-verifier"

[workspace.dependencies]
# https://github.com/alloy-rs/alloy
alloy = { version = "0.11", default-features = false }
alloy-consensus = { version = "0.11", default-features = false }
alloy-eips = { version = "0.11", default-features = false }
alloy-network = { version = "0.11", default-features = false }
alloy-provider = { version = "0.11", default-features = false }
alloy-rpc-types-eth = { version = "0.11", default-features = false }
alloy-serde = { version = "0.11", default-features = false }
alloy-transport = { version = "0.11", default-features = false }
alloy = { version = "0.13", default-features = false }
alloy-consensus = { version = "0.13", default-features = false }
alloy-eips = { version = "0.13", default-features = false }
alloy-network = { version = "0.13", default-features = false }
alloy-provider = { version = "0.13", default-features = false }
alloy-rpc-types-eth = { version = "0.13", default-features = false }
alloy-serde = { version = "0.13", default-features = false }
alloy-transport = { version = "0.13", default-features = false }
# https://github.com/alloy-rs/rlp
alloy-rlp = { version = "0.3", default-features = false }
# https://github.com/alloy-rs/trie
alloy-trie = { version = "0.7", default-features = false }
# https://github.com/alloy-rs/core
alloy-primitives = { version = "0.8", default-features = false, features = ["map-hashbrown", "map-fxhash"] }

reth-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-evm = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-evm-ethereum = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-ethereum-forks = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-execution-types = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-primitives = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-primitives-traits = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-storage-errors = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-trie = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-trie-sparse = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }

reth-scroll-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-scroll-evm = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-scroll-forks = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
reth-scroll-primitives = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }

scroll-alloy-consensus = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
scroll-alloy-rpc-types = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
scroll-alloy-network = { git = "https://github.com/scroll-tech/reth", branch = "zkvm/euclid-v2", default-features = false }
revm = { version = "21.0.0", default-features = false }
revm-bytecode = { version = "2.0.0", default-features = false }
revm-scroll = { git = "https://github.com/scroll-tech/scroll-revm" }

reth-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-evm = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-evm-ethereum = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-ethereum-forks = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-execution-types = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-primitives = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-primitives-traits = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-storage-errors = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-trie = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-trie-sparse = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }

reth-scroll-chainspec = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-scroll-evm = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-scroll-forks = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
reth-scroll-primitives = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }

scroll-alloy-consensus = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
scroll-alloy-rpc-types = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }
scroll-alloy-network = { git = "https://github.com/scroll-tech/reth", branch = "scroll", default-features = false }

async-trait = "0.1"
auto_impl = "1.2"
Expand Down Expand Up @@ -104,43 +108,37 @@ sbv-trie = { path = "crates/trie" }
sbv-helpers = { path = "crates/helpers" }
sbv-utils = { path = "crates/utils" }

[workspace.dependencies.revm]
git = "https://github.com/scroll-tech/revm"
branch = "scroll-evm-executor/feat/v55/euclid-v2"
default-features = false
features = ["std"]

[workspace.lints.rust]
missing-docs = "deny"
missing-debug-implementations = "deny"

[patch.crates-io]
# patched add rkyv support & MSRV 1.77
ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.12.3" }

alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch = "v0.8.18" }
ruint = { git = "https://github.com/scroll-tech/uint.git", branch = "v1.14.0" }
#alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch = "v0.8.18" }
alloy-primitives = { path = "../alloy-core/crates/primitives" }

## for local development
#reth-chainspec = { path = "../reth/crates/chainspec" }
#reth-evm = { path = "../reth/crates/evm" }
#reth-evm-ethereum = { path = "../reth/crates/ethereum/evm" }
#reth-ethereum-forks = { path = "../reth/crates/ethereum-forks" }
#reth-execution-types = { path = "../reth/crates/evm/execution-types" }
#reth-primitives = { path = "../reth/crates/primitives" }
#reth-primitives-traits = { path = "../reth/crates/primitives-traits" }
#reth-storage-errors = { path = "../reth/crates/storage/errors" }
#reth-trie = { path = "../reth/crates/trie/trie" }
#reth-trie-sparse = { path = "../reth/crates/trie/sparse" }
#
#reth-scroll-chainspec = { path = "../reth/crates/scroll/chainspec" }
#reth-scroll-evm = { path = "../reth/crates/scroll/evm" }
#reth-scroll-forks = { path = "../reth/crates/scroll/hardforks" }
#reth-scroll-primitives = { path = "../reth/crates/scroll/primitives" }
#
#scroll-alloy-consensus = { path = "../reth/crates/scroll/alloy/consensus" }
#scroll-alloy-rpc-types = { path = "../reth/crates/scroll/alloy/rpc-types" }
#scroll-alloy-network = { path = "../reth/crates/scroll/alloy/network" }
#
reth-chainspec = { path = "../reth/crates/chainspec" }
reth-evm = { path = "../reth/crates/evm" }
reth-evm-ethereum = { path = "../reth/crates/ethereum/evm" }
reth-ethereum-forks = { path = "../reth/crates/ethereum-forks" }
reth-execution-types = { path = "../reth/crates/evm/execution-types" }
reth-primitives = { path = "../reth/crates/primitives" }
reth-primitives-traits = { path = "../reth/crates/primitives-traits" }
reth-storage-errors = { path = "../reth/crates/storage/errors" }
reth-trie = { path = "../reth/crates/trie/trie" }
reth-trie-sparse = { path = "../reth/crates/trie/sparse" }

reth-scroll-chainspec = { path = "../reth/crates/scroll/chainspec" }
reth-scroll-evm = { path = "../reth/crates/scroll/evm" }
reth-scroll-forks = { path = "../reth/crates/scroll/hardforks" }
reth-scroll-primitives = { path = "../reth/crates/scroll/primitives" }

scroll-alloy-consensus = { path = "../reth/crates/scroll/alloy/consensus" }
scroll-alloy-rpc-types = { path = "../reth/crates/scroll/alloy/rpc-types" }
scroll-alloy-network = { path = "../reth/crates/scroll/alloy/network" }

#revm = { path = "../revm/crates/revm" }
#revm-interpreter = { path = "../revm/crates/interpreter" }
#revm-precompile = { path = "../revm/crates/precompile" }
Expand All @@ -151,27 +149,27 @@ alloy-primitives = { git = "https://github.com/scroll-tech/alloy-core", branch =
#revm-interpreter = { path = "../revm/crates/interpreter" }
#revm-precompile = { path = "../revm/crates/precompile" }
#revm-primitives = { path = "../revm/crates/primitives" }
#
#[patch."https://github.com/scroll-tech/reth"]
#reth-chainspec = { path = "../reth/crates/chainspec" }
#reth-evm = { path = "../reth/crates/evm" }
#reth-evm-ethereum = { path = "../reth/crates/ethereum/evm" }
#reth-ethereum-forks = { path = "../reth/crates/ethereum-forks" }
#reth-execution-types = { path = "../reth/crates/evm/execution-types" }
#reth-primitives = { path = "../reth/crates/primitives" }
#reth-primitives-traits = { path = "../reth/crates/primitives-traits" }
#reth-storage-errors = { path = "../reth/crates/storage/errors" }
#reth-trie = { path = "../reth/crates/trie/trie" }
#reth-trie-sparse = { path = "../reth/crates/trie/sparse" }
#
#reth-scroll-chainspec = { path = "../reth/crates/scroll/chainspec" }
#reth-scroll-evm = { path = "../reth/crates/scroll/evm" }
#reth-scroll-forks = { path = "../reth/crates/scroll/hardforks" }
#reth-scroll-primitives = { path = "../reth/crates/scroll/primitives" }
#
#scroll-alloy-consensus = { path = "../reth/crates/scroll/alloy/consensus" }
#scroll-alloy-rpc-types = { path = "../reth/crates/scroll/alloy/rpc-types" }
#scroll-alloy-network = { path = "../reth/crates/scroll/alloy/network" }

[patch."https://github.com/scroll-tech/reth"]
reth-chainspec = { path = "../reth/crates/chainspec" }
reth-evm = { path = "../reth/crates/evm" }
reth-evm-ethereum = { path = "../reth/crates/ethereum/evm" }
reth-ethereum-forks = { path = "../reth/crates/ethereum-forks" }
reth-execution-types = { path = "../reth/crates/evm/execution-types" }
reth-primitives = { path = "../reth/crates/primitives" }
reth-primitives-traits = { path = "../reth/crates/primitives-traits" }
reth-storage-errors = { path = "../reth/crates/storage/errors" }
reth-trie = { path = "../reth/crates/trie/trie" }
reth-trie-sparse = { path = "../reth/crates/trie/sparse" }

reth-scroll-chainspec = { path = "../reth/crates/scroll/chainspec" }
reth-scroll-evm = { path = "../reth/crates/scroll/evm" }
reth-scroll-forks = { path = "../reth/crates/scroll/hardforks" }
reth-scroll-primitives = { path = "../reth/crates/scroll/primitives" }

scroll-alloy-consensus = { path = "../reth/crates/scroll/alloy/consensus" }
scroll-alloy-rpc-types = { path = "../reth/crates/scroll/alloy/rpc-types" }
scroll-alloy-network = { path = "../reth/crates/scroll/alloy/network" }


[profile.release]
Expand Down
24 changes: 13 additions & 11 deletions crates/bin/src/commands/run/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,23 @@ impl RunFileCommand {
.collect::<Result<Vec<_>, _>>()?;

let chain_spec = get_chain_spec_or_build(Chain::from_id(witnesses.chain_id()), |_spec| {
#[cfg(feature = "scroll")]
{
use sbv::primitives::hardforks::{ForkCondition, ScrollHardfork};
_spec
.inner
.hardforks
.insert(ScrollHardfork::EuclidV2, ForkCondition::Timestamp(0));
}
// FIXME: enable this when scroll reth support euclid v2
// #[cfg(feature = "scroll")]
// {
// use sbv::primitives::hardforks::{ForkCondition, ScrollHardfork};
// _spec
// .inner
// .hardforks
// .insert(ScrollHardfork::EuclidV2, ForkCondition::Timestamp(0));
// }
});

let mut chunk_info_builder =
ChunkInfoBuilder::new(&chain_spec, witnesses.prev_state_root(), &blocks);
if let Some(prev_msg_queue_hash) = self.prev_msg_queue_hash {
chunk_info_builder.set_prev_msg_queue_hash(prev_msg_queue_hash);
}
// FIXME: enable this when scroll reth support euclid v2
// if let Some(prev_msg_queue_hash) = self.prev_msg_queue_hash {
// chunk_info_builder.set_prev_msg_queue_hash(prev_msg_queue_hash);
// }

let mut code_db = NoHashMap::default();
witnesses.import_codes(&mut code_db);
Expand Down
17 changes: 9 additions & 8 deletions crates/bin/src/helpers/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ fn verify_inner<T: BlockWitnessRethExt + BlockWitnessTrieExt + BlockWitnessExt>(
.unwrap();

let chain_spec = get_chain_spec_or_build(Chain::from_id(witness.chain_id()), |_spec| {
#[cfg(feature = "scroll")]
{
use sbv::primitives::hardforks::{ForkCondition, ScrollHardfork};
_spec
.inner
.hardforks
.insert(ScrollHardfork::EuclidV2, ForkCondition::Timestamp(0));
}
// FIXME: enable this when scroll reth support euclid v2
// #[cfg(feature = "scroll")]
// {
// use sbv::primitives::hardforks::{ForkCondition, ScrollHardfork};
// _spec
// .inner
// .hardforks
// .insert(ScrollHardfork::EuclidV2, ForkCondition::Timestamp(0));
// }
});

let mut code_db = NoHashMap::default();
Expand Down
6 changes: 1 addition & 5 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ tracing-subscriber.workspace = true
[features]
scroll = [
"dep:reth-scroll-evm",
"reth-evm/scroll",
"reth-evm-ethereum/scroll",
"reth-execution-types/scroll",
"reth-scroll-evm/scroll",
"sbv-primitives/scroll-all",
]
debug-account = ["sbv-helpers/debug-account"]
Expand All @@ -49,4 +45,4 @@ metrics = ["sbv-helpers/metrics"]
sp1 = ["sbv-trie/sp1"]
cycle-tracker = ["sbv-trie/cycle-tracker"]

openvm = ["sbv-primitives/openvm"]
#openvm = ["sbv-primitives/openvm"]
27 changes: 12 additions & 15 deletions crates/core/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use sbv_primitives::{
Address, B256, Bytes, U256,
types::{
AccountInfo, Bytecode,
revm::{db::BundleAccount, interpreter::analysis::to_analysed},
revm::database::{BundleAccount, DBErrorMarker},
},
};
use sbv_trie::{PartialStateTrie, TrieNode};
use std::{cell::RefCell, fmt};

pub use sbv_primitives::types::revm::db::DatabaseRef;
pub use sbv_primitives::types::revm::database::DatabaseRef;

/// A database that consists of account and storage information.
pub struct EvmDatabase<CodeDb, NodesProvider, BlockHashProvider> {
Expand Down Expand Up @@ -114,12 +114,7 @@ impl<
if let Some(code) = code_cache.get(&hash) {
code.clone()
} else {
let code = self
.code_db
.get(&hash)
.cloned()
.map(Bytecode::new_raw)
.map(to_analysed);
let code = self.code_db.get(&hash).cloned().map(Bytecode::new_raw);
code_cache.insert(hash, code.clone());
code
}
Expand All @@ -144,8 +139,8 @@ impl<
let info = AccountInfo {
balance: account.balance,
nonce: account.nonce,
#[cfg(feature = "scroll")]
code_size: code.as_ref().map(|c| c.len()).unwrap_or(0), // FIXME: this should be remove
// #[cfg(feature = "scroll")]
// code_size: code.as_ref().map(|c| c.len()).unwrap_or(0), // FIXME: this should be remove
code_hash: account.code_hash,
code,
};
Expand Down Expand Up @@ -186,8 +181,10 @@ impl<
}
}

impl From<DatabaseError> for reth_storage_errors::provider::ProviderError {
fn from(e: DatabaseError) -> Self {
reth_storage_errors::provider::ProviderError::TrieWitnessError(e.to_string())
}
}
// impl From<DatabaseError> for reth_storage_errors::provider::ProviderError {
// fn from(e: DatabaseError) -> Self {
// reth_storage_errors::provider::ProviderError::TrieWitnessError(e.to_string())
// }
// }

impl DBErrorMarker for DatabaseError {}
2 changes: 1 addition & 1 deletion crates/core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sbv_primitives::{
chainspec::ChainSpec,
types::{
reth::{Block, Receipt, RecoveredBlock},
revm::db::CacheDB,
revm::database::CacheDB,
},
};
use sbv_trie::TrieNode;
Expand Down
2 changes: 1 addition & 1 deletion crates/helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ debug-storage = ["dep:csv", "dep:serde", "revm/serde"]
dev = ["dep:tracing"]
metrics = ["dep:hyper", "dep:hyper-util", "dep:http-body-util", "dep:once_cell", "dep:prometheus-client", "dep:tokio", "tokio/macros", "tokio/signal"]

openvm = ["revm/openvm"]
#openvm = ["revm/openvm"]
4 changes: 0 additions & 4 deletions crates/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ pub use tracing;
#[macro_use]
mod macros;

mod utils;
#[cfg(any(feature = "debug-account", feature = "debug-storage"))]
pub use utils::debug::DebugRecorder;

/// Metrics module
#[cfg(feature = "metrics")]
#[doc(hidden)]
Expand Down
Loading
Loading