Skip to content
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

perf: reduced delays and syncs in functional tests to run faster #6278

Merged
merged 7 commits into from
Sep 25, 2024
16 changes: 8 additions & 8 deletions test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ def send_tx(self, tx, expected_error = None, reason = None):
except JSONRPCException as e:
assert expected_error in e.error['message']

def slowly_generate_batch(self, count):
self.log.info(f"Slowly generate {count} blocks")
def generate_batch(self, count):
self.log.info(f"Generate {count} blocks")
while count > 0:
self.log.info(f"Generating batch of blocks {count} left")
batch = min(10, count)
batch = min(50, count)
count -= batch
self.bump_mocktime(batch)
self.nodes[1].generate(batch)
Expand Down Expand Up @@ -426,7 +426,7 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
self.validate_credit_pool_balance(locked - 2 * COIN)

self.log.info("Generating many blocks to make quorum far behind (even still active)...")
self.slowly_generate_batch(too_late_height - node.getblockcount() - 1)
self.generate_batch(too_late_height - node.getblockcount() - 1)
self.check_mempool_result(tx=asset_unlock_tx_too_late, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}})
node.generate(1)
self.sync_all()
Expand All @@ -444,7 +444,7 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
for inode in self.nodes:
inode.invalidateblock(block_asset_unlock)
self.validate_credit_pool_balance(locked)
self.slowly_generate_batch(50)
self.generate_batch(50)
self.validate_credit_pool_balance(locked)
for inode in self.nodes:
inode.reconsiderblock(block_to_reconsider)
Expand Down Expand Up @@ -510,7 +510,7 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
assert spend_txid_in_block in block['tx']

self.log.info("Fast forward to the next day to reset all current unlock limits...")
self.slowly_generate_batch(blocks_in_one_day)
self.generate_batch(blocks_in_one_day)
self.mine_quorum_2_nodes(llmq_type_name='llmq_test_platform', llmq_type=106)

total = self.get_credit_pool_balance()
Expand Down Expand Up @@ -585,7 +585,7 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):
assert pending_txid in node.getrawmempool()

self.log.info("Fast forward to next day again...")
self.slowly_generate_batch(blocks_in_one_day - 1)
self.generate_batch(blocks_in_one_day - 1)
self.log.info("Checking mempool is empty now...")
self.mempool_size = 0
self.check_mempool_size()
Expand Down Expand Up @@ -618,7 +618,7 @@ def test_withdrawal_limits(self, node_wallet, node, pubkey):


self.log.info("generate many blocks to be sure that mempool is empty after expiring txes...")
self.slowly_generate_batch(60)
self.generate_batch(60)
self.log.info("Checking that credit pool is not changed...")
assert_equal(new_total, self.get_credit_pool_balance())
self.check_mempool_size()
Expand Down
15 changes: 8 additions & 7 deletions test/functional/feature_llmq_simplepose.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ def test_no_banning(self, expected_connections=None):
for mn in self.mninfo:
assert not self.check_punished(mn) and not self.check_banned(mn)

def mine_quorum_no_check(self, expected_good_nodes, mninfos_online):
def mine_quorum_less_checks(self, expected_good_nodes, mninfos_online):
# Unlike in mine_quorum we skip most of the checks and only care about
# nodes moving forward from phase to phase and the fact that the quorum is actually mined.
self.log.info("Mining a quorum with no checks")
# nodes moving forward from phase to phase correctly and the fact that the quorum is actually mined.
self.log.info("Mining a quorum with less checks")
nodes = [self.nodes[0]] + [mn.node for mn in mninfos_online]

# move forward to next DKG
skip_count = 24 - (self.nodes[0].getblockcount() % 24)
if skip_count != 0:
self.bump_mocktime(1, nodes=nodes)
self.bump_mocktime(skip_count, nodes=nodes)
self.nodes[0].generate(skip_count)
self.sync_blocks(nodes)

Expand All @@ -112,7 +112,7 @@ def mine_quorum_no_check(self, expected_good_nodes, mninfos_online):
self.move_blocks(nodes, 2)

self.log.info("Waiting for phase 2 (contribute)")
self.wait_for_quorum_phase(q, 2, expected_good_nodes, None, 0, mninfos_online)
self.wait_for_quorum_phase(q, 2, expected_good_nodes, "receivedContributions", expected_good_nodes, mninfos_online)
self.move_blocks(nodes, 2)

self.log.info("Waiting for phase 3 (complain)")
Expand All @@ -124,7 +124,7 @@ def mine_quorum_no_check(self, expected_good_nodes, mninfos_online):
self.move_blocks(nodes, 2)

self.log.info("Waiting for phase 5 (commit)")
self.wait_for_quorum_phase(q, 5, expected_good_nodes, None, 0, mninfos_online)
self.wait_for_quorum_phase(q, 5, expected_good_nodes, "receivedPrematureCommitments", expected_good_nodes, mninfos_online)
self.move_blocks(nodes, 2)

self.log.info("Waiting for phase 6 (mining)")
Expand All @@ -147,6 +147,7 @@ def mine_quorum_no_check(self, expected_good_nodes, mninfos_online):
quorum_info = self.nodes[0].quorum("info", 100, new_quorum)

# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks to make sure that the new quorum gets eligible for signing sessions
self.bump_mocktime(8)
self.nodes[0].generate(8)
self.sync_blocks(nodes)
self.log.info("New quorum: height=%d, quorumHash=%s, quorumIndex=%d, minedBlock=%s" % (quorum_info["height"], new_quorum, quorum_info["quorumIndex"], quorum_info["minedBlock"]))
Expand Down Expand Up @@ -174,7 +175,7 @@ def test_banning(self, invalidate_proc, expected_connections):
# 6th time is when it should be banned for sure.
for _ in range(6):
self.reset_probe_timeouts()
self.mine_quorum_no_check(expected_contributors - 1, mninfos_online)
self.mine_quorum_less_checks(expected_contributors - 1, mninfos_online)

assert self.check_banned(mn)

Expand Down
19 changes: 1 addition & 18 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ def activate_by_name(self, name, expected_activation_height=None):
self.wait_for_sporks_same()

# mine blocks in batches
batch_size = 10
batch_size = 50
if expected_activation_height is not None:
height = self.nodes[0].getblockcount()
assert height < expected_activation_height
Expand Down Expand Up @@ -1170,9 +1170,6 @@ def activate_by_name(self, name, expected_activation_height=None):
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", spork17_value)
self.wait_for_sporks_same()

def activate_dip0024(self, expected_activation_height=None):
self.activate_by_name('dip0024', expected_activation_height)

def activate_v19(self, expected_activation_height=None):
self.activate_by_name('v19', expected_activation_height)

Expand Down Expand Up @@ -1794,7 +1791,6 @@ def wait_func():
wait_until_helper(wait_func, timeout=timeout, sleep=sleep)

def move_blocks(self, nodes, num_blocks):
time.sleep(1)
self.bump_mocktime(1, nodes=nodes)
self.nodes[0].generate(num_blocks)
self.sync_blocks(nodes)
Expand Down Expand Up @@ -1913,19 +1909,11 @@ def mine_cycle_quorum(self, llmq_type_name="llmq_test_dip0024", llmq_type=103,
# move forward to next DKG
skip_count = 24 - (self.nodes[0].getblockcount() % 24)

# if skip_count != 0:
# self.bump_mocktime(1, nodes=nodes)
# self.nodes[0].generate(skip_count)
# time.sleep(4)
# self.sync_blocks(nodes)

self.move_blocks(nodes, skip_count)

q_0 = self.nodes[0].getbestblockhash()
self.log.info("Expected quorum_0 at:" + str(self.nodes[0].getblockcount()))
# time.sleep(4)
self.log.info("Expected quorum_0 hash:" + str(q_0))
# time.sleep(4)
self.log.info("quorumIndex 0: Waiting for phase 1 (init)")
self.wait_for_quorum_phase(q_0, 1, expected_members, None, 0, mninfos_online, llmq_type_name)
self.log.info("quorumIndex 0: Waiting for quorum connections (init)")
Expand All @@ -1937,9 +1925,7 @@ def mine_cycle_quorum(self, llmq_type_name="llmq_test_dip0024", llmq_type=103,

q_1 = self.nodes[0].getbestblockhash()
self.log.info("Expected quorum_1 at:" + str(self.nodes[0].getblockcount()))
# time.sleep(2)
self.log.info("Expected quorum_1 hash:" + str(q_1))
# time.sleep(2)
self.log.info("quorumIndex 1: Waiting for phase 1 (init)")
self.wait_for_quorum_phase(q_1, 1, expected_members, None, 0, mninfos_online, llmq_type_name)
self.log.info("quorumIndex 1: Waiting for quorum connections (init)")
Expand Down Expand Up @@ -1996,14 +1982,12 @@ def mine_cycle_quorum(self, llmq_type_name="llmq_test_dip0024", llmq_type=103,

self.log.info("quorumIndex 1: Waiting for phase 6 (finalization)")
self.wait_for_quorum_phase(q_1, 6, expected_members, None, 0, mninfos_online, llmq_type_name)
time.sleep(6)
self.log.info("Mining final commitments")
self.bump_mocktime(1, nodes=nodes)
self.nodes[0].getblocktemplate() # this calls CreateNewBlock
self.nodes[0].generate(1)
self.sync_blocks(nodes)

time.sleep(6)
self.log.info("Waiting for quorum(s) to appear in the list")
self.wait_for_quorums_list(q_0, q_1, nodes, llmq_type_name)

Expand Down Expand Up @@ -2038,7 +2022,6 @@ def move_to_next_cycle(self):
self.bump_mocktime(1, nodes=nodes)
self.nodes[0].generate(skip_count)
self.sync_blocks(nodes)
time.sleep(1)
self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount()))

def wait_for_recovered_sig(self, rec_sig_id, rec_sig_msg_hash, llmq_type=100, timeout=10):
Expand Down
8 changes: 4 additions & 4 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
'feature_dip4_coinbasemerkleroots.py', # NOTE: needs dash_hash to pass
'feature_asset_locks.py', # NOTE: needs dash_hash to pass
'feature_mnehf.py', # NOTE: needs dash_hash to pass
'feature_governance.py --legacy-wallet',
'feature_governance.py --descriptors',
'feature_governance_cl.py --legacy-wallet',
'feature_governance_cl.py --descriptors',
# vv Tests less than 60s vv
'p2p_sendheaders.py', # NOTE: needs dash_hash to pass
'p2p_sendheaders_compressed.py', # NOTE: needs dash_hash to pass
Expand Down Expand Up @@ -293,10 +297,6 @@
'feature_cltv.py',
'feature_new_quorum_type_activation.py',
'feature_governance_objects.py',
'feature_governance.py --legacy-wallet',
'feature_governance.py --descriptors',
'feature_governance_cl.py --legacy-wallet',
'feature_governance_cl.py --descriptors',
'p2p_governance_invs.py',
'rpc_uptime.py',
'feature_discover.py',
Expand Down
Loading