From 6870747246d6cbd1c2157a6d24e9bc9e8afeca30 Mon Sep 17 00:00:00 2001 From: Ahsen Kamal <82591228+ahsenkamal@users.noreply.github.com> Date: Sun, 25 Jan 2026 20:17:22 +0530 Subject: [PATCH] feat(payload): add fn for system transaction check (#21407) Signed-off-by: Ahsen Kamal Co-authored-by: Matthias Seitz Co-authored-by: Amp --- .../tree/src/tree/payload_processor/prewarm.rs | 18 ++---------------- .../primitives/src/transaction/signed.rs | 4 ++++ .../src/transaction/signed.rs | 10 ++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/engine/tree/src/tree/payload_processor/prewarm.rs b/crates/engine/tree/src/tree/payload_processor/prewarm.rs index e68342112a..81e29eea3f 100644 --- a/crates/engine/tree/src/tree/payload_processor/prewarm.rs +++ b/crates/engine/tree/src/tree/payload_processor/prewarm.rs @@ -24,14 +24,13 @@ use crate::tree::{ }; use alloy_consensus::transaction::TxHashRef; use alloy_eip7928::BlockAccessList; -use alloy_eips::Typed2718; use alloy_evm::Database; use alloy_primitives::{keccak256, map::B256Set, B256}; use crossbeam_channel::Sender as CrossbeamSender; use metrics::{Counter, Gauge, Histogram}; use reth_evm::{execute::ExecutableTxFor, ConfigureEvm, Evm, EvmFor, RecoveredTx, SpecFor}; use reth_metrics::Metrics; -use reth_primitives_traits::NodePrimitives; +use reth_primitives_traits::{NodePrimitives, SignedTransaction}; use reth_provider::{ AccountReader, BlockExecutionOutput, BlockReader, StateProvider, StateProviderFactory, StateReader, @@ -66,19 +65,6 @@ struct IndexedTransaction { tx: Tx, } -/// Maximum standard Ethereum transaction type value. -/// -/// Standard transaction types are: -/// - Type 0: Legacy transactions (original Ethereum) -/// - Type 1: EIP-2930 (access list transactions) -/// - Type 2: EIP-1559 (dynamic fee transactions) -/// - Type 3: EIP-4844 (blob transactions) -/// - Type 4: EIP-7702 (set code authorization transactions) -/// -/// Any transaction with a type > 4 is considered a non-standard/system transaction, -/// typically used by L2s for special purposes (e.g., Optimism deposit transactions use type 126). -const MAX_STANDARD_TX_TYPE: u8 = 4; - /// A task that is responsible for caching and prewarming the cache by executing transactions /// individually in parallel. /// @@ -193,7 +179,7 @@ where } let indexed_tx = IndexedTransaction { index: tx_index, tx }; - let is_system_tx = indexed_tx.tx.tx().ty() > MAX_STANDARD_TX_TYPE; + let is_system_tx = indexed_tx.tx.tx().is_system_tx(); // System transactions (type > 4) in the first position set critical metadata // that affects all subsequent transactions (e.g., L1 block info on L2s). diff --git a/crates/optimism/primitives/src/transaction/signed.rs b/crates/optimism/primitives/src/transaction/signed.rs index fc2f63abd8..896e62b304 100644 --- a/crates/optimism/primitives/src/transaction/signed.rs +++ b/crates/optimism/primitives/src/transaction/signed.rs @@ -155,6 +155,10 @@ impl IsTyped2718 for OpTransactionSigned { } impl SignedTransaction for OpTransactionSigned { + fn is_system_tx(&self) -> bool { + self.is_deposit() + } + fn recalculate_hash(&self) -> B256 { keccak256(self.encoded_2718()) } diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index a6212a6c68..9c92f221eb 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -48,6 +48,16 @@ pub trait SignedTransaction: + TxHashRef + IsTyped2718 { + /// Returns whether this is a system transaction. + /// + /// System transactions are created at the protocol level rather than by users. They are + /// typically used by L2s for special purposes (e.g., Optimism deposit transactions with type + /// 126) and may have different validation rules or fee handling compared to standard + /// user-initiated transactions. + fn is_system_tx(&self) -> bool { + false + } + /// Returns whether this transaction type can be __broadcasted__ as full transaction over the /// network. ///