mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-11 00:08:13 -05:00
feat(txpool): EIP-7825 max gas limit check (#16648)
This commit is contained in:
@@ -17,6 +17,9 @@ pub const MAXIMUM_GAS_LIMIT_BLOCK: u64 = 2u64.pow(63) - 1;
|
||||
/// The bound divisor of the gas limit, used in update calculations.
|
||||
pub const GAS_LIMIT_BOUND_DIVISOR: u64 = 1024;
|
||||
|
||||
/// Maximum transaction gas limit as defined by [EIP-7825](https://eips.ethereum.org/EIPS/eip-7825) activated in `Osaka` hardfork.
|
||||
pub const MAX_TX_GAS_LIMIT_OSAKA: u64 = 30_000_000;
|
||||
|
||||
/// The number of blocks to unwind during a reorg that already became a part of canonical chain.
|
||||
///
|
||||
/// In reality, the node can end up in this particular situation very rarely. It would happen only
|
||||
|
||||
@@ -61,6 +61,9 @@ pub enum InvalidTransactionError {
|
||||
/// Thrown if the sender of a transaction is a contract.
|
||||
#[error("transaction signer has bytecode set")]
|
||||
SignerAccountHasBytecode,
|
||||
/// Thrown post Osaka if gas limit is too high.
|
||||
#[error("gas limit too high")]
|
||||
GasLimitTooHigh,
|
||||
}
|
||||
|
||||
/// Represents error variants that can happen when trying to convert a transaction to pooled
|
||||
|
||||
@@ -381,6 +381,9 @@ pub enum RpcInvalidTransactionError {
|
||||
/// Thrown if the transaction gas exceeds the limit
|
||||
#[error("intrinsic gas too high")]
|
||||
GasTooHigh,
|
||||
/// Thrown if the transaction gas limit exceeds the maximum
|
||||
#[error("gas limit too high")]
|
||||
GasLimitTooHigh,
|
||||
/// Thrown if a transaction is not supported in the current network configuration.
|
||||
#[error("transaction type not supported")]
|
||||
TxTypeNotSupported,
|
||||
@@ -617,6 +620,7 @@ impl From<InvalidTransactionError> for RpcInvalidTransactionError {
|
||||
InvalidTransactionError::TipAboveFeeCap => Self::TipAboveFeeCap,
|
||||
InvalidTransactionError::FeeCapTooLow => Self::FeeCapTooLow,
|
||||
InvalidTransactionError::SignerAccountHasBytecode => Self::SenderNoEOA,
|
||||
InvalidTransactionError::GasLimitTooHigh => Self::GasLimitTooHigh,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,8 @@ impl InvalidPoolTransactionError {
|
||||
InvalidTransactionError::ChainIdMismatch |
|
||||
InvalidTransactionError::GasUintOverflow |
|
||||
InvalidTransactionError::TxTypeNotSupported |
|
||||
InvalidTransactionError::SignerAccountHasBytecode => true,
|
||||
InvalidTransactionError::SignerAccountHasBytecode |
|
||||
InvalidTransactionError::GasLimitTooHigh => true,
|
||||
}
|
||||
}
|
||||
Self::ExceedsGasLimit(_, _) => true,
|
||||
|
||||
@@ -25,7 +25,8 @@ use alloy_eips::{
|
||||
};
|
||||
use reth_chainspec::{ChainSpecProvider, EthChainSpec, EthereumHardforks};
|
||||
use reth_primitives_traits::{
|
||||
transaction::error::InvalidTransactionError, Block, GotExpected, SealedBlock,
|
||||
constants::MAX_TX_GAS_LIMIT_OSAKA, transaction::error::InvalidTransactionError, Block,
|
||||
GotExpected, SealedBlock,
|
||||
};
|
||||
use reth_storage_api::{StateProvider, StateProviderFactory};
|
||||
use reth_tasks::TaskSpawner;
|
||||
@@ -459,6 +460,16 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// Osaka validation of max tx gas.
|
||||
if self.fork_tracker.is_osaka_activated() &&
|
||||
transaction.gas_limit() > MAX_TX_GAS_LIMIT_OSAKA
|
||||
{
|
||||
return Err(TransactionValidationOutcome::Invalid(
|
||||
transaction,
|
||||
InvalidTransactionError::GasLimitTooHigh.into(),
|
||||
))
|
||||
}
|
||||
|
||||
Ok(transaction)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user