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},
|
context_interface::{result::ResultAndState, JournalTr},
|
||||||
handler::{handler::EvmTrError, EvmTr, Frame, FrameResult, Handler, MainnetHandler},
|
handler::{handler::EvmTrError, EvmTr, Frame, FrameResult, Handler, MainnetHandler},
|
||||||
inspector::{Inspector, InspectorEvmTr, InspectorFrame, InspectorHandler},
|
inspector::{Inspector, InspectorEvmTr, InspectorFrame, InspectorHandler},
|
||||||
interpreter::{interpreter::EthInterpreter, FrameInput, InitialAndFloorGas, SuccessOrHalt},
|
interpreter::{interpreter::EthInterpreter, FrameInput, SuccessOrHalt},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct HlHandler<EVM, ERROR, FRAME> {
|
pub struct HlHandler<EVM, ERROR, FRAME> {
|
||||||
@ -59,16 +59,6 @@ where
|
|||||||
&self,
|
&self,
|
||||||
evm: &Self::Evm,
|
evm: &Self::Evm,
|
||||||
) -> Result<revm::interpreter::InitialAndFloorGas, Self::Error> {
|
) -> 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)
|
self.mainnet.validate_initial_tx_gas(evm)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,13 +69,9 @@ where
|
|||||||
) -> Result<ResultAndState<Self::HaltReason>, Self::Error> {
|
) -> Result<ResultAndState<Self::HaltReason>, Self::Error> {
|
||||||
let ctx = evm.ctx();
|
let ctx = evm.ctx();
|
||||||
ctx.error();
|
ctx.error();
|
||||||
let tx = ctx.tx();
|
|
||||||
// used gas with refund calculated.
|
// used gas with refund calculated.
|
||||||
let gas_refunded = if tx.is_system_transaction() {
|
let gas_refunded = result.gas().refunded() as u64;
|
||||||
0
|
|
||||||
} else {
|
|
||||||
result.gas().refunded() as u64
|
|
||||||
};
|
|
||||||
let final_gas_used = result.gas().spent() - gas_refunded;
|
let final_gas_used = result.gas().spent() - gas_refunded;
|
||||||
let output = result.output();
|
let output = result.output();
|
||||||
let instruction_result = result.into_interpreter_result();
|
let instruction_result = result.into_interpreter_result();
|
||||||
|
|||||||
@ -11,24 +11,17 @@ use revm::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[auto_impl(&, &mut, Box, Arc)]
|
#[auto_impl(&, &mut, Box, Arc)]
|
||||||
pub trait HlTxTr: Transaction {
|
pub trait HlTxTr: Transaction {}
|
||||||
/// Whether the transaction is a system transaction
|
|
||||||
fn is_system_transaction(&self) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct HlTxEnv<T: Transaction> {
|
pub struct HlTxEnv<T: Transaction> {
|
||||||
pub base: T,
|
pub base: T,
|
||||||
pub is_system_transaction: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Transaction> HlTxEnv<T> {
|
impl<T: Transaction> HlTxEnv<T> {
|
||||||
pub fn new(base: T) -> Self {
|
pub fn new(base: T) -> Self {
|
||||||
Self {
|
Self { base }
|
||||||
base,
|
|
||||||
is_system_transaction: false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +29,6 @@ impl Default for HlTxEnv<TxEnv> {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
base: TxEnv::default(),
|
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> {
|
impl<T: Transaction> HlTxTr for HlTxEnv<T> {}
|
||||||
fn is_system_transaction(&self) -> bool {
|
|
||||||
self.is_system_transaction
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: revm::context::Transaction> IntoTxEnv<Self> for HlTxEnv<T> {
|
impl<T: revm::context::Transaction> IntoTxEnv<Self> for HlTxEnv<T> {
|
||||||
fn into_tx_env(self) -> Self {
|
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 {
|
fn from_recovered_tx(tx: &TransactionSigned, sender: Address) -> Self {
|
||||||
if let Some(gas_price) = tx.gas_price() {
|
if let Some(gas_price) = tx.gas_price() {
|
||||||
if gas_price == 0 {
|
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),
|
reth_primitives::Transaction::Eip7702(tx) => TxEnv::from_recovered_tx(&tx, sender),
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_system_transaction = match tx.gas_price() {
|
Self { base }
|
||||||
Some(x) => x == 0u128,
|
|
||||||
None => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
Self {
|
|
||||||
base,
|
|
||||||
is_system_transaction,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,28 +175,3 @@ impl<T: TransactionEnv> TransactionEnv for HlTxEnv<T> {
|
|||||||
self.base.set_access_list(access_list);
|
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::{
|
use crate::{
|
||||||
evm::transaction::HlTxEnv,
|
evm::transaction::HlTxEnv,
|
||||||
hardforks::HlHardforks,
|
hardforks::HlHardforks,
|
||||||
node::types::{ReadPrecompileCalls, ReadPrecompileInput, ReadPrecompileResult},
|
node::types::{ReadPrecompileInput, ReadPrecompileResult},
|
||||||
};
|
};
|
||||||
use alloy_consensus::{Transaction, TxReceipt};
|
use alloy_consensus::{Transaction, TxReceipt};
|
||||||
use alloy_eips::{eip7685::Requests, Encodable2718};
|
use alloy_eips::{eip7685::Requests, Encodable2718};
|
||||||
@ -39,6 +39,7 @@ where
|
|||||||
Spec: EthChainSpec,
|
Spec: EthChainSpec,
|
||||||
{
|
{
|
||||||
/// Reference to the specification object.
|
/// Reference to the specification object.
|
||||||
|
#[allow(dead_code)]
|
||||||
spec: Spec,
|
spec: Spec,
|
||||||
/// Inner EVM.
|
/// Inner EVM.
|
||||||
evm: EVM,
|
evm: EVM,
|
||||||
@ -46,13 +47,10 @@ where
|
|||||||
gas_used: u64,
|
gas_used: u64,
|
||||||
/// Receipts of executed transactions.
|
/// Receipts of executed transactions.
|
||||||
receipts: Vec<R::Receipt>,
|
receipts: Vec<R::Receipt>,
|
||||||
/// System txs
|
|
||||||
system_txs: Vec<R::Transaction>,
|
|
||||||
/// Read precompile calls
|
|
||||||
read_precompile_calls: ReadPrecompileCalls,
|
|
||||||
/// Receipt builder.
|
/// Receipt builder.
|
||||||
receipt_builder: R,
|
receipt_builder: R,
|
||||||
/// Context for block execution.
|
/// Context for block execution.
|
||||||
|
#[allow(dead_code)]
|
||||||
ctx: HlBlockExecutionCtx<'a>,
|
ctx: HlBlockExecutionCtx<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,10 +129,7 @@ where
|
|||||||
evm,
|
evm,
|
||||||
gas_used: 0,
|
gas_used: 0,
|
||||||
receipts: vec![],
|
receipts: vec![],
|
||||||
system_txs: vec![],
|
|
||||||
read_precompile_calls: ctx.read_precompile_calls.clone().into(),
|
|
||||||
receipt_builder,
|
receipt_builder,
|
||||||
// system_contracts,
|
|
||||||
ctx,
|
ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use crate::{
|
|||||||
evm::{
|
evm::{
|
||||||
api::{ctx::HlContext, HlEvmInner},
|
api::{ctx::HlContext, HlEvmInner},
|
||||||
spec::HlSpecId,
|
spec::HlSpecId,
|
||||||
transaction::{HlTxEnv, HlTxTr},
|
transaction::HlTxEnv,
|
||||||
},
|
},
|
||||||
node::HlNode,
|
node::HlNode,
|
||||||
};
|
};
|
||||||
@ -98,9 +98,6 @@ where
|
|||||||
if self.inspect {
|
if self.inspect {
|
||||||
self.inner.set_tx(tx);
|
self.inner.set_tx(tx);
|
||||||
self.inner.inspect_replay()
|
self.inner.inspect_replay()
|
||||||
} else if tx.is_system_transaction() {
|
|
||||||
self.inner.set_tx(tx);
|
|
||||||
self.inner.inspect_replay()
|
|
||||||
} else {
|
} else {
|
||||||
self.inner.transact(tx)
|
self.inner.transact(tx)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user