feat: add tx-level subpool add and remove traces (#10001)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Dan Cline
2024-08-02 07:35:35 -04:00
committed by GitHub
parent ae4be80cd5
commit 167f6eb596

View File

@ -663,12 +663,21 @@ impl<T: TransactionOrdering> TxPool<T> {
pool: SubPool,
tx: &TransactionId,
) -> Option<Arc<ValidPoolTransaction<T::Transaction>>> {
match pool {
let tx = match pool {
SubPool::Queued => self.queued_pool.remove_transaction(tx),
SubPool::Pending => self.pending_pool.remove_transaction(tx),
SubPool::BaseFee => self.basefee_pool.remove_transaction(tx),
SubPool::Blob => self.blob_pool.remove_transaction(tx),
};
if let Some(ref tx) = tx {
// We trace here instead of in subpool structs directly, because the `ParkedPool` type
// is generic and it would not be possible to distinguish whether a transaction is
// being removed from the `BaseFee` pool, or the `Queued` pool.
trace!(target: "txpool", hash=%tx.transaction.hash(), ?pool, "Removed transaction from a subpool");
}
tx
}
/// Removes the transaction from the given pool and advance sub-pool internal state, with the
@ -678,12 +687,21 @@ impl<T: TransactionOrdering> TxPool<T> {
pool: SubPool,
tx: &TransactionId,
) -> Option<Arc<ValidPoolTransaction<T::Transaction>>> {
match pool {
let tx = match pool {
SubPool::Pending => self.pending_pool.remove_transaction(tx),
SubPool::Queued => self.queued_pool.remove_transaction(tx),
SubPool::BaseFee => self.basefee_pool.remove_transaction(tx),
SubPool::Blob => self.blob_pool.remove_transaction(tx),
};
if let Some(ref tx) = tx {
// We trace here instead of in subpool structs directly, because the `ParkedPool` type
// is generic and it would not be possible to distinguish whether a transaction is
// being pruned from the `BaseFee` pool, or the `Queued` pool.
trace!(target: "txpool", hash=%tx.transaction.hash(), ?pool, "Pruned transaction from a subpool");
}
tx
}
/// Removes _only_ the descendants of the given transaction from the __entire__ pool.
@ -717,19 +735,17 @@ impl<T: TransactionOrdering> TxPool<T> {
pool: SubPool,
tx: Arc<ValidPoolTransaction<T::Transaction>>,
) {
// We trace here instead of in structs directly, because the `ParkedPool` type is
// generic and it would not be possible to distinguish whether a transaction is being
// added to the `BaseFee` pool, or the `Queued` pool.
trace!(target: "txpool", hash=%tx.transaction.hash(), ?pool, "Adding transaction to a subpool");
match pool {
SubPool::Queued => {
self.queued_pool.add_transaction(tx);
}
SubPool::Queued => self.queued_pool.add_transaction(tx),
SubPool::Pending => {
self.pending_pool.add_transaction(tx, self.all_transactions.pending_fees.base_fee);
}
SubPool::BaseFee => {
self.basefee_pool.add_transaction(tx);
}
SubPool::Blob => {
self.blob_pool.add_transaction(tx);
}
SubPool::BaseFee => self.basefee_pool.add_transaction(tx),
SubPool::Blob => self.blob_pool.add_transaction(tx),
}
}