Browse Source

evidence: don't stop evidence verification if an evidence fails (#5189)

pull/5188/head
Callum Waters 4 years ago
committed by GitHub
parent
commit
185cd5b8e5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 14 deletions
  1. +2
    -11
      evidence/pool.go
  2. +3
    -3
      evidence/reactor.go

+ 2
- 11
evidence/pool.go View File

@ -113,7 +113,7 @@ func (evpool *Pool) Update(block *types.Block, state sm.State) {
// prune pending, committed and potential evidence and polc's periodically
if block.Height%state.ConsensusParams.Evidence.MaxAgeNumBlocks == 0 {
evpool.logger.Debug("Pruning no longer necessary evidence")
evpool.logger.Debug("Pruning expired evidence")
evpool.pruneExpiredPOLC()
// NOTE: As this is periodic, this implies that there may be some pending evidence in the
// db that have already expired. However, expired evidence will also be removed whenever
@ -195,7 +195,7 @@ func (evpool *Pool) AddEvidence(evidence types.Evidence) error {
// 1) Verify against state.
if err := sm.VerifyEvidence(evpool.stateDB, state, ev, header); err != nil {
return fmt.Errorf("failed to verify %v: %w", ev, err)
return types.NewErrEvidenceInvalid(ev, err)
}
// For potential amnesia evidence, if this node is indicted it shall retrieve a polc
@ -709,12 +709,3 @@ func keyPOLCFromHeightAndRound(height int64, round int32) []byte {
func keySuffix(evidence types.Evidence) []byte {
return []byte(fmt.Sprintf("%s/%X", bE(evidence.Height()), evidence.Hash()))
}
// ErrInvalidEvidence returns when evidence failed to validate
type ErrInvalidEvidence struct {
Reason error
}
func (e ErrInvalidEvidence) Error() string {
return fmt.Sprintf("evidence is not valid: %v ", e.Reason)
}

+ 3
- 3
evidence/reactor.go View File

@ -75,15 +75,15 @@ func (evR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
for _, ev := range evis {
err := evR.evpool.AddEvidence(ev)
switch err.(type) {
case ErrInvalidEvidence:
evR.Logger.Error("Evidence is not valid", "evidence", evis, "err", err)
case *types.ErrEvidenceInvalid:
evR.Logger.Error(err.Error())
// punish peer
evR.Switch.StopPeerForError(src, err)
return
case nil:
default:
// continue to the next piece of evidence
evR.Logger.Error("Evidence has not been added", "evidence", evis, "err", err)
return
}
}
}


Loading…
Cancel
Save