aboutsummaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorWei-Ning Huang <aitjcize@gmail.com>2018-11-14 10:57:53 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:18 +0800
commit070647ec674c96582ebe93dadeefe017964c0488 (patch)
treecf14e337a1f306adc15ccafa4086f2745f8a4093 /vendor
parentcbb7cc20f824fd96279a0c14eb5d0a2187347955 (diff)
downloadgo-tangerine-070647ec674c96582ebe93dadeefe017964c0488.tar
go-tangerine-070647ec674c96582ebe93dadeefe017964c0488.tar.gz
go-tangerine-070647ec674c96582ebe93dadeefe017964c0488.tar.bz2
go-tangerine-070647ec674c96582ebe93dadeefe017964c0488.tar.lz
go-tangerine-070647ec674c96582ebe93dadeefe017964c0488.tar.xz
go-tangerine-070647ec674c96582ebe93dadeefe017964c0488.tar.zst
go-tangerine-070647ec674c96582ebe93dadeefe017964c0488.zip
core: validate DKG set with correct nodeset in round-2 (#19)
* vendor: sync consensus core * core: validate DKG set with correct nodeset in round-2
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go15
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/constant.go6
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go4
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/lattice.go1
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go11
-rw-r--r--vendor/vendor.json34
6 files changed, 27 insertions, 44 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
index d12d30a6a..3d46c5c8b 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
@@ -315,11 +315,7 @@ func NewConsensus(
logger common.Logger) *Consensus {
// TODO(w): load latest blockHeight from DB, and use config at that height.
- var (
- round uint64
- // round 0 and 1 are decided at beginning.
- roundToNotify = round + 2
- )
+ var round uint64
logger.Debug("Calling Governance.Configuration", "round", round)
config := gov.Configuration(round)
nodeSetCache := NewNodeSetCache(gov)
@@ -366,7 +362,6 @@ func NewConsensus(
authModule: authModule,
event: common.NewEvent(),
logger: logger,
- roundToNotify: roundToNotify,
}
validLeader := func(block *types.Block) (bool, error) {
@@ -416,9 +411,9 @@ func NewConsensus(
// Run starts running DEXON Consensus.
func (con *Consensus) Run(initBlock *types.Block) {
- con.logger.Debug("Calling Governance.NotifyRoundHeight for genesis rounds",
- "block", initBlock)
- notifyGenesisRounds(initBlock, con.gov)
+ // The block past from full node should be delivered already or known by
+ // full node. We don't have to notify it.
+ con.roundToNotify = initBlock.Position.Round + 1
initRound := initBlock.Position.Round
con.logger.Debug("Calling Governance.Configuration", "round", initRound)
initConfig := con.gov.Configuration(initRound)
@@ -1004,7 +999,7 @@ func (con *Consensus) preProcessBlock(b *types.Block) (err error) {
func (con *Consensus) deliverBlock(b *types.Block) {
con.logger.Debug("Calling Application.BlockDelivered", "block", b)
con.app.BlockDelivered(b.Hash, b.Position, b.Finalization.Clone())
- if b.Position.Round+roundShift == con.roundToNotify {
+ if b.Position.Round == con.roundToNotify {
// Only the first block delivered of that round would
// trigger this noitification.
con.logger.Debug("Calling Governance.NotifyRoundHeight",
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/constant.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/constant.go
index 9a61c0abb..563a321f5 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/constant.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/constant.go
@@ -17,9 +17,9 @@
package core
-// round shift refers to the difference between block's round and config round
-// derived from its state.
+// ConfigRoundShift refers to the difference between block's round and config
+// round derived from its state.
//
// For example, when round shift is 2, a block in round 0 should derive config
// for round 2.
-const roundShift uint64 = 2
+const ConfigRoundShift uint64 = 2
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go
index 3a9c0752a..e07476d44 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go
@@ -111,8 +111,8 @@ type Governance interface {
// Return the genesis node set if round == 0.
NodeSet(round uint64) []crypto.PublicKey
- // NotifyRoundHeight notifies governance contract to generate configuration
- // for that round with the block on that consensus height.
+ // NotifyRoundHeight notifies governance contract the consensus height of
+ // the first block of the given round.
NotifyRoundHeight(targetRound, consensusHeight uint64)
//// DKG-related methods.
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice.go
index dcb3368fd..108f2887b 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/lattice.go
@@ -282,7 +282,6 @@ func (l *Lattice) PurgeBlocks(blocks []*types.Block) error {
func (l *Lattice) AppendConfig(round uint64, config *types.Config) (err error) {
l.lock.Lock()
defer l.lock.Unlock()
-
l.pool.resize(config.NumChains)
if err = l.data.appendConfig(round, config); err != nil {
return
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
index 9159be858..6b9ce634f 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
@@ -159,14 +159,3 @@ func DiffUint64(a, b uint64) uint64 {
}
return b - a
}
-
-// notifyGenesisRounds notifies governance to generate configs based on genesis
-// state.
-func notifyGenesisRounds(initBlock *types.Block, gov Governance) {
- if initBlock.Position.Round != 0 || !initBlock.IsGenesis() {
- return
- }
- for round := uint64(0); round < roundShift; round++ {
- gov.NotifyRoundHeight(round, 0)
- }
-}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 83d579652..711396aec 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -105,50 +105,50 @@
{
"checksumSHA1": "ev84RyegNbt2Pr/sK26LK9LoQNI=",
"path": "github.com/dexon-foundation/dexon-consensus/common",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
- "checksumSHA1": "9HDUFD7awHgKX5BhFZQAqr5e8Mo=",
+ "checksumSHA1": "CDbhowufKnHipqNsFhQymXdlAyY=",
"path": "github.com/dexon-foundation/dexon-consensus/core",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "vNsaBvsrXJF+W6K5DCLpgy1rUZY=",
"path": "github.com/dexon-foundation/dexon-consensus/core/blockdb",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "p2jOAulavUU2xyj018pYPHlj8XA=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "6Pf6caC8LTNCI7IflFmglKYnxYo=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "Kzw8b6kQLSApzVHO2WvmxrBfixA=",
"path": "github.com/dexon-foundation/dexon-consensus/core/types",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "ovChyW9OfDGnk/7CDAR+A5vJymc=",
"path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg",
- "revision": "86838fe70789292de0851f82426e5241c0f0cc96",
- "revisionTime": "2018-11-13T07:26:09Z"
+ "revision": "01642721a7768218e7f9a5be8f0829eb8ae7c7b1",
+ "revisionTime": "2018-11-13T08:28:24Z"
},
{
"checksumSHA1": "TAkwduKZqLyimyTPPWIllZWYFuE=",