#36192 test: cover unsatisfiable mining timestamp

full analysis

https://github.com/bitcoin/bitcoin/pull/36192 · Sjors · +124/-29 in 6 files, 5 commits · labels: Tests

Goal

  • Ensure block template creation handles impossible timestamp edge cases gracefully
  • Verify mining interfaces cleanly recover and maintain connections once time advances

This PR adds functional test coverage for an edge case where an attacker mines blocks with timestamps set to the victim node's future-time limit, making median time past (MTP) equal to the maximum allowable block time. It tests that both getblocktemplate and IPC createNewBlock fail cleanly and recover one second later without dropping the IPC connection. It also standardizes regtest timing constants across functional tests and adds a follow-up test assertion for Murch-Zawy boundary heights.

Problem: When an attacker pushes MTP to the node's maximum future block time, template creation cannot satisfy both constraints (nTime > MTP and nTime <= now + 2 hours). While practically infeasible on mainnet, the scenario was untested and it was unverified whether IPC connections survive the resulting error.

Category: Mining (#4 of 13)

P3 · test coverage

  • P3 because it adds test coverage for a reachable but practically infeasible mining edge case
  • Confirms template generation fails cleanly with an error and recovers as soon as time advances

P3 because it adds regression test coverage and documentation for a reachable but impractical mining edge case. The test ensures that both getblocktemplate and the IPC Mining interface fail gracefully with 'time-too-new' and recover cleanly once time advances.

Membership: Adds functional tests for getblocktemplate and the IPC mining interface template generation logic under timestamp constraints.

Factors: security/stability 0, bug 0, performance 0, user value 1, leverage 1

Reviewability: Ready

  • Ready to review with all feedback addressed and passing continuous integration

CI is passing, there are no merge conflicts, and review feedback has been addressed.

Author status: active

Resolved concerns:

  • fjahr noted confusion over whether the unsatisfiable timestamp was related to BIP 54 / Murch-Zawy rules; Sjors clarified the description and added explicit assertions across difficulty period boundaries.
  • fjahr suggested simplifying constants and dropping REGTEST_ prefixes in blocktools.py; Sjors implemented the cleanup.

Agreement: Strong

  • Full code review approval after earlier feedback was resolved (fjahr)
  • Verified the new functional test passes on Ubuntu WSL (adezo24h1)

Strong: fjahr provided a code review ACK after feedback was addressed.

Reviewer fjahr reviewed earlier revisions, had suggestions addressed by the author, and posted a full code review ACK.

  • fjahr gave a code review ACK on db7a485c33 after testing and review comments were addressed.
  • adezo24h1 verified test passes on Ubuntu WSL.

Review verdicts (DrahtBot): 1

Files

153 lines under test/bench/ci.

  • test/functional/interface_ipc_mining.py +92/-0
  • test/functional/mining_basic.py +10/-8
  • test/functional/rpc_blockchain.py +7/-7
  • test/functional/test_framework/blocktools.py +7/-6
  • test/functional/feature_assumeutxo.py +4/-4
  • test/functional/feature_block.py +4/-4

Card

This PR adds functional test coverage verifying that block template generation fails cleanly and recovers once time advances when an attacker temporarily pushes median time past to the node's future-time limit. The test covers both getblocktemplate and the IPC createNewBlock interface, ensuring the remote IPC connection is not dropped on error. It also cleans up shared regtest block constants in the test framework and adds a follow-up assertion for Murch-Zawy difficulty boundaries. The PR has a code review ACK from fjahr and is ready for merge.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:58, confidence high, input hash 3f7c96d225bc6d96