pub struct EquivocationDetector { /* private fields */ }Expand description
Tracks validator votes to detect equivocation
Implementations§
Source§impl EquivocationDetector
impl EquivocationDetector
Sourcepub fn with_storage(storage: Arc<dyn KvStore>) -> Self
pub fn with_storage(storage: Arc<dyn KvStore>) -> Self
Production constructor: write-through to CF_AUDIT under
equivocation/votes/* and equivocation/evidence/*. Hydrates
both maps on construction.
Sourcepub fn check_vote(&self, vote: &Vote) -> Result<Option<EquivocationEvidence>>
pub fn check_vote(&self, vote: &Vote) -> Result<Option<EquivocationEvidence>>
Records a vote and checks for equivocation Returns Ok(None) if no equivocation detected Returns Ok(Some(evidence)) if equivocation detected Returns Err if the vote itself is invalid
Sourcepub fn get_all_evidence(&self) -> Vec<EquivocationEvidence>
pub fn get_all_evidence(&self) -> Vec<EquivocationEvidence>
Gets all detected equivocation evidence
Sourcepub fn get_evidence(
&self,
validator: &Address,
view: u64,
) -> Option<EquivocationEvidence>
pub fn get_evidence( &self, validator: &Address, view: u64, ) -> Option<EquivocationEvidence>
Gets equivocation evidence for a specific validator and view
Sourcepub fn cleanup_old_votes(&self, min_view: u64)
pub fn cleanup_old_votes(&self, min_view: u64)
Clears votes for views below the given minimum (cleanup).
Prunes both the in-memory vote map AND the persisted
equivocation/votes/* rows — without the persisted delete, every
restart re-hydrated an unbounded backlog of stale votes that the
in-memory prune had already discarded (unbounded CF_AUDIT growth
plus stale-vote mis-fires after view-state resets).
Evidence is deliberately KEPT — in memory and on disk. Evidence is the slashing record; pruning it by view would let an equivocator outlast the cleanup window and escape the penalty.
Sourcepub fn vote_count(&self) -> usize
pub fn vote_count(&self) -> usize
Returns the number of tracked votes
Sourcepub fn evidence_count(&self) -> usize
pub fn evidence_count(&self) -> usize
Returns the number of detected equivocations