Skip to content

Commit dc6c35b

Browse files
Merge #6667: feat: fire up 🏃 test chains by first block (v20, mn_rr) - 9/9
ef5cde5 feat: enforce mn_rr activation after v20 on regtest (UdjinM6) 1ac1628 test: simplify calculation of num payees (Konstantin Akimov) 5c3b284 doc: edit commentary about Credit Pool existance (Konstantin Akimov) 96e9cef fix: adjust rpc_blockchin.py functional test (Konstantin Akimov) fd32e57 fix: update number of blocks before pruning for feature_index_prune.py (Konstantin Akimov) 2127f99 test: adjust activation heights on rpc_blockchain.py for v20 and mn_rr (Konstantin Akimov) 046d5ee feat: activate mn_rr fork from block 1 on RegTest (Konstantin Akimov) 080207e test: speed-up feature_asset_locks.py functional test by generating less blocks (Konstantin Akimov) 3d67e7d fix: require v20 fork activated for reallocation block reward to credit pool (Konstantin Akimov) 641f889 feat: start v20 from the same block as DIP0003 on regtest (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented This PR is the final PR that activates all currently buried soft-forks on earlier block as possible. This series of PR chased 3 ultimate goals: - improve performance of functional tests: no need to generate many blocks just waiting until some feature is activated - it helps for unit & functional tests to test actual code that works on mainnet currently with all features enabled. Not some pre-feature status - it helps platform's dev environment to start faster (some final integration is expected after this PR). Prior work: #6511 and other PRs ## What was done? Changes are related to 2 forks that has been activated on high height on regtest: - v20 which set subsidy of each block to fixed value 5, increases governance share of reward (10% to 20%), introduces EHF forks and add to coinbase transaction ChainLocks and Credit Pool, also changes behavior in build SML lists. - mn_rr: part of reward of each block is actually goes to credit pool, triggers platform chain genesis blocks Functional test `rpc_masternode.py` is compatible now with MN_RR fork (expected 3 or 4 outputs of coinbase tx: miner, credit pool, masternode reward, optional operator reward) ### V20 V20 must not be active before fork dip0003 so far as all features depends on DIP0003. For BitcoinTestFramework v20's activation is delayed to block 500 same as DIP0003 because unit tests and functional tests that are backported from bitcoin expects certains behaviour: manually constructed blocks do not have CbTx transaction of version 2 (dip003) or version 3 (v20 with CL) and may not be accepted after DIP3 or v20 activation. For DashTestFramework v20's activation is delayed to block 100 because wallet should have enough coins to create masternodes / evonodes; but with fixed subsidy equaled to 2 it takes thousands of blocks before masternodes can be created. 100 blocks is chosen to match with coinbase maturity. Higher height may cause v20 to be activated too late for some functional tests. Height can be lower than 100 blocks, maybe low as just 50 blocks, but 50 * 500 = 25000 tDash which is not enough to create more than 8 evo nodes. ### MN_RR Part of block reward is not coming to credit pool before it is actually exist (v20 activated). ## How Has This Been Tested? Run unit / functional tests that possible affected by this PR. Time is slightly reduced for `feature_asset_locks.py`, `feature_mnehf.py`, `feature_llmq_chainlocks.py` as expected. Time is unexpectedly increased for `feature_llmq_rotation.py` (should not be changed). Disk usage is significantly reduced as expected (less blocks means less storage for blocks; less logs for each node). PR: ``` feature_asset_locks.py | ✓ Passed | 110 s feature_dip4_coinbasemerkleroots.py | ✓ Passed | 97 s feature_governance.py --descriptors | ✓ Passed | 186 s feature_governance.py --legacy-wallet | ✓ Passed | 184 s feature_llmq_chainlocks.py | ✓ Passed | 105 s feature_llmq_rotation.py | ✓ Passed | 133 s feature_mnehf.py | ✓ Passed | 71 s rpc_blockchain.py --v1transport | ✓ Passed | 13 s rpc_blockchain.py --v2transport | ✓ Passed | 12 s rpc_masternode.py | ✓ Passed | 8 s ALL | ✓ Passed | 919 s (accumulated) Runtime: 186 s ``` Disk usage: ``` 1396020 /tmp/test_runner_∋_🏃_20250512_115202 ``` develop: ``` feature_asset_locks.py | ✓ Passed | 131 s feature_dip4_coinbasemerkleroots.py | ✓ Passed | 90 s feature_governance.py --descriptors | ✓ Passed | 181 s feature_governance.py --legacy-wallet | ✓ Passed | 186 s feature_llmq_chainlocks.py | ✓ Passed | 120 s feature_llmq_rotation.py | ✓ Passed | 92 s feature_mnehf.py | ✓ Passed | 92 s rpc_blockchain.py --v1transport | ✓ Passed | 12 s rpc_blockchain.py --v2transport | ✓ Passed | 12 s rpc_masternode.py | ✓ Passed | 8 s ALL | ✓ Passed | 924 s (accumulated) ``` Disk usage: ``` 1633584 /tmp/test_runner_∋_🏃_20250512_121826/ ``` ## Breaking Changes On Regtest fork `v20` is activated on block 1 if not specified otherwise. Use `-testactivationheight=v20@100` to activate v20 from block 100 and increase subsidy of first blocks, if you want to register any masternode. On Regtest fork `MN_RR` is activated on block 1 if not speicifed otherwise. Use `-testactivationheight=mn_rr@{HEIGHT}` to activate mn_rr from block `{HEIGHT}` to trigger platform activation. `{HEIGHT}` may be less than v20, but actual reward reallocation will happens only since v20 (credit pool in CbTx) is activated. No changes for devnets, testnet3, mainnet.\ ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK ef5cde5 PastaPastaPasta: utACK ef5cde5 Tree-SHA512: f11f61bb5685c67f916d3151a4d6b0a42492bc09b54d97a7150381351da50fafd8d624f5ebb1cab843c6f9fa48fcb6f21c3f8a922079524afdc481aeb45edee8
2 parents 16fcb7a + ef5cde5 commit dc6c35b

24 files changed

+89
-45
lines changed

src/chainparams.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ class CRegTestParams : public CChainParams {
822822
consensus.DIP0024Height = 1; // Always have dip0024 quorums unless overridden
823823
consensus.DIP0024QuorumsHeight = 1; // Always have dip0024 quorums unless overridden
824824
consensus.V19Height = 1; // Always active unless overriden
825-
consensus.V20Height = 900;
826-
consensus.MN_RRHeight = 900;
825+
consensus.V20Height = consensus.DIP0003Height; // Active not earlier than dip0003. Functional tests (DashTestFramework) uses height 100 (same as coinbase maturity)
826+
consensus.MN_RRHeight = consensus.V20Height; // MN_RR does not really have effect before v20 activation
827827
consensus.MinBIP9WarningHeight = 0;
828828
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1
829829
consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day
@@ -958,6 +958,7 @@ class CRegTestParams : public CChainParams {
958958
UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST_PLATFORM);
959959
UpdateLLMQInstantSendDIP0024FromArgs(args);
960960
assert(consensus.V20Height >= consensus.DIP0003Height);
961+
assert(consensus.MN_RRHeight >= consensus.V20Height);
961962
}
962963

963964
/**

src/evo/creditpool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex* pindexP
243243
assert(pindexPrev);
244244

245245
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_MN_RR)) {
246-
// We consider V20 active if mn_rr is active
246+
// If credit pool exists, it means v20 is activated
247247
platformReward = PlatformShare(GetMasternodePayment(pindexPrev->nHeight + 1, blockSubsidy, /*fV20Active=*/ true));
248248
}
249249
}

src/masternode/payments.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ CAmount PlatformShare(const CAmount reward)
4141
bool fV20Active = DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_V20);
4242
CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockSubsidy + feeReward, fV20Active);
4343

44-
if (DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_MN_RR)) {
44+
// Credit Pool doesn't exist before V20. If any part of reward will re-allocated to credit pool before v20
45+
// activation these fund will be just permanently lost. Applyable for devnets, regtest, testnet
46+
if (fV20Active && DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_MN_RR)) {
4547
CAmount masternodeSubsidyReward = GetMasternodePayment(nBlockHeight, blockSubsidy, fV20Active);
4648
const CAmount platformReward = PlatformShare(masternodeSubsidyReward);
4749
masternodeReward -= platformReward;

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("0x06ec12cb5419daf83e04455a24ff8f27fef76cfdbd3e8723ca4946fab91a2f11") },
403403
}
404404
};
405405

test/functional/feature_asset_locks.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def set_test_params(self):
5454
self.set_dash_test_params(2, 0, [[
5555
"-whitelist=127.0.0.1",
5656
"-llmqtestinstantsenddip0024=llmq_test_instantsend",
57-
"-testactivationheight=mn_rr@1400",
5857
]] * 2, evo_count=2)
58+
self.mn_rr_height = 620
5959

6060
def skip_test_if_missing_module(self):
6161
self.skip_if_no_wallet()
@@ -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)
@@ -524,10 +523,13 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
524523
total = self.get_credit_pool_balance()
525524
coins = node_wallet.listunspent()
526525
while total <= 10_901 * COIN:
526+
if len(coins) == 0:
527+
coins = node_wallet.listunspent(query_options={'minimumAmount': 1})
527528
coin = coins.pop()
528529
to_lock = int(coin['amount'] * COIN) - tiny_amount
529-
if to_lock > 99 * COIN:
530+
if to_lock > 99 * COIN and total > 10_000 * COIN:
530531
to_lock = 99 * COIN
532+
531533
total += to_lock
532534
tx = self.create_assetlock(coin, to_lock, pubkey)
533535
self.send_tx_simple(tx)
@@ -627,10 +629,9 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
627629

628630

629631
def test_mn_rr(self, node_wallet, node, pubkey):
630-
self.log.info(node_wallet.getblockcount())
631632
self.log.info("Activate mn_rr...")
632633
locked = self.get_credit_pool_balance()
633-
self.activate_mn_rr(expected_activation_height=1400)
634+
self.activate_mn_rr(expected_activation_height=620)
634635
self.log.info(f'mn-rr height: {node.getblockcount()} credit: {self.get_credit_pool_balance()}')
635636
assert_equal(locked, self.get_credit_pool_balance())
636637

@@ -642,7 +643,7 @@ def test_mn_rr(self, node_wallet, node, pubkey):
642643
all_mn_rewards = platform_reward + owner_reward + operator_reward
643644
assert_equal(all_mn_rewards, bt['coinbasevalue'] * 3 // 4) # 75/25 mn/miner reward split
644645
assert_equal(platform_reward, all_mn_rewards * 375 // 1000) # 0.375 platform share
645-
assert_equal(platform_reward, 57741807)
646+
assert_equal(platform_reward, 104549943)
646647
assert_equal(locked, self.get_credit_pool_balance())
647648
self.generate(node, 1)
648649
locked += platform_reward

test/functional/feature_assumevalid.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ class AssumeValidTest(BitcoinTestFramework):
6262
def set_test_params(self):
6363
self.setup_clean_chain = True
6464
self.num_nodes = 3
65-
self.extra_args = ["-dip3params=9000:9000", '-testactivationheight=v20@9000', "-checkblockindex=0"]
65+
self.extra_args = [
66+
"-dip3params=9000:9000",
67+
'-testactivationheight=v20@9000',
68+
'-testactivationheight=mn_rr@9000',
69+
"-checkblockindex=0",
70+
]
6671
self.rpc_timeout = 120
6772

6873
def setup_network(self):

test/functional/feature_block.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ def set_test_params(self):
9090
# which causes RPC to hang, so we need to increase RPC timeouts
9191
self.rpc_timeout = 180
9292
self.extra_args = [[
93-
'-dip3params=2000:2000', # Must set '-dip3params=2000:2000' to create pre-dip3 blocks only
9493
'-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
9594
'-testactivationheight=bip34@2',
95+
'-dip3params=2000:2000', # Must set '-dip3params=2000:2000' to create pre-dip3 blocks only
9696
'-testactivationheight=dip0001@2000',
9797
'-testactivationheight=v20@2000',
98+
'-testactivationheight=mn_rr@2000',
9899
]]
99100

100101
def setup_nodes(self):

test/functional/feature_cltv.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ def set_test_params(self):
8888
self.extra_args = [[
8989
f'-testactivationheight=cltv@{CLTV_HEIGHT}',
9090
91-
'-dip3params=9000:9000',
92-
'-testactivationheight=v20@9000', # disabled for this test
9391
'-par=1', # Use only one script thread to get the exact reject reason for testing
9492
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
93+
'-dip3params=9000:9000',
94+
'-testactivationheight=v20@9000', # disabled for this test
95+
'-testactivationheight=mn_rr@9000', # disabled for this test
9596
]]
9697
self.setup_clean_chain = True
9798
self.rpc_timeout = 480

test/functional/feature_csv_activation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ def set_test_params(self):
9999
self.extra_args = [[
100100
'-peertimeout=999999', # bump because mocktime might cause a disconnect otherwise
101101
102-
'-dip3params=2000:2000',
103-
'-testactivationheight=v20@2000',
104102
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
105103
'-par=1', # Use only one script thread to get the exact reject reason for testing
104+
'-dip3params=2000:2000',
105+
'-testactivationheight=v20@2000',
106+
'-testactivationheight=mn_rr@2000',
106107
]]
107108
self.supports_cli = False
108109

test/functional/feature_dersig.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ def set_test_params(self):
5050
self.num_nodes = 1
5151
self.extra_args = [[
5252
f'-testactivationheight=dersig@{DERSIG_HEIGHT}',
53-
'-testactivationheight=v20@9000', # due to changes in CbTx
5453
55-
'-dip3params=9000:9000',
5654
'-par=1', # Use only one script thread to get the exact log msg for testing
55+
'-dip3params=9000:9000',
56+
'-testactivationheight=v20@9000', # due to changes in CbTx
57+
'-testactivationheight=mn_rr@9000', # due to changes in CbTx
5758
]]
5859
self.setup_clean_chain = True
5960
self.rpc_timeout = 240

0 commit comments

Comments
 (0)