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

Merge bitcoin/bitcoin#36192: test: cover unsatisfiable mining timestamp

Public commit record

What the developer wrote

Authored by merge-script

100/100 · Strong
Merge bitcoin/bitcoin#36192: test: cover unsatisfiable mining timestamp

c000f6ef15e06856b9111ee433877a2b1bf31eb4 test: assert Murch-Zawy period boundaries (Sjors Provoost)
9b4f05a240a3feaf99976fd14952a21b3f96e029 test: cover unsatisfiable mining timestamp (Sjors Provoost)
2137b7b2ee3ae3c39aa74a9ac7e26d821c1b4988 test: share block timing constants through blocktools (Sjors Provoost)
bb32ef4d541d14752f2dca9b1a633aecea9d40a7 test: drop REGTEST_ prefix from block difficulty constants (Sjors Provoost)
9f34ea1605bd0c8726cc69ecf5686cc6d3d0d125 test: rename REGTEST_RETARGET_PERIOD to HALVING_INTERVAL (Sjors Provoost)

Pull request description:

This PR adds test coverage for what happens in the (extremely unlikely) event that the miner can't satisfy the constraints. This is inspired by the recently added timewarp-protection and Murch-Zawy rules (for the miner, not for consensus, see #30681 and #35949), but this is a pre-existing issue. It is not made worse by these rules.

The test has an attacker mine 6 blocks, which set MTP at the victim's future-time limit. It calls `getblocktemplate` and the equivalent IPC method, which both fail. It then moves mock time one second forward, and demonstrates mining works again (and we don't drop the IPC connection).

This (impractical) attack can be done at any height, be we illustrate it for blocks 142, 143 and 0 of a retarget period, to clarify that the timewarp-protection and Murch-Zawy rules do not matter.

The test was added to `ipc_mining.py`, to avoid having to add IPC support to `mining_basic.py`. Mining coverage is currently split between various test files and not always mirrored between RPC and IPC. A followup could unify these, while still skipping the IPC side when that's not compiled.

A few refactor commits to prepare:

- fix incorrect name: `REGTEST_RETARGET_PERIOD` -> `HALVING_INTERVAL`
- drop `REGTEST_` prefix from `REGTEST_N_BITS` and `REGTEST_TARGET` (consistent with `HALVING_INTERVAL`, `DIFFICULTY_ADJUSTMENT_INTERVAL` and `TIME_GENESIS_BLOCK`).
- move `DIFFICULTY_ADJUSTMENT_INTERVAL` to the framework

The last commit picks up a Murch-Zawy followup suggested in https://github.com/bitcoin/bitcoin/pull/35949#discussion_r3944011135 and takes advantage of our refactor, but is otherwise unrelated.

ACKs for top commit:
fjahr:
reACK c000f6ef15e06856b9111ee433877a2b1bf31eb4
ismaelsadeeq:
reACK c000f6ef15e06856b9111ee433877a2b1bf31eb4
sedited:
ACK c000f6ef15e06856b9111ee433877a2b1bf31eb4

Tree-SHA512: e92c46ba5366024eca6d2af5569f3665bea22db232608ca8b94abf3c921a2cc39e70af1aa2612c972a4ad2838da0d9ad47941d676b6f802bbc8987ed8ac6639c
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit only adds and reorganizes Bitcoin Core's own functional tests. It renames some test constants, moves a shared constant into the test framework, and adds a new test that checks how the mining code behaves when an attacker manipulates block timestamps to make template creation temporarily fail. The commit does not change any production consensus, networking, or wallet code, and the pull request description explicitly calls the scenario an 'impractical' test-case. There is no security patch or vulnerability fix here.

Recommended action

No action required. This is a test-only change. Reviewers may optionally run the updated functional tests (interface_ipc_mining.py and mining_basic.py) to confirm the new coverage passes.

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.