Mutant created against commit dc3cd19.
+0 -2 · cpp
This mutant deletes the original lines without replacement.
This description is AI generated, mistakes can be made.
Intent: Removes the anti-DoS rule that difficulty may change only at retarget boundaries. Headers presync/redownload in HeadersSyncState rely on it to bound how cheaply a peer can feed low-work headers. Final block validation still catches wrong nBits (bad-diffbits), so consensus holds, but a peer can build a presync header chain that mixes difficulties inside a period.
Behaviour change: Original: for mainnet height % 2016 != 0 with new_nbits != old_nbits, it returns false and HeadersSyncState aborts the peer's sync as invalid. Mutant: it returns true, and the presync/redownload phase accepts the header.
Trigger: A mainnet peer sends a low-work headers chain during headers presync in which a header at a non-retarget height lowers the difficulty (e.g., to 0x1d00ffff) relative to its parent. headerssync.cpp:197/245 then accepts it instead of aborting.
Spec violation: pow.h doc comment: PermittedDifficultyTransition '...checks the new value against the old value for blocks at the difficulty adjustment interval, and otherwise requires the values to be the same.'
Severity if undetected: high
Why tests miss it: src/test/pow_tests.cpp (always height = retarget height), src/test/fuzz/pow.cpp pow_transition (retarget height only), src/test/headers_sync_chainwork_tests.cpp (RegTestingSetup -> early return true), test/functional/p2p_headers_presync.py (regtest)
Plausibility: It looks like a harmless simplification of a function whose visible job is 'check the retarget clamps'. The else-if reads as an afterthought.
Equivalence risk: Headers accepted in presync still pass through full ContextualCheckBlockHeader, so consensus is unaffected. The difference shows only in HeadersSyncState's accept/abort decision.
Commands and environment reported by the submitter
cmake -B build -DBUILD_GUI=OFF -DWITH_ZMQ=OFF -DENABLE_IPC=OFF && cmake --build build -j$(nproc)ctest --test-dir build -j$(nproc) && build/test/functional/test_runner.py -j$(nproc)mutant-harness operator: deletion; location: PermittedDifficultyTransition lines 132-134
Imported from mutant-harness 480d7e3.
Commands are shown as text and never executed by MutantHub.
0 comments
No comments yet
Discuss equivalence, reproduction difficulties, or a test that kills this mutant.