Skip to content

Commit

Permalink
fix(txpool): missing condition that tx gas limit equal to block gas l… (
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyodyssey authored Dec 26, 2023
1 parent abc168e commit 9b12f4f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,9 @@ impl<T: PoolTransaction> AllTransactions<T> {
let mut cumulative_cost = U256::ZERO;
let mut updates = Vec::new();

// Current tx does not exceed block gas limit after ensure_valid check
state.insert(TxState::NOT_TOO_MUCH_GAS);

// identifier of the ancestor transaction, will be None if the transaction is the next tx of
// the sender
let ancestor = TransactionId::ancestor(
Expand Down Expand Up @@ -1457,11 +1460,6 @@ impl<T: PoolTransaction> AllTransactions<T> {
state.insert(TxState::ENOUGH_FEE_CAP_BLOCK);
}

// Ensure tx does not exceed block gas limit
if transaction.gas_limit() < self.block_gas_limit {
state.insert(TxState::NOT_TOO_MUCH_GAS);
}

// placeholder for the replaced transaction, if any
let mut replaced_tx = None;

Expand Down Expand Up @@ -2491,6 +2489,20 @@ mod tests {
));
}

#[test]
fn test_tx_equal_gas_limit() {
let on_chain_balance = U256::from(1_000);
let on_chain_nonce = 0;
let mut f = MockTransactionFactory::default();
let mut pool = AllTransactions::default();

let tx = MockTransaction::eip1559().with_gas_limit(30_000_000);

let InsertOk { state, .. } =
pool.insert_tx(f.validated(tx), on_chain_balance, on_chain_nonce).unwrap();
assert!(state.contains(TxState::NOT_TOO_MUCH_GAS));
}

#[test]
fn update_basefee_subpools() {
let mut f = MockTransactionFactory::default();
Expand Down

0 comments on commit 9b12f4f

Please sign in to comment.