Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reject 7702 transactions with empty auth list #10709

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/rpc/rpc-eth-types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use reth_rpc_types::{
error::EthRpcErrorCode, request::TransactionInputError, BlockError, ToRpcError,
};
use reth_transaction_pool::error::{
Eip4844PoolTransactionError, InvalidPoolTransactionError, PoolError, PoolErrorKind,
PoolTransactionError,
Eip4844PoolTransactionError, Eip7702PoolTransactionError, InvalidPoolTransactionError,
PoolError, PoolErrorKind, PoolTransactionError,
};
use revm::primitives::{EVMError, ExecutionResult, HaltReason, OutOfGasError};
use revm_inspectors::tracing::MuxError;
Expand Down Expand Up @@ -593,9 +593,12 @@ pub enum RpcPoolError {
/// Custom pool error
#[error(transparent)]
PoolTransactionError(Box<dyn PoolTransactionError>),
/// Eip-4844 related error
/// EIP-4844 related error
#[error(transparent)]
Eip4844(#[from] Eip4844PoolTransactionError),
/// EIP-7702 related error
#[error(transparent)]
Eip7702(#[from] Eip7702PoolTransactionError),
/// Thrown if a conflicting transaction type is already in the pool
///
/// In other words, thrown if a transaction with the same sender that violates the exclusivity
Expand Down Expand Up @@ -647,6 +650,7 @@ impl From<InvalidPoolTransactionError> for RpcPoolError {
InvalidPoolTransactionError::Underpriced => Self::Underpriced,
InvalidPoolTransactionError::Other(err) => Self::PoolTransactionError(err),
InvalidPoolTransactionError::Eip4844(err) => Self::Eip4844(err),
InvalidPoolTransactionError::Eip7702(err) => Self::Eip7702(err),
InvalidPoolTransactionError::Overdraft => {
Self::Invalid(RpcInvalidTransactionError::InsufficientFunds)
}
Expand Down
17 changes: 16 additions & 1 deletion crates/transaction-pool/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ pub enum Eip4844PoolTransactionError {
Eip4844NonceGap,
}

/// Represents all errors that can happen when validating transactions for the pool for EIP-7702
/// transactions
#[derive(Debug, thiserror::Error)]
pub enum Eip7702PoolTransactionError {
/// Thrown if the transaction has no items in its authorization list
#[error("no items in authorization list for EIP7702 transaction")]
MissingEip7702AuthorizationList,
}

/// Represents errors that can happen when validating transactions for the pool
///
/// See [`TransactionValidator`](crate::TransactionValidator).
Expand Down Expand Up @@ -195,9 +204,12 @@ pub enum InvalidPoolTransactionError {
/// Thrown if the transaction's would require an account to be overdrawn
#[error("transaction overdraws from account")]
Overdraft,
/// Eip-4844 related errors
/// EIP-4844 related errors
#[error(transparent)]
Eip4844(#[from] Eip4844PoolTransactionError),
/// EIP-7702 related errors
#[error(transparent)]
Eip7702(#[from] Eip7702PoolTransactionError),
/// Any other error that occurred while inserting/validating that is transaction specific
#[error(transparent)]
Other(Box<dyn PoolTransactionError>),
Expand Down Expand Up @@ -289,6 +301,9 @@ impl InvalidPoolTransactionError {
}
}
}
Self::Eip7702(eip7702_err) => match eip7702_err {
Eip7702PoolTransactionError::MissingEip7702AuthorizationList => false,
},
}
}

Expand Down
11 changes: 10 additions & 1 deletion crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
use super::constants::DEFAULT_MAX_TX_INPUT_BYTES;
use crate::{
blobstore::BlobStore,
error::{Eip4844PoolTransactionError, InvalidPoolTransactionError},
error::{
Eip4844PoolTransactionError, Eip7702PoolTransactionError, InvalidPoolTransactionError,
},
traits::TransactionOrigin,
validate::{ValidTransaction, ValidationTask, MAX_INIT_CODE_BYTE_SIZE},
EthBlobTransactionSidecar, EthPoolTransaction, LocalTransactionConfig, PoolTransaction,
Expand Down Expand Up @@ -274,6 +276,13 @@ where
InvalidTransactionError::TxTypeNotSupported.into(),
)
}

if transaction.authorization_count() == 0 {
return TransactionValidationOutcome::Invalid(
transaction,
Eip7702PoolTransactionError::MissingEip7702AuthorizationList.into(),
)
}
}

if let Err(err) = ensure_intrinsic_gas(&transaction, &self.fork_tracker) {
Expand Down
Loading