Skip to content

feat: fire up πŸƒ test chains by first block (v20, mn_rr) - 9/9 #6667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
5 changes: 3 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ class CRegTestParams : public CChainParams {
consensus.DIP0024Height = 1; // Always have dip0024 quorums unless overridden
consensus.DIP0024QuorumsHeight = 1; // Always have dip0024 quorums unless overridden
consensus.V19Height = 1; // Always active unless overriden
consensus.V20Height = 900;
consensus.MN_RRHeight = 900;
consensus.V20Height = consensus.DIP0003Height; // Active not earlier than dip0003. Functional tests (DashTestFramework) uses height 100 (same as coinbase maturity)
consensus.MN_RRHeight = consensus.V20Height; // MN_RR does not really have effect before v20 activation
consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1
consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day
Expand Down Expand Up @@ -922,6 +922,7 @@ class CRegTestParams : public CChainParams {
UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST_PLATFORM);
UpdateLLMQInstantSendDIP0024FromArgs(args);
assert(consensus.V20Height >= consensus.DIP0003Height);
assert(consensus.MN_RRHeight >= consensus.V20Height);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/evo/creditpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex* pindexP
assert(pindexPrev);

if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_MN_RR)) {
// We consider V20 active if mn_rr is active
// If credit pool exists, it means v20 is activated
platformReward = PlatformShare(GetMasternodePayment(pindexPrev->nHeight + 1, blockSubsidy, /*fV20Active=*/ true));
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/masternode/payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ CAmount PlatformShare(const CAmount reward)
bool fV20Active = DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_V20);
CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockSubsidy + feeReward, fV20Active);

if (DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_MN_RR)) {
// Credit Pool doesn't exist before V20. If any part of reward will re-allocated to credit pool before v20
// activation these fund will be just permanently lost. Applyable for devnets, regtest, testnet
if (fV20Active && DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_MN_RR)) {
CAmount masternodeSubsidyReward = GetMasternodePayment(nBlockHeight, blockSubsidy, fV20Active);
const CAmount platformReward = PlatformShare(masternodeSubsidyReward);
masternodeReward -= platformReward;
Expand Down
2 changes: 1 addition & 1 deletion src/test/util/setup_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ TestChainSetup::TestChainSetup(int num_blocks, const std::vector<const char*>& e
/*TestChainBRRBeforeActivationSetup=*/
{ 497, uint256S("0x0857a9b5db51835b1c828f019f4c664b5fe6c28ac44a6d868436930f832d31e5") },
/*TestChainV19BeforeActivationSetup=*/
{ 494, uint256S("0x44ee5c8a5e5cbd4437d63c54ddc1d40329be811b25c492fa901e11cdf408f905") },
{ 494, uint256S("0x06ec12cb5419daf83e04455a24ff8f27fef76cfdbd3e8723ca4946fab91a2f11") },
}
};

Expand Down
15 changes: 8 additions & 7 deletions test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def set_test_params(self):
self.set_dash_test_params(2, 0, [[
"-whitelist=127.0.0.1",
"-llmqtestinstantsenddip0024=llmq_test_instantsend",
"-testactivationheight=mn_rr@1400",
]] * 2, evo_count=2)
self.mn_rr_height = 620

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand Down Expand Up @@ -248,8 +248,7 @@ def run_test(self):

self.set_sporks()

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

for _ in range(2):
self.dynamically_add_masternode(evo=True)
Expand Down Expand Up @@ -515,10 +514,13 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
total = self.get_credit_pool_balance()
coins = node_wallet.listunspent()
while total <= 10_901 * COIN:
if len(coins) == 0:
coins = node_wallet.listunspent(query_options={'minimumAmount': 1})
coin = coins.pop()
to_lock = int(coin['amount'] * COIN) - tiny_amount
if to_lock > 99 * COIN:
if to_lock > 99 * COIN and total > 10_000 * COIN:
to_lock = 99 * COIN

total += to_lock
tx = self.create_assetlock(coin, to_lock, pubkey)
self.send_tx_simple(tx)
Expand Down Expand Up @@ -618,10 +620,9 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):


def test_mn_rr(self, node_wallet, node, pubkey):
self.log.info(node_wallet.getblockcount())
self.log.info("Activate mn_rr...")
locked = self.get_credit_pool_balance()
self.activate_mn_rr(expected_activation_height=1400)
self.activate_mn_rr(expected_activation_height=620)
self.log.info(f'mn-rr height: {node.getblockcount()} credit: {self.get_credit_pool_balance()}')
assert_equal(locked, self.get_credit_pool_balance())

Expand All @@ -633,7 +634,7 @@ def test_mn_rr(self, node_wallet, node, pubkey):
all_mn_rewards = platform_reward + owner_reward + operator_reward
assert_equal(all_mn_rewards, bt['coinbasevalue'] * 3 // 4) # 75/25 mn/miner reward split
assert_equal(platform_reward, all_mn_rewards * 375 // 1000) # 0.375 platform share
assert_equal(platform_reward, 57741807)
assert_equal(platform_reward, 104549943)
assert_equal(locked, self.get_credit_pool_balance())
self.generate(node, 1)
locked += platform_reward
Expand Down
7 changes: 6 additions & 1 deletion test/functional/feature_assumevalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ class AssumeValidTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
self.extra_args = ["-dip3params=9000:9000", '-testactivationheight=v20@9000', "-checkblockindex=0"]
self.extra_args = [
"-dip3params=9000:9000",
'-testactivationheight=v20@9000',
'-testactivationheight=mn_rr@9000',
"-checkblockindex=0",
]
self.rpc_timeout = 120

def setup_network(self):
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ def set_test_params(self):
# which causes RPC to hang, so we need to increase RPC timeouts
self.rpc_timeout = 180
self.extra_args = [[
'-dip3params=2000:2000', # Must set '-dip3params=2000:2000' to create pre-dip3 blocks only
'-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
'-testactivationheight=bip34@2',
'-dip3params=2000:2000', # Must set '-dip3params=2000:2000' to create pre-dip3 blocks only
'-testactivationheight=dip0001@2000',
'-testactivationheight=v20@2000',
'-testactivationheight=mn_rr@2000',
]]

def setup_nodes(self):
Expand Down
5 changes: 3 additions & 2 deletions test/functional/feature_cltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ def set_test_params(self):
self.extra_args = [[
f'-testactivationheight=cltv@{CLTV_HEIGHT}',
'[email protected]',
'-dip3params=9000:9000',
'-testactivationheight=v20@9000', # disabled for this test
'-par=1', # Use only one script thread to get the exact reject reason for testing
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
'-dip3params=9000:9000',
'-testactivationheight=v20@9000', # disabled for this test
'-testactivationheight=mn_rr@9000', # disabled for this test
]]
self.setup_clean_chain = True
self.rpc_timeout = 480
Expand Down
5 changes: 3 additions & 2 deletions test/functional/feature_csv_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ def set_test_params(self):
self.extra_args = [[
'-peertimeout=999999', # bump because mocktime might cause a disconnect otherwise
'[email protected]',
'-dip3params=2000:2000',
'-testactivationheight=v20@2000',
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
'-par=1', # Use only one script thread to get the exact reject reason for testing
'-dip3params=2000:2000',
'-testactivationheight=v20@2000',
'-testactivationheight=mn_rr@2000',
]]
self.supports_cli = False

Expand Down
5 changes: 3 additions & 2 deletions test/functional/feature_dersig.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def set_test_params(self):
self.num_nodes = 1
self.extra_args = [[
f'-testactivationheight=dersig@{DERSIG_HEIGHT}',
'-testactivationheight=v20@9000', # due to changes in CbTx
'[email protected]',
'-dip3params=9000:9000',
'-par=1', # Use only one script thread to get the exact log msg for testing
'-dip3params=9000:9000',
'-testactivationheight=v20@9000', # due to changes in CbTx
'-testactivationheight=mn_rr@9000', # due to changes in CbTx
]]
self.setup_clean_chain = True
self.rpc_timeout = 240
Expand Down
2 changes: 2 additions & 0 deletions test/functional/feature_dip4_coinbasemerkleroots.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

DIP0008_HEIGHT = 432
DIP0024_HEIGHT = 900
V20_HEIGHT = 900

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

def remove_masternode(self, idx):
mn = self.mninfo[idx]
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DashGovernanceTest (DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(6, 5, [[
"-budgetparams=10:10:10",
'-testactivationheight=v20@160',
]] * 6)
self.delay_v20_and_mn_rr(height=160)

def check_superblockbudget(self, v20_active):
v20_state = self.nodes[0].getblockchaininfo()["softforks"]["v20"]
Expand Down
9 changes: 6 additions & 3 deletions test/functional/feature_index_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
)
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE

# TODO: remove testactivationheight=v20@3000 when it will be activated from block 1
DEPLOYMENT_ARGS = ["-testactivationheight=v20@3000", "-dip3params=3000:3000"]
DEPLOYMENT_ARGS = [
"-dip3params=3000:3000",
"-testactivationheight=v20@3000",
"-testactivationheight=mn_rr@3000",
]

class FeatureIndexPruneTest(BitcoinTestFramework):
def set_test_params(self):
Expand Down Expand Up @@ -145,7 +148,7 @@ def run_test(self):
for node in self.nodes[:2]:
with node.assert_debug_log(['limited pruning to height 2489']):
pruneheight_new = node.pruneblockchain(2500)
assert_equal(pruneheight_new, 2125)
assert_equal(pruneheight_new, 2196)

self.log.info("ensure that prune locks don't prevent indices from failing in a reorg scenario")
with self.nodes[0].assert_debug_log(['basic block filter index prune lock moved back to 2480']):
Expand Down
5 changes: 3 additions & 2 deletions test/functional/feature_llmq_chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class LLMQChainLocksTest(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(5, 4)
self.delay_v20_and_mn_rr(height=200)

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

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

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

# v20 is active for the next block, not for the tip
self.test_coinbase_best_cl(self.nodes[0], expected_cl_in_cb=False)
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_llmq_evo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def getmnlistdiff(self, baseBlockHash, blockHash):

class LLMQEvoNodesTest(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(5, 4, [["-testactivationheight=mn_rr@400"]] * 5, evo_count=5)
self.set_dash_test_params(5, 4, evo_count=5)
self.set_dash_llmq_test_params(4, 4)
self.mn_rr_height = 400

def run_test(self):
# Connect all nodes to node1 so that we always have the whole network connected
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_llmq_is_cl_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ def on_getdata(self, message):

class LLMQ_IS_CL_Conflicts(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(5, 4, [["-testactivationheight=mn_rr@2000"]] * 5)
self.set_dash_test_params(5, 4)
self.set_dash_llmq_test_params(4, 4)
self.delay_v20_and_mn_rr(2000)
self.supports_cli = False

def run_test(self):
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_llmq_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class LLMQQuorumRotationTest(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(9, 8)
self.set_dash_llmq_test_params(4, 4)
self.delay_v20_and_mn_rr(height=900)

def run_test(self):
llmq_type=103
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_llmq_simplepose.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def set_test_params(self):
self.extra_args = [[ '-testactivationheight=dip0024@9999' ]] * 6
self.set_dash_test_params(6, 5)
self.set_dash_llmq_test_params(5, 3)
self.delay_v20_and_mn_rr(height=9999)

def add_options(self, parser):
parser.add_argument("--disable-spork23", dest="disable_spork23", default=False, action="store_true",
Expand Down
3 changes: 0 additions & 3 deletions test/functional/feature_mnehf.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ def run_test(self):
node = self.nodes[0]

self.set_sporks()
self.log.info("Consensus rules assume there're no EHF signal before V20")
self.activate_v20()

self.log.info("Mine a quorum...")
self.mine_quorum()
self.check_fork('defined')
Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"-testactivationheight=dip0001@2000",
"-testactivationheight=dip0008@2000",
"-testactivationheight=v20@2000",
"-testactivationheight=mn_rr@2000",
]

def mine_large_blocks(node, n):
Expand Down
6 changes: 5 additions & 1 deletion test/functional/p2p_ibd_stalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def on_getheaders(self, message):
class P2PIBDStallingTest(BitcoinTestFramework):
def set_test_params(self):
self.disable_mocktime = True
self.extra_args = [["-dip3params=2000:2000", "-testactivationheight=v20@2000"]]
self.extra_args = [[
"-dip3params=2000:2000",
"-testactivationheight=v20@2000",
"-testactivationheight=mn_rr@2000",
]]
self.setup_clean_chain = True
self.num_nodes = 1

Expand Down
8 changes: 4 additions & 4 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ def _test_getblockchaininfo(self):
'-testactivationheight=dip0024@13',
'-testactivationheight=brr@14',
'-testactivationheight=v19@15',
'-testactivationheight=v20@901',
'-testactivationheight=mn_rr@902',
'-testactivationheight=v20@412', # no earlier than DIP0003
'-testactivationheight=mn_rr@413',
])

res = self.nodes[0].getblockchaininfo()
Expand All @@ -212,8 +212,8 @@ def _test_getblockchaininfo(self):
'dip0024': { 'type': 'buried', 'active': True, 'height': 13},
'realloc': { 'type': 'buried', 'active': True, 'height': 14},
'v19': { 'type': 'buried', 'active': True, 'height': 15},
'v20': { 'type': 'buried', 'active': False, 'height': 901},
'mn_rr': { 'type': 'buried', 'active': False, 'height': 902},
'v20': { 'type': 'buried', 'active': False, 'height': 412},
'mn_rr': { 'type': 'buried', 'active': False, 'height': 413},
'withdrawals': {
'type': 'bip9',
'bip9': {
Expand Down
22 changes: 14 additions & 8 deletions test/functional/rpc_masternode.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,23 @@ def run_test(self):
assert_equal(len(payments), 1)
payments_block = payments[0]
payments_block_payees = payments_block["masternodes"][0]["payees"]

payments_payee = ""
for i in range(0, len(payments_block_payees)):
if i == 0:
assert_equal(payments_block_payees[i]['script'], '6a')
continue

payments_payee += payments_block_payees[i]["address"]
if i < len(payments_block_payees) - 1:
payments_payee += ", "
assert_equal(payments_block["height"], height)
assert_equal(payments_block["blockhash"], blockhash)
assert_equal(winners_payee, payments_payee)
if len(payments_block_payees) == 1:
num_payees = len(payments_block_payees) - 1
if num_payees == 1:
checked_0_operator_reward = True
if len(payments_block_payees) > 1:
if num_payees > 1:
checked_non_0_operator_reward = True

self.log.info("test various `payments` RPC options")
Expand Down Expand Up @@ -73,15 +79,15 @@ def run_test(self):
while not checked_0_operator_reward or not checked_non_0_operator_reward:
payments_masternode = self.nodes[0].masternode("payments")[0]["masternodes"][0]
protx_info = self.nodes[0].protx("info", payments_masternode["proTxHash"])
if len(payments_masternode["payees"]) == 1:
assert_equal(protx_info["state"]["payoutAddress"], payments_masternode["payees"][0]["address"])
if len(payments_masternode["payees"]) == 2:
assert_equal(protx_info["state"]["payoutAddress"], payments_masternode["payees"][1]["address"])
checked_0_operator_reward = True
else:
assert_equal(len(payments_masternode["payees"]), 2)
option1 = protx_info["state"]["payoutAddress"] == payments_masternode["payees"][0]["address"] and \
assert_equal(len(payments_masternode["payees"]), 3)
option1 = protx_info["state"]["payoutAddress"] == payments_masternode["payees"][1]["address"] and \
protx_info["state"]["operatorPayoutAddress"] == payments_masternode["payees"][2]["address"]
option2 = protx_info["state"]["payoutAddress"] == payments_masternode["payees"][2]["address"] and \
protx_info["state"]["operatorPayoutAddress"] == payments_masternode["payees"][1]["address"]
option2 = protx_info["state"]["payoutAddress"] == payments_masternode["payees"][1]["address"] and \
protx_info["state"]["operatorPayoutAddress"] == payments_masternode["payees"][0]["address"]
assert option1 or option2
checked_non_0_operator_reward = True
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
Expand Down
Loading
Loading