aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-19 16:53:34 +0800
committerGitHub <noreply@github.com>2019-03-19 16:53:34 +0800
commit448935829700500ecf512b9e0a6437cbb63504b3 (patch)
tree6a9eb7439f2e8caf60000a14215ce92cd078a518
parent3785190d9154acb0492dd22b6d62e953a0bcf453 (diff)
downloadtangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.tar
tangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.tar.gz
tangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.tar.bz2
tangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.tar.lz
tangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.tar.xz
tangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.tar.zst
tangerine-consensus-448935829700500ecf512b9e0a6437cbb63504b3.zip
core: remove round from addDKG fuction (#501)
-rw-r--r--core/configuration-chain_test.go8
-rw-r--r--core/consensus.go8
-rw-r--r--core/dkg-tsig-protocol_test.go34
-rw-r--r--core/interfaces.go8
-rw-r--r--core/test/app_test.go4
-rw-r--r--core/test/governance.go22
-rw-r--r--core/test/governance_test.go6
-rw-r--r--integration_test/round-event_test.go4
8 files changed, 40 insertions, 54 deletions
diff --git a/core/configuration-chain_test.go b/core/configuration-chain_test.go
index 9de06df..4de0c68 100644
--- a/core/configuration-chain_test.go
+++ b/core/configuration-chain_test.go
@@ -65,14 +65,14 @@ func newTestCCGlobalReceiver(
func (r *testCCGlobalReceiver) ProposeDKGComplaint(
complaint *typesDKG.Complaint) {
for _, gov := range r.govs {
- gov.AddDKGComplaint(complaint.Round, test.CloneDKGComplaint(complaint))
+ gov.AddDKGComplaint(test.CloneDKGComplaint(complaint))
}
}
func (r *testCCGlobalReceiver) ProposeDKGMasterPublicKey(
mpk *typesDKG.MasterPublicKey) {
for _, gov := range r.govs {
- gov.AddDKGMasterPublicKey(mpk.Round, test.CloneDKGMasterPublicKey(mpk))
+ gov.AddDKGMasterPublicKey(test.CloneDKGMasterPublicKey(mpk))
}
}
@@ -103,13 +103,13 @@ func (r *testCCGlobalReceiver) ProposeDKGAntiNackComplaint(
func (r *testCCGlobalReceiver) ProposeDKGMPKReady(ready *typesDKG.MPKReady) {
for _, gov := range r.govs {
- gov.AddDKGMPKReady(ready.Round, test.CloneDKGMPKReady(ready))
+ gov.AddDKGMPKReady(test.CloneDKGMPKReady(ready))
}
}
func (r *testCCGlobalReceiver) ProposeDKGFinalize(final *typesDKG.Finalize) {
for _, gov := range r.govs {
- gov.AddDKGFinalize(final.Round, test.CloneDKGFinalize(final))
+ gov.AddDKGFinalize(test.CloneDKGFinalize(final))
}
}
diff --git a/core/consensus.go b/core/consensus.go
index 7793129..c75f542 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -302,7 +302,7 @@ func (recv *consensusDKGReceiver) ProposeDKGComplaint(
}
recv.logger.Debug("Calling Governace.AddDKGComplaint",
"complaint", complaint)
- recv.gov.AddDKGComplaint(complaint.Round, complaint)
+ recv.gov.AddDKGComplaint(complaint)
}
// ProposeDKGMasterPublicKey propose a DKGMasterPublicKey.
@@ -313,7 +313,7 @@ func (recv *consensusDKGReceiver) ProposeDKGMasterPublicKey(
return
}
recv.logger.Debug("Calling Governance.AddDKGMasterPublicKey", "key", mpk)
- recv.gov.AddDKGMasterPublicKey(mpk.Round, mpk)
+ recv.gov.AddDKGMasterPublicKey(mpk)
}
// ProposeDKGPrivateShare propose a DKGPrivateShare.
@@ -362,7 +362,7 @@ func (recv *consensusDKGReceiver) ProposeDKGMPKReady(ready *typesDKG.MPKReady) {
return
}
recv.logger.Debug("Calling Governance.AddDKGMPKReady", "ready", ready)
- recv.gov.AddDKGMPKReady(ready.Round, ready)
+ recv.gov.AddDKGMPKReady(ready)
}
// ProposeDKGFinalize propose a DKGFinalize message.
@@ -372,7 +372,7 @@ func (recv *consensusDKGReceiver) ProposeDKGFinalize(final *typesDKG.Finalize) {
return
}
recv.logger.Debug("Calling Governance.AddDKGFinalize", "final", final)
- recv.gov.AddDKGFinalize(final.Round, final)
+ recv.gov.AddDKGFinalize(final)
}
// Consensus implements DEXON Consensus algorithm.
diff --git a/core/dkg-tsig-protocol_test.go b/core/dkg-tsig-protocol_test.go
index a022605..9de2027 100644
--- a/core/dkg-tsig-protocol_test.go
+++ b/core/dkg-tsig-protocol_test.go
@@ -171,7 +171,7 @@ func (s *DKGTSIGProtocolTestSuite) TestDKGTSIGProtocol() {
receivers, protocols := s.newProtocols(k, n, round, reset)
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -196,7 +196,7 @@ func (s *DKGTSIGProtocolTestSuite) TestDKGTSIGProtocol() {
for _, receiver := range receivers {
for _, complaint := range receiver.complaints {
- gov.AddDKGComplaint(round, complaint)
+ gov.AddDKGComplaint(complaint)
}
}
@@ -297,7 +297,7 @@ func (s *DKGTSIGProtocolTestSuite) TestErrMPKRegistered() {
PublicKeyShares: *mpk,
})
}
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for ID, protocol := range protocols {
@@ -341,7 +341,7 @@ func (s *DKGTSIGProtocolTestSuite) TestErrMPKRegistered() {
for _, receiver := range receivers {
for _, complaint := range receiver.complaints {
- gov.AddDKGComplaint(round, complaint)
+ gov.AddDKGComplaint(complaint)
}
}
@@ -415,7 +415,7 @@ func (s *DKGTSIGProtocolTestSuite) TestNackComplaint() {
byzantineID := s.nIDs[0]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -464,7 +464,7 @@ func (s *DKGTSIGProtocolTestSuite) TestComplaint() {
protocol := protocols[targetID]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -529,7 +529,7 @@ func (s *DKGTSIGProtocolTestSuite) TestDuplicateComplaint() {
victomID := s.nIDs[1]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
// Test for nack complaints.
@@ -574,7 +574,7 @@ func (s *DKGTSIGProtocolTestSuite) TestAntiComplaint() {
thirdPerson := s.nIDs[2]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -631,7 +631,7 @@ func (s *DKGTSIGProtocolTestSuite) TestEncorceNackComplaint() {
thirdPerson := s.nIDs[2]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -683,7 +683,7 @@ func (s *DKGTSIGProtocolTestSuite) TestQualifyIDs() {
byzantineID := s.nIDs[0]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
// Test for nack complaints.
@@ -750,7 +750,7 @@ func (s *DKGTSIGProtocolTestSuite) TestPartialSignature() {
byzantineID := s.nIDs[0]
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -776,7 +776,7 @@ func (s *DKGTSIGProtocolTestSuite) TestPartialSignature() {
s.Require().Len(recv.complaints, 1)
complaint, exist := recv.complaints[byzantineID]
s.Require().True(exist)
- gov.AddDKGComplaint(round, complaint)
+ gov.AddDKGComplaint(complaint)
}
// DKG is fininished.
@@ -892,7 +892,7 @@ func (s *DKGTSIGProtocolTestSuite) TestTSigVerifierCache() {
receivers, protocols := s.newProtocols(k, n, round, reset)
for _, receiver := range receivers {
- gov.AddDKGMasterPublicKey(round, receiver.mpk)
+ gov.AddDKGMasterPublicKey(receiver.mpk)
}
for _, protocol := range protocols {
@@ -900,7 +900,7 @@ func (s *DKGTSIGProtocolTestSuite) TestTSigVerifierCache() {
}
for _, recv := range receivers {
s.Require().Len(recv.ready, 1)
- gov.AddDKGMPKReady(recv.ready[0].Round, recv.ready[0])
+ gov.AddDKGMPKReady(recv.ready[0])
}
s.Require().True(gov.IsDKGMPKReady(round))
@@ -910,7 +910,7 @@ func (s *DKGTSIGProtocolTestSuite) TestTSigVerifierCache() {
for _, recv := range receivers {
s.Require().Len(recv.final, 1)
- gov.AddDKGFinalize(recv.final[0].Round, recv.final[0])
+ gov.AddDKGFinalize(recv.final[0])
}
s.Require().True(gov.IsDKGFinal(round))
}
@@ -1023,7 +1023,7 @@ func benchmarkDKGGroupPubliKey(k, n int, b *testing.B) {
for _, pk := range pubKeys {
_, pubShare := dkg.NewPrivateKeyShares(k)
- gov.AddDKGMasterPublicKey(round, &typesDKG.MasterPublicKey{
+ gov.AddDKGMasterPublicKey(&typesDKG.MasterPublicKey{
ProposerID: types.NewNodeID(pk),
Round: round,
Reset: reset,
@@ -1068,7 +1068,7 @@ func benchmarkDKGNodePubliKeys(k, n int, b *testing.B) {
for _, pk := range pubKeys {
_, pubShare := dkg.NewPrivateKeyShares(k)
- gov.AddDKGMasterPublicKey(round, &typesDKG.MasterPublicKey{
+ gov.AddDKGMasterPublicKey(&typesDKG.MasterPublicKey{
ProposerID: types.NewNodeID(pk),
Round: round,
Reset: reset,
diff --git a/core/interfaces.go b/core/interfaces.go
index 707563f..06838e0 100644
--- a/core/interfaces.go
+++ b/core/interfaces.go
@@ -122,25 +122,25 @@ type Governance interface {
//// DKG-related methods.
// AddDKGComplaint adds a DKGComplaint.
- AddDKGComplaint(round uint64, complaint *typesDKG.Complaint)
+ AddDKGComplaint(complaint *typesDKG.Complaint)
// DKGComplaints gets all the DKGComplaints of round.
DKGComplaints(round uint64) []*typesDKG.Complaint
// AddDKGMasterPublicKey adds a DKGMasterPublicKey.
- AddDKGMasterPublicKey(round uint64, masterPublicKey *typesDKG.MasterPublicKey)
+ AddDKGMasterPublicKey(masterPublicKey *typesDKG.MasterPublicKey)
// DKGMasterPublicKeys gets all the DKGMasterPublicKey of round.
DKGMasterPublicKeys(round uint64) []*typesDKG.MasterPublicKey
// AddDKGMPKReady adds a DKG ready message.
- AddDKGMPKReady(round uint64, ready *typesDKG.MPKReady)
+ AddDKGMPKReady(ready *typesDKG.MPKReady)
// IsDKGMPKReady checks if DKG's master public key preparation is ready.
IsDKGMPKReady(round uint64) bool
// AddDKGFinalize adds a DKG finalize message.
- AddDKGFinalize(round uint64, final *typesDKG.Finalize)
+ AddDKGFinalize(final *typesDKG.Finalize)
// IsDKGFinal checks if DKG is final.
IsDKGFinal(round uint64) bool
diff --git a/core/test/app_test.go b/core/test/app_test.go
index 1579549..c83aaf6 100644
--- a/core/test/app_test.go
+++ b/core/test/app_test.go
@@ -85,7 +85,7 @@ func (s *AppTestSuite) proposeMPK(
PublicKeyShares: *pubShare,
}
s.Require().NoError(s.signers[idx].SignDKGMasterPublicKey(mpk))
- gov.AddDKGMasterPublicKey(round, mpk)
+ gov.AddDKGMasterPublicKey(mpk)
}
}
@@ -100,7 +100,7 @@ func (s *AppTestSuite) proposeFinalize(
Reset: reset,
}
s.Require().NoError(s.signers[idx].SignDKGFinalize(final))
- gov.AddDKGFinalize(round, final)
+ gov.AddDKGFinalize(final)
}
}
diff --git a/core/test/governance.go b/core/test/governance.go
index 42294fc..62bee70 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -145,14 +145,10 @@ func (g *Governance) ProposeCRS(round uint64, signedCRS []byte) {
}
// AddDKGComplaint add a DKGComplaint.
-func (g *Governance) AddDKGComplaint(
- round uint64, complaint *typesDKG.Complaint) {
+func (g *Governance) AddDKGComplaint(complaint *typesDKG.Complaint) {
if g.isProhibited(StateAddDKGComplaint) {
return
}
- if round != complaint.Round {
- return
- }
if g.IsDKGFinal(complaint.Round) {
return
}
@@ -169,14 +165,10 @@ func (g *Governance) DKGComplaints(round uint64) []*typesDKG.Complaint {
}
// AddDKGMasterPublicKey adds a DKGMasterPublicKey.
-func (g *Governance) AddDKGMasterPublicKey(
- round uint64, masterPublicKey *typesDKG.MasterPublicKey) {
+func (g *Governance) AddDKGMasterPublicKey(masterPublicKey *typesDKG.MasterPublicKey) {
if g.isProhibited(StateAddDKGMasterPublicKey) {
return
}
- if round != masterPublicKey.Round {
- return
- }
if g.IsDKGMPKReady(masterPublicKey.Round) {
return
}
@@ -194,10 +186,7 @@ func (g *Governance) DKGMasterPublicKeys(
}
// AddDKGMPKReady adds a DKG ready message.
-func (g *Governance) AddDKGMPKReady(round uint64, ready *typesDKG.MPKReady) {
- if round != ready.Round {
- return
- }
+func (g *Governance) AddDKGMPKReady(ready *typesDKG.MPKReady) {
if err := g.stateModule.RequestChange(StateAddDKGMPKReady, ready); err != nil {
panic(err)
}
@@ -220,13 +209,10 @@ func (g *Governance) IsDKGMPKReady(round uint64) bool {
}
// AddDKGFinalize adds a DKG finalize message.
-func (g *Governance) AddDKGFinalize(round uint64, final *typesDKG.Finalize) {
+func (g *Governance) AddDKGFinalize(final *typesDKG.Finalize) {
if g.isProhibited(StateAddDKGFinal) {
return
}
- if round != final.Round {
- return
- }
if err := g.stateModule.RequestChange(StateAddDKGFinal, final); err != nil {
panic(err)
}
diff --git a/core/test/governance_test.go b/core/test/governance_test.go
index cb280a8..36819a0 100644
--- a/core/test/governance_test.go
+++ b/core/test/governance_test.go
@@ -121,7 +121,7 @@ func (s *GovernanceTestSuite) TestProhibit() {
PublicKeyShares: *pubShare,
}
s.Require().NoError(signer.SignDKGMasterPublicKey(mpk))
- gov.AddDKGMasterPublicKey(round, mpk)
+ gov.AddDKGMasterPublicKey(mpk)
}
proposeMPK(prvKeys[0])
s.Require().Len(gov.DKGMasterPublicKeys(round), 1)
@@ -139,7 +139,7 @@ func (s *GovernanceTestSuite) TestProhibit() {
Round: round,
}
s.Require().NoError(signer.SignDKGComplaint(comp))
- gov.AddDKGComplaint(round, comp)
+ gov.AddDKGComplaint(comp)
}
proposeComplaint(prvKeys[0])
s.Require().Len(gov.DKGComplaints(round), 1)
@@ -157,7 +157,7 @@ func (s *GovernanceTestSuite) TestProhibit() {
ProposerID: types.NewNodeID(k.PublicKey()),
}
s.Require().NoError(signer.SignDKGFinalize(final))
- gov.AddDKGFinalize(round, final)
+ gov.AddDKGFinalize(final)
}
gov.Prohibit(StateAddDKGFinal)
for _, k := range prvKeys {
diff --git a/integration_test/round-event_test.go b/integration_test/round-event_test.go
index 9bdce7a..d5b432b 100644
--- a/integration_test/round-event_test.go
+++ b/integration_test/round-event_test.go
@@ -85,7 +85,7 @@ func (s *RoundEventTestSuite) proposeMPK(
PublicKeyShares: *pubShare,
}
s.Require().NoError(s.signers[idx].SignDKGMasterPublicKey(mpk))
- gov.AddDKGMasterPublicKey(round, mpk)
+ gov.AddDKGMasterPublicKey(mpk)
}
}
@@ -100,7 +100,7 @@ func (s *RoundEventTestSuite) proposeFinalize(
Reset: reset,
}
s.Require().NoError(s.signers[idx].SignDKGFinalize(final))
- gov.AddDKGFinalize(round, final)
+ gov.AddDKGFinalize(final)
}
}