aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/consensus.go12
-rw-r--r--core/interfaces.go4
-rw-r--r--core/nodeset-cache.go4
-rw-r--r--core/nodeset-cache_test.go6
-rw-r--r--core/test/governance.go4
-rw-r--r--core/types/config.go16
-rw-r--r--core/types/configuration.go40
-rw-r--r--simulation/governance.go4
8 files changed, 26 insertions, 64 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 3b8883e..dc1e3d4 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -259,7 +259,7 @@ func NewConsensus(
gov)
// Register DKG for the initial round. This is a temporary function call for
// simulation.
- cfgModule.registerDKG(0, config.NumDKGSet/3)
+ cfgModule.registerDKG(0, int(config.DKGSetSize)/3)
// Construct Consensus instance.
con := &Consensus{
ID: ID,
@@ -362,7 +362,8 @@ BALoop:
if err != nil {
panic(err)
}
- nIDs = nodes.GetSubSet(con.gov.Configuration(con.round).NumNotarySet,
+ nIDs = nodes.GetSubSet(
+ int(con.gov.Configuration(con.round).NotarySetSize),
types.NewNotarySetTarget(con.gov.CRS(con.round), chainID))
}
agreement.restart(nIDs, con.lattice.NextPosition(chainID))
@@ -465,7 +466,8 @@ func (con *Consensus) initialRound(startTime time.Time) {
})
con.event.RegisterTime(startTime.Add(con.currentConfig.RoundInterval/2),
func(time.Time) {
- con.cfgModule.registerDKG(con.round+1, con.currentConfig.NumDKGSet/3)
+ con.cfgModule.registerDKG(
+ con.round+1, int(con.currentConfig.DKGSetSize/3))
})
con.event.RegisterTime(startTime.Add(con.currentConfig.RoundInterval),
func(time.Time) {
@@ -555,7 +557,7 @@ func (con *Consensus) ProcessAgreementResult(
if _, exist := dkgSet[con.ID]; !exist {
return nil
}
- if len(rand.Votes) <= con.currentConfig.NumNotarySet/3*2 {
+ if len(rand.Votes) <= int(con.currentConfig.NotarySetSize/3*2) {
return ErrNotEnoughVotes
}
if rand.Position.ChainID >= con.currentConfig.NumChains {
@@ -622,7 +624,7 @@ func (con *Consensus) ProcessBlockRandomnessResult(
gpk, err := NewDKGGroupPublicKey(round,
con.gov.DKGMasterPublicKeys(round),
con.gov.DKGComplaints(round),
- con.gov.Configuration(round).NumDKGSet/3)
+ int(con.gov.Configuration(round).DKGSetSize/3))
if err != nil {
return err
}
diff --git a/core/interfaces.go b/core/interfaces.go
index 77d7610..3497535 100644
--- a/core/interfaces.go
+++ b/core/interfaces.go
@@ -29,10 +29,10 @@ import (
// consensus core.
type Application interface {
// PreparePayload is called when consensus core is preparing a block.
- PreparePayload(position types.Position) (payload []byte)
+ PreparePayload(position types.Position) []byte
// PrepareWitness will return the witness data no lower than consensusHeight.
- PrepareWitness(consensusHeight uint64) (witness types.Witness)
+ PrepareWitness(consensusHeight uint64) types.Witness
// VerifyBlock verifies if the block is valid.
VerifyBlock(block *types.Block) bool
diff --git a/core/nodeset-cache.go b/core/nodeset-cache.go
index 8cfe470..4afec28 100644
--- a/core/nodeset-cache.go
+++ b/core/nodeset-cache.go
@@ -181,11 +181,11 @@ func (cache *NodeSetCache) update(
nodeSet: nodeSet,
notarySet: make([]map[types.NodeID]struct{}, cfg.NumChains),
dkgSet: nodeSet.GetSubSet(
- cfg.NumDKGSet, types.NewDKGSetTarget(crs)),
+ int(cfg.DKGSetSize), types.NewDKGSetTarget(crs)),
}
for i := range nIDs.notarySet {
nIDs.notarySet[i] = nodeSet.GetSubSet(
- cfg.NumNotarySet, types.NewNotarySetTarget(crs, uint32(i)))
+ int(cfg.NotarySetSize), types.NewNotarySetTarget(crs, uint32(i)))
}
cache.rounds[round] = nIDs
diff --git a/core/nodeset-cache_test.go b/core/nodeset-cache_test.go
index f36b59a..a9a31c2 100644
--- a/core/nodeset-cache_test.go
+++ b/core/nodeset-cache_test.go
@@ -35,9 +35,9 @@ type testGov struct {
func (g *testGov) Configuration(round uint64) (cfg *types.Config) {
return &types.Config{
- NumNotarySet: 7,
- NumDKGSet: 7,
- NumChains: 4,
+ NotarySetSize: 7,
+ DKGSetSize: 7,
+ NumChains: 4,
}
}
func (g *testGov) CRS(round uint64) (b common.Hash) { return g.crs }
diff --git a/core/test/governance.go b/core/test/governance.go
index f013534..24fd2de 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -95,8 +95,8 @@ func (g *Governance) Configuration(_ uint64) *types.Config {
LambdaDKG: g.lambdaDKG,
K: 0,
PhiRatio: 0.667,
- NumNotarySet: len(g.privateKeys),
- NumDKGSet: len(g.privateKeys),
+ NotarySetSize: uint32(len(g.privateKeys)),
+ DKGSetSize: uint32(len(g.privateKeys)),
RoundInterval: g.RoundInterval,
MinBlockInterval: g.MinBlockInterval,
MaxBlockInterval: g.MaxBlockInterval,
diff --git a/core/types/config.go b/core/types/config.go
index 2b678b1..372ffb4 100644
--- a/core/types/config.go
+++ b/core/types/config.go
@@ -37,8 +37,8 @@ type Config struct {
PhiRatio float32
// Set related.
- NumNotarySet int
- NumDKGSet int
+ NotarySetSize uint32
+ DKGSetSize uint32
// Time related.
RoundInterval time.Duration
@@ -63,10 +63,10 @@ func (c *Config) Bytes() []byte {
binaryPhiRatio := make([]byte, 4)
binary.LittleEndian.PutUint32(binaryPhiRatio, math.Float32bits(c.PhiRatio))
- binaryNumNotarySet := make([]byte, 4)
- binary.LittleEndian.PutUint32(binaryNumNotarySet, uint32(c.NumNotarySet))
- binaryNumDKGSet := make([]byte, 4)
- binary.LittleEndian.PutUint32(binaryNumDKGSet, uint32(c.NumDKGSet))
+ binaryNotarySetSize := make([]byte, 4)
+ binary.LittleEndian.PutUint32(binaryNotarySetSize, c.NotarySetSize)
+ binaryDKGSetSize := make([]byte, 4)
+ binary.LittleEndian.PutUint32(binaryDKGSetSize, c.DKGSetSize)
binaryRoundInterval := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRoundInterval,
@@ -84,8 +84,8 @@ func (c *Config) Bytes() []byte {
enc = append(enc, binaryLambdaDKG...)
enc = append(enc, binaryK...)
enc = append(enc, binaryPhiRatio...)
- enc = append(enc, binaryNumNotarySet...)
- enc = append(enc, binaryNumDKGSet...)
+ enc = append(enc, binaryNotarySetSize...)
+ enc = append(enc, binaryDKGSetSize...)
enc = append(enc, binaryRoundInterval...)
enc = append(enc, binaryMinBlockInterval...)
enc = append(enc, binaryMaxBlockInterval...)
diff --git a/core/types/configuration.go b/core/types/configuration.go
deleted file mode 100644
index 6011b19..0000000
--- a/core/types/configuration.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2018 The dexon-consensus-core Authors
-// This file is part of the dexon-consensus-core library.
-//
-// The dexon-consensus-core library is free software: you can redistribute it
-// and/or modify it under the terms of the GNU Lesser General Public License as
-// published by the Free Software Foundation, either version 3 of the License,
-// or (at your option) any later version.
-//
-// The dexon-consensus-core library is distributed in the hope that it will be
-// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
-// General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the dexon-consensus-core library. If not, see
-// <http://www.gnu.org/licenses/>.
-
-package types
-
-// ConfigurationChangeEventType specifies the action of a membership event.
-type ConfigurationChangeEventType int
-
-// Event enums.
-const (
- KChanged ConfigurationChangeEventType = iota
- PhiRatioChanged
- BlockProposingIntervalChanged
-)
-
-// IntegerEventPayload is a general payload for integer type value.
-type IntegerEventPayload struct {
- Value int64
-}
-
-// ConfigurationChangeEvent specifies the event of membership changes.
-type ConfigurationChangeEvent struct {
- Epoch int
- Event ConfigurationChangeEventType
- Payload interface{}
-}
diff --git a/simulation/governance.go b/simulation/governance.go
index f357b26..23e1884 100644
--- a/simulation/governance.go
+++ b/simulation/governance.go
@@ -96,8 +96,8 @@ func (g *simGovernance) Configuration(round uint64) *types.Config {
LambdaDKG: g.lambdaDKG,
K: g.k,
PhiRatio: g.phiRatio,
- NumNotarySet: len(g.nodeSet),
- NumDKGSet: len(g.nodeSet),
+ NotarySetSize: uint32(len(g.nodeSet)),
+ DKGSetSize: uint32(len(g.nodeSet)),
MinBlockInterval: g.lambdaBA * 3,
MaxBlockInterval: g.lambdaBA * 8,
RoundInterval: g.roundInterval,