def test_single_node_session_timeout(self, do_cycle_llmqs): set_node_times(self.nodes, get_mocktime()) isolate_node(self.nodes[3]) rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1}) rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex'] rawtx = self.nodes[0].signrawtransaction(rawtx)['hex'] txid = self.nodes[3].sendrawtransaction(rawtx) time.sleep(2) # make sure signing is done on node 2 (it's async) # Make the signing session for the IS lock timeout on node 3 set_mocktime(get_mocktime() + 61) set_node_times(self.nodes, get_mocktime()) time.sleep(2) # make sure Cleanup() is called reconnect_isolated_node(self.nodes[3], 0) self.wait_for_mnauth(self.nodes[3], 2) self.nodes[0].sendrawtransaction(rawtx) # Make sure nodes 1 and 2 received the TX self.wait_for_tx(txid, self.nodes[1]) self.wait_for_tx(txid, self.nodes[2]) # Make sure signing is done on nodes 1 and 2 (it's async) time.sleep(5) # node 3 fully reconnected but the signing session is already timed out on it, so no IS lock self.wait_for_instantlock(txid, self.nodes[0], False, 1, do_assert=True) if do_cycle_llmqs: self.cycle_llmqs() self.wait_for_instantlock(txid, self.nodes[0], False, 5, do_assert=True) # Make node 0 consider the TX as safe set_mocktime(get_mocktime() + 10 * 60 + 1) self.nodes[0].setmocktime(get_mocktime()) block = self.nodes[0].generate(1)[0] self.wait_for_chainlocked_block_all_nodes(block)
def run_test(self): while self.nodes[0].getblockchaininfo( )["bip9_softforks"]["dip0008"]["status"] != "active": self.nodes[0].generate(10) sync_blocks(self.nodes, timeout=60 * 5) self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0) self.nodes[0].spork("SPORK_19_CHAINLOCKS_ENABLED", 0) self.nodes[0].spork("SPORK_2_INSTANTSEND_ENABLED", 0) self.nodes[0].spork("SPORK_3_INSTANTSEND_BLOCK_FILTERING", 0) self.nodes[0].spork("SPORK_20_INSTANTSEND_LLMQ_BASED", 0) self.wait_for_sporks_same() self.mine_quorum() self.mine_quorum() # Make sure that all nodes are chainlocked at the same height before starting actual tests self.wait_for_chainlocked_block_all_nodes( self.nodes[0].getbestblockhash()) self.log.info("trying normal IS lock") txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) # 3 nodes should be enough to create an IS lock even if nodes 4 and 5 (which have no tx itself) # are the only "neighbours" in intra-quorum connections for one of them. self.wait_for_instantlock(txid, self.nodes[0], do_assert=True) set_mocktime(get_mocktime() + 1) set_node_times(self.nodes, get_mocktime()) block = self.nodes[0].generate(1)[0] self.wait_for_chainlocked_block_all_nodes(block) self.log.info("testing normal signing with partially known TX") isolate_node(self.nodes[3]) txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) # Make sure nodes 1 and 2 received the TX before we continue, # otherwise it might announce the TX to node 3 when reconnecting self.wait_for_tx(txid, self.nodes[1]) self.wait_for_tx(txid, self.nodes[2]) reconnect_isolated_node(self.nodes[3], 0) self.wait_for_mnauth(self.nodes[3], 2) # node 3 fully reconnected but the TX wasn't relayed to it, so there should be no IS lock self.wait_for_instantlock(txid, self.nodes[0], False, 5, do_assert=True) # push the tx directly via rpc self.nodes[3].sendrawtransaction(self.nodes[0].getrawtransaction(txid)) # node 3 should vote on a tx now since it became aware of it via sendrawtransaction # and this should be enough to complete an IS lock self.wait_for_instantlock(txid, self.nodes[0], do_assert=True) self.log.info("testing retroactive signing with unknown TX") isolate_node(self.nodes[3]) rawtx = self.nodes[0].createrawtransaction( [], {self.nodes[0].getnewaddress(): 1}) rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex'] rawtx = self.nodes[0].signrawtransaction(rawtx)['hex'] txid = self.nodes[3].sendrawtransaction(rawtx) # Make node 3 consider the TX as safe set_mocktime(get_mocktime() + 10 * 60 + 1) set_node_times(self.nodes, get_mocktime()) block = self.nodes[3].generatetoaddress( 1, self.nodes[0].getnewaddress())[0] reconnect_isolated_node(self.nodes[3], 0) self.wait_for_chainlocked_block_all_nodes(block) self.nodes[0].setmocktime(get_mocktime()) self.log.info("testing retroactive signing with partially known TX") isolate_node(self.nodes[3]) txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) # Make sure nodes 1 and 2 received the TX before we continue, # otherwise it might announce the TX to node 3 when reconnecting self.wait_for_tx(txid, self.nodes[1]) self.wait_for_tx(txid, self.nodes[2]) reconnect_isolated_node(self.nodes[3], 0) self.wait_for_mnauth(self.nodes[3], 2) # node 3 fully reconnected but the TX wasn't relayed to it, so there should be no IS lock self.wait_for_instantlock(txid, self.nodes[0], False, 5, do_assert=True) # Make node0 consider the TX as safe set_mocktime(get_mocktime() + 10 * 60 + 1) set_node_times(self.nodes, get_mocktime()) block = self.nodes[0].generate(1)[0] self.wait_for_chainlocked_block_all_nodes(block) self.log.info( "testing retroactive signing with partially known TX and all nodes session timeout" ) self.test_all_nodes_session_timeout(False) self.log.info("repeating test, but with cycled LLMQs") self.test_all_nodes_session_timeout(True) self.log.info( "testing retroactive signing with partially known TX and single node session timeout" ) self.test_single_node_session_timeout(False) self.log.info("repeating test, but with cycled LLMQs") self.test_single_node_session_timeout(True)