2019-05-08 11:13:27 +02:00
|
|
|
#!/usr/bin/env python3
|
2023-12-31 01:00:00 +01:00
|
|
|
# Copyright (c) 2015-2023 The Dash Core developers
|
2019-05-08 11:13:27 +02:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
from test_framework.test_framework import DashTestFramework
|
|
|
|
|
|
|
|
'''
|
2020-07-17 01:44:20 +02:00
|
|
|
feature_llmq_dkgerrors.py
|
2019-05-08 11:13:27 +02:00
|
|
|
|
|
|
|
Simulate and check DKG errors
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
class LLMQDKGErrors(DashTestFramework):
|
2019-09-24 00:57:30 +02:00
|
|
|
def set_test_params(self):
|
2020-01-07 13:49:51 +01:00
|
|
|
self.set_dash_test_params(4, 3, [["-whitelist=127.0.0.1"]] * 4, fast_dip3_enforcement=True)
|
2019-05-08 11:13:27 +02:00
|
|
|
|
|
|
|
def run_test(self):
|
2022-06-18 18:52:45 +02:00
|
|
|
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.wait_for_sporks_same()
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Mine one quorum without simulating any errors")
|
2019-05-08 11:13:27 +02:00
|
|
|
qh = self.mine_quorum()
|
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets omit the contribution")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'contribution-omit', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=2)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets lie in the contribution but provide a correct justification")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'contribution-omit', '0')
|
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=2, expected_justifications=1)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets lie in the contribution and then omit the justification")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'justify-omit', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=2)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Heal some damage (don't get PoSe banned)")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.heal_masternodes(33)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets lie in the contribution and then also lie in the justification")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'justify-omit', '0')
|
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'justify-lie', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=2, expected_justifications=1)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets lie about another MN")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '0')
|
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'justify-lie', '0')
|
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'complain-lie', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=1, expected_justifications=2)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets omit 1 premature commitments")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'complain-lie', '0')
|
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'commit-omit', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=0, expected_justifications=0, expected_commitments=2)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
|
|
|
|
2020-11-28 20:18:01 +01:00
|
|
|
self.log.info("Lets lie in 1 premature commitments")
|
2019-05-08 11:13:27 +02:00
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'commit-omit', '0')
|
|
|
|
self.mninfo[0].node.quorum('dkgsimerror', 'commit-lie', '1')
|
2020-01-07 13:49:51 +01:00
|
|
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=0, expected_justifications=0, expected_commitments=2)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
|
|
|
|
|
|
|
def assert_member_valid(self, quorumHash, proTxHash, expectedValid):
|
|
|
|
q = self.nodes[0].quorum('info', 100, quorumHash, True)
|
|
|
|
for m in q['members']:
|
|
|
|
if m['proTxHash'] == proTxHash:
|
|
|
|
if expectedValid:
|
2021-08-27 21:03:02 +02:00
|
|
|
assert m['valid']
|
2019-05-08 11:13:27 +02:00
|
|
|
else:
|
2021-08-27 21:03:02 +02:00
|
|
|
assert not m['valid']
|
2019-05-08 11:13:27 +02:00
|
|
|
else:
|
2021-08-27 21:03:02 +02:00
|
|
|
assert m['valid']
|
2019-05-08 11:13:27 +02:00
|
|
|
|
|
|
|
def heal_masternodes(self, blockCount):
|
|
|
|
# We're not testing PoSe here, so lets heal the MNs :)
|
2022-06-18 18:52:45 +02:00
|
|
|
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 4070908800)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.wait_for_sporks_same()
|
2020-08-11 02:50:34 +02:00
|
|
|
for _ in range(blockCount):
|
2019-08-09 01:14:11 +02:00
|
|
|
self.bump_mocktime(1)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all()
|
2022-06-18 18:52:45 +02:00
|
|
|
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
|
2019-05-08 11:13:27 +02:00
|
|
|
self.wait_for_sporks_same()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
LLMQDKGErrors().main()
|