dash/test/functional/feature_llmq_is_retroactive.py

199 lines
9.9 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
# Copyright (c) 2015-2024 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
Backport 11796 + 11774 (#3612) * Merge #11796: [tests] Functional test naming convention 5fecd84 [tests] Remove redundant import in blocktools.py test (Anthony Towns) 9b20bb4 [tests] Check tests conform to naming convention (Anthony Towns) 7250b4e [tests] README.md nit fixes (Anthony Towns) 82b2712 [tests] move witness util functions to blocktools.py (John Newbery) 1e10854 [tests] [docs] update README for new test naming scheme (John Newbery) Pull request description: Splitting #11774 into two parts -- this part updates the README with the proposed naming convention, and adds some checks to test_runner.py that the number of tests violating the naming convention doesn't increase too much. Idea is this part of the change should not introduce merge conflicts or require much rebasing, so reviews of the complicated bits won't become invalidated too often; while the second part will just be file renames, which will require regular rebasing and will introduce merge conflicts with pending PRs, but can be merged later, and should also be much easier to review, since it will only include relatively trivial changes. Tree-SHA512: b96557d41714addbbfe2aed62fb5a48639eaeb1eb3aba30ac1b3a86bb3cb8d796c6247f9c414c4695c4bf54c0ec9968ac88e2f88fb62483bc1a2f89368f7fc80 * update violation count Signed-off-by: pasta <pasta@dashboost.org> * Merge #11774: [tests] Rename functional tests 6f881cc880 [tests] Remove EXPECTED_VIOLATION_COUNT (Anthony Towns) 3150b3fea7 [tests] Rename misc functional tests. (Anthony Towns) 81b79f2c39 [tests] Rename rpc_* functional tests. (Anthony Towns) 61b8f7f273 [tests] Rename p2p_* functional tests. (Anthony Towns) 90600bc7db [tests] Rename wallet_* functional tests. (Anthony Towns) ca6523d0c8 [tests] Rename feature_* functional tests. (Anthony Towns) Pull request description: This PR changes the functional tests to have a consistent naming scheme: tests for individual RPC methods are named rpc_... tests for interfaces (REST, ZMQ, RPC features) are named interface_... tests that explicitly test the p2p interface are named p2p_... tests for wallet features are named wallet_... tests for mining features are named mining_... tests for mempool behaviour are named mempool_... tests for full features that aren't wallet/mining/mempool are named feature_... Rationale: it's sometimes difficult for new contributors to know what's already covered by existing tests and where new tests should be added. Naming in a consistent fashion makes it easier to see what's already covered at a glance. Tree-SHA512: 4246790552d42bbd95f6d5bdf67702b81b3b2c583ce7eaf1fe6d8e254721279b47315973c6e9ae82dad6e4c747f12188160764bf2624c0f8f3b4d39330ec8b16 * rename tests and edit associated strings to align test-suite with test name standards Signed-off-by: pasta <pasta@dashboost.org> * fix grammar in test/functional/test_runner.py Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * ci: Fix excluded test names * rename feature_privatesend.py to rpc_privatesend.py Signed-off-by: pasta <pasta@dashboost.org> Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com> Co-authored-by: MarcoFalke <falke.marco@gmail.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: xdustinface <xdustinfacex@gmail.com>
2020-07-17 01:44:20 +02:00
feature_llmq_is_retroactive.py
Tests retroactive signing
We have 5 nodes where node 0 is the control node, nodes 1-4 are masternodes.
Mempool inconsistencies are simulated via disconnecting/reconnecting node 3
and by having a higher relay fee on node 4.
'''
Merge #13054: tests: Enable automatic detection of undefined names in Python tests scripts. Remove wildcard imports. 68400d8b96 tests: Use explicit imports (practicalswift) Pull request description: Enable automatic detection of undefined names in Python tests scripts. Remove wildcard imports. Wildcard imports make it unclear which names are present in the namespace, confusing both readers and many automated tools. An additional benefit of not using wildcard imports in tests scripts is that readers of a test script then can infer the rough testing scope just by looking at the imports. Before this commit: ``` $ contrib/devtools/lint-python.sh | head -10 ./test/functional/feature_rbf.py:8:1: F403 'from test_framework.util import *' used; unable to detect undefined names ./test/functional/feature_rbf.py:9:1: F403 'from test_framework.script import *' used; unable to detect undefined names ./test/functional/feature_rbf.py:10:1: F403 'from test_framework.mininode import *' used; unable to detect undefined names ./test/functional/feature_rbf.py:15:12: F405 bytes_to_hex_str may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:17:58: F405 CScript may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:25:13: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:26:31: F405 satoshi_round may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:26:60: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:30:41: F405 satoshi_round may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:30:68: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util $ ``` After this commit: ``` $ contrib/devtools/lint-python.sh | head -10 $ ``` Tree-SHA512: 3f826d39cffb6438388e5efcb20a9622ff8238247e882d68f7b38609877421b2a8e10e9229575f8eb6a8fa42dec4256986692e92922c86171f750a0e887438d9
2018-08-13 14:24:43 +02:00
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import set_node_times
Merge #13054: tests: Enable automatic detection of undefined names in Python tests scripts. Remove wildcard imports. 68400d8b96 tests: Use explicit imports (practicalswift) Pull request description: Enable automatic detection of undefined names in Python tests scripts. Remove wildcard imports. Wildcard imports make it unclear which names are present in the namespace, confusing both readers and many automated tools. An additional benefit of not using wildcard imports in tests scripts is that readers of a test script then can infer the rough testing scope just by looking at the imports. Before this commit: ``` $ contrib/devtools/lint-python.sh | head -10 ./test/functional/feature_rbf.py:8:1: F403 'from test_framework.util import *' used; unable to detect undefined names ./test/functional/feature_rbf.py:9:1: F403 'from test_framework.script import *' used; unable to detect undefined names ./test/functional/feature_rbf.py:10:1: F403 'from test_framework.mininode import *' used; unable to detect undefined names ./test/functional/feature_rbf.py:15:12: F405 bytes_to_hex_str may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:17:58: F405 CScript may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:25:13: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:26:31: F405 satoshi_round may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:26:60: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:30:41: F405 satoshi_round may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util ./test/functional/feature_rbf.py:30:68: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util $ ``` After this commit: ``` $ contrib/devtools/lint-python.sh | head -10 $ ``` Tree-SHA512: 3f826d39cffb6438388e5efcb20a9622ff8238247e882d68f7b38609877421b2a8e10e9229575f8eb6a8fa42dec4256986692e92922c86171f750a0e887438d9
2018-08-13 14:24:43 +02:00
class LLMQ_IS_RetroactiveSigning(DashTestFramework):
def set_test_params(self):
# -whitelist is needed to avoid the trickling logic on node0
self.set_dash_test_params(5, 4, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"]])
def run_test(self):
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
instantsend: Implement Spork 2 Mempool Signing signalling (#4024) * instantsend: refactor input locking into it's own method Signed-off-by: pasta <pasta@dashboost.org> * instantsend: introduce spork 24 `SPORK_24_INSTANTSEND_SIGNING_ENABLED` This spork tells masternodes to refuse to lock transactions in mempool. Only transactions included in a block should be retroactively signed. Signed-off-by: pasta <pasta@dashboost.org> add spork defenition Signed-off-by: pasta <pasta@dashboost.org> * instantsend: refactor `sed -i 's/allowReSigning/fRetroactive/g' src/llmq/*` Signed-off-by: pasta <pasta@dashboost.org> * instantsend: adjust comments Signed-off-by: pasta <pasta@dashboost.org> * instantsend/tests: implement Spork 24 support in tests, and test it's usage Signed-off-by: pasta <pasta@dashboost.org> * fix feature_llmq_is_retroactive.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * drop Spork 24 and use Spork 2 value 1 as being no mempool signing Signed-off-by: pasta <pasta@dashboost.org> * fix spork check Signed-off-by: pasta <pasta@dashboost.org> * Fix tests Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Change comment Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * IsInstantSendSigningEnabled -> IsInstantSendMempoolSigningEnabled Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-03-08 20:51:39 +01:00
# Turn mempool IS signing off
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 1)
self.wait_for_sporks_same()
self.activate_v19(expected_activation_height=900)
self.mine_cycle_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(), timeout=30)
instantsend: Implement Spork 2 Mempool Signing signalling (#4024) * instantsend: refactor input locking into it's own method Signed-off-by: pasta <pasta@dashboost.org> * instantsend: introduce spork 24 `SPORK_24_INSTANTSEND_SIGNING_ENABLED` This spork tells masternodes to refuse to lock transactions in mempool. Only transactions included in a block should be retroactively signed. Signed-off-by: pasta <pasta@dashboost.org> add spork defenition Signed-off-by: pasta <pasta@dashboost.org> * instantsend: refactor `sed -i 's/allowReSigning/fRetroactive/g' src/llmq/*` Signed-off-by: pasta <pasta@dashboost.org> * instantsend: adjust comments Signed-off-by: pasta <pasta@dashboost.org> * instantsend/tests: implement Spork 24 support in tests, and test it's usage Signed-off-by: pasta <pasta@dashboost.org> * fix feature_llmq_is_retroactive.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * drop Spork 24 and use Spork 2 value 1 as being no mempool signing Signed-off-by: pasta <pasta@dashboost.org> * fix spork check Signed-off-by: pasta <pasta@dashboost.org> * Fix tests Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Change comment Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * IsInstantSendSigningEnabled -> IsInstantSendMempoolSigningEnabled Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-03-08 20:51:39 +01:00
self.log.info("trying normal IS lock w/ signing spork off. Shouldn't be islocked before block is created.")
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], False, 5)
# Have to disable ChainLocks to avoid signing a block with a "safe" tx too early
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4000000000)
instantsend: Implement Spork 2 Mempool Signing signalling (#4024) * instantsend: refactor input locking into it's own method Signed-off-by: pasta <pasta@dashboost.org> * instantsend: introduce spork 24 `SPORK_24_INSTANTSEND_SIGNING_ENABLED` This spork tells masternodes to refuse to lock transactions in mempool. Only transactions included in a block should be retroactively signed. Signed-off-by: pasta <pasta@dashboost.org> add spork defenition Signed-off-by: pasta <pasta@dashboost.org> * instantsend: refactor `sed -i 's/allowReSigning/fRetroactive/g' src/llmq/*` Signed-off-by: pasta <pasta@dashboost.org> * instantsend: adjust comments Signed-off-by: pasta <pasta@dashboost.org> * instantsend/tests: implement Spork 24 support in tests, and test it's usage Signed-off-by: pasta <pasta@dashboost.org> * fix feature_llmq_is_retroactive.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * drop Spork 24 and use Spork 2 value 1 as being no mempool signing Signed-off-by: pasta <pasta@dashboost.org> * fix spork check Signed-off-by: pasta <pasta@dashboost.org> * Fix tests Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Change comment Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * IsInstantSendSigningEnabled -> IsInstantSendMempoolSigningEnabled Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-03-08 20:51:39 +01:00
self.wait_for_sporks_same()
# We have to wait in order to include tx in block
self.bump_mocktime(10 * 60 + 1)
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
instantsend: Implement Spork 2 Mempool Signing signalling (#4024) * instantsend: refactor input locking into it's own method Signed-off-by: pasta <pasta@dashboost.org> * instantsend: introduce spork 24 `SPORK_24_INSTANTSEND_SIGNING_ENABLED` This spork tells masternodes to refuse to lock transactions in mempool. Only transactions included in a block should be retroactively signed. Signed-off-by: pasta <pasta@dashboost.org> add spork defenition Signed-off-by: pasta <pasta@dashboost.org> * instantsend: refactor `sed -i 's/allowReSigning/fRetroactive/g' src/llmq/*` Signed-off-by: pasta <pasta@dashboost.org> * instantsend: adjust comments Signed-off-by: pasta <pasta@dashboost.org> * instantsend/tests: implement Spork 24 support in tests, and test it's usage Signed-off-by: pasta <pasta@dashboost.org> * fix feature_llmq_is_retroactive.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * drop Spork 24 and use Spork 2 value 1 as being no mempool signing Signed-off-by: pasta <pasta@dashboost.org> * fix spork check Signed-off-by: pasta <pasta@dashboost.org> * Fix tests Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Change comment Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * IsInstantSendSigningEnabled -> IsInstantSendMempoolSigningEnabled Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-03-08 20:51:39 +01:00
self.wait_for_instantlock(txid, self.nodes[0])
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 0)
instantsend: Implement Spork 2 Mempool Signing signalling (#4024) * instantsend: refactor input locking into it's own method Signed-off-by: pasta <pasta@dashboost.org> * instantsend: introduce spork 24 `SPORK_24_INSTANTSEND_SIGNING_ENABLED` This spork tells masternodes to refuse to lock transactions in mempool. Only transactions included in a block should be retroactively signed. Signed-off-by: pasta <pasta@dashboost.org> add spork defenition Signed-off-by: pasta <pasta@dashboost.org> * instantsend: refactor `sed -i 's/allowReSigning/fRetroactive/g' src/llmq/*` Signed-off-by: pasta <pasta@dashboost.org> * instantsend: adjust comments Signed-off-by: pasta <pasta@dashboost.org> * instantsend/tests: implement Spork 24 support in tests, and test it's usage Signed-off-by: pasta <pasta@dashboost.org> * fix feature_llmq_is_retroactive.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * drop Spork 24 and use Spork 2 value 1 as being no mempool signing Signed-off-by: pasta <pasta@dashboost.org> * fix spork check Signed-off-by: pasta <pasta@dashboost.org> * Fix tests Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Change comment Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * IsInstantSendSigningEnabled -> IsInstantSendMempoolSigningEnabled Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-03-08 20:51:39 +01:00
self.wait_for_sporks_same()
self.wait_for_chainlocked_block_all_nodes(block)
self.log.info("Enable mempool IS signing")
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 0)
instantsend: Implement Spork 2 Mempool Signing signalling (#4024) * instantsend: refactor input locking into it's own method Signed-off-by: pasta <pasta@dashboost.org> * instantsend: introduce spork 24 `SPORK_24_INSTANTSEND_SIGNING_ENABLED` This spork tells masternodes to refuse to lock transactions in mempool. Only transactions included in a block should be retroactively signed. Signed-off-by: pasta <pasta@dashboost.org> add spork defenition Signed-off-by: pasta <pasta@dashboost.org> * instantsend: refactor `sed -i 's/allowReSigning/fRetroactive/g' src/llmq/*` Signed-off-by: pasta <pasta@dashboost.org> * instantsend: adjust comments Signed-off-by: pasta <pasta@dashboost.org> * instantsend/tests: implement Spork 24 support in tests, and test it's usage Signed-off-by: pasta <pasta@dashboost.org> * fix feature_llmq_is_retroactive.py Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * drop Spork 24 and use Spork 2 value 1 as being no mempool signing Signed-off-by: pasta <pasta@dashboost.org> * fix spork check Signed-off-by: pasta <pasta@dashboost.org> * Fix tests Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * Change comment Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> * IsInstantSendSigningEnabled -> IsInstantSendMempoolSigningEnabled Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-03-08 20:51:39 +01:00
self.wait_for_sporks_same()
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])
self.bump_mocktime(1)
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
self.wait_for_chainlocked_block_all_nodes(block)
self.log.info("testing normal signing with partially known TX")
self.isolate_node(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])
self.reconnect_isolated_node(3, 0)
2020-03-21 12:21:25 +01:00
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
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)
# 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])
self.log.info("testing retroactive signing with unknown TX")
self.isolate_node(3)
rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})
rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex']
rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx)['hex']
txid = self.nodes[3].sendrawtransaction(rawtx)
# Make node 3 consider the TX as safe
self.bump_mocktime(10 * 60 + 1)
block = self.generatetoaddress(self.nodes[3], 1, self.nodes[0].getnewaddress(), sync_fun=self.no_op)[0]
self.reconnect_isolated_node(3, 0)
self.wait_for_chainlocked_block_all_nodes(block)
self.nodes[0].setmocktime(self.mocktime)
self.log.info("testing retroactive signing with partially known TX")
self.isolate_node(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])
self.reconnect_isolated_node(3, 0)
2020-03-21 12:21:25 +01:00
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
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)
# Make node0 consider the TX as safe
self.bump_mocktime(10 * 60 + 1)
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
2021-08-27 21:03:02 +02:00
assert txid in self.nodes[0].getblock(block, 1)['tx']
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)
def cycle_llmqs(self):
self.mine_quorum()
self.mine_quorum()
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash(), timeout=30)
def test_all_nodes_session_timeout(self, do_cycle_llmqs):
set_node_times(self.nodes, self.mocktime)
self.isolate_node(3)
rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})
rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex']
rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx)['hex']
txid = self.nodes[0].sendrawtransaction(rawtx)
txid = self.nodes[3].sendrawtransaction(rawtx)
# Make sure nodes 1 and 2 received the TX before we continue
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)
# Make the signing session for the IS lock timeout on nodes 1-3
self.bump_mocktime(61)
time.sleep(2) # make sure Cleanup() is called
self.reconnect_isolated_node(3, 0)
2020-03-21 12:21:25 +01:00
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
self.wait_for_mnauth(self.nodes[3], 2)
# node 3 fully reconnected but the signing session is already timed out on all nodes, so no IS lock
self.wait_for_instantlock(txid, self.nodes[0], False, 5)
if do_cycle_llmqs:
self.cycle_llmqs()
self.wait_for_instantlock(txid, self.nodes[0], False, 5)
# Make node 0 consider the TX as safe
self.bump_mocktime(10 * 60 + 1)
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
2021-08-27 21:03:02 +02:00
assert txid in self.nodes[0].getblock(block, 1)['tx']
self.wait_for_chainlocked_block_all_nodes(block)
def test_single_node_session_timeout(self, do_cycle_llmqs):
set_node_times(self.nodes, self.mocktime)
self.isolate_node(3)
rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})
rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex']
rawtx = self.nodes[0].signrawtransactionwithwallet(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
self.bump_mocktime(61)
time.sleep(2) # make sure Cleanup() is called
self.reconnect_isolated_node(3, 0)
2020-03-21 12:21:25 +01:00
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
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)
if do_cycle_llmqs:
self.cycle_llmqs()
self.wait_for_instantlock(txid, self.nodes[0], False, 5)
# Make node 0 consider the TX as safe
self.bump_mocktime(10 * 60 + 1)
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
2021-08-27 21:03:02 +02:00
assert txid in self.nodes[0].getblock(block, 1)['tx']
self.wait_for_chainlocked_block_all_nodes(block)
if __name__ == '__main__':
LLMQ_IS_RetroactiveSigning().main()