Skip to content

Commit

Permalink
avoid double function call in validate_one (paradigmxyz#8194)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored May 10, 2024
1 parent a44e085 commit b86c6a5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,14 @@ where
};

// Reject transactions over defined size to prevent DOS attacks
if transaction.size() > self.max_tx_input_bytes {
let size = transaction.size();
let transaction_size = transaction.size();
if transaction_size > self.max_tx_input_bytes {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidPoolTransactionError::OversizedData(size, self.max_tx_input_bytes),
InvalidPoolTransactionError::OversizedData(
transaction_size,
self.max_tx_input_bytes,
),
)
}

Expand All @@ -211,11 +214,14 @@ where
}

// Checks for gas limit
if transaction.gas_limit() > self.block_gas_limit {
let gas_limit = transaction.gas_limit();
let transaction_gas_limit = transaction.gas_limit();
if transaction_gas_limit > self.block_gas_limit {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidPoolTransactionError::ExceedsGasLimit(gas_limit, self.block_gas_limit),
InvalidPoolTransactionError::ExceedsGasLimit(
transaction_gas_limit,
self.block_gas_limit,
),
)
}

Expand Down

0 comments on commit b86c6a5

Please sign in to comment.