mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
remove: Remove unused fields
This commit is contained in:
@ -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<EVM, ERROR, FRAME> {
|
||||
@ -59,16 +59,6 @@ where
|
||||
&self,
|
||||
evm: &Self::Evm,
|
||||
) -> Result<revm::interpreter::InitialAndFloorGas, Self::Error> {
|
||||
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<ResultAndState<Self::HaltReason>, 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();
|
||||
|
||||
@ -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<T: Transaction> {
|
||||
pub base: T,
|
||||
pub is_system_transaction: bool,
|
||||
}
|
||||
|
||||
impl<T: Transaction> HlTxEnv<T> {
|
||||
pub fn new(base: T) -> Self {
|
||||
Self {
|
||||
base,
|
||||
is_system_transaction: false,
|
||||
}
|
||||
Self { base }
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +29,6 @@ impl Default for HlTxEnv<TxEnv> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
base: TxEnv::default(),
|
||||
is_system_transaction: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,11 +112,7 @@ impl<T: Transaction> Transaction for HlTxEnv<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Transaction> HlTxTr for HlTxEnv<T> {
|
||||
fn is_system_transaction(&self) -> bool {
|
||||
self.is_system_transaction
|
||||
}
|
||||
}
|
||||
impl<T: Transaction> HlTxTr for HlTxEnv<T> {}
|
||||
|
||||
impl<T: revm::context::Transaction> IntoTxEnv<Self> for HlTxEnv<T> {
|
||||
fn into_tx_env(self) -> Self {
|
||||
@ -145,7 +133,10 @@ impl FromRecoveredTx<TransactionSigned> for HlTxEnv<TxEnv> {
|
||||
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<TransactionSigned> for HlTxEnv<TxEnv> {
|
||||
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<T: TransactionEnv> TransactionEnv for HlTxEnv<T> {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<R::Receipt>,
|
||||
/// System txs
|
||||
system_txs: Vec<R::Transaction>,
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user