From c7b4045802450df361216d9e7da3ec318e67cc34 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Wed, 19 Dec 2018 17:16:40 +0800 Subject: core: Add a `MPKReady` so `MasterPublicKey` cannot be added afterwards (#375) * Add type DKGReady * Add DKGReady to interface and state * DKG will wait for MPK to be ready before running * Modify test * Check if self's MPK is registered * Add test for delay add MPK * Rename Ready to MPKReady --- core/consensus.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'core/consensus.go') diff --git a/core/consensus.go b/core/consensus.go index 741330e..bf49a72 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -329,6 +329,16 @@ func (recv *consensusDKGReceiver) ProposeDKGAntiNackComplaint( recv.network.BroadcastDKGPrivateShare(prv) } +// ProposeDKGMPKReady propose a DKGMPKReady message. +func (recv *consensusDKGReceiver) ProposeDKGMPKReady(ready *typesDKG.MPKReady) { + if err := recv.authModule.SignDKGMPKReady(ready); err != nil { + recv.logger.Error("Failed to sign DKG ready", "error", err) + return + } + recv.logger.Debug("Calling Governance.AddDKGFinalize", "ready", ready) + recv.gov.AddDKGMPKReady(ready.Round, ready) +} + // ProposeDKGFinalize propose a DKGFinalize message. func (recv *consensusDKGReceiver) ProposeDKGFinalize(final *typesDKG.Finalize) { if err := recv.authModule.SignDKGFinalize(final); err != nil { @@ -631,7 +641,7 @@ func (con *Consensus) runCRS(round uint64) { } con.logger.Debug("Calling Governance.IsDKGFinal to check if ready to run CRS", "round", round) - if con.cfgModule.isDKGReady(round) { + if con.cfgModule.isDKGFinal(round) { break } con.logger.Debug("DKG is not ready for running CRS. Retry later...", -- cgit v1.2.3