Skip to content
Merged
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
36 changes: 18 additions & 18 deletions crates/handler/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ pub fn validate_priority_fee_tx(
Ok(())
}

/// Validate priority fee for transactions that support EIP-1559 (Eip1559, Eip4844, Eip7702).
#[inline]
fn validate_priority_fee_for_tx<TX: Transaction>(
tx: TX,
base_fee: Option<u128>,
disable_priority_fee_check: bool,
) -> Result<(), InvalidTransaction> {
validate_priority_fee_tx(
tx.max_fee_per_gas(),
tx.max_priority_fee_per_gas().unwrap_or_default(),
base_fee,
disable_priority_fee_check,
)
}

/// Validate EIP-4844 transaction.
pub fn validate_eip4844_tx(
blobs: &[B256],
Expand Down Expand Up @@ -157,24 +172,14 @@ pub fn validate_tx_env<CTX: ContextTr>(
if !spec_id.is_enabled_in(SpecId::LONDON) {
return Err(InvalidTransaction::Eip1559NotSupported);
}
validate_priority_fee_tx(
tx.max_fee_per_gas(),
tx.max_priority_fee_per_gas().unwrap_or_default(),
base_fee,
disable_priority_fee_check,
)?;
validate_priority_fee_for_tx(tx, base_fee, disable_priority_fee_check)?;
}
TransactionType::Eip4844 => {
if !spec_id.is_enabled_in(SpecId::CANCUN) {
return Err(InvalidTransaction::Eip4844NotSupported);
}

validate_priority_fee_tx(
tx.max_fee_per_gas(),
tx.max_priority_fee_per_gas().unwrap_or_default(),
base_fee,
disable_priority_fee_check,
)?;
validate_priority_fee_for_tx(tx, base_fee, disable_priority_fee_check)?;

validate_eip4844_tx(
tx.blob_versioned_hashes(),
Expand All @@ -189,12 +194,7 @@ pub fn validate_tx_env<CTX: ContextTr>(
return Err(InvalidTransaction::Eip7702NotSupported);
}

validate_priority_fee_tx(
tx.max_fee_per_gas(),
tx.max_priority_fee_per_gas().unwrap_or_default(),
base_fee,
disable_priority_fee_check,
)?;
validate_priority_fee_for_tx(tx, base_fee, disable_priority_fee_check)?;

let auth_list_len = tx.authorization_list_len();
// The transaction is considered invalid if the length of authorization_list is zero.
Expand Down
Loading