Browse Source

state.VerifyEvidence enforces EvidenceParams.MaxAge

pull/592/head
Ethan Buchman 7 years ago
parent
commit
cc418e5dab
2 changed files with 9 additions and 2 deletions
  1. +7
    -0
      state/state.go
  2. +2
    -2
      types/params.go

+ 7
- 0
state/state.go 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
}


+ 2
- 2
types/params.go View File

@ -40,7 +40,7 @@ type BlockGossip struct {
// EvidenceParams determine how we handle evidence of malfeasance
type EvidenceParams struct {
MaxHeightDiff int `json:"max_height_diff"` // only accept new evidence more recent than this
MaxAge int `json:"max_age"` // only accept new evidence more recent than this
}
// DefaultConsensusParams returns a default ConsensusParams.
@ -80,7 +80,7 @@ func DefaultBlockGossip() BlockGossip {
// DefaultEvidence Params returns a default EvidenceParams.
func DefaultEvidenceParams() EvidenceParams {
return EvidenceParams{
MaxHeightDiff: 100000, // 27.8 hrs at 1block/s
MaxAge: 100000, // 27.8 hrs at 1block/s
}
}


Loading…
Cancel
Save