refactor(tx-pool): add enum InvalidKind to mark_invalid (#12845)

This commit is contained in:
Léa Narzis
2024-11-28 17:23:27 +01:00
committed by GitHub
parent cca6372e87
commit 9f20ebc29a
5 changed files with 94 additions and 33 deletions

View File

@ -27,13 +27,13 @@ use reth_payload_builder_primitives::PayloadBuilderError;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_primitives::{
proofs::{self},
Block, BlockBody, BlockExt, EthereumHardforks, Receipt,
Block, BlockBody, BlockExt, EthereumHardforks, InvalidTransactionError, Receipt,
};
use reth_provider::{ChainSpecProvider, StateProviderFactory};
use reth_revm::database::StateProviderDatabase;
use reth_transaction_pool::{
noop::NoopTransactionPool, BestTransactions, BestTransactionsAttributes, TransactionPool,
ValidPoolTransaction,
error::InvalidPoolTransactionError, noop::NoopTransactionPool, BestTransactions,
BestTransactionsAttributes, TransactionPool, ValidPoolTransaction,
};
use reth_trie::HashedPostState;
use revm::{
@ -228,7 +228,10 @@ where
// we can't fit this transaction into the block, so we need to mark it as invalid
// which also removes all dependent transaction from the iterator before we can
// continue
best_txs.mark_invalid(&pool_tx);
best_txs.mark_invalid(
&pool_tx,
InvalidPoolTransactionError::ExceedsGasLimit(pool_tx.gas_limit(), block_gas_limit),
);
continue
}
@ -250,7 +253,13 @@ where
// the iterator. This is similar to the gas limit condition
// for regular transactions above.
trace!(target: "payload_builder", tx=?tx.hash, ?sum_blob_gas_used, ?tx_blob_gas, "skipping blob transaction because it would exceed the max data gas per block");
best_txs.mark_invalid(&pool_tx);
best_txs.mark_invalid(
&pool_tx,
InvalidPoolTransactionError::ExceedsGasLimit(
tx_blob_gas,
MAX_DATA_GAS_PER_BLOCK,
),
);
continue
}
}
@ -270,7 +279,12 @@ where
// if the transaction is invalid, we can skip it and all of its
// descendants
trace!(target: "payload_builder", %err, ?tx, "skipping invalid transaction and its descendants");
best_txs.mark_invalid(&pool_tx);
best_txs.mark_invalid(
&pool_tx,
InvalidPoolTransactionError::Consensus(
InvalidTransactionError::TxTypeNotSupported,
),
);
}
continue