Skip to content

Commit 5d718f6

Browse files
committed
Mitigate timeout in CalculateTotalBumpFees
The slow fuzz seed described in #27799 was just slower than expected, not an endless loop. Ensuring that every anscestor is only processed once speeds up the termination of the graph traversal. Fixes #27799
1 parent 34ac3f4 commit 5d718f6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node/mini_miner.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,20 @@ std::optional<CAmount> MiniMiner::CalculateTotalBumpFees(const CFeeRate& target_
346346
to_process.insert(iter);
347347
ancestors.insert(iter);
348348
}
349+
350+
std::set<uint256> has_been_processed;
349351
while (!to_process.empty()) {
350352
auto iter = to_process.begin();
351353
const CTransaction& tx = (*iter)->second.GetTx();
352354
for (const auto& input : tx.vin) {
353355
if (auto parent_it{m_entries_by_txid.find(input.prevout.hash)}; parent_it != m_entries_by_txid.end()) {
354-
to_process.insert(parent_it);
356+
if (!has_been_processed.count(input.prevout.hash)) {
357+
to_process.insert(parent_it);
358+
}
355359
ancestors.insert(parent_it);
356360
}
357361
}
362+
has_been_processed.insert(tx.GetHash());
358363
to_process.erase(iter);
359364
}
360365
const auto ancestor_package_size = std::accumulate(ancestors.cbegin(), ancestors.cend(), int64_t{0},

0 commit comments

Comments
 (0)