Skip to content

Commit 2227589

Browse files
eth/catalyst: return 0x0 on Invalid block on top of pow block (#25006)
1 parent 3c6d6f7 commit 2227589

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

eth/catalyst/api.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,12 @@ func computePayloadId(headBlockHash common.Hash, params *beacon.PayloadAttribute
354354
func (api *ConsensusAPI) invalid(err error, latestValid *types.Block) beacon.PayloadStatusV1 {
355355
currentHash := api.eth.BlockChain().CurrentBlock().Hash()
356356
if latestValid != nil {
357-
currentHash = latestValid.Hash()
357+
// Set latest valid hash to 0x0 if parent is PoW block
358+
currentHash = common.Hash{}
359+
if latestValid.Difficulty().BitLen() == 0 {
360+
// Otherwise set latest valid hash to parent hash
361+
currentHash = latestValid.Hash()
362+
}
358363
}
359364
errorMsg := err.Error()
360365
return beacon.PayloadStatusV1{Status: beacon.INVALID, LatestValidHash: &currentHash, ValidationError: &errorMsg}

eth/catalyst/api_test.go

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

0 commit comments

Comments
 (0)