MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / CheckEvidence

Method CheckEvidence

evidence/pool.go:192–230  ·  view source on GitHub ↗

CheckEvidence takes an array of evidence from a block and verifies all the evidence there. If it has already verified the evidence then it jumps to the next one. It ensures that no evidence has already been committed or is being proposed twice. It also adds any evidence that it doesn't currently hav

(evList types.EvidenceList)

Source from the content-addressed store, hash-verified

190// evidence has already been committed or is being proposed twice. It also adds any
191// evidence that it doesn't currently have so that it can quickly form ABCI Evidence later.
192func (evpool *Pool) CheckEvidence(evList types.EvidenceList) error {
193 hashes := make([][]byte, len(evList))
194 for idx, ev := range evList {
195
196 _, isLightEv := ev.(*types.LightClientAttackEvidence)
197
198 // We must verify light client attack evidence regardless because there could be a
199 // different conflicting block with the same hash.
200 if isLightEv || !evpool.isPending(ev) {
201 // check that the evidence isn't already committed
202 if evpool.isCommitted(ev) {
203 return &types.ErrInvalidEvidence{Evidence: ev, Reason: errors.New("evidence was already committed")}
204 }
205
206 err := evpool.verify(ev)
207 if err != nil {
208 return err
209 }
210
211 if err := evpool.addPendingEvidence(ev); err != nil {
212 // Something went wrong with adding the evidence but we already know it is valid
213 // hence we log an error and continue
214 evpool.logger.Error("Can't add evidence to pending list", "err", err, "ev", ev)
215 }
216
217 evpool.logger.Info("Check evidence: verified evidence of byzantine behavior", "evidence", ev)
218 }
219
220 // check for duplicate evidence. We cache hashes so we don't have to work them out again.
221 hashes[idx] = ev.Hash()
222 for i := idx - 1; i >= 0; i-- {
223 if bytes.Equal(hashes[i], hashes[idx]) {
224 return &types.ErrInvalidEvidence{Evidence: ev, Reason: errors.New("duplicate evidence")}
225 }
226 }
227 }
228
229 return nil
230}
231
232// EvidenceFront goes to the first evidence in the clist
233func (evpool *Pool) EvidenceFront() *clist.CElement {

Calls 8

isPendingMethod · 0.95
isCommittedMethod · 0.95
verifyMethod · 0.95
addPendingEvidenceMethod · 0.95
ErrorMethod · 0.65
InfoMethod · 0.65
HashMethod · 0.65
EqualMethod · 0.65