Skip to content

Commit

Permalink
feat: add tx-level subpool add and remove traces (#10001)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
Rjected and mattsse authored Aug 2, 2024
1 parent ae4be80 commit 167f6eb
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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),
}
}

Expand Down

0 comments on commit 167f6eb

Please sign in to comment.