diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-09 11:18:17 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:55 +0800 |
commit | 39eed97ed5fdc201b2d17f34ec23753b87e685b1 (patch) | |
tree | c58979348aa49603eeac7b1a2c73ca51a5ed3797 | |
parent | 06de3ff42efa5e53e56284d08928ee598cf40751 (diff) | |
download | go-tangerine-39eed97ed5fdc201b2d17f34ec23753b87e685b1.tar.gz go-tangerine-39eed97ed5fdc201b2d17f34ec23753b87e685b1.tar.zst go-tangerine-39eed97ed5fdc201b2d17f34ec23753b87e685b1.zip |
vendor: sync to latest core
6 files changed, 58 insertions, 33 deletions
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 ca7d10f2e..f1a383bb3 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -383,7 +383,11 @@ func (recv *consensusBAReceiver) ReportForkVote(v1, v2 *types.Vote) { } func (recv *consensusBAReceiver) ReportForkBlock(b1, b2 *types.Block) { - recv.consensus.gov.ReportForkBlock(b1, b2) + b1Clone := b1.Clone() + b2Clone := b2.Clone() + b1Clone.Payload = []byte{} + b2Clone.Payload = []byte{} + recv.consensus.gov.ReportForkBlock(b1Clone, b2Clone) } // consensusDKGReceiver implements dkgReceiver. @@ -1338,7 +1342,11 @@ func (con *Consensus) ProcessAgreementResult( return nil } // Sanity Check. - if err := VerifyAgreementResult(rand, con.nodeSetCache); err != nil { + notarySet, err := con.nodeSetCache.GetNotarySet(rand.Position.Round) + if err != nil { + return err + } + if err := VerifyAgreementResult(rand, notarySet); err != nil { con.baMgr.untouchAgreementResult(rand) return err } diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go index d39c24627..b414e1146 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/agreement.go @@ -176,7 +176,12 @@ func (a *agreement) processAgreementResult(r *types.AgreementResult) { a.logger.Trace("Agreement result cached", "result", r) return } - if err := core.VerifyAgreementResult(r, a.cache); err != nil { + notarySet, err := a.cache.GetNotarySet(r.Position.Round) + if err != nil { + a.logger.Error("unable to get notary set", "result", r, "error", err) + return + } + if err := core.VerifyAgreementResult(r, notarySet); err != nil { a.logger.Error("Agreement result verification failed", "result", r, "error", err) @@ -252,13 +257,18 @@ func (a *agreement) processNewCRS(round uint64) { a.latestCRSRound = round // Verify all pending results. for r := prevRound; r <= a.latestCRSRound; r++ { + notarySet, err := a.cache.GetNotarySet(r) + if err != nil { + a.logger.Error("Unable to get notary set", "round", r, "error", err) + continue + } pendingsForRound := a.pendingAgrs[r] if pendingsForRound == nil { continue } delete(a.pendingAgrs, r) for _, res := range pendingsForRound { - if err := core.VerifyAgreementResult(res, a.cache); err != nil { + if err := core.VerifyAgreementResult(res, notarySet); err != nil { a.logger.Error("Invalid agreement result", "result", res, "error", err) diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go index 0250cf29b..c9d5f840f 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go @@ -158,17 +158,13 @@ func HashConfigurationBlock( // VerifyAgreementResult perform sanity check against a types.AgreementResult // instance. func VerifyAgreementResult( - res *types.AgreementResult, cache *utils.NodeSetCache) error { + res *types.AgreementResult, notarySet map[types.NodeID]struct{}) error { if res.Position.Round >= DKGDelayRound { if len(res.Randomness) == 0 { return ErrMissingRandomness } return nil } - notarySet, err := cache.GetNotarySet(res.Position.Round) - if err != nil { - return err - } if len(res.Votes) < len(notarySet)*2/3+1 { return ErrNotEnoughVotes } diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go index 34bf08ff3..7fd3a7776 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go @@ -63,6 +63,12 @@ func VerifyBlockSignature(b *types.Block) (err error) { err = ErrIncorrectHash return } + return VerifyBlockSignatureWithoutPayload(b) +} + +// VerifyBlockSignatureWithoutPayload verifies the signature of types.Block but +// does not check if PayloadHash is correct. +func VerifyBlockSignatureWithoutPayload(b *types.Block) (err error) { hash, err := HashBlock(b) if err != nil { return diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/penalty-helper.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/penalty-helper.go index 2b2456c62..0b38474a6 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/penalty-helper.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/penalty-helper.go @@ -27,6 +27,8 @@ import ( var ( // ErrInvalidDKGMasterPublicKey means the DKG MasterPublicKey is invalid. ErrInvalidDKGMasterPublicKey = errors.New("invalid DKG master public key") + // ErrPayloadNotEmpty means the payload of block is not empty. + ErrPayloadNotEmpty = errors.New("payload not empty") ) // NeedPenaltyDKGPrivateShare checks if the proposer of dkg private share @@ -95,8 +97,11 @@ func NeedPenaltyForkBlock(block1, block2 *types.Block) (bool, error) { block1.Hash == block2.Hash { return false, nil } + if len(block1.Payload) != 0 || len(block2.Payload) != 0 { + return false, ErrPayloadNotEmpty + } verifyBlock := func(block *types.Block) (bool, error) { - err := VerifyBlockSignature(block) + err := VerifyBlockSignatureWithoutPayload(block) switch err { case nil: return true, nil diff --git a/vendor/vendor.json b/vendor/vendor.json index bfad63954..3423e04ea 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -141,16 +141,16 @@ { "checksumSHA1": "In6vBHYUsX7DUIGiFN2hQggBgvI=", "path": "github.com/dexon-foundation/dexon-consensus/common", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "kUp9PP8aT6Gw6BP2tXaPWcSrqLw=", + "checksumSHA1": "ccoiRDJLMikegFi9CPyJtrmJa3c=", "path": "github.com/dexon-foundation/dexon-consensus/core", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, @@ -165,64 +165,64 @@ { "checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "m5lUT04qSHKtFukvxjnFX5Jo2hI=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "BhLKK8RveoLaeXc9UyUKMwQqchU=", "path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "hj/KetWUHp+1CX+50V0QnCthfWc=", "path": "github.com/dexon-foundation/dexon-consensus/core/db", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "DILLD61kp1c3JZnyLZK84mMK9Jw=", + "checksumSHA1": "B+2VHG7l1JXbxjuL52d+yp54K1g=", "path": "github.com/dexon-foundation/dexon-consensus/core/syncer", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "zIgCdN4FJiAuPGMhB+/9YGK/Wgk=", "path": "github.com/dexon-foundation/dexon-consensus/core/types", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { "checksumSHA1": "lbG7yqVgzo2CV/CQPYjG78xp5jg=", "path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, { - "checksumSHA1": "Ht0TdiYL3/nJ0nV91rTgponeCPg=", + "checksumSHA1": "1VsJIshz0loXnGwCtrMM8SuIo6Y=", "path": "github.com/dexon-foundation/dexon-consensus/core/utils", - "revision": "337b5729c1cea837ac5ee8e1646dca587f52ebbd", - "revisionTime": "2019-04-08T07:31:25Z", + "revision": "a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8", + "revisionTime": "2019-04-09T03:17:03Z", "version": "single-chain", "versionExact": "single-chain" }, |