diff options
Diffstat (limited to 'vendor')
4 files changed, 52 insertions, 27 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/blockchain.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/blockchain.go index 03c8561c5..30895f8ec 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/blockchain.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/blockchain.go @@ -530,6 +530,17 @@ func (bc *blockChain) prepareBlock(position types.Position, return } else if empty { b.Timestamp = bc.dMoment + } else { + bc.logger.Debug("Calling genesis Application.PreparePayload") + if b.Payload, err = bc.app.PreparePayload(b.Position); err != nil { + b = nil + return + } + bc.logger.Debug("Calling genesis Application.PrepareWitness") + if b.Witness, err = bc.app.PrepareWitness(0); err != nil { + b = nil + return + } } } else { tipConfig := bc.tipConfig() @@ -553,12 +564,14 @@ func (bc *blockChain) prepareBlock(position types.Position, bc.logger.Debug("Calling Application.PreparePayload", "position", b.Position) if b.Payload, err = bc.app.PreparePayload(b.Position); err != nil { + b = nil return } bc.logger.Debug("Calling Application.PrepareWitness", "height", tip.Witness.Height) if b.Witness, err = bc.app.PrepareWitness( tip.Witness.Height); err != nil { + b = nil return } if !b.Timestamp.After(tip.Timestamp) { @@ -578,6 +591,7 @@ func (bc *blockChain) prepareBlock(position types.Position, } } else { if err = bc.signer.SignBlock(b); err != nil { + b = nil return } } 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 0f665f29a..0f4daa766 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -41,8 +41,6 @@ var ( "hash of block is incorrect") ErrIncorrectSignature = fmt.Errorf( "signature of block is incorrect") - ErrGenesisBlockNotEmpty = fmt.Errorf( - "genesis block should be empty") ErrUnknownBlockProposed = fmt.Errorf( "unknown block is proposed") ErrIncorrectAgreementResultPosition = fmt.Errorf( @@ -831,6 +829,16 @@ func (con *Consensus) initialRound( con.initialRound( startHeight+config.RoundLength, nextRound, nextConfig) }) + // Touch nodeSetCache for next round. + con.event.RegisterHeight(startHeight+config.RoundLength*9/10, func(uint64) { + go func() { + // TODO(jimmy): check DKGResetCount and do not touch if nextRound is reset. + if err := con.nodeSetCache.Touch(round + 1); err != nil { + con.logger.Warn("Failed to update nodeSetCache", + "round", round+1, "error", err) + } + }() + }) } // Stop the Consensus core. @@ -1242,8 +1250,5 @@ func (con *Consensus) proposeBlock(position types.Position) ( if err = con.signer.SignCRS(b, crs); err != nil { return nil, err } - if b.IsGenesis() && len(b.Payload) != 0 { - return nil, ErrGenesisBlockNotEmpty - } return b, nil } diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go index 6249665ac..e09120d9a 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/nodeset-cache.go @@ -165,6 +165,12 @@ func (cache *NodeSetCache) GetLeaderNode(pos types.Position) ( return IDs.leaderNode[pos.Height], nil } +// Touch updates the internal cache of round. +func (cache *NodeSetCache) Touch(round uint64) (err error) { + _, err = cache.update(round) + return +} + func (cache *NodeSetCache) cloneMap( nIDs map[types.NodeID]struct{}) map[types.NodeID]struct{} { nIDsCopy := make(map[types.NodeID]struct{}, len(nIDs)) diff --git a/vendor/vendor.json b/vendor/vendor.json index f23bffa07..902311947 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -141,16 +141,16 @@ { "checksumSHA1": "8EuKVkP1v/w5fRuuvUaXX5k/F+I=", "path": "github.com/dexon-foundation/dexon-consensus/common", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "lBrWTbcqhk1+yYRdQ3185yJP5MQ=", + "checksumSHA1": "r+N+XXh95Zps97hB0mPsJ44eIgI=", "path": "github.com/dexon-foundation/dexon-consensus/core", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, @@ -165,64 +165,64 @@ { "checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "vTI0nncFqZ052WvofDhFxLw1Bk4=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "BhLKK8RveoLaeXc9UyUKMwQqchU=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "zpuCdMT8MGsy4pLgHKpg/Wd4izU=", "path": "github.com/dexon-foundation/dexon-consensus/core/db", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "T9TNx0oUpaRdlbCuy7AvkK1eQ18=", "path": "github.com/dexon-foundation/dexon-consensus/core/syncer", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "id8imcgp3SqYhIx0k3Chd0VZrUQ=", "path": "github.com/dexon-foundation/dexon-consensus/core/types", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "s28gYj+iji8oT7N7Su6HIFHMuwI=", "path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "C8Q8sfOSs+FPw/5sPwAR04QFc3U=", + "checksumSHA1": "GGQv132mkXvrjfhqP7zR65I95P4=", "path": "github.com/dexon-foundation/dexon-consensus/core/utils", - "revision": "aff897fd2385152a7bfd8a8ac0846ef5ad736b96", - "revisionTime": "2019-03-06T06:32:02Z", + "revision": "69c8d0dba506f640af4c5539fa424957cdd35db3", + "revisionTime": "2019-03-07T03:15:15Z", "version": "single-chain", "versionExact": "single-chain" }, |