mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
Refactor of state_change functionality (#11878)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -6400,12 +6400,12 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"metrics",
|
"metrics",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
|
"reth-evm",
|
||||||
"reth-metrics",
|
"reth-metrics",
|
||||||
"reth-payload-builder",
|
"reth-payload-builder",
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-revm",
|
|
||||||
"reth-tasks",
|
"reth-tasks",
|
||||||
"reth-transaction-pool",
|
"reth-transaction-pool",
|
||||||
"revm",
|
"revm",
|
||||||
@ -7427,6 +7427,8 @@ dependencies = [
|
|||||||
"parking_lot 0.12.3",
|
"parking_lot 0.12.3",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-consensus",
|
"reth-consensus",
|
||||||
|
"reth-consensus-common",
|
||||||
|
"reth-ethereum-forks",
|
||||||
"reth-execution-errors",
|
"reth-execution-errors",
|
||||||
"reth-execution-types",
|
"reth-execution-types",
|
||||||
"reth-metrics",
|
"reth-metrics",
|
||||||
@ -8585,8 +8587,6 @@ version = "1.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"reth-chainspec",
|
|
||||||
"reth-consensus-common",
|
|
||||||
"reth-ethereum-forks",
|
"reth-ethereum-forks",
|
||||||
"reth-execution-errors",
|
"reth-execution-errors",
|
||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
|
|||||||
@ -6,14 +6,15 @@ use eyre::OptionExt;
|
|||||||
use pretty_assertions::Comparison;
|
use pretty_assertions::Comparison;
|
||||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||||
use reth_engine_primitives::InvalidBlockHook;
|
use reth_engine_primitives::InvalidBlockHook;
|
||||||
use reth_evm::{system_calls::SystemCaller, ConfigureEvm};
|
use reth_evm::{
|
||||||
|
state_change::post_block_balance_increments, system_calls::SystemCaller, ConfigureEvm,
|
||||||
|
};
|
||||||
use reth_primitives::{Header, Receipt, SealedBlockWithSenders, SealedHeader};
|
use reth_primitives::{Header, Receipt, SealedBlockWithSenders, SealedHeader};
|
||||||
use reth_provider::{BlockExecutionOutput, ChainSpecProvider, StateProviderFactory};
|
use reth_provider::{BlockExecutionOutput, ChainSpecProvider, StateProviderFactory};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
database::StateProviderDatabase,
|
database::StateProviderDatabase,
|
||||||
db::states::bundle_state::BundleRetention,
|
db::states::bundle_state::BundleRetention,
|
||||||
primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg},
|
primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg},
|
||||||
state_change::post_block_balance_increments,
|
|
||||||
DatabaseCommit, StateBuilder,
|
DatabaseCommit, StateBuilder,
|
||||||
};
|
};
|
||||||
use reth_rpc_api::DebugApiClient;
|
use reth_rpc_api::DebugApiClient;
|
||||||
|
|||||||
@ -12,14 +12,16 @@ use reth_beacon_consensus::{BeaconEngineMessage, BeaconOnNewPayloadError, OnFork
|
|||||||
use reth_engine_primitives::EngineTypes;
|
use reth_engine_primitives::EngineTypes;
|
||||||
use reth_errors::{BlockExecutionError, BlockValidationError, RethError, RethResult};
|
use reth_errors::{BlockExecutionError, BlockValidationError, RethError, RethResult};
|
||||||
use reth_ethereum_forks::EthereumHardforks;
|
use reth_ethereum_forks::EthereumHardforks;
|
||||||
use reth_evm::{system_calls::SystemCaller, ConfigureEvm};
|
use reth_evm::{
|
||||||
|
state_change::post_block_withdrawals_balance_increments, system_calls::SystemCaller,
|
||||||
|
ConfigureEvm,
|
||||||
|
};
|
||||||
use reth_payload_validator::ExecutionPayloadValidator;
|
use reth_payload_validator::ExecutionPayloadValidator;
|
||||||
use reth_primitives::{proofs, Block, BlockBody, Header, Receipt, Receipts};
|
use reth_primitives::{proofs, Block, BlockBody, Header, Receipt, Receipts};
|
||||||
use reth_provider::{BlockReader, ExecutionOutcome, ProviderError, StateProviderFactory};
|
use reth_provider::{BlockReader, ExecutionOutcome, ProviderError, StateProviderFactory};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
database::StateProviderDatabase,
|
database::StateProviderDatabase,
|
||||||
db::{states::bundle_state::BundleRetention, State},
|
db::{states::bundle_state::BundleRetention, State},
|
||||||
state_change::post_block_withdrawals_balance_increments,
|
|
||||||
DatabaseCommit,
|
DatabaseCommit,
|
||||||
};
|
};
|
||||||
use reth_rpc_types_compat::engine::payload::block_to_payload;
|
use reth_rpc_types_compat::engine::payload::block_to_payload;
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use reth_evm::{
|
|||||||
BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput,
|
BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput,
|
||||||
BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
|
BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
|
||||||
},
|
},
|
||||||
|
state_change::post_block_balance_increments,
|
||||||
system_calls::{NoopHook, OnStateHook, SystemCaller},
|
system_calls::{NoopHook, OnStateHook, SystemCaller},
|
||||||
ConfigureEvm,
|
ConfigureEvm,
|
||||||
};
|
};
|
||||||
@ -25,7 +26,6 @@ use reth_prune_types::PruneModes;
|
|||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
batch::BlockBatchRecord,
|
batch::BlockBatchRecord,
|
||||||
db::{states::bundle_state::BundleRetention, State},
|
db::{states::bundle_state::BundleRetention, State},
|
||||||
state_change::post_block_balance_increments,
|
|
||||||
Evm,
|
Evm,
|
||||||
};
|
};
|
||||||
use revm_primitives::{
|
use revm_primitives::{
|
||||||
|
|||||||
@ -16,13 +16,13 @@ use reth_evm::{
|
|||||||
BlockExecutionError, BlockExecutionStrategy, BlockExecutionStrategyFactory,
|
BlockExecutionError, BlockExecutionStrategy, BlockExecutionStrategyFactory,
|
||||||
BlockValidationError, ProviderError,
|
BlockValidationError, ProviderError,
|
||||||
},
|
},
|
||||||
|
state_change::post_block_balance_increments,
|
||||||
system_calls::{OnStateHook, SystemCaller},
|
system_calls::{OnStateHook, SystemCaller},
|
||||||
ConfigureEvm, ConfigureEvmEnv,
|
ConfigureEvm, ConfigureEvmEnv,
|
||||||
};
|
};
|
||||||
use reth_primitives::{BlockWithSenders, Header, Receipt};
|
use reth_primitives::{BlockWithSenders, Header, Receipt};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
db::{states::bundle_state::BundleRetention, BundleState},
|
db::{states::bundle_state::BundleRetention, BundleState},
|
||||||
state_change::post_block_balance_increments,
|
|
||||||
Database, DatabaseCommit, State,
|
Database, DatabaseCommit, State,
|
||||||
};
|
};
|
||||||
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256};
|
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256};
|
||||||
|
|||||||
@ -14,6 +14,7 @@ workspace = true
|
|||||||
# reth
|
# reth
|
||||||
reth-chainspec.workspace = true
|
reth-chainspec.workspace = true
|
||||||
reth-consensus.workspace = true
|
reth-consensus.workspace = true
|
||||||
|
reth-consensus-common.workspace = true
|
||||||
reth-execution-errors.workspace = true
|
reth-execution-errors.workspace = true
|
||||||
reth-execution-types.workspace = true
|
reth-execution-types.workspace = true
|
||||||
reth-metrics = { workspace = true, optional = true }
|
reth-metrics = { workspace = true, optional = true }
|
||||||
@ -37,6 +38,7 @@ parking_lot = { workspace = true, optional = true }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
|
reth-ethereum-forks.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
@ -31,6 +31,7 @@ pub mod execute;
|
|||||||
pub mod metrics;
|
pub mod metrics;
|
||||||
pub mod noop;
|
pub mod noop;
|
||||||
pub mod provider;
|
pub mod provider;
|
||||||
|
pub mod state_change;
|
||||||
pub mod system_calls;
|
pub mod system_calls;
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-utils"))]
|
#[cfg(any(test, feature = "test-utils"))]
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
//! State changes that are not related to transactions.
|
||||||
|
|
||||||
use alloy_primitives::{map::HashMap, Address, U256};
|
use alloy_primitives::{map::HashMap, Address, U256};
|
||||||
use reth_chainspec::EthereumHardforks;
|
use reth_chainspec::EthereumHardforks;
|
||||||
use reth_consensus_common::calc;
|
use reth_consensus_common::calc;
|
||||||
@ -14,6 +14,7 @@ use reth_evm::{
|
|||||||
BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput,
|
BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput,
|
||||||
BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
|
BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
|
||||||
},
|
},
|
||||||
|
state_change::post_block_balance_increments,
|
||||||
system_calls::{NoopHook, OnStateHook, SystemCaller},
|
system_calls::{NoopHook, OnStateHook, SystemCaller},
|
||||||
ConfigureEvm,
|
ConfigureEvm,
|
||||||
};
|
};
|
||||||
@ -22,10 +23,7 @@ use reth_optimism_consensus::validate_block_post_execution;
|
|||||||
use reth_optimism_forks::OptimismHardfork;
|
use reth_optimism_forks::OptimismHardfork;
|
||||||
use reth_primitives::{BlockWithSenders, Header, Receipt, Receipts, TxType};
|
use reth_primitives::{BlockWithSenders, Header, Receipt, Receipts, TxType};
|
||||||
use reth_prune_types::PruneModes;
|
use reth_prune_types::PruneModes;
|
||||||
use reth_revm::{
|
use reth_revm::{batch::BlockBatchRecord, db::states::bundle_state::BundleRetention, Evm, State};
|
||||||
batch::BlockBatchRecord, db::states::bundle_state::BundleRetention,
|
|
||||||
state_change::post_block_balance_increments, Evm, State,
|
|
||||||
};
|
|
||||||
use revm_primitives::{
|
use revm_primitives::{
|
||||||
db::{Database, DatabaseCommit},
|
db::{Database, DatabaseCommit},
|
||||||
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState,
|
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState,
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use reth_evm::{
|
|||||||
BlockExecutionError, BlockExecutionStrategy, BlockExecutionStrategyFactory,
|
BlockExecutionError, BlockExecutionStrategy, BlockExecutionStrategyFactory,
|
||||||
BlockValidationError, ProviderError,
|
BlockValidationError, ProviderError,
|
||||||
},
|
},
|
||||||
|
state_change::post_block_balance_increments,
|
||||||
system_calls::{OnStateHook, SystemCaller},
|
system_calls::{OnStateHook, SystemCaller},
|
||||||
ConfigureEvm, ConfigureEvmEnv,
|
ConfigureEvm, ConfigureEvmEnv,
|
||||||
};
|
};
|
||||||
@ -21,7 +22,6 @@ use reth_optimism_forks::OptimismHardfork;
|
|||||||
use reth_primitives::{BlockWithSenders, Header, Receipt, TxType};
|
use reth_primitives::{BlockWithSenders, Header, Receipt, TxType};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
db::{states::bundle_state::BundleRetention, BundleState},
|
db::{states::bundle_state::BundleRetention, BundleState},
|
||||||
state_change::post_block_balance_increments,
|
|
||||||
Database, State,
|
Database, State,
|
||||||
};
|
};
|
||||||
use revm_primitives::{
|
use revm_primitives::{
|
||||||
|
|||||||
@ -15,12 +15,12 @@ workspace = true
|
|||||||
# reth
|
# reth
|
||||||
reth-chainspec.workspace = true
|
reth-chainspec.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
reth-revm.workspace = true
|
|
||||||
reth-transaction-pool.workspace = true
|
reth-transaction-pool.workspace = true
|
||||||
reth-provider.workspace = true
|
reth-provider.workspace = true
|
||||||
reth-payload-builder.workspace = true
|
reth-payload-builder.workspace = true
|
||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
reth-tasks.workspace = true
|
reth-tasks.workspace = true
|
||||||
|
reth-evm.workspace = true
|
||||||
|
|
||||||
# ethereum
|
# ethereum
|
||||||
alloy-rlp.workspace = true
|
alloy-rlp.workspace = true
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use alloy_primitives::{Bytes, B256, U256};
|
|||||||
use futures_core::ready;
|
use futures_core::ready;
|
||||||
use futures_util::FutureExt;
|
use futures_util::FutureExt;
|
||||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||||
|
use reth_evm::state_change::post_block_withdrawals_balance_increments;
|
||||||
use reth_payload_builder::{
|
use reth_payload_builder::{
|
||||||
database::CachedReads, KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJobGenerator,
|
database::CachedReads, KeepPayloadJobAlive, PayloadId, PayloadJob, PayloadJobGenerator,
|
||||||
};
|
};
|
||||||
@ -27,7 +28,6 @@ use reth_primitives::{
|
|||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
BlockReaderIdExt, BlockSource, CanonStateNotification, ProviderError, StateProviderFactory,
|
BlockReaderIdExt, BlockSource, CanonStateNotification, ProviderError, StateProviderFactory,
|
||||||
};
|
};
|
||||||
use reth_revm::state_change::post_block_withdrawals_balance_increments;
|
|
||||||
use reth_tasks::TaskSpawner;
|
use reth_tasks::TaskSpawner;
|
||||||
use reth_transaction_pool::TransactionPool;
|
use reth_transaction_pool::TransactionPool;
|
||||||
use revm::{Database, State};
|
use revm::{Database, State};
|
||||||
|
|||||||
@ -13,11 +13,9 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# reth
|
# reth
|
||||||
reth-chainspec.workspace = true
|
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
reth-storage-errors.workspace = true
|
reth-storage-errors.workspace = true
|
||||||
reth-execution-errors.workspace = true
|
reth-execution-errors.workspace = true
|
||||||
reth-consensus-common.workspace = true
|
|
||||||
reth-prune-types.workspace = true
|
reth-prune-types.workspace = true
|
||||||
reth-storage-api.workspace = true
|
reth-storage-api.workspace = true
|
||||||
reth-trie = { workspace = true, optional = true }
|
reth-trie = { workspace = true, optional = true }
|
||||||
|
|||||||
@ -16,9 +16,6 @@ pub mod database;
|
|||||||
|
|
||||||
pub mod batch;
|
pub mod batch;
|
||||||
|
|
||||||
/// State changes that are not related to transactions.
|
|
||||||
pub mod state_change;
|
|
||||||
|
|
||||||
/// Common test helpers
|
/// Common test helpers
|
||||||
#[cfg(any(test, feature = "test-utils"))]
|
#[cfg(any(test, feature = "test-utils"))]
|
||||||
pub mod test_utils;
|
pub mod test_utils;
|
||||||
|
|||||||
@ -11,7 +11,10 @@ use alloy_primitives::{BlockNumber, B256, U256};
|
|||||||
use alloy_rpc_types::BlockNumberOrTag;
|
use alloy_rpc_types::BlockNumberOrTag;
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||||
use reth_evm::{system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv};
|
use reth_evm::{
|
||||||
|
state_change::post_block_withdrawals_balance_increments, system_calls::SystemCaller,
|
||||||
|
ConfigureEvm, ConfigureEvmEnv,
|
||||||
|
};
|
||||||
use reth_execution_types::ExecutionOutcome;
|
use reth_execution_types::ExecutionOutcome;
|
||||||
use reth_primitives::{
|
use reth_primitives::{
|
||||||
constants::{eip4844::MAX_DATA_GAS_PER_BLOCK, BEACON_NONCE},
|
constants::{eip4844::MAX_DATA_GAS_PER_BLOCK, BEACON_NONCE},
|
||||||
@ -27,9 +30,7 @@ use reth_provider::{
|
|||||||
BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ProviderError,
|
BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ProviderError,
|
||||||
ReceiptProvider, StateProviderFactory,
|
ReceiptProvider, StateProviderFactory,
|
||||||
};
|
};
|
||||||
use reth_revm::{
|
use reth_revm::database::StateProviderDatabase;
|
||||||
database::StateProviderDatabase, state_change::post_block_withdrawals_balance_increments,
|
|
||||||
};
|
|
||||||
use reth_rpc_eth_types::{EthApiError, PendingBlock, PendingBlockEnv, PendingBlockEnvOrigin};
|
use reth_rpc_eth_types::{EthApiError, PendingBlock, PendingBlockEnv, PendingBlockEnvOrigin};
|
||||||
use reth_transaction_pool::{BestTransactionsAttributes, TransactionPool};
|
use reth_transaction_pool::{BestTransactionsAttributes, TransactionPool};
|
||||||
use reth_trie::HashedPostState;
|
use reth_trie::HashedPostState;
|
||||||
@ -157,7 +158,7 @@ pub trait LoadPendingBlock: EthApiTypes {
|
|||||||
pending.origin.header().hash() == pending_block.block.parent_hash &&
|
pending.origin.header().hash() == pending_block.block.parent_hash &&
|
||||||
now <= pending_block.expires_at
|
now <= pending_block.expires_at
|
||||||
{
|
{
|
||||||
return Ok(Some((pending_block.block.clone(), pending_block.receipts.clone())))
|
return Ok(Some((pending_block.block.clone(), pending_block.receipts.clone())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user