Skip to content

Commit 4a31f8c

Browse files
committed
Merge bitcoin#31156: test: Don't enforce BIP94 on regtest unless specified by arg
e60cecc doc: add release note for 31156 (Martin Zumsande) fc7dfb3 test: Don't enforce BIP94 on regtest unless specified by arg (Martin Zumsande) Pull request description: The added arg `-test=bip94` is only used in a functional test for BIP94. This is done because the default regtest consensus rules should follow mainnet, not testnet. Fixes bitcoin#31137. ACKs for top commit: achow101: ACK e60cecc tdb3: cr and light test ACK e60cecc rkrux: tACK e60cecc BrandonOdiwuor: utACK e60cecc laanwj: Code review ACK e60cecc Tree-SHA512: ca2f322f89d8808dfc3565fe020d2615cfcc110e188a02128ad7108fef51c735b33d55b5e6a70c505d78f7291f3c635dc7dfbcd78be1348d4d6e483883be4216
2 parents 02be3dc + e60cecc commit 4a31f8c

File tree

6 files changed

+9
-1
lines changed

6 files changed

+9
-1
lines changed

doc/release-notes-31156.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Test
2+
------
3+
4+
The BIP94 timewarp attack mitigation (designed for testnet4) is no longer active on the regtest network. (#31156)

src/chainparams.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& option
4444
void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options)
4545
{
4646
if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value;
47+
if (HasTestOption(args, "bip94")) options.enforce_bip94 = true;
4748

4849
for (const std::string& arg : args.GetArgs("-testactivationheight")) {
4950
const auto found{arg.find('@')};

src/common/args.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
709709

710710
const std::vector<std::string> TEST_OPTIONS_DOC{
711711
"addrman (use deterministic addrman)",
712+
"bip94 (enforce BIP94 consensus rules)",
712713
};
713714

714715
bool HasTestOption(const ArgsManager& args, const std::string& test_option)

src/kernel/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class CRegTestParams : public CChainParams
542542
consensus.nPowTargetTimespan = 24 * 60 * 60; // one day
543543
consensus.nPowTargetSpacing = 10 * 60;
544544
consensus.fPowAllowMinDifficultyBlocks = true;
545-
consensus.enforce_BIP94 = true;
545+
consensus.enforce_BIP94 = opts.enforce_bip94;
546546
consensus.fPowNoRetargeting = true;
547547
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
548548
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)

src/kernel/chainparams.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class CChainParams
155155
std::unordered_map<Consensus::DeploymentPos, VersionBitsParameters> version_bits_parameters{};
156156
std::unordered_map<Consensus::BuriedDeployment, int> activation_heights{};
157157
bool fastprune{false};
158+
bool enforce_bip94{false};
158159
};
159160

160161
static std::unique_ptr<const CChainParams> RegTest(const RegTestOptions& options);

test/functional/mining_basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def test_blockmintxfee_parameter(self):
122122
def test_timewarp(self):
123123
self.log.info("Test timewarp attack mitigation (BIP94)")
124124
node = self.nodes[0]
125+
self.restart_node(0, extra_args=['-test=bip94'])
125126

126127
self.log.info("Mine until the last block of the retarget period")
127128
blockchain_info = self.nodes[0].getblockchaininfo()

0 commit comments

Comments
 (0)