state.VerifyEvidence enforces EvidenceParams.MaxAge

This commit is contained in:
Ethan Buchman
2017-11-19 23:51:51 +00:00
parent c7acdfadf2
commit cc418e5dab
2 changed files with 9 additions and 2 deletions

View File

@ -389,6 +389,13 @@ func (s *State) GetValidators() (last *types.ValidatorSet, current *types.Valida
// NOTE: return error may be ErrNoValSetForHeight, in which case the validator set
// for the evidence height could not be loaded.
func (s *State) VerifyEvidence(evidence types.Evidence) (priority int, err error) {
evidenceAge := s.LastBlockHeight - evidence.Height()
maxAge := s.Params.EvidenceParams.MaxAge
if evidenceAge > maxAge {
return priority, fmt.Errorf("Evidence from height %d is too old. Min height is %d",
evidence.Height(), s.LastBlockHeight-maxAge)
}
if err := evidence.Verify(s.ChainID); err != nil {
return priority, err
}