diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-01-17 16:36:37 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:56 +0800 |
commit | 1dc1093dc48231aca0c1794a5a35c8595a1704c9 (patch) | |
tree | 307bcc63d9cb8e048c5127d15bdd69da689ec357 /vendor | |
parent | 4b309234c376b5d2fa083e00369683e35fa734b5 (diff) | |
download | dexon-1dc1093dc48231aca0c1794a5a35c8595a1704c9.tar.gz dexon-1dc1093dc48231aca0c1794a5a35c8595a1704c9.tar.zst dexon-1dc1093dc48231aca0c1794a5a35c8595a1704c9.zip |
core: sync to latest core (#158)
* vendor: sync to latest core
* param: Update config
* core: update genesis alloc
Diffstat (limited to 'vendor')
5 files changed, 57 insertions, 41 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go index e468e9c2e..d3cf533c6 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go @@ -258,13 +258,20 @@ func (mgr *agreementMgr) processAgreementResult( if isStop(aID) { return nil } - if result.Position.Newer(&aID) { + if result.Position == aID { mgr.logger.Info("Syncing BA", "position", &result.Position) + for key := range result.Votes { + if err := agreement.processVote(&result.Votes[key]); err != nil { + return err + } + } + } else if result.Position.Newer(&aID) { + mgr.logger.Info("Fast syncing BA", "position", &result.Position) nodes, err := mgr.cache.GetNodeSet(result.Position.Round) if err != nil { return err } - mgr.logger.Debug("Calling Network.PullBlocks for syncing BA", + mgr.logger.Debug("Calling Network.PullBlocks for fast syncing BA", "hash", result.BlockHash) mgr.network.PullBlocks(common.Hashes{result.BlockHash}) mgr.logger.Debug("Calling Governance.CRS", "round", result.Position.Round) @@ -459,16 +466,16 @@ Loop: "round", recv.round(), "chainID", setting.chainID) err = nil - nextHeight = oldPos.Height + nextHeight = restartPos.Height } - if isStop(oldPos) || nextHeight == 0 { + if isStop(restartPos) || nextHeight == 0 { break } - if nextHeight > oldPos.Height { + if nextHeight > restartPos.Height { break } mgr.logger.Debug("Lattice not ready!!!", - "old", &oldPos, "next", nextHeight) + "old", &restartPos, "next", nextHeight) time.Sleep(100 * time.Millisecond) } nextPos := types.Position{ diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go index 62bbe250f..c17c59f8a 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement.go @@ -545,17 +545,22 @@ func (a *agreement) addCandidateBlockNoLock(block *types.Block) { a.candidateBlock[block.Hash] = block } -func (a *agreement) findCandidateBlock(hash common.Hash) (*types.Block, bool) { - a.lock.RLock() - defer a.lock.RUnlock() - return a.findCandidateBlockNoLock(hash) -} - func (a *agreement) findCandidateBlockNoLock( hash common.Hash) (*types.Block, bool) { b, e := a.candidateBlock[hash] return b, e } + +// find a block in both candidate blocks and pending blocks in leader-selector. +// A block might be confirmed by others while we can't verify its validity. +func (a *agreement) findBlockNoLock(hash common.Hash) (*types.Block, bool) { + b, e := a.findCandidateBlockNoLock(hash) + if !e { + b, e = a.data.leader.findPendingBlock(hash) + } + return b, e +} + func (a *agreementData) countVote(period uint64, voteType types.VoteType) ( blockHash common.Hash, ok bool) { a.lock.RLock() 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 0754e800f..b84947a86 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -137,7 +137,7 @@ func (recv *consensusBAReceiver) ConfirmBlock( } } else { var exist bool - block, exist = recv.agreementModule.findCandidateBlockNoLock(hash) + block, exist = recv.agreementModule.findBlockNoLock(hash) if !exist { recv.consensus.logger.Error("Unknown block confirmed", "hash", hash.String()[:6], diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go index bcfa57fe6..214b4cb6e 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/leader-selector.go @@ -55,7 +55,7 @@ type leaderSelector struct { numCRS *big.Int minCRSBlock *big.Int minBlockHash common.Hash - pendingBlocks []*types.Block + pendingBlocks map[common.Hash]*types.Block validLeader validLeaderFn lock sync.Mutex logger common.Logger @@ -94,13 +94,12 @@ func (l *leaderSelector) restart(crs common.Hash) { l.hashCRS = crs l.minCRSBlock = maxHash l.minBlockHash = common.Hash{} - l.pendingBlocks = []*types.Block{} + l.pendingBlocks = make(map[common.Hash]*types.Block) } func (l *leaderSelector) leaderBlockHash() common.Hash { l.lock.Lock() defer l.lock.Unlock() - newPendingBlocks := []*types.Block{} for _, b := range l.pendingBlocks { ok, dist := l.potentialLeader(b) if !ok { @@ -109,15 +108,14 @@ func (l *leaderSelector) leaderBlockHash() common.Hash { ok, err := l.validLeader(b) if err != nil { l.logger.Error("Error checking validLeader", "error", err, "block", b) + delete(l.pendingBlocks, b.Hash) continue } if ok { l.updateLeader(b, dist) - } else { - newPendingBlocks = append(newPendingBlocks, b) + delete(l.pendingBlocks, b.Hash) } } - l.pendingBlocks = newPendingBlocks return l.minBlockHash } @@ -140,7 +138,7 @@ func (l *leaderSelector) processBlock(block *types.Block) error { return err } if !ok { - l.pendingBlocks = append(l.pendingBlocks, block) + l.pendingBlocks[block.Hash] = block return nil } l.updateLeader(block, dist) @@ -157,3 +155,9 @@ func (l *leaderSelector) updateLeader(block *types.Block, dist *big.Int) { l.minCRSBlock = dist l.minBlockHash = block.Hash } + +func (l *leaderSelector) findPendingBlock( + hash common.Hash) (*types.Block, bool) { + b, e := l.pendingBlocks[hash] + return b, e +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 6d367a737..d0f201e20 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -141,16 +141,16 @@ { "checksumSHA1": "ZUuiRqS6PnoNIvBmLStVQiyhkOM=", "path": "github.com/dexon-foundation/dexon-consensus/common", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { - "checksumSHA1": "TKAPWiezlt9t0oZca1Cq9S388lI=", + "checksumSHA1": "ki1Mf8qUb5j5ajqWNLggSpa7rac=", "path": "github.com/dexon-foundation/dexon-consensus/core", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, @@ -165,64 +165,64 @@ { "checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "W2P7pkuJ+26BpJg03K4Y0nB5obI=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "6Pf6caC8LTNCI7IflFmglKYnxYo=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "zpuCdMT8MGsy4pLgHKpg/Wd4izU=", "path": "github.com/dexon-foundation/dexon-consensus/core/db", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "eq19vhMpc90UUJ7I91ti5P2CkQ0=", "path": "github.com/dexon-foundation/dexon-consensus/core/syncer", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "zkrt3MOtqHPB3BmZtppZ9uesw3s=", "path": "github.com/dexon-foundation/dexon-consensus/core/types", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "rmv8uxwrqMhJAeA3RPvwYP8mFro=", "path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, { "checksumSHA1": "FUHa68Hif8F8YHmx4h0sQIUNp40=", "path": "github.com/dexon-foundation/dexon-consensus/core/utils", - "revision": "f4f572e4638309e523bbbde751547a9ea4d489bc", - "revisionTime": "2019-01-16T02:21:07Z", + "revision": "c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3", + "revisionTime": "2019-01-17T03:00:42Z", "version": "master", "versionExact": "master" }, |