Skip to content

Commit

Permalink
Fix wrong block hash value for the 1st EVM block with PrevRandao
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Nov 19, 2024
1 parent b3212e0 commit f64631b
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 f64631b

Please sign in to comment.