diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-09 11:17:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-09 11:17:03 +0800 |
commit | a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8 (patch) | |
tree | 9e67cf4e7077ca36929939965b8311a60624510a /core/utils | |
parent | 26c83d1cd15ab9225cb13d7324ac721b00a3fcd1 (diff) | |
download | tangerine-consensus-a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8.tar.gz tangerine-consensus-a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8.tar.zst tangerine-consensus-a10fb3e2cf82782da2d8d69c2b0a6209c11d82b8.zip |
core: remove payload from reportForkBlock (#555)
Diffstat (limited to 'core/utils')
-rw-r--r-- | core/utils/crypto.go | 6 | ||||
-rw-r--r-- | core/utils/penalty-helper.go | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/core/utils/crypto.go b/core/utils/crypto.go index 34bf08f..7fd3a77 100644 --- a/core/utils/crypto.go +++ b/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/core/utils/penalty-helper.go b/core/utils/penalty-helper.go index 2b2456c..0b38474 100644 --- a/core/utils/penalty-helper.go +++ b/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 |