diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44ed5994..72f4cfd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,10 +43,10 @@ jobs: # Windows: all features except gmp - os: windows-latest rust: stable - flags: "--features std,secp256k1,op,overrides,call-util,engine,asm-keccak,rpc" + flags: "--features std,secp256k1,overrides,call-util,engine,asm-keccak,rpc" - os: windows-latest rust: nightly - flags: "--features std,secp256k1,op,overrides,call-util,engine,asm-keccak,rpc" + flags: "--features std,secp256k1,overrides,call-util,engine,asm-keccak,rpc" steps: - uses: actions/checkout@v5 - uses: dtolnay/rust-toolchain@master diff --git a/Cargo.toml b/Cargo.toml index fdd6e395..9533836e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,15 +48,8 @@ alloy-hardforks = { version = "0.4.7" } alloy-rpc-types-eth = { version = "1.5.2", default-features = false } alloy-rpc-types-engine = { version = "1.5.2", default-features = false } -# op-alloy -alloy-op-hardforks = { version = "0.4.7" } -op-alloy = { version = "0.24", default-features = false, features = [ - "consensus", -] } - # revm revm = { version = "36.0.0", default-features = false } -op-revm = { version = "17.0.0", default-features = false } # tracing tracing = { version = "0.1", default-features = false } diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 5988793c..0e2ff3c8 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -19,13 +19,10 @@ alloy-primitives.workspace = true alloy-sol-types.workspace = true alloy-eips.workspace = true alloy-hardforks.workspace = true -alloy-op-hardforks = { workspace = true, optional = true } alloy-rpc-types-eth = { workspace = true, optional = true } alloy-rpc-types-engine = { workspace = true, optional = true } revm.workspace = true -op-revm = { workspace = true, optional = true } -op-alloy = { workspace = true, optional = true } auto_impl.workspace = true derive_more.workspace = true @@ -50,9 +47,7 @@ std = [ "alloy-eips/std", "alloy-sol-types/std", "derive_more/std", - "op-revm?/std", "thiserror/std", - "op-alloy?/std", "alloy-rpc-types-eth?/std", "alloy-rpc-types-engine?/std", "tracing/std" @@ -60,9 +55,8 @@ std = [ gmp = [ "revm/gmp", ] -op = ["op-revm", "op-alloy", "alloy-op-hardforks"] overrides = ["dep:alloy-rpc-types-eth"] call-util = ["overrides"] -engine = ["dep:alloy-rpc-types-engine", "op-alloy?/rpc-types-engine"] +engine = ["dep:alloy-rpc-types-engine"] asm-keccak = ["alloy-primitives/asm-keccak", "revm/asm-keccak"] -rpc = ["dep:alloy-rpc-types-eth", "op-alloy?/rpc-types"] +rpc = ["dep:alloy-rpc-types-eth"] diff --git a/crates/evm/src/error.rs b/crates/evm/src/error.rs index ea3ca066..15b1d6dc 100644 --- a/crates/evm/src/error.rs +++ b/crates/evm/src/error.rs @@ -91,13 +91,3 @@ where } } } - -#[cfg(feature = "op")] -impl InvalidTxError for op_revm::OpTransactionError { - fn as_invalid_tx_err(&self) -> Option<&InvalidTransaction> { - match self { - Self::Base(tx) => Some(tx), - _ => None, - } - } -} diff --git a/crates/evm/src/eth/mod.rs b/crates/evm/src/eth/mod.rs index 8361d997..416cc487 100644 --- a/crates/evm/src/eth/mod.rs +++ b/crates/evm/src/eth/mod.rs @@ -2,9 +2,6 @@ pub use env::NextEvmEnvAttributes; -#[cfg(feature = "op")] -pub(crate) use env::EvmEnvInput; - use crate::{env::EvmEnv, evm::EvmFactory, precompiles::PrecompilesMap, Database, Evm}; use alloy_primitives::{Address, Bytes}; use core::{ diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 7de7dbff..ea320e56 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -24,8 +24,6 @@ pub mod traits; pub use traits::*; #[cfg(feature = "call-util")] pub mod call; -#[cfg(feature = "op")] -pub mod op; #[cfg(feature = "overrides")] pub mod overrides; pub mod precompiles; @@ -36,9 +34,7 @@ pub mod tracing; mod either; -// re-export revm and op-revm -#[cfg(feature = "op")] -pub use op_revm; +// re-export revm pub use revm; pub use eth::spec_id::{spec, spec_by_timestamp_and_block_number}; diff --git a/crates/evm/src/op/env.rs b/crates/evm/src/op/env.rs deleted file mode 100644 index 53449914..00000000 --- a/crates/evm/src/op/env.rs +++ /dev/null @@ -1,121 +0,0 @@ -use crate::{ - eth::{EvmEnvInput, NextEvmEnvAttributes}, - EvmEnv, -}; -use alloy_consensus::BlockHeader; -use alloy_op_hardforks::OpHardforks; -use alloy_primitives::{ChainId, U256}; -use op_revm::OpSpecId; -use revm::{ - context::{BlockEnv, CfgEnv}, - context_interface::block::BlobExcessGasAndPrice, - primitives::hardfork::SpecId, -}; - -impl EvmEnv { - /// Create a new `EvmEnv` with [`OpSpecId`] from a block `header`, `chain_id` and `chain_spec`. - /// - /// # Arguments - /// - /// * `header` - The block to make the env out of. - /// * `chain_spec` - The chain hardfork description, must implement [`OpHardforks`]. - /// * `chain_id` - The chain identifier. - /// * `blob_params` - Optional parameters that sets limits on gas and count for blobs. - pub fn for_op_block( - header: impl BlockHeader, - chain_spec: impl OpHardforks, - chain_id: ChainId, - ) -> Self { - Self::for_op(EvmEnvInput::from_block_header(header), chain_spec, chain_id) - } - - /// Create a new `EvmEnv` with [`SpecId`] from a parent block `header`, `chain_id` and - /// `chain_spec`. - /// - /// # Arguments - /// - /// * `header` - The parent block to make the env out of. - /// * `base_fee_per_gas` - Base fee per gas for the next block. - /// * `chain_spec` - The chain hardfork description, must implement [`OpHardforks`]. - /// * `chain_id` - The chain identifier. - pub fn for_op_next_block( - header: impl BlockHeader, - attributes: NextEvmEnvAttributes, - base_fee_per_gas: u64, - chain_spec: impl OpHardforks, - chain_id: ChainId, - ) -> Self { - Self::for_op( - EvmEnvInput::for_next(header, attributes, base_fee_per_gas, None), - chain_spec, - chain_id, - ) - } - - fn for_op(input: EvmEnvInput, chain_spec: impl OpHardforks, chain_id: ChainId) -> Self { - let spec = crate::op::spec_by_timestamp_after_bedrock(&chain_spec, input.timestamp); - let cfg_env = CfgEnv::new().with_chain_id(chain_id).with_spec_and_mainnet_gas_params(spec); - - let blob_excess_gas_and_price = spec - .into_eth_spec() - .is_enabled_in(SpecId::CANCUN) - .then_some(BlobExcessGasAndPrice { excess_blob_gas: 0, blob_gasprice: 1 }); - - let is_merge_active = spec.into_eth_spec() >= SpecId::MERGE; - - let block_env = BlockEnv { - number: U256::from(input.number), - beneficiary: input.beneficiary, - timestamp: U256::from(input.timestamp), - difficulty: if is_merge_active { U256::ZERO } else { input.difficulty }, - prevrandao: if is_merge_active { input.mix_hash } else { None }, - gas_limit: input.gas_limit, - basefee: input.base_fee_per_gas, - // EIP-4844 excess blob gas of this block, introduced in Cancun - blob_excess_gas_and_price, - slot_num: 0, - }; - - Self::new(cfg_env, block_env) - } -} - -#[cfg(feature = "engine")] -mod payload { - use super::*; - use op_alloy::rpc_types_engine::OpExecutionPayload; - - impl EvmEnv { - /// Create a new `EvmEnv` with [`OpSpecId`] from a `payload`, `chain_id`, `chain_spec` and - /// optional `blob_params`. - /// - /// # Arguments - /// - /// * `header` - The block to make the env out of. - /// * `chain_spec` - The chain hardfork description, must implement [`OpHardforks`]. - /// * `chain_id` - The chain identifier. - /// * `blob_params` - Optional parameters that sets limits on gas and count for blobs. - pub fn for_op_payload( - payload: &OpExecutionPayload, - chain_spec: impl OpHardforks, - chain_id: ChainId, - ) -> Self { - Self::for_op(EvmEnvInput::from_op_payload(payload), chain_spec, chain_id) - } - } - - impl EvmEnvInput { - pub(crate) fn from_op_payload(payload: &OpExecutionPayload) -> Self { - Self { - timestamp: payload.timestamp(), - number: payload.block_number(), - beneficiary: payload.as_v1().fee_recipient, - mix_hash: Some(payload.as_v1().prev_randao), - difficulty: payload.as_v1().prev_randao.into(), - gas_limit: payload.as_v1().gas_limit, - excess_blob_gas: payload.as_v3().map(|v| v.excess_blob_gas), - base_fee_per_gas: payload.as_v1().base_fee_per_gas.saturating_to(), - } - } - } -} diff --git a/crates/evm/src/op/mod.rs b/crates/evm/src/op/mod.rs deleted file mode 100644 index a501a58f..00000000 --- a/crates/evm/src/op/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Optimism EVM implementation. - -mod env; -#[cfg(feature = "rpc")] -mod rpc; -mod spec_id; -mod tx; - -pub use spec_id::{spec, spec_by_timestamp_after_bedrock}; diff --git a/crates/evm/src/op/rpc.rs b/crates/evm/src/op/rpc.rs deleted file mode 100644 index 1a341bd0..00000000 --- a/crates/evm/src/op/rpc.rs +++ /dev/null @@ -1,47 +0,0 @@ -use crate::{ - env::BlockEnvironment, - rpc::{EthTxEnvError, TryIntoTxEnv}, - EvmEnv, -}; -use alloy_primitives::Bytes; -use op_alloy::rpc_types::OpTransactionRequest; -use op_revm::OpTransaction; -use revm::context::TxEnv; - -impl TryIntoTxEnv, Spec, Block> - for OpTransactionRequest -{ - type Err = EthTxEnvError; - - fn try_into_tx_env( - self, - evm_env: &EvmEnv, - ) -> Result, Self::Err> { - Ok(OpTransaction { - base: self.as_ref().clone().try_into_tx_env(evm_env)?, - enveloped_tx: Some(Bytes::new()), - deposit: Default::default(), - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_op_into_tx_env() { - use op_revm::{transaction::OpTxTr, OpSpecId}; - use revm::context::{BlockEnv, Transaction}; - - let s = r#"{"from":"0x0000000000000000000000000000000000000000","to":"0x6d362b9c3ab68c0b7c79e8a714f1d7f3af63655f","input":"0x1626ba7ec8ee0d506e864589b799a645ddb88b08f5d39e8049f9f702b3b61fa15e55fc73000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000550000002d6db27c52e3c11c1cf24072004ac75cba49b25bf45f513902e469755e1f3bf2ca8324ad16930b0a965c012a24bb1101f876ebebac047bd3b6bf610205a27171eaaeffe4b5e5589936f4e542d637b627311b0000000000000000000000","data":"0x1626ba7ec8ee0d506e864589b799a645ddb88b08f5d39e8049f9f702b3b61fa15e55fc73000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000550000002d6db27c52e3c11c1cf24072004ac75cba49b25bf45f513902e469755e1f3bf2ca8324ad16930b0a965c012a24bb1101f876ebebac047bd3b6bf610205a27171eaaeffe4b5e5589936f4e542d637b627311b0000000000000000000000","chainId":"0x7a69"}"#; - - let req: OpTransactionRequest = serde_json::from_str(s).unwrap(); - - let evm_env = EvmEnv::::default(); - let tx_env = req.try_into_tx_env(&evm_env).unwrap(); - assert_eq!(tx_env.gas_limit(), evm_env.block_env().gas_limit); - assert_eq!(tx_env.gas_price(), 0); - assert!(tx_env.enveloped_tx().unwrap().is_empty()); - } -} diff --git a/crates/evm/src/op/spec_id.rs b/crates/evm/src/op/spec_id.rs deleted file mode 100644 index fc209081..00000000 --- a/crates/evm/src/op/spec_id.rs +++ /dev/null @@ -1,156 +0,0 @@ -use alloy_consensus::BlockHeader; -use alloy_op_hardforks::OpHardforks; -use op_revm::OpSpecId; - -/// Map the latest active hardfork at the given header to a revm [`OpSpecId`]. -pub fn spec(chain_spec: impl OpHardforks, header: impl BlockHeader) -> OpSpecId { - spec_by_timestamp_after_bedrock(chain_spec, header.timestamp()) -} - -/// Returns the revm [`OpSpecId`] at the given timestamp. -/// -/// # Note -/// -/// This is only intended to be used after the Bedrock, when hardforks are activated by -/// timestamp. -pub fn spec_by_timestamp_after_bedrock(chain_spec: impl OpHardforks, timestamp: u64) -> OpSpecId { - if chain_spec.is_interop_active_at_timestamp(timestamp) { - OpSpecId::INTEROP - } else if chain_spec.is_jovian_active_at_timestamp(timestamp) { - OpSpecId::JOVIAN - } else if chain_spec.is_isthmus_active_at_timestamp(timestamp) { - OpSpecId::ISTHMUS - } else if chain_spec.is_holocene_active_at_timestamp(timestamp) { - OpSpecId::HOLOCENE - } else if chain_spec.is_granite_active_at_timestamp(timestamp) { - OpSpecId::GRANITE - } else if chain_spec.is_fjord_active_at_timestamp(timestamp) { - OpSpecId::FJORD - } else if chain_spec.is_ecotone_active_at_timestamp(timestamp) { - OpSpecId::ECOTONE - } else if chain_spec.is_canyon_active_at_timestamp(timestamp) { - OpSpecId::CANYON - } else if chain_spec.is_regolith_active_at_timestamp(timestamp) { - OpSpecId::REGOLITH - } else { - OpSpecId::BEDROCK - } -} - -#[cfg(test)] -mod tests { - use super::*; - use alloy_consensus::Header; - use alloy_hardforks::EthereumHardfork; - use alloy_op_hardforks::{ - EthereumHardforks, ForkCondition, OpChainHardforks, OpHardfork, - OP_MAINNET_CANYON_TIMESTAMP, OP_MAINNET_ECOTONE_TIMESTAMP, OP_MAINNET_FJORD_TIMESTAMP, - OP_MAINNET_GRANITE_TIMESTAMP, OP_MAINNET_HOLOCENE_TIMESTAMP, OP_MAINNET_ISTHMUS_TIMESTAMP, - OP_MAINNET_JOVIAN_TIMESTAMP, OP_MAINNET_REGOLITH_TIMESTAMP, - }; - use alloy_primitives::BlockTimestamp; - - struct FakeHardfork { - fork: OpHardfork, - cond: ForkCondition, - } - - impl FakeHardfork { - fn interop() -> Self { - Self::from_timestamp_zero(OpHardfork::Interop) - } - - fn jovian() -> Self { - Self::from_timestamp_zero(OpHardfork::Jovian) - } - - fn isthmus() -> Self { - Self::from_timestamp_zero(OpHardfork::Isthmus) - } - - fn holocene() -> Self { - Self::from_timestamp_zero(OpHardfork::Holocene) - } - - fn granite() -> Self { - Self::from_timestamp_zero(OpHardfork::Granite) - } - - fn fjord() -> Self { - Self::from_timestamp_zero(OpHardfork::Fjord) - } - - fn ecotone() -> Self { - Self::from_timestamp_zero(OpHardfork::Ecotone) - } - - fn canyon() -> Self { - Self::from_timestamp_zero(OpHardfork::Canyon) - } - - fn regolith() -> Self { - Self::from_timestamp_zero(OpHardfork::Regolith) - } - - fn bedrock() -> Self { - Self::from_block_zero(OpHardfork::Bedrock) - } - - fn from_block_zero(fork: OpHardfork) -> Self { - Self { fork, cond: ForkCondition::Block(0) } - } - - fn from_timestamp_zero(fork: OpHardfork) -> Self { - Self { fork, cond: ForkCondition::Timestamp(0) } - } - } - - impl EthereumHardforks for FakeHardfork { - fn ethereum_fork_activation(&self, _: EthereumHardfork) -> ForkCondition { - unimplemented!() - } - } - - impl OpHardforks for FakeHardfork { - fn op_fork_activation(&self, fork: OpHardfork) -> ForkCondition { - if fork == self.fork { - self.cond - } else { - ForkCondition::Never - } - } - } - - #[test_case::test_case(FakeHardfork::interop(), OpSpecId::INTEROP; "Interop")] - #[test_case::test_case(FakeHardfork::jovian(), OpSpecId::JOVIAN; "Jovian")] - #[test_case::test_case(FakeHardfork::isthmus(), OpSpecId::ISTHMUS; "Isthmus")] - #[test_case::test_case(FakeHardfork::holocene(), OpSpecId::HOLOCENE; "Holocene")] - #[test_case::test_case(FakeHardfork::granite(), OpSpecId::GRANITE; "Granite")] - #[test_case::test_case(FakeHardfork::fjord(), OpSpecId::FJORD; "Fjord")] - #[test_case::test_case(FakeHardfork::ecotone(), OpSpecId::ECOTONE; "Ecotone")] - #[test_case::test_case(FakeHardfork::canyon(), OpSpecId::CANYON; "Canyon")] - #[test_case::test_case(FakeHardfork::regolith(), OpSpecId::REGOLITH; "Regolith")] - #[test_case::test_case(FakeHardfork::bedrock(), OpSpecId::BEDROCK; "Bedrock")] - fn test_spec_maps_hardfork_successfully(fork: impl OpHardforks, expected_spec: OpSpecId) { - let header = Header::default(); - let actual_spec = spec(fork, &header); - - assert_eq!(actual_spec, expected_spec); - } - - #[test_case::test_case(OP_MAINNET_JOVIAN_TIMESTAMP, OpSpecId::JOVIAN; "Jovian")] - #[test_case::test_case(OP_MAINNET_ISTHMUS_TIMESTAMP, OpSpecId::ISTHMUS; "Isthmus")] - #[test_case::test_case(OP_MAINNET_HOLOCENE_TIMESTAMP, OpSpecId::HOLOCENE; "Holocene")] - #[test_case::test_case(OP_MAINNET_GRANITE_TIMESTAMP, OpSpecId::GRANITE; "Granite")] - #[test_case::test_case(OP_MAINNET_FJORD_TIMESTAMP, OpSpecId::FJORD; "Fjord")] - #[test_case::test_case(OP_MAINNET_ECOTONE_TIMESTAMP, OpSpecId::ECOTONE; "Ecotone")] - #[test_case::test_case(OP_MAINNET_CANYON_TIMESTAMP, OpSpecId::CANYON; "Canyon")] - #[test_case::test_case(OP_MAINNET_REGOLITH_TIMESTAMP, OpSpecId::REGOLITH; "Regolith")] - fn test_op_spec_maps_hardfork_successfully(timestamp: BlockTimestamp, expected_spec: OpSpecId) { - let fork = OpChainHardforks::op_mainnet(); - let header = Header { timestamp, ..Default::default() }; - let actual_spec = spec(&fork, &header); - - assert_eq!(actual_spec, expected_spec); - } -} diff --git a/crates/evm/src/op/tx.rs b/crates/evm/src/op/tx.rs deleted file mode 100644 index c4f02eb9..00000000 --- a/crates/evm/src/op/tx.rs +++ /dev/null @@ -1,215 +0,0 @@ -use crate::{FromRecoveredTx, FromTxWithEncoded}; - -use alloy_consensus::{ - Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip7702, TxLegacy, -}; -use alloy_eips::{eip7594::Encodable7594, Encodable2718, Typed2718}; -use alloy_primitives::{Address, Bytes}; -use op_alloy::consensus::{OpTxEnvelope, TxDeposit}; -use op_revm::{transaction::deposit::DepositTransactionParts, OpTransaction}; -use revm::context::TxEnv; - -impl FromRecoveredTx for TxEnv { - fn from_recovered_tx(tx: &OpTxEnvelope, caller: Address) -> Self { - match tx { - OpTxEnvelope::Legacy(tx) => Self::from_recovered_tx(tx.tx(), caller), - OpTxEnvelope::Eip1559(tx) => Self::from_recovered_tx(tx.tx(), caller), - OpTxEnvelope::Eip2930(tx) => Self::from_recovered_tx(tx.tx(), caller), - OpTxEnvelope::Eip7702(tx) => Self::from_recovered_tx(tx.tx(), caller), - OpTxEnvelope::Deposit(tx) => Self::from_recovered_tx(tx.inner(), caller), - } - } -} - -impl FromRecoveredTx for TxEnv { - fn from_recovered_tx(tx: &TxDeposit, caller: Address) -> Self { - let TxDeposit { - to, - value, - gas_limit, - input, - source_hash: _, - from: _, - mint: _, - is_system_transaction: _, - } = tx; - Self { - tx_type: tx.ty(), - caller, - gas_limit: *gas_limit, - kind: *to, - value: *value, - data: input.clone(), - ..Default::default() - } - } -} - -impl FromTxWithEncoded for TxEnv { - fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, _encoded: Bytes) -> Self { - Self::from_recovered_tx(tx, caller) - } -} - -impl FromRecoveredTx for OpTransaction { - fn from_recovered_tx(tx: &OpTxEnvelope, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, encoded: Bytes) -> Self { - match tx { - OpTxEnvelope::Legacy(tx) => Self::from_encoded_tx(tx, caller, encoded), - OpTxEnvelope::Eip1559(tx) => Self::from_encoded_tx(tx, caller, encoded), - OpTxEnvelope::Eip2930(tx) => Self::from_encoded_tx(tx, caller, encoded), - OpTxEnvelope::Eip7702(tx) => Self::from_encoded_tx(tx, caller, encoded), - OpTxEnvelope::Deposit(tx) => Self::from_encoded_tx(tx.inner(), caller, encoded), - } - } -} - -impl FromRecoveredTx> for OpTransaction { - fn from_recovered_tx(tx: &Signed, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded> for OpTransaction { - fn from_encoded_tx(tx: &Signed, caller: Address, encoded: Bytes) -> Self { - Self::from_encoded_tx(tx.tx(), caller, encoded) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &TxLegacy, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - Self { base, enveloped_tx: Some(encoded), deposit: Default::default() } - } -} - -impl FromRecoveredTx> for OpTransaction { - fn from_recovered_tx(tx: &Signed, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded> for OpTransaction { - fn from_encoded_tx(tx: &Signed, caller: Address, encoded: Bytes) -> Self { - Self::from_encoded_tx(tx.tx(), caller, encoded) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &TxEip2930, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - Self { base, enveloped_tx: Some(encoded), deposit: Default::default() } - } -} - -impl FromRecoveredTx> for OpTransaction { - fn from_recovered_tx(tx: &Signed, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded> for OpTransaction { - fn from_encoded_tx(tx: &Signed, caller: Address, encoded: Bytes) -> Self { - Self::from_encoded_tx(tx.tx(), caller, encoded) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &TxEip1559, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - Self { base, enveloped_tx: Some(encoded), deposit: Default::default() } - } -} - -impl FromRecoveredTx> for OpTransaction { - fn from_recovered_tx(tx: &Signed, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded> for OpTransaction { - fn from_encoded_tx(tx: &Signed, caller: Address, encoded: Bytes) -> Self { - Self::from_encoded_tx(tx.tx(), caller, encoded) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &TxEip4844, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - Self { base, enveloped_tx: Some(encoded), deposit: Default::default() } - } -} - -/// `TxEip4844Variant` conversion is not necessary for `OpTransaction`, but it's useful -/// sugar for Foundry. -impl FromRecoveredTx>> for OpTransaction -where - T: Encodable7594 + Send + Sync, -{ - fn from_recovered_tx(tx: &Signed>, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded>> for OpTransaction { - fn from_encoded_tx(tx: &Signed>, caller: Address, encoded: Bytes) -> Self { - Self::from_encoded_tx(tx.tx(), caller, encoded) - } -} - -impl FromTxWithEncoded> for OpTransaction { - fn from_encoded_tx(tx: &TxEip4844Variant, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - Self { base, enveloped_tx: Some(encoded), deposit: Default::default() } - } -} - -impl FromRecoveredTx> for OpTransaction { - fn from_recovered_tx(tx: &Signed, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded> for OpTransaction { - fn from_encoded_tx(tx: &Signed, caller: Address, encoded: Bytes) -> Self { - Self::from_encoded_tx(tx.tx(), caller, encoded) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &TxEip7702, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - Self { base, enveloped_tx: Some(encoded), deposit: Default::default() } - } -} - -impl FromRecoveredTx for OpTransaction { - fn from_recovered_tx(tx: &TxDeposit, sender: Address) -> Self { - let encoded = tx.encoded_2718(); - Self::from_encoded_tx(tx, sender, encoded.into()) - } -} - -impl FromTxWithEncoded for OpTransaction { - fn from_encoded_tx(tx: &TxDeposit, caller: Address, encoded: Bytes) -> Self { - let base = TxEnv::from_recovered_tx(tx, caller); - let deposit = DepositTransactionParts { - source_hash: tx.source_hash, - mint: Some(tx.mint), - is_system_transaction: tx.is_system_transaction, - }; - Self { base, enveloped_tx: Some(encoded), deposit } - } -} diff --git a/crates/evm/src/tx.rs b/crates/evm/src/tx.rs index 0564c565..0d5a8672 100644 --- a/crates/evm/src/tx.rs +++ b/crates/evm/src/tx.rs @@ -79,16 +79,6 @@ where } } -#[cfg(feature = "op")] -impl IntoTxEnv for op_revm::OpTransaction -where - T: revm::context_interface::transaction::Transaction, -{ - fn into_tx_env(self) -> Self { - self - } -} - /// Helper trait for building a transaction environment from a recovered transaction. /// /// This trait enables the conversion of consensus transaction types (which have been recovered