diff --git a/crates/primitives/src/transaction/error.rs b/crates/primitives/src/transaction/error.rs index e3860ab3af..b45ac8cb08 100644 --- a/crates/primitives/src/transaction/error.rs +++ b/crates/primitives/src/transaction/error.rs @@ -20,11 +20,14 @@ pub enum InvalidTransactionError { #[error("Transaction's chain ID does not match.")] ChainIdMismatch, /// The transaction requires EIP-2930 which is not enabled currently. - #[error("EIP-2930 transactions are not valid before Berlin.")] + #[error("EIP-2930 transactions are disabled.")] Eip2930Disabled, /// The transaction requires EIP-1559 which is not enabled currently. - #[error("EIP-1559 transactions are not valid before London.")] + #[error("EIP-1559 transactions are disabled.")] Eip1559Disabled, + /// The transaction requires EIP-4844 which is not enabled currently. + #[error("EIP-4844 transactions are disabled.")] + Eip4844Disabled, /// Thrown if a transaction is not supported in the current network configuration. #[error("Transaction type not supported")] TxTypeNotSupported, diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index d4c8813f5d..b3cb1f6302 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -381,10 +381,9 @@ impl From for RpcInvalidTransactionErr RpcInvalidTransactionError::OldLegacyChainId } InvalidTransactionError::ChainIdMismatch => RpcInvalidTransactionError::InvalidChainId, - InvalidTransactionError::Eip2930Disabled => { - RpcInvalidTransactionError::TxTypeNotSupported - } - InvalidTransactionError::Eip1559Disabled => { + InvalidTransactionError::Eip2930Disabled | + InvalidTransactionError::Eip1559Disabled | + InvalidTransactionError::Eip4844Disabled => { RpcInvalidTransactionError::TxTypeNotSupported } InvalidTransactionError::TxTypeNotSupported => { diff --git a/crates/transaction-pool/src/error.rs b/crates/transaction-pool/src/error.rs index 75b2f66316..12ccfbebe5 100644 --- a/crates/transaction-pool/src/error.rs +++ b/crates/transaction-pool/src/error.rs @@ -175,7 +175,8 @@ impl InvalidPoolTransactionError { false } InvalidTransactionError::Eip2930Disabled | - InvalidTransactionError::Eip1559Disabled => { + InvalidTransactionError::Eip1559Disabled | + InvalidTransactionError::Eip4844Disabled => { // settings false } diff --git a/crates/transaction-pool/src/validate/eth.rs b/crates/transaction-pool/src/validate/eth.rs index 168546a71a..7bf3ecb94c 100644 --- a/crates/transaction-pool/src/validate/eth.rs +++ b/crates/transaction-pool/src/validate/eth.rs @@ -11,7 +11,7 @@ use crate::{ }; use reth_primitives::{ constants::ETHEREUM_BLOCK_GAS_LIMIT, ChainSpec, InvalidTransactionError, EIP1559_TX_TYPE_ID, - EIP2930_TX_TYPE_ID, LEGACY_TX_TYPE_ID, + EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, }; use reth_provider::{AccountReader, StateProviderFactory}; use reth_tasks::TaskSpawner; @@ -128,10 +128,14 @@ pub struct EthTransactionValidatorBuilder { chain_spec: Arc, /// Fork indicator whether we are in the Shanghai stage. shanghai: bool, + /// Fork indicator whether we are in the Cancun hardfork. + cancun: bool, /// Fork indicator whether we are using EIP-2718 type transactions. eip2718: bool, /// Fork indicator whether we are using EIP-1559 type transactions. eip1559: bool, + /// Fork indicator whether we are using EIP-4844 blob transactions. + eip4844: bool, /// The current max gas limit block_gas_limit: u64, /// Minimum priority fee to enforce for acceptance into the pool. @@ -157,9 +161,24 @@ impl EthTransactionValidatorBuilder { additional_tasks: 1, // default to true, can potentially take this as a param in the future propagate_local_transactions: true, + + // TODO: can hard enable by default once transitioned + cancun: false, + eip4844: false, } } + /// Disables the Cancun fork. + pub fn no_cancun(self) -> Self { + self.set_cancun(false) + } + + /// Set the Cancun fork. + pub fn set_cancun(mut self, cancun: bool) -> Self { + self.cancun = cancun; + self + } + /// Disables the Shanghai fork. pub fn no_shanghai(self) -> Self { self.set_shanghai(false) @@ -238,8 +257,10 @@ impl EthTransactionValidatorBuilder { let Self { chain_spec, shanghai, + cancun, eip2718, eip1559, + eip4844, block_gas_limit, minimum_priority_fee, additional_tasks, @@ -252,6 +273,8 @@ impl EthTransactionValidatorBuilder { shanghai, eip2718, eip1559, + cancun, + eip4844, block_gas_limit, minimum_priority_fee, propagate_local_transactions, @@ -290,18 +313,22 @@ struct EthTransactionValidatorInner { client: Client, /// Fork indicator whether we are in the Shanghai stage. shanghai: bool, + /// Fork indicator whether we are in the Cancun hardfork. + cancun: bool, /// Fork indicator whether we are using EIP-2718 type transactions. eip2718: bool, /// Fork indicator whether we are using EIP-1559 type transactions. eip1559: bool, + /// Fork indicator whether we are using EIP-4844 blob transactions. + eip4844: bool, /// The current max gas limit block_gas_limit: u64, /// Minimum priority fee to enforce for acceptance into the pool. minimum_priority_fee: Option, - /// Marker for the transaction type - _marker: PhantomData, /// Toggle to determine if a local transaction should be propagated propagate_local_transactions: bool, + /// Marker for the transaction type + _marker: PhantomData, } // === impl EthTransactionValidatorInner === @@ -340,7 +367,6 @@ where ) } } - EIP1559_TX_TYPE_ID => { // Reject dynamic fee transactions until EIP-1559 activates. if !self.eip1559 { @@ -350,6 +376,15 @@ where ) } } + EIP4844_TX_TYPE_ID => { + // Reject blob transactions. + if !self.eip4844 { + return TransactionValidationOutcome::Invalid( + transaction, + InvalidTransactionError::Eip4844Disabled.into(), + ) + } + } _ => { return TransactionValidationOutcome::Invalid( @@ -414,6 +449,11 @@ where } } + // blob tx checks + if self.cancun { + // TODO: implement blob tx checks + } + let account = match self .client .latest()