consensus: verify header hash is same as input hash in getEpochSwitchInfo (#1627)

This commit is contained in:
Wanwiset Peerapatanapokin 2025-10-28 09:30:38 +07:00 committed by GitHub
parent 25a70e8770
commit b49f6cb0f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,6 +42,10 @@ func (x *XDPoS_v2) getEpochSwitchInfo(chain consensus.ChainReader, header *types
if h == nil {
return nil, fmt.Errorf("[getEpochSwitchInfo] can not find header from db hash %v", hash.Hex())
}
} else {
if h.Hash() != hash {
return nil, fmt.Errorf("[getEpochSwitchInfo] header hash not match, header hash %v, input hash %v", h.Hash().Hex(), hash.Hex())
}
}
isEpochSwitch, _, err := x.IsEpochSwitch(h)
if err != nil {