Skip to content

Commit 2a786ea

Browse files
committed
Merge bitcoin/bitcoin#27780: fuzz: Avoid timeout in utxo_total_supply
fafb4da fuzz: Avoid timeout in utxo_total_supply (MarcoFalke) Pull request description: Looks like for high block counts it may be better to mock the chain, otherwise a high limit will lead to fuzz input bloat and timeouts, see bitcoin/bitcoin#17860 (comment). It can be checked that the fuzz target can still find the CVE, see bitcoin/bitcoin#17860 (review) with a diff of: ```diff diff --git a/src/consensus/tx_check.cpp b/src/consensus/tx_check.cpp index f949655..6f4cfb5f51 100644 --- a/src/consensus/tx_check.cpp +++ b/src/consensus/tx_check.cpp @@ -39,8 +39,6 @@ bool CheckTransaction(const CTransaction& tx, TxValidationState& state) // the underlying coins database. std::set<COutPoint> vInOutPoints; for (const auto& txin : tx.vin) { - if (!vInOutPoints.insert(txin.prevout).second) - return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-inputs-duplicate"); } if (tx.IsCoinBase()) ``` Also, fix a nit, see bitcoin/bitcoin#17860 (comment) ACKs for top commit: dergoegge: ACK fafb4da Tree-SHA512: a28fe9cd6ebb4c9bed5a5b35be76c1c436a87586c8fc3b3c4c8559a4a77ac08098324370da421d794c99579882c0872b6b29415de47ade6a05a08504a3d494c4
2 parents 1b8b28d + fafb4da commit 2a786ea

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/test/fuzz/utxo_total_supply.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ FUZZ_TARGET(utxo_total_supply)
119119
current_block = PrepareNextBlock();
120120
StoreLastTxo();
121121

122-
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes(), 100'000)
122+
// Limit to avoid timeout, but enough to cover duplicate_coinbase_height
123+
// and CVE-2018-17144.
124+
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes(), 2'000)
123125
{
124126
CallOneOf(
125127
fuzzed_data_provider,
@@ -142,14 +144,14 @@ FUZZ_TARGET(utxo_total_supply)
142144
node::RegenerateCommitments(*current_block, chainman);
143145
const bool was_valid = !MineBlock(node, current_block).IsNull();
144146

147+
if (duplicate_coinbase_height == ActiveHeight()) {
148+
// we mined the duplicate coinbase
149+
assert(current_block->vtx.at(0)->vin.at(0).scriptSig == duplicate_coinbase_script);
150+
}
151+
145152
const auto prev_utxo_stats = utxo_stats;
146153
if (was_valid) {
147154
circulation += GetBlockSubsidy(ActiveHeight(), Params().GetConsensus());
148-
149-
if (duplicate_coinbase_height == ActiveHeight()) {
150-
// we mined the duplicate coinbase
151-
assert(current_block->vtx.at(0)->vin.at(0).scriptSig == duplicate_coinbase_script);
152-
}
153155
}
154156

155157
UpdateUtxoStats();

0 commit comments

Comments
 (0)