fix(txpool): missing condition that tx gas limit equal to block gas l… (#5858)

This commit is contained in:
Siyuan Han
2023-12-26 20:22:07 +08:00
committed by GitHub
parent abc168efa6
commit 9b12f4ff93

View File

@@ -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(
@@ -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;
@@ -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();