diff --git a/Cargo.lock b/Cargo.lock index 44bc3c899bf8..1d55ac9a90ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7742,7 +7742,6 @@ dependencies = [ "reth-primitives-traits", "reth-static-file-types", "reth-trie-common", - "revm", "revm-primitives", "roaring", "secp256k1", @@ -8334,6 +8333,7 @@ dependencies = [ "reth-provider", "reth-tasks", "reth-tracing", + "revm", "rustc-hash", "schnellru", "serde", diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index 61c3474c16af..c7886ebf2845 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -40,4 +40,5 @@ optimism = [ "reth-primitives/optimism", "reth-provider/optimism", "reth-optimism-consensus/optimism", + "reth-revm/optimism", ] diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index 607031ea5324..8b9ecf0a03cc 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -66,4 +66,5 @@ optimism = [ "reth-evm-optimism/optimism", "reth-optimism-payload-builder/optimism", "reth-beacon-consensus/optimism", + "reth-revm/optimism", ] diff --git a/crates/optimism/payload/Cargo.toml b/crates/optimism/payload/Cargo.toml index ca6fb8e100d1..357f13956e1a 100644 --- a/crates/optimism/payload/Cargo.toml +++ b/crates/optimism/payload/Cargo.toml @@ -42,4 +42,5 @@ optimism = [ "reth-provider/optimism", "reth-rpc-types-compat/optimism", "reth-evm-optimism/optimism", -] \ No newline at end of file + "reth-revm/optimism", +] diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 1b2dfab727f5..f5ae16277681 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -19,7 +19,6 @@ reth-ethereum-forks.workspace = true reth-static-file-types.workspace = true reth-trie-common.workspace = true reth-chainspec.workspace = true -revm.workspace = true revm-primitives = { workspace = true, features = ["serde"] } # ethereum @@ -48,7 +47,7 @@ once_cell.workspace = true rayon.workspace = true serde.workspace = true tempfile = { workspace = true, optional = true } -thiserror-no-std = { workspace = true , default-features = false } +thiserror-no-std = { workspace = true, default-features = false } zstd = { version = "0.13", features = ["experimental"], optional = true } roaring = "0.10.2" @@ -103,24 +102,15 @@ arbitrary = [ "dep:proptest-derive", "zstd-codec", ] -c-kzg = [ - "dep:c-kzg", - "revm/c-kzg", - "revm-primitives/c-kzg", - "dep:tempfile", - "alloy-eips/kzg", -] +c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg", "dep:tempfile", "alloy-eips/kzg"] zstd-codec = ["dep:zstd"] optimism = [ "reth-chainspec/optimism", "reth-codecs/optimism", "reth-ethereum-forks/optimism", - "revm/optimism", -] -alloy-compat = [ - "reth-primitives-traits/alloy-compat", - "alloy-rpc-types", + "revm-primitives/optimism", ] +alloy-compat = ["reth-primitives-traits/alloy-compat", "dep:alloy-rpc-types"] std = ["thiserror-no-std/std"] test-utils = ["reth-primitives-traits/test-utils"] diff --git a/crates/primitives/src/revm/compat.rs b/crates/primitives/src/revm/compat.rs index cb492e6aa1b7..808ac98bbd9b 100644 --- a/crates/primitives/src/revm/compat.rs +++ b/crates/primitives/src/revm/compat.rs @@ -1,5 +1,4 @@ -use crate::{revm_primitives::AccountInfo, Account, Address, TxKind, KECCAK_EMPTY, U256}; -use revm::{interpreter::gas::validate_initial_tx_gas, primitives::SpecId}; +use crate::{revm_primitives::AccountInfo, Account, KECCAK_EMPTY}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; @@ -27,17 +26,3 @@ pub fn into_revm_acc(reth_acc: Account) -> AccountInfo { code: None, } } - -/// Calculates the Intrinsic Gas usage for a Transaction -/// -/// Caution: This only checks past the Merge hardfork. -#[inline] -pub fn calculate_intrinsic_gas_after_merge( - input: &[u8], - kind: &TxKind, - access_list: &[(Address, Vec)], - is_shanghai: bool, -) -> u64 { - let spec_id = if is_shanghai { SpecId::SHANGHAI } else { SpecId::MERGE }; - validate_initial_tx_gas(spec_id, input, kind.is_create(), access_list) -} diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 5462da7383da..4d7a7f684de0 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -36,6 +36,8 @@ tracing.workspace = true reth-trie.workspace = true [features] -default = ["std"] +default = ["std", "c-kzg"] std = [] +c-kzg = ["revm/c-kzg"] test-utils = ["dep:reth-trie"] +optimism = ["revm/optimism"] diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index 378f665bf90b..096409ab251b 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -96,4 +96,5 @@ optimism = [ "reth-provider/optimism", "dep:reth-evm-optimism", "reth-evm-optimism/optimism", + "reth-revm/optimism", ] diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index 03b5d1d5f21a..a90b16083f42 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -19,6 +19,7 @@ reth-primitives.workspace = true reth-fs-util.workspace = true reth-provider.workspace = true reth-tasks.workspace = true +revm.workspace = true # ethereum alloy-rlp.workspace = true diff --git a/crates/transaction-pool/src/validate/eth.rs b/crates/transaction-pool/src/validate/eth.rs index 3b3779cfdcb5..8bdd68d62154 100644 --- a/crates/transaction-pool/src/validate/eth.rs +++ b/crates/transaction-pool/src/validate/eth.rs @@ -16,12 +16,12 @@ use reth_primitives::{ ETHEREUM_BLOCK_GAS_LIMIT, }, kzg::KzgSettings, - revm::compat::calculate_intrinsic_gas_after_merge, - GotExpected, InvalidTransactionError, SealedBlock, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, - EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, + Address, GotExpected, InvalidTransactionError, SealedBlock, TxKind, EIP1559_TX_TYPE_ID, + EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U256, }; use reth_provider::{AccountReader, BlockReaderIdExt, StateProviderFactory}; use reth_tasks::TaskSpawner; +use revm::{interpreter::gas::validate_initial_tx_gas, primitives::SpecId}; use std::{ marker::PhantomData, sync::{atomic::AtomicBool, Arc}, @@ -728,6 +728,20 @@ pub fn ensure_intrinsic_gas( } } +/// Calculates the Intrinsic Gas usage for a Transaction +/// +/// Caution: This only checks past the Merge hardfork. +#[inline] +pub fn calculate_intrinsic_gas_after_merge( + input: &[u8], + kind: &TxKind, + access_list: &[(Address, Vec)], + is_shanghai: bool, +) -> u64 { + let spec_id = if is_shanghai { SpecId::SHANGHAI } else { SpecId::MERGE }; + validate_initial_tx_gas(spec_id, input, kind.is_create(), access_list) +} + #[cfg(test)] mod tests { use super::*;