1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//! `SlashingEvidence` — outer wrapper that carries offense classification,
//! reporter identity, epoch, and the per-offense payload.
//!
//! Traces to: [SPEC.md §3.5](../../docs/resources/SPEC.md), catalogue rows
//! [DSL-002](../../docs/requirements/domains/evidence/specs/DSL-002.md) +
//! [DSL-010](../../docs/requirements/domains/evidence/specs/DSL-010.md) +
//! [DSL-157](../../docs/requirements/domains/evidence/specs/DSL-157.md).
//!
//! # Role
//!
//! Everything the lifecycle needs to ingest an offense report flows
//! through this envelope:
//!
//! - `offense_type` — tags the slash for base-penalty lookup
//! (DSL-001) and REMARK magic dispatch (DSL-102).
//! - `reporter_validator_index` + `reporter_puzzle_hash` — reward
//! routing (DSL-025) and self-accuse short-circuit (DSL-012).
//! - `epoch` — drives `OffenseTooOld` check (DSL-011) and bond-escrow
//! lifetime.
//! - `payload` — the variant-specific fraud proof bytes that verifiers
//! re-execute (DSL-013 / DSL-014..017 / DSL-018..020).
//!
//! # Content-addressed identity
//!
//! [`SlashingEvidence::hash`] (DSL-002) is the primary key for two
//! runtime structures:
//!
//! - `SlashingManager::processed` — dedup map keyed by envelope hash
//! (DSL-026 AlreadySlashed short-circuit).
//! - `BondEscrow::Reporter(hash)` — bond tag binding the reporter's
//! escrowed bond to the exact envelope they submitted (DSL-023).
//!
//! Both structures require bit-exact determinism AND total field coverage:
//! mutating any byte of the envelope MUST shift the hash, else a reporter
//! could submit a mutated envelope under a colliding key and double-spend
//! either the dedup slot or the bond.
//!
//! The digest is `SHA-256(DOMAIN_SLASHING_EVIDENCE || bincode(self))`
//! using `chia_sha2::Sha256` (same hasher as attester signing roots, so
//! one crypto stack for the whole crate).
//!
//! # Per-validator fan-out
//!
//! [`SlashingEvidence::slashable_validators`] (DSL-010) returns the list
//! of validator indices the evidence accuses. Proposer / InvalidBlock
//! always return `[proposer_index]` (cardinality 1); Attester returns
//! the sorted `slashable_indices()` intersection (cardinality 0..=N,
//! DSL-007).
use Sha256;
use Bytes32;
use ;
use crateDOMAIN_SLASHING_EVIDENCE;
use crateAttesterSlashing;
use crateInvalidBlockProof;
use crateOffenseType;
use crateProposerSlashing;
/// Per-offense fraud-proof payload.
///
/// One variant per `OffenseType`, but note that `AttesterDoubleVote` and
/// `AttesterSurroundVote` share the `Attester` variant: the two predicates
/// are distinguished by `verify_attester_slashing` (DSL-014 / DSL-015),
/// not by a payload tag.
///
/// Per [SPEC §3.5](../../docs/resources/SPEC.md).
///
/// # Enum size
///
/// The variants are deliberately asymmetric — `ProposerSlashing` carries
/// two full `L2BlockHeader`s (~1.5 KB), `Attester` carries two indexed
/// attestation index-lists (up to 2_048 × 4 bytes each), `InvalidBlock`
/// carries one header plus witness bytes. We accept the variance because
/// this enum is itself heap-resident inside `SlashingEvidence` and is
/// never used in tight loops — boxing would just add indirection to every
/// `hash()`/`bincode` path without changing the on-wire bytes or the
/// size of the enclosing `SlashingEvidence`. The wire format is what
/// matters, not the in-memory layout of a type that only ever lives one
/// per reporter-submission.
/// Slashing-evidence envelope.
///
/// Per [SPEC §3.5](../../docs/resources/SPEC.md). Fields are frozen wire
/// protocol; their order matters for the deterministic bincode serialization
/// consumed by [`SlashingEvidence::hash`] — do NOT reorder without bumping
/// the protocol version.