feat: alloy-evm and new revm integration (#14021)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: rakita <rakita@users.noreply.github.com>
This commit is contained in:
Arsenii Kulikov
2025-02-17 23:59:23 +04:00
committed by GitHub
parent bb6dec7ceb
commit 336c3d1fac
142 changed files with 1841 additions and 1929 deletions

View File

@ -39,7 +39,8 @@ alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-consensus.workspace = true
revm.workspace = true
revm-database.workspace = true
revm-state = { workspace = true, optional = true }
# async
tokio = { workspace = true, features = ["sync", "macros", "rt-multi-thread"] }
@ -75,6 +76,8 @@ reth-testing-utils.workspace = true
reth-ethereum-engine-primitives.workspace = true
reth-ethereum-primitives.workspace = true
revm-database-interface.workspace = true
revm-state.workspace = true
parking_lot.workspace = true
tempfile.workspace = true
assert_matches.workspace = true
@ -84,6 +87,12 @@ eyre.workspace = true
alloy-consensus.workspace = true
[features]
optimism = [
"reth-execution-types/optimism",
"reth-codecs/op",
"reth-db/optimism",
"reth-db-api/optimism",
]
serde = [
"dashmap/serde",
"notify/serde",
@ -93,7 +102,6 @@ serde = [
"alloy-consensus/serde",
"alloy-eips/serde",
"alloy-rpc-types-engine/serde",
"revm/serde",
"reth-codecs/serde",
"reth-primitives-traits/serde",
"reth-execution-types/serde",
@ -101,6 +109,9 @@ serde = [
"reth-trie/serde",
"reth-stages-types/serde",
"reth-prune-types/serde",
"revm-database/serde",
"revm-database-interface/serde",
"revm-state?/serde",
]
test-utils = [
"reth-db/test-utils",
@ -117,7 +128,7 @@ test-utils = [
"reth-codecs/test-utils",
"reth-db-api/test-utils",
"reth-trie-db/test-utils",
"revm/test-utils",
"reth-prune-types/test-utils",
"reth-stages-types/test-utils",
"revm-state",
]

View File

@ -1,5 +1,5 @@
use alloy_primitives::{B256, U256};
use revm::db::states::RevertToSlot;
use revm_database::states::RevertToSlot;
use std::iter::Peekable;
/// Iterator over storage reverts.

View File

@ -36,7 +36,7 @@ pub use reth_execution_types::*;
pub mod bundle_state;
/// Re-export `OriginalValuesKnown`
pub use revm::db::states::OriginalValuesKnown;
pub use revm_database::states::OriginalValuesKnown;
/// Writer standalone type.
pub mod writer;

View File

@ -23,7 +23,7 @@ use reth_chain_state::{
use reth_chainspec::{ChainInfo, EthereumHardforks};
use reth_db::{models::BlockNumberAddress, transaction::DbTx, Database};
use reth_db_api::models::{AccountBeforeTx, StoredBlockBodyIndices};
use reth_evm::{env::EvmEnv, ConfigureEvmEnv};
use reth_evm::{ConfigureEvmEnv, EvmEnv};
use reth_execution_types::ExecutionOutcome;
use reth_node_types::{BlockTy, HeaderTy, NodeTypesWithDB, ReceiptTy, TxTy};
use reth_primitives::{
@ -40,10 +40,7 @@ use reth_storage_api::{
use reth_storage_errors::provider::ProviderResult;
use reth_trie::HashedPostState;
use reth_trie_db::StateCommitment;
use revm::{
db::BundleState,
primitives::{BlockEnv, CfgEnvWithHandlerCfg},
};
use revm_database::BundleState;
use std::{
ops::{Add, RangeBounds, RangeInclusive, Sub},
sync::Arc,
@ -811,7 +808,7 @@ mod tests {
self, random_block, random_block_range, random_changeset_range, random_eoa_accounts,
random_receipt, BlockParams, BlockRangeParams,
};
use revm::db::BundleState;
use revm_database::BundleState;
use std::{
ops::{Bound, Deref, Range, RangeBounds},
sync::Arc,

View File

@ -187,7 +187,7 @@ impl<SP: StateProvider, EDP: ExecutionDataProvider> StateProofProvider
impl<SP: StateProvider, EDP: ExecutionDataProvider> HashedPostStateProvider
for BundleStateProvider<SP, EDP>
{
fn hashed_post_state(&self, bundle_state: &revm::db::BundleState) -> HashedPostState {
fn hashed_post_state(&self, bundle_state: &revm_database::BundleState) -> HashedPostState {
self.state_provider.hashed_post_state(bundle_state)
}
}

View File

@ -30,7 +30,7 @@ use reth_storage_api::{
StateProvider, StorageChangeSetReader,
};
use reth_storage_errors::provider::ProviderResult;
use revm::db::states::PlainStorageRevert;
use revm_database::states::PlainStorageRevert;
use std::{
ops::{Add, Bound, RangeBounds, RangeInclusive, Sub},
sync::Arc,
@ -1492,7 +1492,7 @@ mod tests {
use reth_testing_utils::generators::{
self, random_block_range, random_changeset_range, random_eoa_accounts, BlockRangeParams,
};
use revm::db::BundleState;
use revm_database::BundleState;
use std::{
ops::{Bound, Range, RangeBounds},
sync::Arc,

View File

@ -28,7 +28,7 @@ use reth_storage_api::{
use reth_storage_errors::provider::ProviderResult;
use reth_trie::HashedPostState;
use reth_trie_db::StateCommitment;
use revm::db::BundleState;
use revm_database::BundleState;
use std::{
ops::{RangeBounds, RangeInclusive},
path::Path,

View File

@ -66,7 +66,7 @@ use reth_trie::{
HashedPostStateSorted, Nibbles, StateRoot, StoredNibbles,
};
use reth_trie_db::{DatabaseStateRoot, DatabaseStorageTrieCursor};
use revm::db::states::{
use revm_database::states::{
PlainStateReverts, PlainStorageChangeset, PlainStorageRevert, StateChangeset,
};
use std::{

View File

@ -395,7 +395,7 @@ impl<Provider: DBProvider + BlockNumReader + StateCommitmentProvider> StateProof
impl<Provider: StateCommitmentProvider> HashedPostStateProvider
for HistoricalStateProviderRef<'_, Provider>
{
fn hashed_post_state(&self, bundle_state: &revm::db::BundleState) -> HashedPostState {
fn hashed_post_state(&self, bundle_state: &revm_database::BundleState) -> HashedPostState {
HashedPostState::from_bundle_state::<
<Provider::StateCommitment as StateCommitment>::KeyHasher,
>(bundle_state.state())

View File

@ -152,7 +152,7 @@ impl<Provider: DBProvider + StateCommitmentProvider> StateProofProvider
impl<Provider: DBProvider + StateCommitmentProvider> HashedPostStateProvider
for LatestStateProviderRef<'_, Provider>
{
fn hashed_post_state(&self, bundle_state: &revm::db::BundleState) -> HashedPostState {
fn hashed_post_state(&self, bundle_state: &revm_database::BundleState) -> HashedPostState {
HashedPostState::from_bundle_state::<
<Provider::StateCommitment as StateCommitment>::KeyHasher,
>(bundle_state.state())

View File

@ -58,7 +58,7 @@ macro_rules! delegate_provider_impls {
fn witness(&self, input: reth_trie::TrieInput, target: reth_trie::HashedPostState) -> reth_storage_errors::provider::ProviderResult<alloy_primitives::map::B256Map<alloy_primitives::Bytes>>;
}
HashedPostStateProvider $(where [$($generics)*])? {
fn hashed_post_state(&self, bundle_state: &revm::db::BundleState) -> reth_trie::HashedPostState;
fn hashed_post_state(&self, bundle_state: &revm_database::BundleState) -> reth_trie::HashedPostState;
}
);
}

View File

@ -16,7 +16,8 @@ use reth_primitives::{
TransactionSigned, TxType,
};
use reth_trie::root::{state_root_unhashed, storage_root_unhashed};
use revm::{db::BundleState, primitives::AccountInfo};
use revm_database::BundleState;
use revm_state::AccountInfo;
use std::{str::FromStr, sync::LazyLock};
/// Assert genesis block

View File

@ -729,10 +729,10 @@ impl<T: Transaction, ChainSpec: EthChainSpec> StateProofProvider for MockEthProv
}
}
impl<T: Transaction, ChainSpec: EthChainSpec> HashedPostStateProvider
impl<T: Transaction, ChainSpec: EthChainSpec + 'static> HashedPostStateProvider
for MockEthProvider<T, ChainSpec>
{
fn hashed_post_state(&self, _state: &revm::db::BundleState) -> HashedPostState {
fn hashed_post_state(&self, _state: &revm_database::BundleState) -> HashedPostState {
HashedPostState::default()
}
}

View File

@ -2,7 +2,7 @@ use alloy_primitives::BlockNumber;
use reth_execution_types::ExecutionOutcome;
use reth_storage_errors::provider::ProviderResult;
use reth_trie::HashedPostStateSorted;
use revm::db::{
use revm_database::{
states::{PlainStateReverts, StateChangeset},
OriginalValuesKnown,
};

View File

@ -11,7 +11,7 @@ use reth_primitives::{NodePrimitives, StaticFileSegment};
use reth_primitives_traits::SignedTransaction;
use reth_storage_api::{DBProvider, StageCheckpointWriter, TransactionsProviderExt};
use reth_storage_errors::writer::UnifiedStorageWriterError;
use revm::db::OriginalValuesKnown;
use revm_database::OriginalValuesKnown;
use std::sync::Arc;
use tracing::debug;
@ -242,17 +242,15 @@ mod tests {
HashedPostState, HashedStorage, StateRoot, StorageRoot,
};
use reth_trie_db::{DatabaseStateRoot, DatabaseStorageRoot};
use revm::{
db::{
states::{
bundle_state::BundleRetention, changes::PlainStorageRevert, PlainStorageChangeset,
},
BundleState, EmptyDB,
use revm_database::{
states::{
bundle_state::BundleRetention, changes::PlainStorageRevert, PlainStorageChangeset,
},
primitives::{
Account as RevmAccount, AccountInfo as RevmAccountInfo, AccountStatus, EvmStorageSlot,
},
DatabaseCommit, State,
BundleState, State,
};
use revm_database_interface::{DatabaseCommit, EmptyDB};
use revm_state::{
Account as RevmAccount, AccountInfo as RevmAccountInfo, AccountStatus, EvmStorageSlot,
};
use std::{collections::BTreeMap, str::FromStr};