From d5b2c260a468e259d662f0cc3bdd30153df0ef79 Mon Sep 17 00:00:00 2001 From: Odysseas Gabrielides Date: Fri, 10 Nov 2023 16:32:01 +0200 Subject: [PATCH] test: ensure that mining is possible without CL info (#5689) ## Issue being fixed or feature implemented With DIP29 added to v20, miners include best CL Signature in CbTx. The purpose of this test, is to ensure that mining is still possible when CL information isn't available. In such case, miners are expected to copy best CL Signature from CbTx of previous block. ## What was done? Two scenarios are implemented: - Add dynamically a node, make sure `getbestchainlock()` fails, let it mine a block. - Disable `SPORK_19_CHAINLOCKS_ENABLED`, add dynamically a node, make sure `getbestchainlock()` fails, let it mine a block. In both tests, we make sure the block is accepted by everyone and that the `bestCLSignature` in CbTx is copied from previous block. ## How Has This Been Tested? `feature_llmq_chainlocks.py` ## Breaking Changes no ## Checklist: - [x] I have performed a self-review of my own code - [ ] 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 _(for repository code-owners and collaborators only)_ --------- Co-authored-by: UdjinM6 --- test/functional/feature_llmq_chainlocks.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index efce799a70..93959bc154 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -13,7 +13,7 @@ Checks LLMQs based ChainLocks import time from test_framework.test_framework import DashTestFramework -from test_framework.util import force_finish_mnsync, assert_equal +from test_framework.util import force_finish_mnsync, assert_equal, assert_raises_rpc_error class LLMQChainLocksTest(DashTestFramework): @@ -187,6 +187,24 @@ class LLMQChainLocksTest(DashTestFramework): self.reconnect_isolated_node(0, 1) self.wait_for_chainlocked_block(self.nodes[0], self.nodes[0].getbestblockhash(), timeout=30) + for i in range(2): + self.log.info(f"{'Disable' if i == 0 else 'Enable'} Chainlock") + self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800 if i == 0 else 0) + self.wait_for_sporks_same() + + self.log.info("Add a new node and let it sync") + self.dynamically_add_masternode(evo=False) + added_idx = len(self.nodes) - 1 + assert_raises_rpc_error(-32603, "Unable to find any chainlock", self.nodes[added_idx].getbestchainlock) + + self.log.info("Test that new node can mine without Chainlock info") + tip_0 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2) + self.nodes[added_idx].generate(1) + self.sync_blocks(self.nodes) + tip_1 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2) + assert_equal(tip_1['cbTx']['bestCLSignature'], tip_0['cbTx']['bestCLSignature']) + assert_equal(tip_1['cbTx']['bestCLHeightDiff'], tip_0['cbTx']['bestCLHeightDiff'] + 1) + def create_chained_txs(self, node, amount): txid = node.sendtoaddress(node.getnewaddress(), amount) tx = node.getrawtransaction(txid, 1)