Skip to content

Commit b49f6cb

Browse files
authored
consensus: verify header hash is same as input hash in getEpochSwitchInfo (#1627)
1 parent 25a70e8 commit b49f6cb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

consensus/XDPoS/engines/engine_v2/epochSwitch.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func (x *XDPoS_v2) getEpochSwitchInfo(chain consensus.ChainReader, header *types
4242
if h == nil {
4343
return nil, fmt.Errorf("[getEpochSwitchInfo] can not find header from db hash %v", hash.Hex())
4444
}
45+
} else {
46+
if h.Hash() != hash {
47+
return nil, fmt.Errorf("[getEpochSwitchInfo] header hash not match, header hash %v, input hash %v", h.Hash().Hex(), hash.Hex())
48+
}
4549
}
4650
isEpochSwitch, _, err := x.IsEpochSwitch(h)
4751
if err != nil {

0 commit comments

Comments
 (0)