diff --git a/Cargo.lock b/Cargo.lock index ceeb53a2e4a7..fcd1527ba02f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,6 +61,7 @@ dependencies = [ "cfg-if", "getrandom 0.2.15", "once_cell", + "serde", "version_check", "zerocopy", ] @@ -97,9 +98,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-chains" -version = "0.1.34" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8158b4878c67837e5413721cc44298e6a2d88d39203175ea025e51892a16ba4c" +checksum = "94c225801d42099570d0674701dddd4142f0ef715282aeb5985042e2ec962df7" dependencies = [ "alloy-rlp", "arbitrary", @@ -2612,6 +2613,15 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "enr" version = "0.12.1" @@ -3101,6 +3111,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -3673,6 +3698,22 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.9" @@ -4929,6 +4970,23 @@ dependencies = [ "unsigned-varint 0.7.2", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.26.4" @@ -5270,12 +5328,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -5434,6 +5530,35 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pevm" +version = "0.1.0" +source = "git+https://github.com/risechain/pevm?rev=de7de2683201c53b8adaba19c01b3033fb37b5d8#de7de2683201c53b8adaba19c01b3033fb37b5d8" +dependencies = [ + "ahash", + "alloy-chains", + "alloy-consensus", + "alloy-primitives", + "alloy-provider", + "alloy-rlp", + "alloy-rpc-types", + "alloy-transport", + "alloy-transport-http", + "alloy-trie", + "bincode", + "bitflags 2.6.0", + "bitvec", + "clap", + "dashmap 6.1.0", + "flate2", + "reqwest", + "revm", + "serde", + "serde_json", + "smallvec", + "tokio", +] + [[package]] name = "pharos" version = "0.5.3" @@ -6159,18 +6284,22 @@ checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", + "encoding_rs", "futures-core", "futures-util", + "h2", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -6183,7 +6312,9 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper 1.0.1", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -7350,6 +7481,7 @@ dependencies = [ "alloy-genesis", "alloy-primitives", "alloy-sol-types", + "pevm", "reth-chainspec", "reth-ethereum-consensus", "reth-ethereum-forks", @@ -9191,11 +9323,11 @@ dependencies = [ [[package]] name = "revm" version = "14.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "641702b12847f9ed418d552f4fcabe536d867a2c980e96b6e7e25d7b992f929f" +source = "git+https://github.com/risechain/revm?rev=cf599db31b5c64547ce91998f18ca97522876d7c#cf599db31b5c64547ce91998f18ca97522876d7c" dependencies = [ "auto_impl", "cfg-if", + "dashmap 6.1.0", "dyn-clone", "revm-interpreter", "revm-precompile", @@ -9206,8 +9338,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c44af0bf801f48d25f7baf25cf72aff4c02d610f83b428175228162fef0246" +source = "git+https://github.com/risechain/revm-inspectors?rev=348e7996ed4fa88f58d81bd136a60ea537174252#348e7996ed4fa88f58d81bd136a60ea537174252" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -9225,8 +9356,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "10.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5e14002afae20b5bf1566f22316122f42f57517000e559c55b25bf7a49cba2" +source = "git+https://github.com/risechain/revm?rev=cf599db31b5c64547ce91998f18ca97522876d7c#cf599db31b5c64547ce91998f18ca97522876d7c" dependencies = [ "revm-primitives", "serde", @@ -9235,8 +9365,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "11.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3198c06247e8d4ad0d1312591edf049b0de4ddffa9fecb625c318fd67db8639b" +source = "git+https://github.com/risechain/revm?rev=cf599db31b5c64547ce91998f18ca97522876d7c#cf599db31b5c64547ce91998f18ca97522876d7c" dependencies = [ "aurora-engine-modexp", "blst", @@ -9255,8 +9384,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "10.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f1525851a03aff9a9d6a1d018b414d76252d6802ab54695b27093ecd7e7a101" +source = "git+https://github.com/risechain/revm?rev=cf599db31b5c64547ce91998f18ca97522876d7c#cf599db31b5c64547ce91998f18ca97522876d7c" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -10288,6 +10416,27 @@ dependencies = [ "windows 0.57.0", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -10568,6 +10717,16 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -11125,6 +11284,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vergen" version = "8.3.2" diff --git a/Cargo.toml b/Cargo.toml index 8c1ee8c4514c..6278443bc8f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -406,18 +406,18 @@ reth-trie-db = { path = "crates/trie/db" } reth-trie-parallel = { path = "crates/trie/parallel" } # revm -revm = { version = "14.0.3", features = [ +revm = { git = "https://github.com/risechain/revm", rev = "cf599db31b5c64547ce91998f18ca97522876d7c", features = [ "std", "secp256k1", "blst", ], default-features = false } -revm-inspectors = "0.8.1" -revm-primitives = { version = "10.0.0", features = [ +revm-primitives = { git = "https://github.com/risechain/revm", rev = "cf599db31b5c64547ce91998f18ca97522876d7c", features = [ "std", ], default-features = false } +revm-inspectors = { git = "https://github.com/risechain/revm-inspectors", rev = "348e7996ed4fa88f58d81bd136a60ea537174252" } # eth -alloy-chains = "0.1.32" +alloy-chains = "0.1.35" alloy-dyn-abi = "0.8.0" alloy-primitives = { version = "0.8.4", default-features = false } alloy-rlp = "0.3.4" diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index 61ce0a23b904..a00671a54c34 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -29,6 +29,8 @@ alloy-primitives.workspace = true alloy-eips.workspace = true alloy-sol-types.workspace = true +pevm = { git = "https://github.com/risechain/pevm", rev = "de7de2683201c53b8adaba19c01b3033fb37b5d8" } + [dev-dependencies] reth-testing-utils.workspace = true reth-revm = { workspace = true, features = ["test-utils"] } diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index f1d7de115d57..b82fe8d6b67f 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -6,7 +6,8 @@ use crate::{ }; use alloc::{boxed::Box, sync::Arc, vec, vec::Vec}; use alloy_primitives::{BlockNumber, U256}; -use core::fmt::Display; +use core::{fmt::Display, num::NonZeroUsize}; +use pevm::{chain::PevmEthereum, Pevm}; use reth_chainspec::{ChainSpec, EthereumHardforks, MAINNET}; use reth_ethereum_consensus::validate_block_post_execution; use reth_evm::{ @@ -27,7 +28,7 @@ use reth_revm::{ Evm, }; use revm_primitives::{ - db::{Database, DatabaseCommit}, + db::{DatabaseCommit, DatabaseRef}, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, }; @@ -63,12 +64,15 @@ where { fn eth_executor(&self, db: DB) -> EthBlockExecutor where - DB: Database>, + DB: DatabaseRef + Display> + Send + Sync, { EthBlockExecutor::new( self.chain_spec.clone(), self.evm_config.clone(), State::builder().with_database(db).with_bundle_update().without_state_clear().build(), + Pevm::default(), + PevmEthereum::mainnet(), + NonZeroUsize::new(8).unwrap(), ) } } @@ -77,22 +81,22 @@ impl BlockExecutorProvider for EthExecutorProvider where EvmConfig: ConfigureEvm
, { - type Executor + Display>> = + type Executor + Display> + Send + Sync> = EthBlockExecutor; - type BatchExecutor + Display>> = + type BatchExecutor + Display> + Send + Sync> = EthBatchExecutor; fn executor(&self, db: DB) -> Self::Executor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { self.eth_executor(db) } fn batch_executor(&self, db: DB) -> Self::BatchExecutor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { let executor = self.eth_executor(db); EthBatchExecutor { executor, batch_record: BlockBatchRecord::default() } @@ -130,14 +134,13 @@ where /// /// It does __not__ apply post-execution changes that do not require an [EVM](Evm), for that see /// [`EthBlockExecutor::post_execution`]. - fn execute_state_transitions( + fn _execute_state_transitions( &self, block: &BlockWithSenders, mut evm: Evm<'_, Ext, &mut State>, - ) -> Result + ) -> Result<(EthExecuteOutput, Vec), BlockExecutionError> where - DB: Database, - DB::Error: Into + Display, + DB: DatabaseRef + Display> + Send + Sync, { let mut system_caller = SystemCaller::new(&self.evm_config, &self.chain_spec); @@ -146,6 +149,7 @@ where // execute transactions let mut cumulative_gas_used = 0; let mut receipts = Vec::with_capacity(block.body.transactions.len()); + let mut results = Vec::with_capacity(block.body.transactions.len()); for (sender, transaction) in block.transactions_with_sender() { // The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior, // must be no greater than the block’s gasLimit. @@ -161,7 +165,7 @@ where self.evm_config.fill_tx_env(evm.tx_mut(), transaction, *sender); // Execute transaction. - let ResultAndState { result, state } = evm.transact().map_err(move |err| { + let result_and_state = evm.transact().map_err(move |err| { let new_err = err.map_db_err(|e| e.into()); // Ensure hash is calculated for error log, if not already done BlockValidationError::EVM { @@ -169,10 +173,11 @@ where error: Box::new(new_err), } })?; - evm.db_mut().commit(state); + results.push(result_and_state.clone()); + evm.db_mut().commit(result_and_state.state); // append gas used - cumulative_gas_used += result.gas_used(); + cumulative_gas_used += result_and_state.result.gas_used(); // Push transaction changeset and calculate header bloom filter for receipt. receipts.push( @@ -181,10 +186,10 @@ where tx_type: transaction.tx_type(), // Success flag was added in `EIP-658: Embedding transaction status code in // receipts`. - success: result.is_success(), + success: result_and_state.result.is_success(), cumulative_gas_used, // convert to reth log - logs: result.into_logs(), + logs: result_and_state.result.into_logs(), ..Default::default() }, ); @@ -202,7 +207,7 @@ where vec![] }; - Ok(EthExecuteOutput { receipts, requests, gas_used: cumulative_gas_used }) + Ok((EthExecuteOutput { receipts, requests, gas_used: cumulative_gas_used }, results)) } } @@ -217,12 +222,29 @@ pub struct EthBlockExecutor { executor: EthEvmExecutor, /// The state to use for execution state: State, + /// Parallel executor + pevm: Pevm, + chain: PevmEthereum, + concurrency_level: NonZeroUsize, } impl EthBlockExecutor { /// Creates a new Ethereum block executor. - pub const fn new(chain_spec: Arc, evm_config: EvmConfig, state: State) -> Self { - Self { executor: EthEvmExecutor { chain_spec, evm_config }, state } + pub const fn new( + chain_spec: Arc, + evm_config: EvmConfig, + state: State, + pevm: Pevm, + chain: PevmEthereum, + concurrency_level: NonZeroUsize, + ) -> Self { + Self { + executor: EthEvmExecutor { chain_spec, evm_config }, + state, + pevm, + chain, + concurrency_level, + } } #[inline] @@ -240,14 +262,14 @@ impl EthBlockExecutor { impl EthBlockExecutor where EvmConfig: ConfigureEvm
, - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { /// Configures a new evm configuration and block environment for the given block. /// /// # Caution /// /// This does not initialize the tx environment. - fn evm_env_for_block(&self, header: &Header, total_difficulty: U256) -> EnvWithHandlerCfg { + fn _evm_env_for_block(&self, header: &Header, total_difficulty: U256) -> EnvWithHandlerCfg { let mut cfg = CfgEnvWithHandlerCfg::new(Default::default(), Default::default()); let mut block_env = BlockEnv::default(); self.executor.evm_config.fill_cfg_and_block_env( @@ -275,16 +297,60 @@ where self.on_new_block(&block.header); // 2. configure the evm and execute - let env = self.evm_env_for_block(&block.header, total_difficulty); - let output = { - let evm = self.executor.evm_config.evm_with_env(&mut self.state, env); - self.executor.execute_state_transitions(block, evm) - }?; + let spec_id = crate::config::revm_spec( + self.chain_spec(), + &reth_chainspec::Head { + number: block.header.number, + timestamp: block.header.timestamp, + difficulty: block.header.difficulty, + total_difficulty, + hash: Default::default(), + }, + ); + let mut block_env = BlockEnv::default(); + self.executor.evm_config.fill_block_env( + &mut block_env, + &block.header, + spec_id >= revm_primitives::SpecId::MERGE, + ); + let mut tx_envs = Vec::with_capacity(block.body.transactions.len()); + for (sender, transaction) in block.transactions_with_sender() { + let mut tx_env = revm_primitives::TxEnv::default(); + self.executor.evm_config.fill_tx_env(&mut tx_env, transaction, *sender); + tx_envs.push(tx_env); + } + let results = + if tx_envs.len() < self.concurrency_level.into() || block.header.gas_used < 4_000_000 { + pevm::execute_revm_sequential(&self.state, &self.chain, spec_id, block_env, tx_envs) + } else { + self.pevm.execute_revm_parallel( + &self.state, + &self.chain, + spec_id, + block_env, + tx_envs, + self.concurrency_level, + ) + } + .unwrap_or_else(|err| panic!("{:?}", err)); + let mut cumulative_gas_used = 0; + let mut receipts = Vec::with_capacity(block.body.transactions.len()); + for (tx, ResultAndState { result, state }) in block.body.transactions().zip(results) { + cumulative_gas_used += result.gas_used(); + receipts.push(Receipt { + tx_type: tx.tx_type(), + success: result.is_success(), + cumulative_gas_used, + logs: result.into_logs(), + ..Default::default() + }); + self.state.commit(state); + } // 3. apply post execution changes self.post_execution(block, total_difficulty)?; - Ok(output) + Ok(EthExecuteOutput { receipts, requests: Vec::new(), gas_used: cumulative_gas_used }) } /// Apply settings before a new block is executed. @@ -329,7 +395,7 @@ where impl Executor for EthBlockExecutor where EvmConfig: ConfigureEvm
, - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; type Output = BlockExecutionOutput; @@ -393,7 +459,7 @@ impl EthBatchExecutor { impl BatchExecutor for EthBatchExecutor where EvmConfig: ConfigureEvm
, - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; type Output = ExecutionOutcome; diff --git a/crates/ethereum/payload/src/lib.rs b/crates/ethereum/payload/src/lib.rs index 5d2fcde2f7e5..c28f17a331c2 100644 --- a/crates/ethereum/payload/src/lib.rs +++ b/crates/ethereum/payload/src/lib.rs @@ -354,7 +354,7 @@ where // calculate the state root let hashed_state = HashedPostState::from_bundle_state(&execution_outcome.state().state); let (state_root, trie_output) = { - let state_provider = db.database.0.inner.borrow_mut(); + let state_provider = db.database.inner.borrow_mut(); state_provider.db.state_root_with_updates(hashed_state.clone()).inspect_err(|err| { warn!(target: "payload_builder", parent_hash=%parent_block.hash(), diff --git a/crates/evm/src/either.rs b/crates/evm/src/either.rs index a3fca50ec7ee..9d5f0e0888ec 100644 --- a/crates/evm/src/either.rs +++ b/crates/evm/src/either.rs @@ -9,7 +9,7 @@ use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionO use reth_primitives::{BlockWithSenders, Receipt}; use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderError; -use revm_primitives::db::Database; +use revm::DatabaseRef; // re-export Either pub use futures_util::future::Either; @@ -20,15 +20,15 @@ where A: BlockExecutorProvider, B: BlockExecutorProvider, { - type Executor + Display>> = + type Executor + Display> + Send + Sync> = Either, B::Executor>; - type BatchExecutor + Display>> = + type BatchExecutor + Display> + Send + Sync> = Either, B::BatchExecutor>; fn executor(&self, db: DB) -> Self::Executor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { match self { Self::Left(a) => Either::Left(a.executor(db)), @@ -38,7 +38,7 @@ where fn batch_executor(&self, db: DB) -> Self::BatchExecutor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { match self { Self::Left(a) => Either::Left(a.batch_executor(db)), @@ -61,7 +61,7 @@ where Output = BlockExecutionOutput, Error = BlockExecutionError, >, - DB: Database + Display>, + DB: DatabaseRef + Display>, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; type Output = BlockExecutionOutput; @@ -103,7 +103,7 @@ where Output = ExecutionOutcome, Error = BlockExecutionError, >, - DB: Database + Display>, + DB: DatabaseRef + Display>, { type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>; type Output = ExecutionOutcome; diff --git a/crates/evm/src/execute.rs b/crates/evm/src/execute.rs index ffc08469dc8d..9854555f3682 100644 --- a/crates/evm/src/execute.rs +++ b/crates/evm/src/execute.rs @@ -10,7 +10,7 @@ use core::fmt::Display; use reth_primitives::{BlockWithSenders, Receipt}; use reth_prune_types::PruneModes; use revm::State; -use revm_primitives::db::Database; +use revm_primitives::db::DatabaseRef; /// A general purpose executor trait that executes an input (e.g. block) and produces an output /// (e.g. state changes and receipts). @@ -118,7 +118,7 @@ pub trait BlockExecutorProvider: Send + Sync + Clone + Unpin + 'static { /// /// It is not expected to validate the state trie root, this must be done by the caller using /// the returned state. - type Executor + Display>>: for<'a> Executor< + type Executor + Display> + Send + Sync>: for<'a> Executor< DB, Input<'a> = BlockExecutionInput<'a, BlockWithSenders>, Output = BlockExecutionOutput, @@ -126,7 +126,7 @@ pub trait BlockExecutorProvider: Send + Sync + Clone + Unpin + 'static { >; /// An executor that can execute a batch of blocks given a database. - type BatchExecutor + Display>>: for<'a> BatchExecutor< + type BatchExecutor + Display> + Send + Sync>: for<'a> BatchExecutor< DB, Input<'a> = BlockExecutionInput<'a, BlockWithSenders>, Output = ExecutionOutcome, @@ -138,7 +138,7 @@ pub trait BlockExecutorProvider: Send + Sync + Clone + Unpin + 'static { /// This is used to execute a single block and get the changed state. fn executor(&self, db: DB) -> Self::Executor where - DB: Database + Display>; + DB: DatabaseRef + Display> + Send + Sync; /// Creates a new batch executor with the given database and pruning modes. /// @@ -146,7 +146,7 @@ pub trait BlockExecutorProvider: Send + Sync + Clone + Unpin + 'static { /// during historical sync which involves executing multiple blocks in sequence. fn batch_executor(&self, db: DB) -> Self::BatchExecutor where - DB: Database + Display>; + DB: DatabaseRef + Display> + Send + Sync; } #[cfg(test)] @@ -160,19 +160,21 @@ mod tests { struct TestExecutorProvider; impl BlockExecutorProvider for TestExecutorProvider { - type Executor + Display>> = TestExecutor; - type BatchExecutor + Display>> = TestExecutor; + type Executor + Display> + Send + Sync> = + TestExecutor; + type BatchExecutor + Display> + Send + Sync> = + TestExecutor; fn executor(&self, _db: DB) -> Self::Executor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { TestExecutor(PhantomData) } fn batch_executor(&self, _db: DB) -> Self::BatchExecutor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { TestExecutor(PhantomData) } diff --git a/crates/evm/src/noop.rs b/crates/evm/src/noop.rs index 392bfd0bd722..45e8cfdeb4e2 100644 --- a/crates/evm/src/noop.rs +++ b/crates/evm/src/noop.rs @@ -8,7 +8,7 @@ use reth_primitives::{BlockWithSenders, Receipt}; use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderError; use revm::State; -use revm_primitives::db::Database; +use revm_primitives::db::DatabaseRef; use crate::execute::{BatchExecutor, BlockExecutorProvider, Executor}; @@ -20,20 +20,20 @@ const UNAVAILABLE_FOR_NOOP: &str = "execution unavailable for noop"; pub struct NoopBlockExecutorProvider; impl BlockExecutorProvider for NoopBlockExecutorProvider { - type Executor + Display>> = Self; + type Executor + Display> + Send + Sync> = Self; - type BatchExecutor + Display>> = Self; + type BatchExecutor + Display> + Send + Sync> = Self; fn executor(&self, _: DB) -> Self::Executor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { Self } fn batch_executor(&self, _: DB) -> Self::BatchExecutor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { Self } diff --git a/crates/evm/src/test_utils.rs b/crates/evm/src/test_utils.rs index cf45930aece9..bdf2d75b5ff7 100644 --- a/crates/evm/src/test_utils.rs +++ b/crates/evm/src/test_utils.rs @@ -10,8 +10,7 @@ use reth_execution_types::ExecutionOutcome; use reth_primitives::{BlockWithSenders, Receipt}; use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderError; -use revm::State; -use revm_primitives::db::Database; +use revm::{DatabaseRef, State}; use std::{fmt::Display, sync::Arc}; /// A [`BlockExecutorProvider`] that returns mocked execution results. @@ -28,20 +27,20 @@ impl MockExecutorProvider { } impl BlockExecutorProvider for MockExecutorProvider { - type Executor + Display>> = Self; + type Executor + Display> + Send + Sync> = Self; - type BatchExecutor + Display>> = Self; + type BatchExecutor + Display> + Send + Sync> = Self; fn executor(&self, _: DB) -> Self::Executor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { self.clone() } fn batch_executor(&self, _: DB) -> Self::BatchExecutor where - DB: Database + Display>, + DB: DatabaseRef + Display> + Send + Sync, { self.clone() } diff --git a/crates/payload/basic/src/lib.rs b/crates/payload/basic/src/lib.rs index f9487ec784ca..fcabc4d886be 100644 --- a/crates/payload/basic/src/lib.rs +++ b/crates/payload/basic/src/lib.rs @@ -27,7 +27,7 @@ use reth_provider::{ use reth_revm::state_change::post_block_withdrawals_balance_increments; use reth_tasks::TaskSpawner; use reth_transaction_pool::TransactionPool; -use revm::{Database, State}; +use revm::{DatabaseRef, State}; use std::{ fmt, future::Future, @@ -900,7 +900,7 @@ impl WithdrawalsOutcome { /// Returns the withdrawals root. /// /// Returns `None` values pre shanghai -pub fn commit_withdrawals>( +pub fn commit_withdrawals>( db: &mut State, chain_spec: &ChainSpec, timestamp: u64, diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 1e5760768990..445a63821260 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -630,10 +630,12 @@ where .cache .contracts .iter() - .map(|(hash, code)| (*hash, code.bytes())) + .map(|r| (*r.key(), r.value().bytes())) .collect(); - for (address, account) in &statedb.cache.accounts { + for r in &statedb.cache.accounts { + let address = r.key(); + let account = r.value(); let hashed_address = keccak256(address); hashed_state.accounts.insert( hashed_address, diff --git a/crates/storage/libmdbx-rs/src/transaction.rs b/crates/storage/libmdbx-rs/src/transaction.rs index 88236ebe9914..502b5f93958c 100644 --- a/crates/storage/libmdbx-rs/src/transaction.rs +++ b/crates/storage/libmdbx-rs/src/transaction.rs @@ -580,12 +580,12 @@ impl TransactionPtr { if let Some(lock) = self.lock.try_lock() { lock } else { - tracing::debug!( - target: "libmdbx", - txn = %self.txn as usize, - backtrace = %std::backtrace::Backtrace::force_capture(), - "Transaction lock is already acquired, blocking..." - ); + // tracing::debug!( + // target: "libmdbx", + // txn = %self.txn as usize, + // backtrace = %std::backtrace::Backtrace::force_capture(), + // "Transaction lock is already acquired, blocking..." + // ); self.lock.lock() } }