diff --git a/src/evm/handler.rs b/src/evm/handler.rs index d65e1aa00..6e3deb083 100644 --- a/src/evm/handler.rs +++ b/src/evm/handler.rs @@ -9,7 +9,7 @@ use revm::{ context_interface::{result::ResultAndState, JournalTr}, handler::{handler::EvmTrError, EvmTr, Frame, FrameResult, Handler, MainnetHandler}, inspector::{Inspector, InspectorEvmTr, InspectorFrame, InspectorHandler}, - interpreter::{interpreter::EthInterpreter, FrameInput, InitialAndFloorGas, SuccessOrHalt}, + interpreter::{interpreter::EthInterpreter, FrameInput, SuccessOrHalt}, }; pub struct HlHandler { @@ -59,16 +59,6 @@ where &self, evm: &Self::Evm, ) -> Result { - let ctx = evm.ctx_ref(); - let tx = ctx.tx(); - - if tx.is_system_transaction() { - return Ok(InitialAndFloorGas { - initial_gas: 0, - floor_gas: 0, - }); - } - self.mainnet.validate_initial_tx_gas(evm) } @@ -79,13 +69,9 @@ where ) -> Result, Self::Error> { let ctx = evm.ctx(); ctx.error(); - let tx = ctx.tx(); + // used gas with refund calculated. - let gas_refunded = if tx.is_system_transaction() { - 0 - } else { - result.gas().refunded() as u64 - }; + let gas_refunded = result.gas().refunded() as u64; let final_gas_used = result.gas().spent() - gas_refunded; let output = result.output(); let instruction_result = result.into_interpreter_result(); diff --git a/src/evm/transaction.rs b/src/evm/transaction.rs index 3b76232fd..9851dbc87 100644 --- a/src/evm/transaction.rs +++ b/src/evm/transaction.rs @@ -11,24 +11,17 @@ use revm::{ }; #[auto_impl(&, &mut, Box, Arc)] -pub trait HlTxTr: Transaction { - /// Whether the transaction is a system transaction - fn is_system_transaction(&self) -> bool; -} +pub trait HlTxTr: Transaction {} #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct HlTxEnv { pub base: T, - pub is_system_transaction: bool, } impl HlTxEnv { pub fn new(base: T) -> Self { - Self { - base, - is_system_transaction: false, - } + Self { base } } } @@ -36,7 +29,6 @@ impl Default for HlTxEnv { fn default() -> Self { Self { base: TxEnv::default(), - is_system_transaction: false, } } } @@ -120,11 +112,7 @@ impl Transaction for HlTxEnv { } } -impl HlTxTr for HlTxEnv { - fn is_system_transaction(&self) -> bool { - self.is_system_transaction - } -} +impl HlTxTr for HlTxEnv {} impl IntoTxEnv for HlTxEnv { fn into_tx_env(self) -> Self { @@ -145,7 +133,10 @@ impl FromRecoveredTx for HlTxEnv { fn from_recovered_tx(tx: &TransactionSigned, sender: Address) -> Self { if let Some(gas_price) = tx.gas_price() { if gas_price == 0 { - return Self::new(TxEnv::from_recovered_tx(tx, s_to_address(tx.signature().s()))); + return Self::new(TxEnv::from_recovered_tx( + tx, + s_to_address(tx.signature().s()), + )); } } @@ -163,15 +154,7 @@ impl FromTxWithEncoded for HlTxEnv { reth_primitives::Transaction::Eip7702(tx) => TxEnv::from_recovered_tx(&tx, sender), }; - let is_system_transaction = match tx.gas_price() { - Some(x) => x == 0u128, - None => false, - }; - - Self { - base, - is_system_transaction, - } + Self { base } } } @@ -192,28 +175,3 @@ impl TransactionEnv for HlTxEnv { self.base.set_access_list(access_list); } } - -#[cfg(test)] -mod tests { - - use super::*; - use revm::primitives::Address; - - #[test] - fn test_hl_transaction_fields() { - let hl_tx = HlTxEnv { - base: TxEnv { - tx_type: 0, - gas_limit: 10, - gas_price: 100, - gas_priority_fee: Some(5), - ..Default::default() - }, - is_system_transaction: false, - }; - - assert_eq!(hl_tx.tx_type(), 0); - assert_eq!(hl_tx.gas_limit(), 10); - assert_eq!(hl_tx.kind(), revm::primitives::TxKind::Call(Address::ZERO)); - } -} diff --git a/src/node/evm/executor.rs b/src/node/evm/executor.rs index df0ca0ea8..5815876e6 100644 --- a/src/node/evm/executor.rs +++ b/src/node/evm/executor.rs @@ -3,7 +3,7 @@ use super::patch::patch_mainnet_after_tx; use crate::{ evm::transaction::HlTxEnv, hardforks::HlHardforks, - node::types::{ReadPrecompileCalls, ReadPrecompileInput, ReadPrecompileResult}, + node::types::{ReadPrecompileInput, ReadPrecompileResult}, }; use alloy_consensus::{Transaction, TxReceipt}; use alloy_eips::{eip7685::Requests, Encodable2718}; @@ -39,6 +39,7 @@ where Spec: EthChainSpec, { /// Reference to the specification object. + #[allow(dead_code)] spec: Spec, /// Inner EVM. evm: EVM, @@ -46,13 +47,10 @@ where gas_used: u64, /// Receipts of executed transactions. receipts: Vec, - /// System txs - system_txs: Vec, - /// Read precompile calls - read_precompile_calls: ReadPrecompileCalls, /// Receipt builder. receipt_builder: R, /// Context for block execution. + #[allow(dead_code)] ctx: HlBlockExecutionCtx<'a>, } @@ -131,10 +129,7 @@ where evm, gas_used: 0, receipts: vec![], - system_txs: vec![], - read_precompile_calls: ctx.read_precompile_calls.clone().into(), receipt_builder, - // system_contracts, ctx, } } diff --git a/src/node/evm/mod.rs b/src/node/evm/mod.rs index c4daca1ed..6f16c1f30 100644 --- a/src/node/evm/mod.rs +++ b/src/node/evm/mod.rs @@ -2,7 +2,7 @@ use crate::{ evm::{ api::{ctx::HlContext, HlEvmInner}, spec::HlSpecId, - transaction::{HlTxEnv, HlTxTr}, + transaction::HlTxEnv, }, node::HlNode, }; @@ -98,9 +98,6 @@ where if self.inspect { self.inner.set_tx(tx); self.inner.inspect_replay() - } else if tx.is_system_transaction() { - self.inner.set_tx(tx); - self.inner.inspect_replay() } else { self.inner.transact(tx) }