Merge pull request #2202 from rlan35/s3

fix one-off beacon bad block fully
pull/2207/head
Leo Chen 5 years ago committed by GitHub
commit 2cfc6d074d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      core/block_validator.go

@ -32,6 +32,9 @@ import (
"github.com/harmony-one/harmony/internal/params"
)
// Beacon chain block 1213181 is a one-off block with empty receipts which is expected to be non-empty.
const beaconBadBlock = 1213181
// BlockValidator is responsible for validating block headers, uncles and
// processed state.
//
@ -89,14 +92,16 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
// Validate the received block's bloom with the one derived from the generated receipts.
// For valid blocks this should always validate to true.
rbloom := types.CreateBloom(receipts)
// Beacon chain block 1213181 is a one-off block with empty bloom which is expected to be non-empty.
// Beacon chain block 1213181 is a one-off block with empty receipts which is expected to be non-empty.
// Skip the validation for it to avoid failure.
if rbloom != header.Bloom() && (block.NumberU64() != 1213181 || block.ShardID() != 0) {
if rbloom != header.Bloom() && (block.NumberU64() != beaconBadBlock || block.ShardID() != 0) {
return fmt.Errorf("invalid bloom (remote: %x local: %x)", header.Bloom(), rbloom)
}
// Tre receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, R1]]))
receiptSha := types.DeriveSha(receipts)
if receiptSha != header.ReceiptHash() {
// Beacon chain block 1213181 is a one-off block with empty receipts which is expected to be non-empty.
// Skip the validation for it to avoid failure.
if receiptSha != header.ReceiptHash() && (block.NumberU64() != beaconBadBlock || block.ShardID() != 0) {
return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", header.ReceiptHash(), receiptSha)
}

Loading…
Cancel
Save