AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 15 Bitcoin

Merge bitcoin/bitcoin#36231: test: add pow tests covering live mutants

Public commit record

What the developer wrote

Authored by merge-script

91/100 · Strong
Merge bitcoin/bitcoin#36231: test: add pow tests covering live mutants

e6975adf58c354dbd167b419ad7aadc7b8053af6 test: cover non-retarget heights in PermittedDifficultyTransition (ViniciusCestarii)
a9873943e259b23884fb4295591a82168c831026 test: cover lower bound rounding in PermittedDifficultyTransition (ViniciusCestarii)
7834db23914a3faa3660cb609144cd1c345a1ef3 test: cover negative timespan in CalculateNextWorkRequired (ViniciusCestarii)
1811735255b98257e7bf385325599c8d9bb69ad0 test: cover first block time selection in GetNextWorkRequired (ViniciusCestarii)

Pull request description:

Kills 4 live mutants on pow.cpp found with https://github.com/ViniciusCestarii/mutant-harness. The first 2 affect consensus. The third affect header sync and could stall IBD. The forth cover header sync hardening against DoS. They are:

pow.cpp (killed by 1811735255b98257e7bf385325599c8d9bb69ad0):

```diff
diff --git a/src/pow.cpp b/src/pow.cpp
index 9a9f4e5..9872b2c 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -44,7 +44,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
const CBlockIndex* pindexFirst = pindexLast->GetAncestor(nHeightFirst);
assert(pindexFirst);

- return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);
+ return CalculateNextWorkRequired(pindexLast, pindexFirst->GetMedianTimePast(), params);
}

unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
```

pow.cpp (killed by 7834db23914a3faa3660cb609144cd1c345a1ef3):

```diff
diff --git a/src/pow.cpp b/src/pow.cpp
index 9a9f4e5..1917b7b 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -53,7 +53,7 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
return pindexLast->nBits;

// Limit adjustment step
- int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime;
+ uint32_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime;
if (nActualTimespan < params.nPowTargetTimespan/4)
nActualTimespan = params.nPowTargetTimespan/4;
if (nActualTimespan > params.nPowTargetTimespan*4)
```

pow.cpp (killed by a9873943e259b23884fb4295591a82168c831026):

```diff
diff --git a/src/pow.cpp b/src/pow.cpp
index 9a9f4e5..028fa9f 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -124,11 +124,8 @@ bool PermittedDifficultyTransition(const Consensus::Params& params, int64_t heig
smallest_difficulty_target = pow_limit;
}

- // Round and then compare this new calculated value to what is
- // observed.
- arith_uint256 minimum_new_target;
- minimum_new_target.SetCompact(smallest_difficulty_target.GetCompact());
- if (minimum_new_target > observed_new_target) return false;
+ // Compare this new calculated value to what is observed.
+ if (smallest_difficulty_target > observed_new_target) return false;
} else if (old_nbits != new_nbits) {
return false;
}
```

pow.cpp (killed by e6975adf58c354dbd167b419ad7aadc7b8053af6):

```diff
diff --git a/src/pow.cpp b/src/pow.cpp
index 9a9f4e5..ef2e788 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -129,8 +129,6 @@ bool PermittedDifficultyTransition(const Consensus::Params& params, int64_t heig
arith_uint256 minimum_new_target;
minimum_new_target.SetCompact(smallest_difficulty_target.GetCompact());
if (minimum_new_target > observed_new_target) return false;
- } else if (old_nbits != new_nbits) {
- return false;
}
return true;
}
```

Recommend reviewing per commit.

ACKs for top commit:
brunoerg:
ACK e6975adf58c354dbd167b419ad7aadc7b8053af6
sedited:
ACK e6975adf58c354dbd167b419ad7aadc7b8053af6

Tree-SHA512: da29cf0226393a870e5c0bb8b228143abf124a905c70caf1006830854a9ac1f26b087a0c65570c8c0661d5a8db67ff91c22accb1d7ed5d4f5d1597ef1d66fe5a
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit only adds new test cases to Bitcoin Core's proof-of-work test file. It does not change any production code. The tests are designed to detect if future code changes accidentally break subtle consensus rules around difficulty retargeting. There is no vulnerability being fixed here.

Recommended action

No action required. This is a defensive test-only change. Reviewers may optionally verify the new test vectors match the intended consensus semantics described in the PR.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.