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 fromREGTEST_N_BITSandREGTEST_TARGET(consistent withHALVING_INTERVAL,DIFFICULTY_ADJUSTMENT_INTERVALandTIME_GENESIS_BLOCK). - move
DIFFICULTY_ADJUSTMENT_INTERVALto the framework
The last commit picks up a Murch-Zawy followup suggested in #35949 (review) and takes advantage of our refactor, but is otherwise unrelated.