Skip to main content

dig_slashing/
lib.rs

1//! # dig-slashing
2//!
3//! Validator slashing, attestation participation accounting, inactivity
4//! accounting, and fraud-proof appeal system for the DIG Network L2 blockchain.
5//!
6//! Traces to: [SPEC.md](../docs/resources/SPEC.md) v0.4+.
7//!
8//! # Scope
9//!
10//! Validator slashing only. Four discrete offenses (`ProposerEquivocation`,
11//! `InvalidBlock`, `AttesterDoubleVote`, `AttesterSurroundVote`). Continuous
12//! inactivity accounting (Ethereum Bellatrix parity). Optimistic slashing
13//! lifecycle with 8-epoch fraud-proof appeal window.
14//!
15//! DFSP / storage-provider slashing is **out of scope** — different
16//! subsystem, different future crate.
17//!
18//! # Re-exports
19//!
20//! The crate root re-exports every public type and constant named in any
21//! `DSL-NNN` requirement. Downstream consumers should import from here,
22//! not from individual modules, to keep dependency edges clean.
23//!
24//! # Module layout
25//!
26//! - [`constants`] — protocol constants (BPS, quotients, domain tags)
27//! - [`evidence`] — offense types, evidence envelopes, verifiers
28//!
29//! (Further modules land as their DSL-NNN requirements are implemented.)
30
31pub mod appeal;
32pub mod bonds;
33pub mod constants;
34pub mod error;
35pub mod evidence;
36pub mod inactivity;
37pub mod manager;
38pub mod orchestration;
39pub mod participation;
40pub mod pending;
41pub mod protection;
42pub mod remark;
43pub mod system;
44pub mod traits;
45
46// ── Public re-exports (alphabetical within category) ────────────────────────
47
48pub use appeal::{
49    AppealAdjudicationResult, AppealRejectReason, AppealSustainReason, AppealVerdict,
50    AttesterAppealGround, AttesterSlashingAppeal, BondSplitResult, ClawbackResult,
51    InvalidBlockAppeal, InvalidBlockAppealGround, ProposerAppealGround, ProposerSlashingAppeal,
52    ReporterPenalty, ShortfallAbsorption, SlashAppeal, SlashAppealPayload,
53    adjudicate_absorb_clawback_shortfall, adjudicate_appeal, adjudicate_rejected_challenge_open,
54    adjudicate_rejected_forfeit_appellant_bond, adjudicate_sustained_clawback_rewards,
55    adjudicate_sustained_forfeit_reporter_bond, adjudicate_sustained_reporter_penalty,
56    adjudicate_sustained_restore_status, adjudicate_sustained_revert_base_slash,
57    adjudicate_sustained_revert_collateral, adjudicate_sustained_status_reverted,
58    verify_attester_appeal_attestations_identical, verify_attester_appeal_empty_intersection,
59    verify_attester_appeal_invalid_indexed_attestation_structure,
60    verify_attester_appeal_not_slashable_by_predicate, verify_attester_appeal_signature_a_invalid,
61    verify_attester_appeal_signature_b_invalid,
62    verify_attester_appeal_validator_not_in_intersection,
63    verify_invalid_block_appeal_block_actually_valid,
64    verify_invalid_block_appeal_evidence_epoch_mismatch,
65    verify_invalid_block_appeal_failure_reason_mismatch,
66    verify_invalid_block_appeal_proposer_signature_invalid,
67    verify_proposer_appeal_headers_identical, verify_proposer_appeal_proposer_index_mismatch,
68    verify_proposer_appeal_signature_a_invalid, verify_proposer_appeal_signature_b_invalid,
69    verify_proposer_appeal_slot_mismatch, verify_proposer_appeal_validator_not_active_at_epoch,
70};
71pub use bonds::{BondError, BondEscrow, BondTag};
72pub use constants::{
73    APPELLANT_BOND_MOJOS, ATTESTATION_BASE_BPS, BASE_REWARD_FACTOR, BLS_PUBLIC_KEY_SIZE,
74    BLS_SIGNATURE_SIZE, BOND_AWARD_TO_WINNER_BPS, BPS_DENOMINATOR, DOMAIN_BEACON_ATTESTER,
75    DOMAIN_BEACON_PROPOSER, DOMAIN_SLASH_APPEAL, DOMAIN_SLASHING_EVIDENCE, EQUIVOCATION_BASE_BPS,
76    INACTIVITY_PENALTY_QUOTIENT, INACTIVITY_SCORE_BIAS, INACTIVITY_SCORE_RECOVERY_RATE,
77    INVALID_BLOCK_BASE_BPS, MAX_APPEAL_ATTEMPTS_PER_SLASH, MAX_APPEAL_PAYLOAD_BYTES,
78    MAX_APPEALS_PER_BLOCK, MAX_PENALTY_BPS, MAX_PENDING_SLASHES, MAX_SLASH_PROPOSAL_PAYLOAD_BYTES,
79    MAX_SLASH_PROPOSALS_PER_BLOCK, MAX_VALIDATORS_PER_COMMITTEE, MIN_ATTESTATION_INCLUSION_DELAY,
80    MIN_EFFECTIVE_BALANCE, MIN_EPOCHS_TO_INACTIVITY_PENALTY, MIN_SLASHING_PENALTY_QUOTIENT,
81    PROPORTIONAL_SLASHING_MULTIPLIER, PROPOSER_REWARD_QUOTIENT, PROPOSER_WEIGHT,
82    REPORTER_BOND_MOJOS, SLASH_APPEAL_REMARK_MAGIC_V1, SLASH_APPEAL_WINDOW_EPOCHS,
83    SLASH_EVIDENCE_REMARK_MAGIC_V1, SLASH_LOCK_EPOCHS, TIMELY_HEAD_FLAG_INDEX, TIMELY_HEAD_WEIGHT,
84    TIMELY_SOURCE_FLAG_INDEX, TIMELY_SOURCE_MAX_DELAY_SLOTS, TIMELY_SOURCE_WEIGHT,
85    TIMELY_TARGET_FLAG_INDEX, TIMELY_TARGET_MAX_DELAY_SLOTS, TIMELY_TARGET_WEIGHT,
86    WEIGHT_DENOMINATOR, WHISTLEBLOWER_REWARD_QUOTIENT,
87};
88pub use error::SlashingError;
89pub use evidence::{
90    AttestationData, AttesterSlashing, Checkpoint, IndexedAttestation, InvalidBlockProof,
91    InvalidBlockReason, OffenseType, ProposerSlashing, SignedBlockHeader, SlashingEvidence,
92    SlashingEvidencePayload, VerifiedEvidence, block_signing_message, verify_attester_slashing,
93    verify_evidence, verify_evidence_for_inclusion, verify_invalid_block, verify_proposer_slashing,
94};
95pub use inactivity::{InactivityScoreTracker, in_finality_stall};
96pub use manager::{FinalisationResult, PerValidatorSlash, SlashingManager, SlashingResult};
97pub use orchestration::{
98    EpochBoundaryReport, JustificationView, ReorgReport, rewind_all_on_reorg, run_epoch_boundary,
99};
100pub use participation::{
101    FlagDelta, ParticipationError, ParticipationFlags, ParticipationTracker, base_reward,
102    classify_timeliness, compute_flag_deltas, proposer_inclusion_reward,
103};
104pub use pending::{
105    AppealAttempt, AppealOutcome, PendingSlash, PendingSlashBook, PendingSlashStatus,
106};
107pub use protection::SlashingProtection;
108pub use remark::{
109    BlockAdmissionReport, encode_slash_appeal_remark_payload_v1,
110    encode_slashing_evidence_remark_payload_v1, enforce_block_level_appeal_caps,
111    enforce_block_level_slashing_caps, enforce_slash_appeal_mempool_dedup_policy,
112    enforce_slash_appeal_mempool_policy, enforce_slash_appeal_payload_cap,
113    enforce_slash_appeal_remark_admission, enforce_slash_appeal_terminal_status_policy,
114    enforce_slash_appeal_variant_policy, enforce_slash_appeal_window_policy,
115    enforce_slashing_evidence_mempool_dedup_policy, enforce_slashing_evidence_mempool_policy,
116    enforce_slashing_evidence_payload_cap, enforce_slashing_evidence_remark_admission,
117    parse_slash_appeals_from_conditions, parse_slashing_evidence_from_conditions,
118    process_block_admissions, slash_appeal_remark_puzzle_hash_v1,
119    slash_appeal_remark_puzzle_reveal_v1, slashing_evidence_remark_puzzle_hash_v1,
120    slashing_evidence_remark_puzzle_reveal_v1,
121};
122pub use system::{GenesisParameters, SlashingSystem};
123pub use traits::{
124    CollateralError, CollateralSlasher, EffectiveBalanceView, ExecutionOutcome, InvalidBlockOracle,
125    ProposerView, PublicKeyLookup, RewardClawback, RewardPayout, ValidatorEntry, ValidatorView,
126};
127
128// Re-export the slash-lookback window from `dig-epoch` so downstream
129// consumers do not need to pull the dep transitively to compute
130// `OffenseTooOld` boundaries for tests or REMARK-admission policy.
131// Per SPEC §2.7.
132pub use dig_epoch::SLASH_LOOKBACK_EPOCHS;