aboutsummaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-24 16:14:51 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:51 +0800
commit60e4a1212cc2690acea6898fa727a7900d14f3bf (patch)
treee88efd82ca90b47416e556ded40ef7a3bce37f04 /vendor
parent59d1677e97c4220b7fc25c38f831fb1dc807f805 (diff)
downloaddexon-60e4a1212cc2690acea6898fa727a7900d14f3bf.tar.gz
dexon-60e4a1212cc2690acea6898fa727a7900d14f3bf.tar.zst
dexon-60e4a1212cc2690acea6898fa727a7900d14f3bf.zip
vendor: sync consensus core
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go22
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice-data.go5
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice.go33
-rw-r--r--vendor/vendor.json30
4 files changed, 43 insertions, 47 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go
index c7bef4bb1..03855587c 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go
@@ -81,6 +81,10 @@ func (recv *consensusBAReceiver) ProposeVote(vote *types.Vote) {
func (recv *consensusBAReceiver) ProposeBlock() common.Hash {
block := recv.consensus.proposeBlock(recv.chainID, recv.round)
+ if block == nil {
+ recv.consensus.logger.Error("unable to propose block")
+ return nullBlockHash
+ }
recv.consensus.baModules[recv.chainID].addCandidateBlock(block)
if err := recv.consensus.preProcessBlock(block); err != nil {
recv.consensus.logger.Error("Failed to pre-process block", "error", err)
@@ -230,9 +234,6 @@ type Consensus struct {
authModule *Authenticator
currentConfig *types.Config
- // Modules.
- nbModule *nonBlocking
-
// BA.
baModules []*agreement
receivers []*consensusBAReceiver
@@ -248,6 +249,7 @@ type Consensus struct {
// Interfaces.
db blockdb.BlockDatabase
+ app Application
gov Governance
network Network
tickerObj Ticker
@@ -294,11 +296,9 @@ func NewConsensus(
authModule := NewAuthenticator(prv)
// Check if the application implement Debug interface.
debugApp, _ := app.(Debug)
- // Setup nonblocking module.
- nbModule := newNonBlocking(app, debugApp)
// Init lattice.
lattice := NewLattice(
- dMoment, config, authModule, nbModule, nbModule, db, logger)
+ dMoment, config, authModule, app, debugApp, db, logger)
// Init configuration chain.
ID := types.NewNodeID(prv.PublicKey())
recv := &consensusDKGReceiver{
@@ -321,7 +321,7 @@ func NewConsensus(
currentConfig: config,
ccModule: newCompactionChain(gov),
lattice: lattice,
- nbModule: nbModule,
+ app: app,
gov: gov,
db: db,
network: network,
@@ -814,7 +814,7 @@ func (con *Consensus) ProcessBlockRandomnessResult(
// preProcessBlock performs Byzantine Agreement on the block.
func (con *Consensus) preProcessBlock(b *types.Block) (err error) {
- if err = con.lattice.SanityCheck(b, true); err != nil {
+ if err = con.lattice.SanityCheck(b); err != nil {
return
}
if err = con.baModules[b.Position.ChainID].processBlock(b); err != nil {
@@ -849,7 +849,7 @@ func (con *Consensus) processBlock(block *types.Block) (err error) {
return
}
// TODO(mission): clone types.FinalizationResult
- con.nbModule.BlockDelivered(b.Hash, b.Finalization)
+ con.app.BlockDelivered(b.Hash, b.Finalization)
}
if err = con.lattice.PurgeBlocks(deliveredBlocks); err != nil {
return
@@ -859,7 +859,7 @@ func (con *Consensus) processBlock(block *types.Block) (err error) {
// processFinalizedBlock is the entry point for syncing blocks.
func (con *Consensus) processFinalizedBlock(block *types.Block) (err error) {
- if err = con.lattice.SanityCheck(block, false); err != nil {
+ if err = con.lattice.SanityCheck(block); err != nil {
return
}
con.ccModule.processFinalizedBlock(block)
@@ -878,7 +878,7 @@ func (con *Consensus) processFinalizedBlock(block *types.Block) (err error) {
}
err = nil
}
- con.nbModule.BlockDelivered(b.Hash, b.Finalization)
+ con.app.BlockDelivered(b.Hash, b.Finalization)
if b.Position.Round+2 == con.roundToNotify {
// Only the first block delivered of that round would
// trigger this noitification.
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice-data.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice-data.go
index 31604a6d7..b0fe9cfdd 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice-data.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice-data.go
@@ -268,11 +268,6 @@ func (data *latticeData) addBlock(
bAck *types.Block
updated bool
)
- // TODO(mission): sanity check twice, might hurt performance.
- // If a block does not pass sanity check, report error.
- if err = data.sanityCheck(block); err != nil {
- return
- }
if err = data.chains[block.Position.ChainID].addBlock(block); err != nil {
return
}
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice.go
index 0357a8d99..3259f3540 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/lattice.go
@@ -104,11 +104,10 @@ func (s *Lattice) PrepareEmptyBlock(b *types.Block) (err error) {
}
// SanityCheck check if a block is valid.
-// If checkRelation is true, it also checks with current lattice status.
//
// If some acking blocks don't exists, Lattice would help to cache this block
// and retry when lattice updated in Lattice.ProcessBlock.
-func (s *Lattice) SanityCheck(b *types.Block, checkRelation bool) (err error) {
+func (s *Lattice) SanityCheck(b *types.Block) (err error) {
if b.IsEmpty() {
// Only need to verify block's hash.
var hash common.Hash
@@ -134,6 +133,22 @@ func (s *Lattice) SanityCheck(b *types.Block, checkRelation bool) (err error) {
return
}
}
+ if err = func() (err error) {
+ s.lock.RLock()
+ defer s.lock.RUnlock()
+ if err = s.data.sanityCheck(b); err != nil {
+ // Add to block pool, once the lattice updated,
+ // would be checked again.
+ if err == ErrAckingBlockNotExists {
+ s.pool.addBlock(b)
+ }
+ s.logger.Error("Sanity Check failed", "error", err)
+ return
+ }
+ return
+ }(); err != nil {
+ return
+ }
// Verify data in application layer.
s.logger.Debug("Calling Application.VerifyBlock", "block", b)
// TODO(jimmy-dexon): handle types.VerifyRetryLater.
@@ -141,20 +156,6 @@ func (s *Lattice) SanityCheck(b *types.Block, checkRelation bool) (err error) {
err = ErrInvalidBlock
return err
}
- if !checkRelation {
- return
- }
- s.lock.RLock()
- defer s.lock.RUnlock()
- if err = s.data.sanityCheck(b); err != nil {
- // Add to block pool, once the lattice updated,
- // would be checked again.
- if err == ErrAckingBlockNotExists {
- s.pool.addBlock(b)
- }
- s.logger.Error("Sanity Check failed", "error", err)
- return
- }
return
}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index e0fd8cc5c..cd7af1a10 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -105,44 +105,44 @@
{
"checksumSHA1": "IKOLx0ZjJoT9x9zO/bVAXWcNXs8=",
"path": "github.com/dexon-foundation/dexon-consensus-core/common",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
- "checksumSHA1": "rcPl7V6DiiKQCvkX/h6THwOAGoc=",
+ "checksumSHA1": "h+9DsEkDRxBqu5/GHdNfRuNSYdY=",
"path": "github.com/dexon-foundation/dexon-consensus-core/core",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
"checksumSHA1": "69/j3ROwzhdGPWKymJnGjaJ5QzY=",
"path": "github.com/dexon-foundation/dexon-consensus-core/core/blockdb",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
"checksumSHA1": "GXHmtn3UlUftllBXI+M8RBkilzY=",
"path": "github.com/dexon-foundation/dexon-consensus-core/core/crypto",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
"checksumSHA1": "sh19Kk6G7esEcBPC2QsaFF3V/Ds=",
"path": "github.com/dexon-foundation/dexon-consensus-core/core/crypto/dkg",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
"checksumSHA1": "priVCcv7H4LTooiN/1EUu8qFiSs=",
"path": "github.com/dexon-foundation/dexon-consensus-core/core/crypto/ecdsa",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
"checksumSHA1": "dKIKJdmVmYKd1ihBAfEoOn6qeCc=",
"path": "github.com/dexon-foundation/dexon-consensus-core/core/types",
- "revision": "83c4f24de2aa8f13f6b97c06aa29f204b4fc2f8b",
- "revisionTime": "2018-10-23T09:14:47Z"
+ "revision": "47885b50ad94c3b34118554bed2a142717e6ee72",
+ "revisionTime": "2018-10-24T04:03:50Z"
},
{
"checksumSHA1": "TAkwduKZqLyimyTPPWIllZWYFuE=",