-
Notifications
You must be signed in to change notification settings - Fork 717
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
Long Living Masternode Quorums - Part 3, DKG #2722
Conversation
Can rebase it on top of 2719 once more. Ready to start reviewing this beauty :) |
691ec0c
to
06d45a7
Compare
Have added test coverage for #2719 here: furszy@b1c7c78 If you cherry-pick it, and reorder the commits to be placed on top of 7334c3f, i could close #2719. |
06d45a7
to
18b38c7
Compare
done. |
18b38c7
to
d9d77cc
Compare
Rebased on master. |
d9d77cc
to
fb01bfd
Compare
… to tiertwo/init.cpp and add disabledkg init flag c445333 init: add flag to disable the DKG processes. (furszy) 6035112 init: move tier two objects initializers and the Masternodes collateral transactions' output lock in wallet to the tiertwo/init.cpp file. (furszy) 38b92b9 init: improve dmn collateral locking. (furszy) 918db4e init: move Masternode arguments inside tiertwo/init GetTierTwoHelpString (furszy) Pull request description: Follow-up to #2684, built on top of #2647. Starting in 296e6fa. Focused on the following points: 1) Move init arguments help messages to a new `GetTierTwoHelpString()`, the tier two objects initializers and the Masternodes collateral output locking process to the tiertwo/init files. 2) Improve DMN collateral locking process: * Walking through the DMN list only once instead of one-time per wallet. * Removing the wallet dependency on `evo/deterministicmns.h`. 3) Add `-disabledkg` init argument so the `p2p_quorum_connect.py` functional test does not get affected by the automatic DKG sessions processes (coming in #2722). The same flag will be used in other future tests that perform manual operations as well. ACKs for top commit: random-zebra: utACK c445333 Fuzzbawls: ACK c445333 Tree-SHA512: ed879a1b2ce840777bc9144297bfe76aa3184d6b3aede925c6bb2a8f6854a4b87b5acfa734d8f5da128cf5880a8927999f9c5798e17174f97b26f3a392e1b8cb
fb01bfd
to
19db189
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round, left some comments
19db189
to
51b0a15
Compare
Thanks for the review, furszy. Feedback addressed, and rebased on master fixing conflicts. |
94e75f9
to
59ad88d
Compare
Great thanks. Second round: code wise is looking good. |
d224a7a
to
ff72027
Compare
Added error simulation and relative functional test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome new test!👌
>>> adapted from dash@d157718243222479c2e0e98208dff168e2a16bef + dash@f44dd06eef21a5083528295aeb534cc3fa131f2b * llqm: Fix thread handling in CDKGSessionManager and CDKGSessionHandler * llmq: Removed unused thread_pool from CDKGSessionManager * Tweak `CDKGSessionHandler::StartThread()` * llmq: Simplify CDKGSessionHandler's thread naming * llmq: Make sure CDKGSessionHandler uses a valid LLMQ type * Having "const char*" leads to undefined behaviour if the "const char*" is deallocated before the thread used it. Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
* -Wrange-loop-analysis (VerifyLLMQCommitment) * -Wpessimizing-move (CDKGPendingMessages::PopPendingMessages)
also remove unused timers
to set the error type and rate to simulate during the DKG of LLMQ_TEST
and refactor check_final_commitment out of mine_quorum
31f651c
to
f8a7dd8
Compare
Rebased due to conflicts with recently merged PRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase utACK f8a7dd8
As soon as this one gets merged, will push the GUI PR 🤘 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple minor nits, otherwise ACK
Ok. Will fix them in a subsequent PR, so reviews don't get dismissed. |
sounds good :) |
e2d3a4a Trivial: rename cxxtimer.hpp to cxxtimer.h (random-zebra) 21dedda RPC: fix mnconnect when first param is missing (random-zebra) Pull request description: Tackling last nits left in #2722 (review) ACKs for top commit: furszy: utACK e2d3a4a Fuzzbawls: ACK e2d3a4a Tree-SHA512: cdda59b60914516b98436ce79649556d318b450690fd476c1cb9435842c3c2b510641465ac94bcdbdd398ac307ffed79ccf27cacfb6d53547bec673ca8994375
… selection algorithm b4e7fe1 Refactor: remove unneeded lambda in llmq::GetQuorumRelayMembers (random-zebra) 68c7d71 Refactor: remove code duplication in net_quorum_tests (random-zebra) 3d65f84 Refactor: assert forMemberIndex in GetQuorumRelayMembers and simplify (random-zebra) 2858d50 LLMQ: GetQuorumRelayMembers returning a single element for the special case of quorum size of two members. (furszy) 34a80fa Refactor: no need to double check the proTx in GetQuorumRelayMembers (random-zebra) fb1c533 Fix for GetQuorumRelayMembers infinite loop. (furszy) 69cd4cc Test: validate GetQuorumRelayMembers algorithm and prove infinite loop. (furszy) 4bc864d Remove extra 'GetAllQuorumMembers' call from 'GetQuorumConnections' (furszy) 6e2f536 Faster and cleaner GetQuorumRelayMembers calculation. (furszy) a854b89 CDKGSessionHandler: No need to walk-backwards through the chain to get the last quorum index. (furszy) f8ea90c CDKGSession: remove not used messageHandlerPool field (furszy) 023c6ba CDKGSessionHandler::GetPhaseAndQuorumHash(), make return object more descriptive and readable. (furszy) Pull request description: Follow-up work to my on-going review of #2722 (review). Starts in eeefe79. The current intra-quorum relay members selection algorithm receives a quorum member and selects a number of relay connections equals to the quorum size bits count. So, for example: each DMN, in a quorum of 400 members, deterministically selects 9 other members and mark them as intra-quorum-relay members. In the test LLMQ params case, with a quorum of 2, this algorithm falls into an infinite loop. Blocking the node's LLMQ session forever. The process cannot select the input member for intra-quorum relay and expects to return a minimum of 2 elements. Added a test case commit first so the issue can be easily verified/tested. Aside from that, added some other performance improvements and cleanups for the LLMQ sessions: 1. Faster and cleaner GetQuorumRelayMembers calculation. 1. No need to re-calculate the quorum members internally, the function' callers already have calculated the DMN list. 2. As 'onlyOutbound' argument is always true. There is no need to loop over all the quorum members. The function only calculates the local DMN outbound relay connections. 2. Inside the `CDKGSessionHandler::UpdateBlockTip`: No need to walk-backwards through the chain to get the last quorum index. Can just look it up on chainActive`. 3. GetPhaseAndQuorumHash() returning an struct instead of a pair. 4. Remove unused 'messageHandlerPool' field in the CDKGSession` class. ACKs for top commit: random-zebra: obviously, ACK b4e7fe1 Tree-SHA512: 25c5795ecd1c721b4e29514bb17c5def0d41d45797fb4f2c700c5b9e04d339af07aa0632acd7f1c0559ecfabbf26375520a6d7bef929bbcd21181a62029ec709
This PR continues the work started with #2607 and #2647, implementing the distributed key generation protocol.
As outlined in DIP 6, this is a decentralized BLS M-of-N threshold scheme, based on Shamir's Secrete Sharing, and it consists in 7 phases:
LLMQComm
special transaction, and mine a block with it.The 7-th phase has been already introduced in #2607.
The communication between the participants of the DKG (phases 1 to 6) is supported by the following new P2P message types (which are exchanged only between the quorum members):
qcontrib
qcomplaint
qjustify
qpcommit
Sessions of the DKG are implemented in the
CDKGSession
class and the flow of message calls is identical for all phases:ReceiveMessage
, which does additional validationSessions are owned and called by
CDKGSessionHandler
, which manages multiple sequential sessions of one specific LLMQ type (there is one instance of this class per LLMQ type). It is responsible for starting the phase handler thread which constantly loops, processing the received messages, calling the required function for the current phase (CDKGSession::Contribute
,CDKGSession::VerifyAndComplain
,CDKGSession::VerifyAndJustify
,CDKGSession::VerifyAndCommit
), and waiting for the next one if needed.A global
CDKGSessionManager
object keeps track of of all session handlers.New functional tests are introduced to check the status (messages sent and received) of the nodes during the phases of the DKG (
CDKGDebugSessionStatus
accessed viaquorumdkgstatus
RPC) and to verify the DKG effectiveness as proof-of-service (non participating nodes get eventually "PoSe banned").