dig_slashing/participation/error.rs
1//! Errors produced by the participation tracker.
2//!
3//! Traces to: [SPEC §17.2](../../../docs/resources/SPEC.md),
4//! catalogue rows
5//! [DSL-078..080](../../../docs/requirements/domains/participation/specs/).
6//!
7//! # Scope
8//!
9//! Separate error enum from `SlashingError` — participation
10//! bookkeeping is a non-slashing code path, and mixing the two
11//! would force consumers to match exhaustively on variants that
12//! do not apply to them. The runtime may convert a
13//! `ParticipationError` into whatever its own error surface
14//! needs.
15
16use thiserror::Error;
17
18/// Failure modes for `ParticipationTracker` operations.
19///
20/// Traces to SPEC §17.2.
21#[derive(Debug, Clone, PartialEq, Eq, Error)]
22pub enum ParticipationError {
23 /// `attesting_indices[i] >= validator_count` — the tracker's
24 /// per-validator storage is sized at construction and cannot
25 /// accommodate indices beyond it.
26 ///
27 /// Raised by DSL-078 `record_attestation`. Carries the
28 /// offending index for diagnostics.
29 #[error("validator index out of range: {0}")]
30 IndexOutOfRange(u32),
31
32 /// `attesting_indices` is non-monotonic (some `w[0] > w[1]`).
33 ///
34 /// Raised by DSL-079 `record_attestation`. The evidence
35 /// canonicalisation layer (DSL-005) guarantees ascending
36 /// indices for any valid attestation; a violation here is
37 /// either a bug or a deliberately-malformed input.
38 #[error("attesting indices not strictly ascending")]
39 NonAscendingIndices,
40
41 /// `attesting_indices` contains a duplicate (some
42 /// `w[0] == w[1]`).
43 ///
44 /// Raised by DSL-079. Carries the duplicated index for
45 /// diagnostics. Distinct from `NonAscendingIndices` because
46 /// the two failure modes have different root causes (sort
47 /// bug vs dedup bug); keeping the variants separate lets
48 /// callers log accurately.
49 #[error("duplicate attesting index: {0}")]
50 DuplicateIndex(u32),
51}