eth/catalyst: return 0x0 on Invalid block on top of pow block (#25006)
This commit is contained in:
parent
3c6d6f7ee8
commit
2227589f9b
@ -354,8 +354,13 @@ func computePayloadId(headBlockHash common.Hash, params *beacon.PayloadAttribute
|
|||||||
func (api *ConsensusAPI) invalid(err error, latestValid *types.Block) beacon.PayloadStatusV1 {
|
func (api *ConsensusAPI) invalid(err error, latestValid *types.Block) beacon.PayloadStatusV1 {
|
||||||
currentHash := api.eth.BlockChain().CurrentBlock().Hash()
|
currentHash := api.eth.BlockChain().CurrentBlock().Hash()
|
||||||
if latestValid != nil {
|
if latestValid != nil {
|
||||||
|
// 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()
|
currentHash = latestValid.Hash()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
errorMsg := err.Error()
|
errorMsg := err.Error()
|
||||||
return beacon.PayloadStatusV1{Status: beacon.INVALID, LatestValidHash: ¤tHash, ValidationError: &errorMsg}
|
return beacon.PayloadStatusV1{Status: beacon.INVALID, LatestValidHash: ¤tHash, ValidationError: &errorMsg}
|
||||||
}
|
}
|
||||||
|
@ -647,7 +647,8 @@ func TestEmptyBlocks(t *testing.T) {
|
|||||||
if status.Status != beacon.INVALID {
|
if status.Status != beacon.INVALID {
|
||||||
t.Errorf("invalid status: expected INVALID got: %v", status.Status)
|
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[:]) {
|
if !bytes.Equal(status.LatestValidHash[:], expected[:]) {
|
||||||
t.Fatalf("invalid LVH: got %v want %v", status.LatestValidHash, expected)
|
t.Fatalf("invalid LVH: got %v want %v", status.LatestValidHash, expected)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user