mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-26 15:48:13 -05:00
feat(transaction-pool): enforce EIP-2681 (#16967)
This commit is contained in:
@@ -851,6 +851,9 @@ impl From<InvalidPoolTransactionError> for RpcPoolError {
|
||||
}
|
||||
InvalidPoolTransactionError::OversizedData(_, _) => Self::OversizedData,
|
||||
InvalidPoolTransactionError::Underpriced => Self::Underpriced,
|
||||
InvalidPoolTransactionError::Eip2681 => {
|
||||
Self::Invalid(RpcInvalidTransactionError::NonceMaxValue)
|
||||
}
|
||||
InvalidPoolTransactionError::Other(err) => Self::PoolTransactionError(err),
|
||||
InvalidPoolTransactionError::Eip4844(err) => Self::Eip4844(err),
|
||||
InvalidPoolTransactionError::Eip7702(err) => Self::Eip7702(err),
|
||||
|
||||
@@ -247,6 +247,10 @@ pub enum InvalidPoolTransactionError {
|
||||
/// Balance of account.
|
||||
balance: U256,
|
||||
},
|
||||
/// EIP-2681 error thrown if the nonce is higher or equal than `U64::max`
|
||||
/// `<https://eips.ethereum.org/EIPS/eip-2681>`
|
||||
#[error("nonce exceeds u64 limit")]
|
||||
Eip2681,
|
||||
/// EIP-4844 related errors
|
||||
#[error(transparent)]
|
||||
Eip4844(#[from] Eip4844PoolTransactionError),
|
||||
@@ -326,6 +330,7 @@ impl InvalidPoolTransactionError {
|
||||
Self::IntrinsicGasTooLow => true,
|
||||
Self::Overdraft { .. } => false,
|
||||
Self::Other(err) => err.is_bad_transaction(),
|
||||
Self::Eip2681 => true,
|
||||
Self::Eip4844(eip4844_err) => {
|
||||
match eip4844_err {
|
||||
Eip4844PoolTransactionError::MissingEip4844BlobSidecar => {
|
||||
|
||||
@@ -293,6 +293,15 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
// Reject transactions with a nonce equal to U64::max according to EIP-2681
|
||||
let tx_nonce = transaction.nonce();
|
||||
if tx_nonce == u64::MAX {
|
||||
return Err(TransactionValidationOutcome::Invalid(
|
||||
transaction,
|
||||
InvalidPoolTransactionError::Eip2681,
|
||||
))
|
||||
}
|
||||
|
||||
// Reject transactions over defined size to prevent DOS attacks
|
||||
let tx_input_len = transaction.input().len();
|
||||
if tx_input_len > self.max_tx_input_bytes {
|
||||
|
||||
Reference in New Issue
Block a user