Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#28789: fuzz: Avoid utxo_total_supply timeout (t…
Browse files Browse the repository at this point in the history
…ake 2)

fa7ba92 fuzz: Avoid utxo_total_supply timeout (MarcoFalke)

Pull request description:

  Looks like this still may take a long time to run large fuzz inputs. Thus, reduce it further, but still allow it to catch the regression, if re-introduced:

  ```diff
  diff --git a/src/consensus/tx_check.cpp b/src/consensus/tx_check.cpp
  index f949655909..4bdd15c5ee 100644
  --- a/src/consensus/tx_check.cpp
  +++ b/src/consensus/tx_check.cpp
  @@ -40,7 +40,7 @@ bool CheckTransaction(const CTransaction& tx, TxValidationState& state)
       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");
  +            {}//return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-inputs-duplicate");
       }

       if (tx.IsCoinBase())
  ```

  This is the second take, see bitcoin/bitcoin#27780. If in the future it still times out, I think the fuzz test can just be removed.

  Example input:

  ```
  JREROy5pcnAgQyw7IC4ODg4ODg4ODg4O0dEODg4ODg4ZDg4ODg4ODg4ODg7RDg4ODg4ODg4O0dEODg4ODg4ODg4ODg7R0Q4ODg4ODg4ODtHRDg4ODtHR0dEODg4O0dEODg7R0Q4ODg4ODg4ODtHRDg4ODg4ODg4ODg4O0dEODg4ODg4ODg7R0Q4ODg7R0Q4O0dEODg4ODg4ODg4ODg7R0Q4ODg4ODtHRDg4ODtHR

ACKs for top commit:
  dergoegge:
    ACK fa7ba92
  brunoerg:
    utACK fa7ba92

Tree-SHA512: 154a4895834babede6ce7b775562a7026637af1097e53e55676e92f6cf966ae0c092300ebf7e51a397eebd11f7b41d020586663e781f70d084efda1c0fe851b4
  • Loading branch information
fanquake committed Nov 7, 2023
2 parents 0387ca0 + fa7ba92 commit 2b3f43b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/test/fuzz/utxo_total_supply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ FUZZ_TARGET(utxo_total_supply)
assert(ActiveHeight() == 0);
// Get at which height we duplicate the coinbase
// Assuming that the fuzzer will mine relatively short chains (less than 200 blocks), we want the duplicate coinbase to be not too high.
// Up to 2000 seems reasonable.
int64_t duplicate_coinbase_height = fuzzed_data_provider.ConsumeIntegralInRange(0, 20 * COINBASE_MATURITY);
// Up to 300 seems reasonable.
int64_t duplicate_coinbase_height = fuzzed_data_provider.ConsumeIntegralInRange(0, 300);
// Always pad with OP_0 at the end to avoid bad-cb-length error
const CScript duplicate_coinbase_script = CScript() << duplicate_coinbase_height << OP_0;
// Mine the first block with this duplicate
Expand All @@ -121,7 +121,7 @@ FUZZ_TARGET(utxo_total_supply)

// Limit to avoid timeout, but enough to cover duplicate_coinbase_height
// and CVE-2018-17144.
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes(), 2'000)
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes(), 2'00)
{
CallOneOf(
fuzzed_data_provider,
Expand Down

0 comments on commit 2b3f43b

Please sign in to comment.