2023-02-14 19:48:33 +01:00
|
|
|
#!/usr/bin/env python3
|
2023-12-31 01:00:00 +01:00
|
|
|
# Copyright (c) 2015-2024 The Dash Core developers
|
2023-02-14 19:48:33 +01:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
'''
|
2023-08-17 21:01:12 +02:00
|
|
|
feature_llmq_evo.py
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
Checks EvoNodes
|
2023-02-14 19:48:33 +01:00
|
|
|
|
|
|
|
'''
|
|
|
|
from _decimal import Decimal
|
2023-02-19 18:33:18 +01:00
|
|
|
from io import BytesIO
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2024-01-15 20:35:29 +01:00
|
|
|
from test_framework.p2p import P2PInterface
|
2021-06-24 12:47:04 +02:00
|
|
|
from test_framework.messages import CBlock, CBlockHeader, CCbTx, CMerkleBlock, from_hex, hash256, msg_getmnlistd, \
|
2023-02-19 18:33:18 +01:00
|
|
|
QuorumId, ser_uint256
|
2023-02-14 19:48:33 +01:00
|
|
|
from test_framework.test_framework import DashTestFramework
|
|
|
|
from test_framework.util import (
|
2024-08-22 15:19:46 +02:00
|
|
|
assert_equal, assert_greater_than_or_equal, p2p_port
|
2023-02-14 19:48:33 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def extract_quorum_members(quorum_info):
|
|
|
|
return [d['proTxHash'] for d in quorum_info["members"]]
|
|
|
|
|
2023-02-19 18:33:18 +01:00
|
|
|
class TestP2PConn(P2PInterface):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
self.last_mnlistdiff = None
|
|
|
|
|
|
|
|
def on_mnlistdiff(self, message):
|
|
|
|
self.last_mnlistdiff = message
|
|
|
|
|
|
|
|
def wait_for_mnlistdiff(self, timeout=30):
|
|
|
|
def received_mnlistdiff():
|
|
|
|
return self.last_mnlistdiff is not None
|
2020-08-27 08:21:53 +02:00
|
|
|
return self.wait_until(received_mnlistdiff, timeout=timeout)
|
2023-02-19 18:33:18 +01:00
|
|
|
|
|
|
|
def getmnlistdiff(self, baseBlockHash, blockHash):
|
|
|
|
msg = msg_getmnlistd(baseBlockHash, blockHash)
|
|
|
|
self.last_mnlistdiff = None
|
|
|
|
self.send_message(msg)
|
|
|
|
self.wait_for_mnlistdiff()
|
|
|
|
return self.last_mnlistdiff
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
class LLMQEvoNodesTest(DashTestFramework):
|
2023-02-14 19:48:33 +01:00
|
|
|
def set_test_params(self):
|
2024-08-22 15:19:46 +02:00
|
|
|
self.set_dash_test_params(5, 4, fast_dip3_enforcement=True, evo_count=5)
|
2023-02-14 19:48:33 +01:00
|
|
|
self.set_dash_llmq_test_params(4, 4)
|
|
|
|
|
|
|
|
def run_test(self):
|
|
|
|
# Connect all nodes to node1 so that we always have the whole network connected
|
|
|
|
# Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks
|
|
|
|
# Usually node0 is the one that does this, but in this test we isolate it multiple times
|
|
|
|
|
2023-02-19 18:33:18 +01:00
|
|
|
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn())
|
|
|
|
null_hash = format(0, "064x")
|
|
|
|
|
2023-02-14 19:48:33 +01:00
|
|
|
for i in range(len(self.nodes)):
|
|
|
|
if i != 0:
|
|
|
|
self.connect_nodes(i, 0)
|
|
|
|
|
|
|
|
self.activate_dip8()
|
|
|
|
|
|
|
|
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
2023-11-20 17:17:04 +01:00
|
|
|
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 1)
|
2023-02-14 19:48:33 +01:00
|
|
|
self.wait_for_sporks_same()
|
|
|
|
|
2023-02-19 18:33:18 +01:00
|
|
|
expectedUpdated = [mn.proTxHash for mn in self.mninfo]
|
|
|
|
b_0 = self.nodes[0].getbestblockhash()
|
|
|
|
self.test_getmnlistdiff(null_hash, b_0, {}, [], expectedUpdated)
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.log.info("Test that EvoNodes registration is rejected before v19")
|
|
|
|
self.test_evo_is_rejected_before_v19()
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.test_masternode_count(expected_mns_count=4, expected_evo_count=0)
|
2023-02-17 19:29:46 +01:00
|
|
|
|
2023-02-14 19:48:33 +01:00
|
|
|
self.activate_v19(expected_activation_height=900)
|
|
|
|
self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount()))
|
|
|
|
|
2023-11-20 17:17:04 +01:00
|
|
|
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 0)
|
|
|
|
self.wait_for_sporks_same()
|
|
|
|
|
2023-02-14 19:48:33 +01:00
|
|
|
self.move_to_next_cycle()
|
|
|
|
self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount()))
|
|
|
|
self.move_to_next_cycle()
|
|
|
|
self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount()))
|
|
|
|
self.move_to_next_cycle()
|
|
|
|
self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount()))
|
|
|
|
|
2023-11-20 17:17:04 +01:00
|
|
|
self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103)
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
evo_protxhash_list = list()
|
2024-08-22 15:19:46 +02:00
|
|
|
for i in range(self.evo_count):
|
2023-08-17 21:01:12 +02:00
|
|
|
evo_info = self.dynamically_add_masternode(evo=True)
|
|
|
|
evo_protxhash_list.append(evo_info.proTxHash)
|
2023-02-14 19:48:33 +01:00
|
|
|
self.nodes[0].generate(8)
|
|
|
|
self.sync_blocks(self.nodes)
|
2023-02-19 18:33:18 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
expectedUpdated.append(evo_info.proTxHash)
|
2023-02-19 18:33:18 +01:00
|
|
|
b_i = self.nodes[0].getbestblockhash()
|
|
|
|
self.test_getmnlistdiff(null_hash, b_i, {}, [], expectedUpdated)
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.test_masternode_count(expected_mns_count=4, expected_evo_count=i+1)
|
|
|
|
self.dynamically_evo_update_service(evo_info)
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.log.info("Test llmq_platform are formed only with EvoNodes")
|
2020-08-11 02:50:34 +02:00
|
|
|
for _ in range(3):
|
2023-02-17 20:20:56 +01:00
|
|
|
quorum_i_hash = self.mine_quorum(llmq_type_name='llmq_test_platform', llmq_type=106, expected_connections=2, expected_members=3, expected_contributions=3, expected_complaints=0, expected_justifications=0, expected_commitments=3 )
|
2023-08-17 21:01:12 +02:00
|
|
|
self.test_quorum_members_are_evo_nodes(quorum_i_hash, llmq_type=106)
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.log.info("Test that EvoNodes are present in MN list")
|
|
|
|
self.test_evo_protx_are_in_mnlist(evo_protxhash_list)
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.log.info("Test that EvoNodes are paid 4x blocks in a row")
|
2023-11-07 15:03:03 +01:00
|
|
|
self.test_evo_payments(window_analysis=48)
|
2024-08-22 15:19:46 +02:00
|
|
|
self.test_masternode_winners()
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-10-18 05:31:40 +02:00
|
|
|
self.activate_v20()
|
2023-08-01 06:52:48 +02:00
|
|
|
self.activate_mn_rr()
|
|
|
|
self.log.info("Activated MN RewardReallocation at height:" + str(self.nodes[0].getblockcount()))
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
# Generate a few blocks to make EvoNode/MN analysis on a pure MN RewardReallocation window
|
2023-08-01 06:52:48 +02:00
|
|
|
self.bump_mocktime(1)
|
|
|
|
self.nodes[0].generate(4)
|
|
|
|
self.sync_blocks()
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
self.log.info("Test that EvoNodes are paid 1 block in a row after MN RewardReallocation activation")
|
2023-11-07 15:03:03 +01:00
|
|
|
self.test_evo_payments(window_analysis=48, v20active=True)
|
2024-08-22 15:19:46 +02:00
|
|
|
self.test_masternode_winners(mn_rr_active=True)
|
2023-08-01 06:52:48 +02:00
|
|
|
|
2023-02-14 19:48:33 +01:00
|
|
|
self.log.info(self.nodes[0].masternodelist())
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
def test_evo_payments(self, window_analysis, v20active=False):
|
|
|
|
current_evo = None
|
2023-04-09 07:09:18 +02:00
|
|
|
consecutive_payments = 0
|
2023-08-01 06:52:48 +02:00
|
|
|
n_payments = 0 if v20active else 4
|
2023-02-14 19:48:33 +01:00
|
|
|
for i in range(0, window_analysis):
|
|
|
|
payee = self.get_mn_payee_for_block(self.nodes[0].getbestblockhash())
|
2023-08-17 21:01:12 +02:00
|
|
|
if payee is not None and payee.evo:
|
|
|
|
if current_evo is not None and payee.proTxHash == current_evo.proTxHash:
|
|
|
|
# same EvoNode
|
2023-04-09 07:09:18 +02:00
|
|
|
assert consecutive_payments > 0
|
2023-08-01 06:52:48 +02:00
|
|
|
if not v20active:
|
|
|
|
consecutive_payments += 1
|
2023-08-17 21:01:12 +02:00
|
|
|
consecutive_payments_rpc = self.nodes[0].protx('info', current_evo.proTxHash)['state']['consecutivePayments']
|
2023-04-09 07:09:18 +02:00
|
|
|
assert_equal(consecutive_payments, consecutive_payments_rpc)
|
2023-02-14 19:48:33 +01:00
|
|
|
else:
|
2023-08-17 21:01:12 +02:00
|
|
|
# new EvoNode
|
|
|
|
if current_evo is not None:
|
2023-08-01 06:52:48 +02:00
|
|
|
# make sure the old one was paid N times in a row
|
|
|
|
assert_equal(consecutive_payments, n_payments)
|
2023-08-17 21:01:12 +02:00
|
|
|
consecutive_payments_rpc = self.nodes[0].protx('info', current_evo.proTxHash)['state']['consecutivePayments']
|
|
|
|
# old EvoNode should have its nConsecutivePayments reset to 0
|
2023-04-09 07:09:18 +02:00
|
|
|
assert_equal(consecutive_payments_rpc, 0)
|
|
|
|
consecutive_payments_rpc = self.nodes[0].protx('info', payee.proTxHash)['state']['consecutivePayments']
|
2023-08-17 21:01:12 +02:00
|
|
|
# if EvoNode is the one we start "for" loop with,
|
2023-04-09 07:09:18 +02:00
|
|
|
# we have no idea how many times it was paid before - rely on rpc results here
|
2023-08-01 06:52:48 +02:00
|
|
|
new_payment_value = 0 if v20active else 1
|
2023-08-17 21:01:12 +02:00
|
|
|
consecutive_payments = consecutive_payments_rpc if i == 0 and current_evo is None else new_payment_value
|
|
|
|
current_evo = payee
|
2023-04-09 07:09:18 +02:00
|
|
|
assert_equal(consecutive_payments, consecutive_payments_rpc)
|
2023-02-14 19:48:33 +01:00
|
|
|
else:
|
2023-08-17 21:01:12 +02:00
|
|
|
# not an EvoNode
|
|
|
|
if current_evo is not None:
|
2023-08-01 06:52:48 +02:00
|
|
|
# make sure the old one was paid N times in a row
|
|
|
|
assert_equal(consecutive_payments, n_payments)
|
2023-08-17 21:01:12 +02:00
|
|
|
consecutive_payments_rpc = self.nodes[0].protx('info', current_evo.proTxHash)['state']['consecutivePayments']
|
|
|
|
# old EvoNode should have its nConsecutivePayments reset to 0
|
2023-04-09 07:09:18 +02:00
|
|
|
assert_equal(consecutive_payments_rpc, 0)
|
2023-08-17 21:01:12 +02:00
|
|
|
current_evo = None
|
2023-04-09 07:09:18 +02:00
|
|
|
consecutive_payments = 0
|
2023-02-14 19:48:33 +01:00
|
|
|
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
if i % 8 == 0:
|
|
|
|
self.sync_blocks()
|
|
|
|
|
|
|
|
def get_mn_payee_for_block(self, block_hash):
|
|
|
|
mn_payee_info = self.nodes[0].masternode("payments", block_hash)[0]
|
|
|
|
mn_payee_protx = mn_payee_info['masternodes'][0]['proTxHash']
|
|
|
|
|
|
|
|
mninfos_online = self.mninfo.copy()
|
|
|
|
for mn_info in mninfos_online:
|
|
|
|
if mn_info.proTxHash == mn_payee_protx:
|
|
|
|
return mn_info
|
|
|
|
return None
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
def test_quorum_members_are_evo_nodes(self, quorum_hash, llmq_type):
|
2023-02-14 19:48:33 +01:00
|
|
|
quorum_info = self.nodes[0].quorum("info", llmq_type, quorum_hash)
|
|
|
|
quorum_members = extract_quorum_members(quorum_info)
|
|
|
|
mninfos_online = self.mninfo.copy()
|
|
|
|
for qm in quorum_members:
|
|
|
|
found = False
|
|
|
|
for mn in mninfos_online:
|
|
|
|
if mn.proTxHash == qm:
|
2023-08-17 21:01:12 +02:00
|
|
|
assert_equal(mn.evo, True)
|
2023-02-14 19:48:33 +01:00
|
|
|
found = True
|
|
|
|
break
|
|
|
|
assert_equal(found, True)
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
def test_evo_protx_are_in_mnlist(self, evo_protx_list):
|
2023-02-14 19:48:33 +01:00
|
|
|
mn_list = self.nodes[0].masternodelist()
|
2023-08-17 21:01:12 +02:00
|
|
|
for evo_protx in evo_protx_list:
|
2023-02-14 19:48:33 +01:00
|
|
|
found = False
|
|
|
|
for mn in mn_list:
|
2023-08-17 21:01:12 +02:00
|
|
|
if mn_list.get(mn)['proTxHash'] == evo_protx:
|
2023-02-14 19:48:33 +01:00
|
|
|
found = True
|
2023-08-17 21:01:12 +02:00
|
|
|
assert_equal(mn_list.get(mn)['type'], "Evo")
|
2023-02-14 19:48:33 +01:00
|
|
|
assert_equal(found, True)
|
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
def test_evo_is_rejected_before_v19(self):
|
2023-02-14 19:48:33 +01:00
|
|
|
bls = self.nodes[0].bls('generate')
|
|
|
|
collateral_address = self.nodes[0].getnewaddress()
|
|
|
|
funds_address = self.nodes[0].getnewaddress()
|
|
|
|
owner_address = self.nodes[0].getnewaddress()
|
|
|
|
voting_address = self.nodes[0].getnewaddress()
|
|
|
|
reward_address = self.nodes[0].getnewaddress()
|
|
|
|
|
|
|
|
collateral_amount = 4000
|
2023-04-09 07:09:18 +02:00
|
|
|
outputs = {collateral_address: collateral_amount, funds_address: 1}
|
|
|
|
collateral_txid = self.nodes[0].sendmany("", outputs)
|
2023-11-20 17:17:04 +01:00
|
|
|
self.nodes[0].generate(8)
|
2023-02-14 19:48:33 +01:00
|
|
|
self.sync_all(self.nodes)
|
|
|
|
|
2023-11-20 17:17:04 +01:00
|
|
|
rawtx = self.nodes[0].getrawtransaction(collateral_txid, 1)
|
2023-04-09 07:09:18 +02:00
|
|
|
collateral_vout = 0
|
2023-02-14 19:48:33 +01:00
|
|
|
for txout in rawtx['vout']:
|
|
|
|
if txout['value'] == Decimal(collateral_amount):
|
|
|
|
collateral_vout = txout['n']
|
|
|
|
break
|
|
|
|
assert collateral_vout is not None
|
|
|
|
|
|
|
|
ipAndPort = '127.0.0.1:%d' % p2p_port(len(self.nodes))
|
|
|
|
operatorReward = len(self.nodes)
|
|
|
|
|
|
|
|
try:
|
2023-08-17 21:01:12 +02:00
|
|
|
self.nodes[0].protx('register_evo', collateral_txid, collateral_vout, ipAndPort, owner_address, bls['public'], voting_address, operatorReward, reward_address, funds_address, True)
|
2023-04-09 07:09:18 +02:00
|
|
|
# this should never succeed
|
|
|
|
assert False
|
2023-02-14 19:48:33 +01:00
|
|
|
except:
|
2023-08-17 21:01:12 +02:00
|
|
|
self.log.info("protx_evo rejected")
|
2023-02-14 19:48:33 +01:00
|
|
|
|
2023-08-17 21:01:12 +02:00
|
|
|
def test_masternode_count(self, expected_mns_count, expected_evo_count):
|
2023-02-17 19:29:46 +01:00
|
|
|
mn_count = self.nodes[0].masternode('count')
|
2023-08-17 21:01:12 +02:00
|
|
|
assert_equal(mn_count['total'], expected_mns_count + expected_evo_count)
|
2023-02-17 19:29:46 +01:00
|
|
|
detailed_count = mn_count['detailed']
|
|
|
|
assert_equal(detailed_count['regular']['total'], expected_mns_count)
|
2023-08-17 21:01:12 +02:00
|
|
|
assert_equal(detailed_count['evo']['total'], expected_evo_count)
|
2023-02-17 19:29:46 +01:00
|
|
|
|
2024-08-22 15:19:46 +02:00
|
|
|
def test_masternode_winners(self, mn_rr_active=False):
|
|
|
|
# ignore recent winners, test future ones only
|
|
|
|
# we get up to 21 entries here: tip + up to 20 future payees
|
|
|
|
winners = self.nodes[0].masternode('winners', '0')
|
|
|
|
weighted_count = self.mn_count + self.evo_count * (1 if mn_rr_active else 4)
|
|
|
|
assert_equal(len(winners.keys()) - 1, 20 if weighted_count > 20 else weighted_count)
|
|
|
|
consecutive_payments = 0
|
|
|
|
full_consecutive_payments_found = 0
|
|
|
|
payment_cycles = 0
|
|
|
|
first_payee = None
|
|
|
|
prev_winner = None
|
|
|
|
for height in winners.keys():
|
|
|
|
winner = winners[height]
|
|
|
|
if mn_rr_active:
|
|
|
|
assert_equal(prev_winner == winner, False)
|
|
|
|
else:
|
|
|
|
if prev_winner == winner:
|
|
|
|
consecutive_payments += 1
|
|
|
|
else:
|
|
|
|
if consecutive_payments == 3:
|
|
|
|
full_consecutive_payments_found += 1
|
|
|
|
consecutive_payments = 0
|
|
|
|
assert_greater_than_or_equal(3, consecutive_payments)
|
|
|
|
if consecutive_payments == 0 and winner == first_payee:
|
|
|
|
payment_cycles += 1
|
|
|
|
if first_payee is None:
|
|
|
|
first_payee = winner
|
|
|
|
prev_winner = winner
|
|
|
|
if mn_rr_active:
|
|
|
|
assert_equal(full_consecutive_payments_found, 0)
|
|
|
|
else:
|
|
|
|
assert_greater_than_or_equal(full_consecutive_payments_found, (len(winners.keys()) - 1 - self.mn_count) // 4 - 1)
|
|
|
|
assert_equal(payment_cycles, (len(winners.keys()) - 1) // weighted_count)
|
|
|
|
|
2023-02-19 18:33:18 +01:00
|
|
|
def test_getmnlistdiff(self, baseBlockHash, blockHash, baseMNList, expectedDeleted, expectedUpdated):
|
|
|
|
d = self.test_getmnlistdiff_base(baseBlockHash, blockHash)
|
|
|
|
|
|
|
|
# Assert that the deletedMNs and mnList fields are what we expected
|
|
|
|
assert_equal(set(d.deletedMNs), set([int(e, 16) for e in expectedDeleted]))
|
|
|
|
assert_equal(set([e.proRegTxHash for e in d.mnList]), set(int(e, 16) for e in expectedUpdated))
|
|
|
|
|
|
|
|
# Build a new list based on the old list and the info from the diff
|
|
|
|
newMNList = baseMNList.copy()
|
|
|
|
for e in d.deletedMNs:
|
|
|
|
newMNList.pop(format(e, '064x'))
|
|
|
|
for e in d.mnList:
|
|
|
|
newMNList[format(e.proRegTxHash, '064x')] = e
|
|
|
|
|
|
|
|
cbtx = CCbTx()
|
|
|
|
cbtx.deserialize(BytesIO(d.cbTx.vExtraPayload))
|
|
|
|
|
|
|
|
# Verify that the merkle root matches what we locally calculate
|
|
|
|
hashes = []
|
|
|
|
for mn in sorted(newMNList.values(), key=lambda mn: ser_uint256(mn.proRegTxHash)):
|
2023-06-11 19:29:00 +02:00
|
|
|
hashes.append(hash256(mn.serialize(with_version = False)))
|
2023-02-19 18:33:18 +01:00
|
|
|
merkleRoot = CBlock.get_merkle_root(hashes)
|
|
|
|
assert_equal(merkleRoot, cbtx.merkleRootMNList)
|
|
|
|
|
|
|
|
return newMNList
|
|
|
|
|
|
|
|
def test_getmnlistdiff_base(self, baseBlockHash, blockHash):
|
|
|
|
hexstr = self.nodes[0].getblockheader(blockHash, False)
|
2021-06-24 12:47:04 +02:00
|
|
|
header = from_hex(CBlockHeader(), hexstr)
|
2023-02-19 18:33:18 +01:00
|
|
|
|
|
|
|
d = self.test_node.getmnlistdiff(int(baseBlockHash, 16), int(blockHash, 16))
|
|
|
|
assert_equal(d.baseBlockHash, int(baseBlockHash, 16))
|
|
|
|
assert_equal(d.blockHash, int(blockHash, 16))
|
|
|
|
|
|
|
|
# Check that the merkle proof is valid
|
|
|
|
proof = CMerkleBlock(header, d.merkleProof)
|
|
|
|
proof = proof.serialize().hex()
|
|
|
|
assert_equal(self.nodes[0].verifytxoutproof(proof), [d.cbTx.hash])
|
|
|
|
|
|
|
|
# Check if P2P messages match with RPCs
|
|
|
|
d2 = self.nodes[0].protx("diff", baseBlockHash, blockHash)
|
|
|
|
assert_equal(d2["baseBlockHash"], baseBlockHash)
|
|
|
|
assert_equal(d2["blockHash"], blockHash)
|
|
|
|
assert_equal(d2["cbTxMerkleTree"], d.merkleProof.serialize().hex())
|
|
|
|
assert_equal(d2["cbTx"], d.cbTx.serialize().hex())
|
|
|
|
assert_equal(set([int(e, 16) for e in d2["deletedMNs"]]), set(d.deletedMNs))
|
|
|
|
assert_equal(set([int(e["proRegTxHash"], 16) for e in d2["mnList"]]), set([e.proRegTxHash for e in d.mnList]))
|
|
|
|
assert_equal(set([QuorumId(e["llmqType"], int(e["quorumHash"], 16)) for e in d2["deletedQuorums"]]), set(d.deletedQuorums))
|
|
|
|
assert_equal(set([QuorumId(e["llmqType"], int(e["quorumHash"], 16)) for e in d2["newQuorums"]]), set([QuorumId(e.llmqType, e.quorumHash) for e in d.newQuorums]))
|
|
|
|
|
|
|
|
return d
|
|
|
|
|
2023-02-14 19:48:33 +01:00
|
|
|
if __name__ == '__main__':
|
2023-08-17 21:01:12 +02:00
|
|
|
LLMQEvoNodesTest().main()
|