Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/catalyst: return 0x0 on Invalid block on top of pow block #25006

Merged
merged 1 commit into from Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion eth/catalyst/api.go
Expand Up @@ -354,7 +354,12 @@ func computePayloadId(headBlockHash common.Hash, params *beacon.PayloadAttribute
func (api *ConsensusAPI) invalid(err error, latestValid *types.Block) beacon.PayloadStatusV1 {
currentHash := api.eth.BlockChain().CurrentBlock().Hash()
if latestValid != nil {
currentHash = latestValid.Hash()
// Set latest valid hash to 0x0 if parent is PoW block
currentHash = common.Hash{}
if latestValid.Difficulty().BitLen() == 0 {
// Otherwise set latest valid hash to parent hash
currentHash = latestValid.Hash()
}
}
errorMsg := err.Error()
return beacon.PayloadStatusV1{Status: beacon.INVALID, LatestValidHash: &currentHash, ValidationError: &errorMsg}
Expand Down
3 changes: 2 additions & 1 deletion eth/catalyst/api_test.go
Expand Up @@ -647,7 +647,8 @@ func TestEmptyBlocks(t *testing.T) {
if status.Status != beacon.INVALID {
t.Errorf("invalid status: expected INVALID got: %v", status.Status)
}
expected := commonAncestor.Hash()
// Expect 0x0 on INVALID block on top of PoW block
expected := common.Hash{}
if !bytes.Equal(status.LatestValidHash[:], expected[:]) {
t.Fatalf("invalid LVH: got %v want %v", status.LatestValidHash, expected)
}
Expand Down