Skip to content

Commit 641f889

Browse files
committed
feat: start v20 from the same block as DIP0003 on regtest
1 parent 0f94e3e commit 641f889

File tree

10 files changed

+22
-12
lines changed

10 files changed

+22
-12
lines changed

src/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class CRegTestParams : public CChainParams {
795795
consensus.DIP0024Height = 1; // Always have dip0024 quorums unless overridden
796796
consensus.DIP0024QuorumsHeight = 1; // Always have dip0024 quorums unless overridden
797797
consensus.V19Height = 1; // Always active unless overriden
798-
consensus.V20Height = 900;
798+
consensus.V20Height = consensus.DIP0003Height; // Active not earlier than dip0003. Functional tests (DashTestFramework) uses height 100 (same as coinbase maturity)
799799
consensus.MN_RRHeight = 900;
800800
consensus.MinBIP9WarningHeight = 0;
801801
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ TestChainSetup::TestChainSetup(int num_blocks, const std::vector<const char*>& e
399399
/*TestChainBRRBeforeActivationSetup=*/
400400
{ 497, uint256S("0x0857a9b5db51835b1c828f019f4c664b5fe6c28ac44a6d868436930f832d31e5") },
401401
/*TestChainV19BeforeActivationSetup=*/
402-
{ 494, uint256S("0x44ee5c8a5e5cbd4437d63c54ddc1d40329be811b25c492fa901e11cdf408f905") },
402+
{ 494, uint256S("72c5b8760d9070ca3b6402094dcea76cd25806bc20d1bf3777a7be712e17bbd2") },
403403
}
404404
};
405405

test/functional/feature_asset_locks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ def run_test(self):
248248

249249
self.set_sporks()
250250

251-
self.activate_v20(expected_activation_height=900)
252-
self.log.info("Activated v20 at height:" + str(node.getblockcount()))
251+
assert_equal(self.nodes[0].getblockchaininfo()['softforks']['v20']['active'], True)
253252

254253
for _ in range(2):
255254
self.dynamically_add_masternode(evo=True)
@@ -515,10 +514,13 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
515514
total = self.get_credit_pool_balance()
516515
coins = node_wallet.listunspent()
517516
while total <= 10_901 * COIN:
517+
if len(coins) == 0:
518+
coins = node_wallet.listunspent(query_options={'minimumAmount': 1})
518519
coin = coins.pop()
519520
to_lock = int(coin['amount'] * COIN) - tiny_amount
520-
if to_lock > 99 * COIN:
521+
if to_lock > 99 * COIN and total > 10_000 * COIN:
521522
to_lock = 99 * COIN
523+
522524
total += to_lock
523525
tx = self.create_assetlock(coin, to_lock, pubkey)
524526
self.send_tx_simple(tx)

test/functional/feature_dip4_coinbasemerkleroots.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
DIP0008_HEIGHT = 432
2121
DIP0024_HEIGHT = 900
22+
V20_HEIGHT = 900
2223

2324
# TODO: this helper used in many tests, find a new home for it
2425
class TestP2PConn(P2PInterface):
@@ -46,6 +47,7 @@ class LLMQCoinbaseCommitmentsTest(DashTestFramework):
4647
def set_test_params(self):
4748
self.extra_args = [[ f'-testactivationheight=dip0008@{DIP0008_HEIGHT}', f'-testactivationheight=dip0024@{DIP0024_HEIGHT}', "-vbparams=testdummy:999999999999:999999999999" ]] * 4
4849
self.set_dash_test_params(4, 3, extra_args = self.extra_args)
50+
self.delay_v20(height=V20_HEIGHT)
4951

5052
def remove_masternode(self, idx):
5153
mn = self.mninfo[idx]

test/functional/feature_governance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class DashGovernanceTest (DashTestFramework):
1717
def set_test_params(self):
1818
self.set_dash_test_params(6, 5, [[
1919
"-budgetparams=10:10:10",
20-
'-testactivationheight=v20@160',
2120
]] * 6)
21+
self.delay_v20(height=160)
2222

2323
def check_superblockbudget(self, v20_active):
2424
v20_state = self.nodes[0].getblockchaininfo()["softforks"]["v20"]

test/functional/feature_llmq_chainlocks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
class LLMQChainLocksTest(DashTestFramework):
2121
def set_test_params(self):
2222
self.set_dash_test_params(5, 4)
23+
self.delay_v20(height=200)
2324

2425
def run_test(self):
2526
# Connect all nodes to node1 so that we always have the whole network connected
@@ -30,8 +31,8 @@ def run_test(self):
3031

3132
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)
3233

33-
self.activate_mn_rr(expected_activation_height=900)
34-
self.log.info("Activated MN_RR at height:" + str(self.nodes[0].getblockcount()))
34+
self.activate_v20(expected_activation_height=200)
35+
self.log.info("Activated v20 at height:" + str(self.nodes[0].getblockcount()))
3536

3637
# v20 is active for the next block, not for the tip
3738
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)

test/functional/feature_llmq_rotation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class LLMQQuorumRotationTest(DashTestFramework):
5353
def set_test_params(self):
5454
self.set_dash_test_params(9, 8)
5555
self.set_dash_llmq_test_params(4, 4)
56+
self.delay_v20(height=900)
5657

5758
def run_test(self):
5859
llmq_type=103

test/functional/feature_llmq_simplepose.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def set_test_params(self):
2222
self.extra_args = [[ '-testactivationheight=dip0024@9999' ]] * 6
2323
self.set_dash_test_params(6, 5)
2424
self.set_dash_llmq_test_params(5, 3)
25+
self.delay_v20(height=9999)
2526

2627
def add_options(self, parser):
2728
parser.add_argument("--disable-spork23", dest="disable_spork23", default=False, action="store_true",

test/functional/feature_mnehf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ def run_test(self):
121121
node = self.nodes[0]
122122

123123
self.set_sporks()
124-
self.log.info("Consensus rules assume there're no EHF signal before V20")
125-
self.activate_v20()
126-
127124
self.log.info("Mine a quorum...")
128125
self.mine_quorum()
129126
self.check_fork('defined')

test/functional/test_framework/test_framework.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ def add_dynamically_node(self, extra_args=None, *, rpchost=None, binary=None):
599599
self.nodes.append(t_node)
600600
return t_node
601601

602+
# TODO: move it to DashTestFramework where it belongs
602603
def dynamically_initialize_datadir(self, node_p2p_port, node_rpc_port):
603604
source_data_dir = get_datadir_path(self.options.tmpdir, 0) # use node0 as a source
604605
new_data_dir = get_datadir_path(self.options.tmpdir, len(self.nodes))
@@ -633,6 +634,7 @@ def dynamically_initialize_datadir(self, node_p2p_port, node_rpc_port):
633634
f.write("natpmp=0\n")
634635
f.write("shrinkdebugfile=0\n")
635636
f.write("dip3params=2:2\n")
637+
f.write(f"testactivationheight=v20@{self.v20_height}\n")
636638
os.makedirs(os.path.join(new_data_dir, 'stderr'), exist_ok=True)
637639
os.makedirs(os.path.join(new_data_dir, 'stdout'), exist_ok=True)
638640

@@ -1170,7 +1172,7 @@ def add_nodes(self, num_nodes: int, extra_args=None, *, rpchost=None, binary=Non
11701172
old_num_nodes = len(self.nodes)
11711173
super().add_nodes(num_nodes, extra_args, rpchost=rpchost, binary=binary, binary_cli=binary_cli, versions=versions)
11721174
for i in range(old_num_nodes, old_num_nodes + num_nodes):
1173-
append_config(self.nodes[i].datadir, ["dip3params=2:2"])
1175+
append_config(self.nodes[i].datadir, ["dip3params=2:2", f"testactivationheight=v20@{self.v20_height}"])
11741176
if old_num_nodes == 0:
11751177
# controller node is the only node that has an extra option allowing it to submit sporks
11761178
append_config(self.nodes[0].datadir, ["sporkkey=cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK"])
@@ -1190,6 +1192,7 @@ def set_dash_test_params(self, num_nodes, masterodes_count, extra_args=None, evo
11901192
self.num_nodes = num_nodes
11911193
self.mninfo = []
11921194
self.setup_clean_chain = True
1195+
self.v20_height = 100
11931196
# additional args
11941197
if extra_args is None:
11951198
extra_args = [[]] * num_nodes
@@ -1207,6 +1210,9 @@ def set_dash_test_params(self, num_nodes, masterodes_count, extra_args=None, evo
12071210
self.quorum_data_request_expiration_timeout = 360
12081211

12091212

1213+
def delay_v20(self, height=None):
1214+
self.v20_height = height
1215+
12101216
def activate_by_name(self, name, expected_activation_height=None, slow_mode=True):
12111217
assert not softfork_active(self.nodes[0], name)
12121218
self.log.info("Wait for " + name + " activation")

0 commit comments

Comments
 (0)