aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-04-03 16:43:49 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit89aed9c306ea8b1b712bf8e84c1f79b328e19052 (patch)
treee6f80dd9051bcf773ec8dbf0368426aec6b6f6eb /vendor/github.com
parentc597b2ff15aefcc73d55a0a3f8c8e0f6e18f083c (diff)
downloadgo-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.tar
go-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.tar.gz
go-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.tar.bz2
go-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.tar.lz
go-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.tar.xz
go-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.tar.zst
go-tangerine-89aed9c306ea8b1b712bf8e84c1f79b328e19052.zip
vendor: sync to latest core
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go28
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go31
2 files changed, 53 insertions, 6 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 8cb4c2e37..582a72e7d 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
@@ -159,6 +159,22 @@ func (mgr *agreementMgr) prepare() {
// Hacky way to make agreement module self contained.
mgr.recv.agreementModule = agr
mgr.baModule = agr
+ if round >= DKGDelayRound {
+ setting := mgr.generateSetting(round)
+ if setting == nil {
+ mgr.logger.Warn("Unable to prepare init setting", "round", round)
+ } else if _, exist := setting.dkgSet[mgr.ID]; exist {
+ mgr.logger.Debug("Preparing signer and npks.", "round", round)
+ npk, signer, err := mgr.con.cfgModule.getDKGInfo(round, false)
+ if err != nil {
+ mgr.logger.Error("Failed to prepare signer and npks.",
+ "round", round,
+ "error", err)
+ }
+ mgr.logger.Debug("Prepared signer and npks.",
+ "round", round, "signer", signer != nil, "npks", npk != nil)
+ }
+ }
return
}
@@ -362,7 +378,7 @@ func (mgr *agreementMgr) generateSetting(round uint64) *baRoundSetting {
var err error
dkgSet, err = mgr.cache.GetNotarySet(round)
if err != nil {
- mgr.logger.Error("Failed to get notarySet", "round", round)
+ mgr.logger.Error("Failed to get notarySet", "round", round, "error", err)
return nil
}
}
@@ -431,11 +447,6 @@ Loop:
default:
}
mgr.recv.isNotary = checkRound()
- // Run BA for this round.
- mgr.recv.restartNotary <- types.Position{
- Round: currentRound,
- Height: math.MaxUint64,
- }
mgr.voteFilter = utils.NewVoteFilter()
mgr.recv.emptyBlockHashMap = &sync.Map{}
if currentRound >= DKGDelayRound && mgr.recv.isNotary {
@@ -450,6 +461,11 @@ Loop:
mgr.recv.npks = nil
mgr.recv.psigSigner = nil
}
+ // Run BA for this round.
+ mgr.recv.restartNotary <- types.Position{
+ Round: currentRound,
+ Height: math.MaxUint64,
+ }
if err := mgr.baRoutineForOneRound(setting); err != nil {
mgr.logger.Error("BA routine failed",
"error", err,
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go
index f777e35bb..f4681a268 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/consensus.go
@@ -86,6 +86,7 @@ type Consensus struct {
// NewConsensus creates an instance for Consensus (syncer consensus).
func NewConsensus(
+ initHeight uint64,
dMoment time.Time,
app core.Application,
gov core.Governance,
@@ -122,9 +123,39 @@ func NewConsensus(
defer con.agreementWaitGroup.Done()
con.agreementModule.run()
}()
+ if err := con.deliverPendingBlocks(initHeight); err != nil {
+ panic(err)
+ }
return con
}
+func (con *Consensus) deliverPendingBlocks(height uint64) error {
+ if height >= con.initChainTipHeight {
+ return nil
+ }
+ blocks := make([]*types.Block, 0, con.initChainTipHeight-height)
+ hash, _ := con.db.GetCompactionChainTipInfo()
+ for {
+ block, err := con.db.GetBlock(hash)
+ if err != nil {
+ return err
+ }
+ if block.Position.Height == height {
+ break
+ }
+ blocks = append(blocks, &block)
+ hash = block.ParentHash
+ }
+ sort.Sort(types.BlocksByPosition(blocks))
+ for _, b := range blocks {
+ con.logger.Debug("Syncer BlockConfirmed", "block", b)
+ con.app.BlockConfirmed(*b)
+ con.logger.Debug("Syncer BlockDelivered", "block", b)
+ con.app.BlockDelivered(b.Hash, b.Position, b.Randomness)
+ }
+ return nil
+}
+
func (con *Consensus) assureBuffering() {
if func() bool {
con.lock.RLock()