aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-04-03 16:43:49 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:50:06 +0800
commit59bff3ac2672e3c30e4a3d917b9c84e35e5b6938 (patch)
treeb26a09c3d665ec6baabfe4b2a0017b48bbbc042b
parent5fae1cfd6f4575a5e6a788fb629db815995616ec (diff)
downloaddexon-59bff3ac2672e3c30e4a3d917b9c84e35e5b6938.tar.gz
dexon-59bff3ac2672e3c30e4a3d917b9c84e35e5b6938.tar.zst
dexon-59bff3ac2672e3c30e4a3d917b9c84e35e5b6938.zip
vendor: sync to latest core
-rw-r--r--dex/blockproposer.go7
-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
-rw-r--r--vendor/vendor.json44
4 files changed, 79 insertions, 31 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go
index 0b66a6cc1..8eaeb9761 100644
--- a/dex/blockproposer.go
+++ b/dex/blockproposer.go
@@ -121,10 +121,12 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) {
atomic.StoreInt32(&b.syncing, 1)
defer atomic.StoreInt32(&b.syncing, 0)
+ cb := b.dex.blockchain.CurrentBlock()
+
db := db.NewDatabase(b.dex.chainDb)
privkey := coreEcdsa.NewPrivateKeyFromECDSA(b.dex.config.PrivateKey)
- consensusSync := syncer.NewConsensus(b.dMoment, b.dex.app, b.dex.governance,
- db, b.dex.network, privkey, log.Root())
+ consensusSync := syncer.NewConsensus(cb.NumberU64(), b.dMoment, b.dex.app,
+ b.dex.governance, db, b.dex.network, privkey, log.Root())
// Start the watchCat.
b.watchCat.Start()
@@ -132,7 +134,6 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) {
log.Info("Started sync watchCat")
// Feed the current block we have in local blockchain.
- cb := b.dex.blockchain.CurrentBlock()
if cb.NumberU64() > 0 {
var block coreTypes.Block
if err := rlp.DecodeBytes(cb.Header().DexconMeta, &block); err != nil {
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()
diff --git a/vendor/vendor.json b/vendor/vendor.json
index f6e974cdd..b0334bc4b 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -141,16 +141,16 @@
{
"checksumSHA1": "In6vBHYUsX7DUIGiFN2hQggBgvI=",
"path": "github.com/dexon-foundation/dexon-consensus/common",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
- "checksumSHA1": "iFSmNrfc8OsbwuZtqF1njr6MPp0=",
+ "checksumSHA1": "7V+3tAuEC/s/sgOU2AxH/J6iMd0=",
"path": "github.com/dexon-foundation/dexon-consensus/core",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
@@ -165,64 +165,64 @@
{
"checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "mMdctxTa/jNwAwZjjYoyEZdLoF8=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "BhLKK8RveoLaeXc9UyUKMwQqchU=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "hj/KetWUHp+1CX+50V0QnCthfWc=",
"path": "github.com/dexon-foundation/dexon-consensus/core/db",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
- "checksumSHA1": "pxAzlI5kjyIAJSX+/aRGjjhR+pw=",
+ "checksumSHA1": "DILLD61kp1c3JZnyLZK84mMK9Jw=",
"path": "github.com/dexon-foundation/dexon-consensus/core/syncer",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "zIgCdN4FJiAuPGMhB+/9YGK/Wgk=",
"path": "github.com/dexon-foundation/dexon-consensus/core/types",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "QVeatfLQUBE8/vwjvVImyQiTijE=",
"path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "YooeNHTYxH05Ky5vnoyZsQR4/08=",
"path": "github.com/dexon-foundation/dexon-consensus/core/utils",
- "revision": "37bb1f320bbdd7ef1a33d400a3ea6b67e301a135",
- "revisionTime": "2019-04-02T11:03:14Z",
+ "revision": "1ebfe09074d9eb80ae6a3380d1b706035fd4c9c9",
+ "revisionTime": "2019-04-03T07:55:43Z",
"version": "single-chain",
"versionExact": "single-chain"
},