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(txpool): missing condition that tx gas limit equal to block gas l… #5858

Merged
merged 3 commits into from
Dec 26, 2023
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
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
Loading