Skip to content

Commit 43f4f3c

Browse files
MariusVanDerWijdencp-wjhan
authored andcommitted
eth/catalyst: return 0x0 on Invalid block on top of pow block (ethereum#25006)
1 parent 65051f3 commit 43f4f3c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

eth/catalyst/api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ func computePayloadId(headBlockHash common.Hash, params *beacon.PayloadAttribute
361361
func (api *ConsensusAPI) invalid(err error, latestValid *types.Block) beacon.PayloadStatusV1 {
362362
currentHash := api.eth.BlockChain().CurrentBlock().Hash()
363363
if latestValid != nil {
364-
currentHash = latestValid.Hash()
364+
// Set latest valid hash to 0x0 if parent is PoW block
365+
currentHash = common.Hash{}
366+
if latestValid.Difficulty().BitLen() == 0 {
367+
// Otherwise set latest valid hash to parent hash
368+
currentHash = latestValid.Hash()
369+
}
365370
}
366371
errorMsg := err.Error()
367372
return beacon.PayloadStatusV1{Status: beacon.INVALID, LatestValidHash: &currentHash, ValidationError: &errorMsg}

eth/catalyst/api_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ func TestEmptyBlocks(t *testing.T) {
648648
if status.Status != beacon.INVALID {
649649
t.Errorf("invalid status: expected INVALID got: %v", status.Status)
650650
}
651-
expected := commonAncestor.Hash()
651+
// Expect 0x0 on INVALID block on top of PoW block
652+
expected := common.Hash{}
652653
if !bytes.Equal(status.LatestValidHash[:], expected[:]) {
653654
t.Fatalf("invalid LVH: got %v want %v", status.LatestValidHash, expected)
654655
}

0 commit comments

Comments
 (0)