Skip to content

Commit fa4db86

Browse files
author
MarcoFalke
committed
test: Activate all regtest softforks at height 1, unless overridden
1 parent faad1e5 commit fa4db86

13 files changed

+52
-44
lines changed

doc/release-notes.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ Tests
109109
-----
110110

111111
- For the `regtest` network the activation heights of several softforks were
112-
changed.
113-
* BIP 34 (blockheight in coinbase) from 500 to 2 (#16333)
114-
* BIP 66 (DERSIG) from 1251 to 102 (#22632)
115-
* BIP 65 (CLTV) from 1351 to 111 (#21862)
112+
set to block height 1. They can be changed by the runtime setting
113+
`-testactivationheight=name@height`. (#22818)
116114

117115
Credits
118116
=======

src/chainparams.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,12 @@ class CRegTestParams : public CChainParams {
390390
consensus.signet_challenge.clear();
391391
consensus.nSubsidyHalvingInterval = 150;
392392
consensus.BIP16Exception = uint256();
393-
consensus.BIP34Height = 2; // BIP34 activated on regtest (Block at height 1 not enforced for testing purposes)
393+
consensus.BIP34Height = 1; // Always active unless overridden
394394
consensus.BIP34Hash = uint256();
395-
consensus.BIP65Height = 111; // BIP65 activated on regtest (Block at height 110 and earlier not enforced for testing purposes)
396-
consensus.BIP66Height = 102; // BIP66 activated on regtest (Block at height 101 and earlier not enforced for testing purposes)
397-
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
398-
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
395+
consensus.BIP65Height = 1; // Always active unless overridden
396+
consensus.BIP66Height = 1; // Always active unless overridden
397+
consensus.CSVHeight = 1; // Always active unless overridden
398+
consensus.SegwitHeight = 1; // Always active unless overridden
399399
consensus.MinBIP9WarningHeight = 0;
400400
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
401401
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
@@ -502,6 +502,14 @@ static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& conse
502502
}
503503
if (name == "segwit") {
504504
consensus.SegwitHeight = int{height};
505+
} else if (name == "bip34") {
506+
consensus.BIP34Height = int{height};
507+
} else if (name == "dersig") {
508+
consensus.BIP66Height = int{height};
509+
} else if (name == "cltv") {
510+
consensus.BIP65Height = int{height};
511+
} else if (name == "csv") {
512+
consensus.CSVHeight = int{height};
505513
} else {
506514
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
507515
}

src/chainparamsbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
2020
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2121
argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
2222
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
23-
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name'. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
23+
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
2424
argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2525
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2626
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);

src/test/txvalidationcache_tests.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@
1313

1414
#include <boost/test/unit_test.hpp>
1515

16+
struct Dersig100Setup : public TestChain100Setup {
17+
Dersig100Setup()
18+
: TestChain100Setup{{"-testactivationheight=dersig@102"}} {}
19+
};
20+
1621
bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
1722
const CCoinsViewCache& inputs, unsigned int flags, bool cacheSigStore,
1823
bool cacheFullScriptStore, PrecomputedTransactionData& txdata,
1924
std::vector<CScriptCheck>* pvChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
2025

2126
BOOST_AUTO_TEST_SUITE(txvalidationcache_tests)
2227

23-
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
28+
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
2429
{
2530
// Make sure skipping validation of transactions that were
2631
// validated going into the memory pool does not allow
@@ -153,7 +158,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
153158
}
154159
}
155160

156-
BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
161+
BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
157162
{
158163
// Test that passing CheckInputScripts with one set of script flags doesn't imply
159164
// that we would pass again with a different set of flags.

test/functional/feature_bip68_sequence.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ class BIP68Test(BitcoinTestFramework):
4141
def set_test_params(self):
4242
self.num_nodes = 2
4343
self.extra_args = [
44-
["-acceptnonstdtxn=1"],
45-
["-acceptnonstdtxn=0"],
44+
[
45+
'-testactivationheight=csv@432',
46+
"-acceptnonstdtxn=1",
47+
],
48+
[
49+
'-testactivationheight=csv@432',
50+
"-acceptnonstdtxn=0",
51+
],
4652
]
4753

4854
def skip_test_if_missing_module(self):

test/functional/feature_block.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ class FullBlockTest(BitcoinTestFramework):
8282
def set_test_params(self):
8383
self.num_nodes = 1
8484
self.setup_clean_chain = True
85-
self.extra_args = [['-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy
85+
self.extra_args = [[
86+
'-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
87+
'-testactivationheight=bip34@2',
88+
]]
8689

8790
def run_test(self):
8891
node = self.nodes[0] # convenience reference to the node

test/functional/feature_cltv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99

1010
from test_framework.blocktools import (
11-
CLTV_HEIGHT,
1211
create_block,
1312
create_coinbase,
1413
)
@@ -76,10 +75,14 @@ def cltv_validate(tx, height):
7675
cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
7776

7877

78+
CLTV_HEIGHT = 111
79+
80+
7981
class BIP65Test(BitcoinTestFramework):
8082
def set_test_params(self):
8183
self.num_nodes = 1
8284
self.extra_args = [[
85+
f'-testactivationheight=cltv@{CLTV_HEIGHT}',
8386
8487
'-par=1', # Use only one script thread to get the exact reject reason for testing
8588
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard

test/functional/feature_csv_activation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import time
4242

4343
from test_framework.blocktools import (
44-
CSV_ACTIVATION_HEIGHT,
4544
create_block,
4645
create_coinbase,
4746
)
@@ -89,12 +88,16 @@ def all_rlt_txs(txs):
8988
return [tx['tx'] for tx in txs]
9089

9190

91+
CSV_ACTIVATION_HEIGHT = 432
92+
93+
9294
class BIP68_112_113Test(BitcoinTestFramework):
9395
def set_test_params(self):
9496
self.num_nodes = 1
9597
self.setup_clean_chain = True
9698
self.extra_args = [[
9799
100+
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
98101
'-par=1', # Use only one script thread to get the exact reject reason for testing
99102
]]
100103
self.supports_cli = False

test/functional/feature_dersig.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99

1010
from test_framework.blocktools import (
11-
DERSIG_HEIGHT,
1211
create_block,
1312
create_coinbase,
1413
)
@@ -42,10 +41,14 @@ def unDERify(tx):
4241
tx.vin[0].scriptSig = CScript(newscript)
4342

4443

44+
DERSIG_HEIGHT = 102
45+
46+
4547
class BIP66Test(BitcoinTestFramework):
4648
def set_test_params(self):
4749
self.num_nodes = 1
4850
self.extra_args = [[
51+
f'-testactivationheight=dersig@{DERSIG_HEIGHT}',
4952
5053
'-par=1', # Use only one script thread to get the exact log msg for testing
5154
]]

test/functional/rpc_blockchain.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
from test_framework.address import ADDRESS_BCRT1_P2WSH_OP_TRUE
2929
from test_framework.blocktools import (
30-
CLTV_HEIGHT,
31-
DERSIG_HEIGHT,
3230
create_block,
3331
create_coinbase,
3432
TIME_GENESIS_BLOCK,
@@ -142,11 +140,11 @@ def _test_getblockchaininfo(self):
142140
assert_greater_than(res['size_on_disk'], 0)
143141

144142
assert_equal(res['softforks'], {
145-
'bip34': {'type': 'buried', 'active': True, 'height': 2},
146-
'bip66': {'type': 'buried', 'active': True, 'height': DERSIG_HEIGHT},
147-
'bip65': {'type': 'buried', 'active': True, 'height': CLTV_HEIGHT},
148-
'csv': {'type': 'buried', 'active': False, 'height': 432},
149-
'segwit': {'type': 'buried', 'active': True, 'height': 0},
143+
'bip34': {'type': 'buried', 'active': True, 'height': 1},
144+
'bip66': {'type': 'buried', 'active': True, 'height': 1},
145+
'bip65': {'type': 'buried', 'active': True, 'height': 1},
146+
'csv': {'type': 'buried', 'active': True, 'height': 1},
147+
'segwit': {'type': 'buried', 'active': True, 'height': 1},
150148
'testdummy': {
151149
'type': 'bip9',
152150
'bip9': {

0 commit comments

Comments
 (0)