Skip to content

Commit

Permalink
Pool Hack
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Oct 22, 2024
1 parent f33d25d commit 0adb7c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
20 changes: 10 additions & 10 deletions vendor/transaction-pool/src/graph/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,8 @@ impl<Hash: hash::Hash + Member, Ex> BestIterator<Hash, Ex> {
impl<Hash: hash::Hash + Member, Ex> sc_transaction_pool_api::ReadyTransactions
for BestIterator<Hash, Ex>
{
fn report_invalid(&mut self, _tx: &Self::Item) {
// HACK: This is a temparary hack for https://github.com/frequency-chain/frequency/issues/1927
// See the issue for more details
// Why: Valid transactions were being marked as invalid to do blocks
// Cost: Invalid transactions will not be removed from the pool until the node restarts
// BestIterator::report_invalid(self, tx)
fn report_invalid(&mut self, tx: &Self::Item) {
BestIterator::report_invalid(self, tx)
}
}

Expand All @@ -523,16 +519,20 @@ impl<Hash: hash::Hash + Member, Ex> BestIterator<Hash, Ex> {
/// As a consequence, all values that depend on the invalid one will be skipped.
/// When given transaction is not in the pool it has no effect.
/// When invoked on a fully drained iterator it has no effect either.
pub fn _report_invalid(&mut self, tx: &Arc<Transaction<Hash, Ex>>) {
pub fn report_invalid(&mut self, tx: &Arc<Transaction<Hash, Ex>>) {
if let Some(to_report) = self.all.get(&tx.hash) {
debug!(
target: LOG_TARGET,
"[{:?}] Reported as invalid. Will skip sub-chains while iterating.",
to_report.transaction.transaction.hash
);
for hash in &to_report.unlocks {
self.invalid.insert(hash.clone());
}
// HACK: This is a temparary hack for https://github.com/frequency-chain/frequency/issues/1927
// See the issue for more details
// Why: Valid transactions were being marked as invalid to do blocks
// Cost: Invalid transactions will not be removed from the pool until the node restarts
// for hash in &to_report.unlocks {
// self.invalid.insert(hash.clone());
// }
}
}
}
Expand Down
27 changes: 17 additions & 10 deletions vendor/transaction-pool/src/graph/validated_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,21 +598,28 @@ impl<B: ChainApi> ValidatedPool<B> {
return vec![]
}

log::debug!(target: LOG_TARGET, "Removing invalid transactions: {:?}", hashes);
// HACK: This is a temparary hack for https://github.com/frequency-chain/frequency/issues/1927
// See the issue for more details
// Why: Valid transactions were being marked as invalid to do blocks
// Cost: Invalid transactions will not be removed from the pool until the node restarts
log::debug!(target: LOG_TARGET, "HACK LOG: NOT Removing invalid transactions: {:?}", hashes);
return vec![];

// temporarily ban invalid transactions
self.rotator.ban(&Instant::now(), hashes.iter().cloned());
// log::debug!(target: LOG_TARGET, "Removing invalid transactions: {:?}", hashes);

let invalid = self.pool.write().remove_subtree(hashes);
// // temporarily ban invalid transactions
// self.rotator.ban(&Instant::now(), hashes.iter().cloned());

log::debug!(target: LOG_TARGET, "Removed invalid transactions: {:?}", invalid);
// let invalid = self.pool.write().remove_subtree(hashes);

let mut listener = self.listener.write();
for tx in &invalid {
listener.invalid(&tx.hash);
}
// log::debug!(target: LOG_TARGET, "Removed invalid transactions: {:?}", invalid);

// let mut listener = self.listener.write();
// for tx in &invalid {
// listener.invalid(&tx.hash);
// }

invalid
// invalid
}

/// Get an iterator for ready transactions ordered by priority
Expand Down

0 comments on commit 0adb7c4

Please sign in to comment.