Skip to content

Commit

Permalink
Merge pull request #666 from onflow/mpeter/testnet-fix-wrong-block-hash
Browse files Browse the repository at this point in the history
Fix wrong block hash value for the 1st EVM block with `PrevRandao`
  • Loading branch information
m-Peter authored Nov 20, 2024
2 parents b3212e0 + f64631b commit 0c2ca41
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions storage/pebble/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ func (b *Blocks) getBlock(keyCode byte, key []byte) (*models.Block, error) {
}

if b.chainID == flowGo.Testnet && slices.Contains(testnetBrokenParentHashBlockHeights, block.Height) {
// Since we are going to modify the `block.ParentBlockHash` field,
// we need to set the `block.FixedHash` field. If we don't do so,
// `block.Hash()` will return a different hash.
blockHash, err := block.Hash()
if err != nil {
return nil, err
}
block.FixedHash = blockHash

parentBlock, err := b.getBlock(blockHeightKey, uint64Bytes(block.Height-1))
if err != nil {
return nil, err
Expand Down

0 comments on commit 0c2ca41

Please sign in to comment.