Skip to content

Commit 6cbeb3a

Browse files
committed
backport: Merge bitcoin#27780: fuzz: Avoid timeout in utxo_total_supply
Backport of bitcoin#27780 Automated backport — cherry-pick of `2a786ea349`.
1 parent d3b0c98 commit 6cbeb3a

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/test/fuzz/utxo_total_supply.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ FUZZ_TARGET(utxo_total_supply)
122122
current_block = PrepareNextBlock();
123123
StoreLastTxo();
124124

125-
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes(), 100'000)
125+
// Limit to avoid timeout, but enough to cover duplicate_coinbase_height
126+
// and CVE-2018-17144.
127+
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes(), 2'000)
126128
{
127129
CallOneOf(
128130
fuzzed_data_provider,
@@ -145,14 +147,14 @@ FUZZ_TARGET(utxo_total_supply)
145147
current_block->hashMerkleRoot = BlockMerkleRoot(*current_block);
146148
const bool was_valid = !MineBlock(node, current_block).IsNull();
147149

150+
if (duplicate_coinbase_height == ActiveHeight()) {
151+
// we mined the duplicate coinbase
152+
assert(current_block->vtx.at(0)->vin.at(0).scriptSig == duplicate_coinbase_script);
153+
}
154+
148155
const auto prev_utxo_stats = utxo_stats;
149156
if (was_valid) {
150157
circulation += GetBlockSubsidy(ActiveTip(), Params().GetConsensus());
151-
152-
if (duplicate_coinbase_height == ActiveHeight()) {
153-
// we mined the duplicate coinbase
154-
assert(current_block->vtx.at(0)->vin.at(0).scriptSig == duplicate_coinbase_script);
155-
}
156158
}
157159

158160
UpdateUtxoStats();

0 commit comments

Comments
 (0)