@aztec-labs/slasher 6.0.0-nightly.20260829

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +232 -0
  2. package/dest/config.d.ts +6 -0
  3. package/dest/config.d.ts.map +1 -0
  4. package/dest/config.js +146 -0
  5. package/dest/factory/create_facade.d.ts +19 -0
  6. package/dest/factory/create_facade.d.ts.map +1 -0
  7. package/dest/factory/create_facade.js +49 -0
  8. package/dest/factory/create_implementation.d.ts +17 -0
  9. package/dest/factory/create_implementation.d.ts.map +1 -0
  10. package/dest/factory/create_implementation.js +25 -0
  11. package/dest/factory/get_settings.d.ts +4 -0
  12. package/dest/factory/get_settings.d.ts.map +1 -0
  13. package/dest/factory/get_settings.js +36 -0
  14. package/dest/factory/index.d.ts +3 -0
  15. package/dest/factory/index.d.ts.map +1 -0
  16. package/dest/factory/index.js +2 -0
  17. package/dest/generated/slasher-defaults.d.ts +21 -0
  18. package/dest/generated/slasher-defaults.d.ts.map +1 -0
  19. package/dest/generated/slasher-defaults.js +21 -0
  20. package/dest/index.d.ts +13 -0
  21. package/dest/index.d.ts.map +1 -0
  22. package/dest/index.js +12 -0
  23. package/dest/metrics.d.ts +23 -0
  24. package/dest/metrics.d.ts.map +1 -0
  25. package/dest/metrics.js +38 -0
  26. package/dest/null_slasher_client.d.ts +16 -0
  27. package/dest/null_slasher_client.d.ts.map +1 -0
  28. package/dest/null_slasher_client.js +30 -0
  29. package/dest/own_validator_slash_monitor.d.ts +66 -0
  30. package/dest/own_validator_slash_monitor.d.ts.map +1 -0
  31. package/dest/own_validator_slash_monitor.js +163 -0
  32. package/dest/slash_offenses_collector.d.ts +46 -0
  33. package/dest/slash_offenses_collector.d.ts.map +1 -0
  34. package/dest/slash_offenses_collector.js +114 -0
  35. package/dest/slash_round_monitor.d.ts +30 -0
  36. package/dest/slash_round_monitor.d.ts.map +1 -0
  37. package/dest/slash_round_monitor.js +52 -0
  38. package/dest/slasher_client.d.ts +118 -0
  39. package/dest/slasher_client.d.ts.map +1 -0
  40. package/dest/slasher_client.js +373 -0
  41. package/dest/slasher_client_facade.d.ts +44 -0
  42. package/dest/slasher_client_facade.d.ts.map +1 -0
  43. package/dest/slasher_client_facade.js +75 -0
  44. package/dest/slasher_client_interface.d.ts +25 -0
  45. package/dest/slasher_client_interface.d.ts.map +1 -0
  46. package/dest/slasher_client_interface.js +1 -0
  47. package/dest/stores/offenses_store.d.ts +37 -0
  48. package/dest/stores/offenses_store.d.ts.map +1 -0
  49. package/dest/stores/offenses_store.js +130 -0
  50. package/dest/stores/schema_version.d.ts +2 -0
  51. package/dest/stores/schema_version.d.ts.map +1 -0
  52. package/dest/stores/schema_version.js +1 -0
  53. package/dest/test/dummy_watcher.d.ts +11 -0
  54. package/dest/test/dummy_watcher.d.ts.map +1 -0
  55. package/dest/test/dummy_watcher.js +14 -0
  56. package/dest/watcher.d.ts +28 -0
  57. package/dest/watcher.d.ts.map +1 -0
  58. package/dest/watcher.js +2 -0
  59. package/dest/watchers/attestations_block_watcher.d.ts +47 -0
  60. package/dest/watchers/attestations_block_watcher.d.ts.map +1 -0
  61. package/dest/watchers/attestations_block_watcher.js +157 -0
  62. package/dest/watchers/attested_invalid_proposal_watcher.d.ts +42 -0
  63. package/dest/watchers/attested_invalid_proposal_watcher.d.ts.map +1 -0
  64. package/dest/watchers/attested_invalid_proposal_watcher.js +117 -0
  65. package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.d.ts +38 -0
  66. package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.d.ts.map +1 -0
  67. package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.js +138 -0
  68. package/dest/watchers/checkpoint_equivocation_watcher.d.ts +30 -0
  69. package/dest/watchers/checkpoint_equivocation_watcher.d.ts.map +1 -0
  70. package/dest/watchers/checkpoint_equivocation_watcher.js +69 -0
  71. package/dest/watchers/data_withholding_watcher.d.ts +69 -0
  72. package/dest/watchers/data_withholding_watcher.d.ts.map +1 -0
  73. package/dest/watchers/data_withholding_watcher.js +223 -0
  74. package/package.json +90 -0
  75. package/src/config.ts +177 -0
  76. package/src/factory/create_facade.ts +85 -0
  77. package/src/factory/create_implementation.ts +83 -0
  78. package/src/factory/get_settings.ts +58 -0
  79. package/src/factory/index.ts +2 -0
  80. package/src/generated/slasher-defaults.ts +23 -0
  81. package/src/index.ts +12 -0
  82. package/src/metrics.ts +58 -0
  83. package/src/null_slasher_client.ts +37 -0
  84. package/src/own_validator_slash_monitor.ts +183 -0
  85. package/src/slash_offenses_collector.ts +156 -0
  86. package/src/slash_round_monitor.ts +62 -0
  87. package/src/slasher_client.ts +477 -0
  88. package/src/slasher_client_facade.ts +99 -0
  89. package/src/slasher_client_interface.ts +31 -0
  90. package/src/stores/offenses_store.ts +173 -0
  91. package/src/stores/schema_version.ts +1 -0
  92. package/src/test/dummy_watcher.ts +20 -0
  93. package/src/watcher.ts +35 -0
  94. package/src/watchers/attestations_block_watcher.ts +199 -0
  95. package/src/watchers/attested_invalid_proposal_watcher.ts +167 -0
  96. package/src/watchers/broadcasted_invalid_checkpoint_proposal_watcher.ts +191 -0
  97. package/src/watchers/checkpoint_equivocation_watcher.ts +95 -0
  98. package/src/watchers/data_withholding_watcher.ts +256 -0
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ # Slasher
2
+
3
+ ## Overview
4
+
5
+ The slasher module implements validator slashing for the Aztec network. Slashing punishes validators who misbehave or are inactive by reducing their stake. This mechanism ensures network security and liveness.
6
+
7
+ ## Usage
8
+
9
+ The slasher is integrated into the Aztec node and activates when:
10
+ 1. The node is configured as a validator
11
+ 2. The validator is selected as proposer for a slot
12
+ 3. Slashable offenses have been detected
13
+
14
+ No manual intervention is required for normal operation. The slasher client handles:
15
+ - Monitoring for offenses
16
+ - Generating appropriate slash actions
17
+ - Coordinating with the SequencerPublisher for L1 execution
18
+
19
+ ## Slashing Model
20
+
21
+ The slashing model uses consensus-based voting where proposers vote on individual validator offenses. Time is divided into rounds, and during each round, proposers submit votes indicating which validators from a given past round should be slashed (eg round N votes to slash the validators from round N-2). Votes are encoded as bytes where each validator's vote is represented by 2 bits indicating the slash amount (0-3 slash units) for each validator. The L1 contract tallies votes and slashes validators that reach quorum.
22
+
23
+ Key characteristics:
24
+ - Proposers vote directly on validator offenses
25
+ - Requires a slash offset to vote on validators from past rounds
26
+ - Requires quorum to execute slashing
27
+ - L1 contract determines which offenses reach consensus
28
+ - Execution happens after a delay period for review
29
+ - Slash payloads can be vetoed during the execution delay period
30
+
31
+ ## Architecture
32
+
33
+ ### Core Components
34
+
35
+ #### SlasherClientInterface
36
+ Interface implemented by the slasher client. Provides methods for:
37
+ - `getProposerActions()`: Returns actions for the current proposer
38
+ - `gatherOffensesForRound()`: Collects offenses for a specific round
39
+
40
+ #### SlashOffensesCollector
41
+ Collects slashable offenses from watchers and stores them in the offenses store. Features:
42
+ - Subscribes to `WANT_TO_SLASH_EVENT` from watchers
43
+ - Manages offense lifecycle and automatic expiration
44
+
45
+ #### SlasherOffensesStore
46
+ Persistent storage for offenses. Tracks:
47
+ - Pending offenses awaiting slashing
48
+ - Executed offenses to prevent double slashing
49
+ - Round-based offense organization
50
+ - Automatic expiration of old offenses based on configurable rounds
51
+
52
+ #### SlashRoundMonitor
53
+ Monitors slashing rounds and triggers actions on round transitions:
54
+ - Tracks current round based on L2 slots
55
+ - Emits events when rounds change
56
+
57
+ #### ProposerSlashAction
58
+ Actions returned by the slasher client to the SequencerPublisher:
59
+ - `vote-offenses`: Vote on validator offenses
60
+ - `execute-slash`: Execute slashing for a round that reached quorum
61
+
62
+ ### Integration Flow
63
+
64
+ 1. **Offense Detection**: Watchers monitor the network and emit `WANT_TO_SLASH_EVENT` when they detect violations
65
+ 2. **Offense Collection**: SlashOffensesCollector receives events and stores offenses in SlasherOffensesStore
66
+ 3. **Action Generation**: When a validator is proposer, the slasher client generates ProposerSlashActions
67
+ 4. **Action Execution**: SequencerPublisher receives actions and executes them on L1
68
+ 5. **Round Monitoring**: SlashRoundMonitor tracks rounds and triggers execution when conditions are met
69
+
70
+ ## Vetoing
71
+
72
+ The slashing system includes a veto mechanism that allows designated vetoers to block slash payloads during the execution delay period. When a slash payload is ready for execution, the system first checks if it has been vetoed before proceeding.
73
+
74
+ Key features:
75
+ - Slash payloads can be vetoed by authorized addresses on the L1 slasher contract
76
+ - Veto checks are performed automatically before execution attempts
77
+ - The veto mechanism provides a safety valve for incorrectly proposed slashes
78
+
79
+ ## Slashable Offenses
80
+
81
+ List of all slashable offenses in the system:
82
+
83
+ ### DATA_WITHHOLDING
84
+ **Description**: The transaction data for a published checkpoint was not made available within the tolerance window.
85
+ **Detection**: DataWithholdingWatcher checks each published checkpoint's txs against the local mempool once `slashDataWithholdingToleranceSlots` full slots have elapsed past the checkpoint's slot (i.e. at `slotStart(checkpoint.slot + slashDataWithholdingToleranceSlots + 1)`).
86
+ **Target**: Validators who attested to the checkpoint.
87
+ **Time Unit**: Slot-based offense (the checkpoint's slot).
88
+
89
+ ### INACTIVITY
90
+ **Description**: A proposer failed to attest or propose blocks during their assigned slots.
91
+ **Detection**: Sentinel tracks validator performance and identifies validators who miss attestations beyond threshold.
92
+ **Target**: Individual inactive validator.
93
+ **Time Unit**: Epoch-based offense.
94
+
95
+ ### BROADCASTED_INVALID_BLOCK_PROPOSAL
96
+ **Description**: A proposer broadcast an invalid block proposal over the p2p network.
97
+ **Detection**: Validators detect invalid proposals during attestation validation.
98
+ **Target**: Proposer who broadcast the invalid block.
99
+ **Time Unit**: Slot-based offense.
100
+
101
+ ### PROPOSED_INSUFFICIENT_ATTESTATIONS
102
+ **Description**: A proposer submitted a block to L1 without sufficient committee attestations.
103
+ **Detection**: AttestationsBlockWatcher checks L1 blocks for attestation count.
104
+ **Target**: Block proposer.
105
+ **Time Unit**: Slot-based offense.
106
+
107
+ ### PROPOSED_INCORRECT_ATTESTATIONS
108
+ **Description**: A proposer submitted a block to L1 with signatures from non-committee members.
109
+ **Detection**: AttestationsBlockWatcher validates attestation signatures against committee membership.
110
+ **Target**: Block proposer.
111
+ **Time Unit**: Slot-based offense.
112
+
113
+ ### PROPOSED_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS
114
+ **Description**: A proposer published a checkpoint to L1 that builds on an invalid checkpoint (one with invalid or insufficient attestations).
115
+ **Detection**: AttestationsBlockWatcher tracks invalid checkpoints and their descendants.
116
+ **Target**: Proposer of the descendant checkpoint.
117
+ **Time Unit**: Slot-based offense.
118
+
119
+ ### DUPLICATE_PROPOSAL
120
+ **Description**: A proposer sent multiple block or checkpoint proposals for the same position (slot and indexWithinCheckpoint for blocks, or slot for checkpoints) with different content. Since each slot has exactly one designated proposer, sending conflicting proposals is equivocation. This also covers the case where a proposer broadcasts one checkpoint proposal via P2P but submits a different checkpoint to L1 for the same slot.
121
+ **Detection**: Detected in two places. (1) The P2P layer flags duplicates when a second proposal arrives for the same position with a different archive; the AttestationPool tracks proposals by position and the first duplicate is propagated (Accept) so other validators can witness the offense. (2) CheckpointEquivocationWatcher compares the archive root of each L1-confirmed checkpoint against retained signed P2P checkpoint proposals from the same slot's proposer and flags any mismatch.
122
+ **Target**: Proposer who broadcast the duplicate proposal.
123
+ **Time Unit**: Slot-based offense.
124
+
125
+ ### DUPLICATE_ATTESTATION
126
+ **Description**: A validator signed attestations for different checkpoint proposals (different archives) at the same slot. Validators must attest to at most one checkpoint per slot, so signing conflicting attestations is equivocation.
127
+ **Detection**: The P2P AttestationPool tracks attestations by slot and signer. A second attestation from the same signer for a different proposal at the same slot triggers the duplicate-attestation callback; the duplicate is propagated (Accept) so other validators can witness the offense. The ValidatorClient emits the slash event.
128
+ **Target**: The attester who equivocated.
129
+ **Time Unit**: Slot-based offense.
130
+
131
+ ### ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL
132
+ **Description**: A committee member attested to a checkpoint proposal in a slot where this node detected a slashable invalid block proposal.
133
+ **Detection**: ValidatorClient marks slots with invalid block proposals detected via reexecution and slashes checkpoint attesters seen for that slot. If proposal equivocation is later detected for the slot, pending bad-attestation offenses are cleared.
134
+ **Target**: Committee members who attested in the invalid proposal slot.
135
+ **Time Unit**: Slot-based offense.
136
+
137
+ ### BROADCASTED_INVALID_CHECKPOINT_PROPOSAL
138
+ **Description**: A proposer broadcast an invalid checkpoint proposal, either one that terminates before a higher-index block proposal signed by the same proposer in the same slot, one whose signed header does not match deterministic validator recomputation, or one with a malformed fee asset price modifier. The first case also covers AZIP-7's _Submitting Block Proposal After Checkpoint_: a later block signed by the same proposer in the same slot makes the prior checkpoint retroactively invalid.
139
+ **Detection**: BroadcastedInvalidCheckpointProposalWatcher scans retained P2P proposal evidence and compares checkpoint archive roots to signed block proposals from the same slot and signer. ValidatorClient also validates checkpoint proposals during the all-nodes callback and emits this offense when checkpoint header recomputation fails or the signed fee asset price modifier is malformed.
140
+ **Target**: Proposer who broadcast the invalid checkpoint proposal.
141
+ **Time Unit**: Slot-based offense.
142
+
143
+ ## Configuration
144
+
145
+ ### L1 System Settings (L1ContractsConfig)
146
+ These settings are deployed with the L1 contracts and apply system-wide to the protocol:
147
+
148
+ - `slashingQuorumSize`: Votes required to slash (defaults to half the validators in a round, plus one)
149
+ - `slashingRoundSizeInEpochs`: Number of epochs per slashing round
150
+ - `slashingOffsetInRounds`: How many rounds to look back for offenses
151
+ - `slashingExecutionDelayInRounds`: Rounds to wait before execution
152
+ - `slashingLifetimeInRounds`: Maximum age of executable rounds
153
+ - `slashingAmounts`: Valid values for each individual slash
154
+
155
+ Considerations:
156
+
157
+ - The `slashingQuorumSize` should be more than half and less than the total number of validators in a round, so that we require a majority to slash. The number of validators in a round is the committee size times the number of epochs in a round.
158
+ - The bigger a `slashingRoundSizeInEpochs`, the bigger the upper bound on the quorum size. This increases security, as we need more validators to agree before slashing. However, it also makes slashing slower, and more expensive to execute in terms of gas.
159
+ - The `slashingOffsetInRounds` is required because the validators in a given slashing round must vote for _past_ offenses. Otherwise, if someone commits an offense near the end of a round, they can get away with their offense without the validators being able to collect enough votes to slash them. The offset needs to be big enough so that all offenses are discoverable, so this value should be strictly greater than the data-withholding tolerance window so that there is time to detect missing data and vote.
160
+ - The `slashingExecutionDelayInRounds` allows vetoers to stop an invalid slash. This should be large enough to give vetoers time to act, but strictly smaller than the validator exit window, so an offender cannot escape before they are slashed. It should also be small enough so that an offender that would be kicked out does not get picked up to be a committee member again before their slash is executed. In other words, if a validator commits a serious enough offense that we want them out of the validator set as soon as possible, the execution delay should not allow them to be chosen to participate in another committee.
161
+
162
+ ### Local Node Configuration (SlasherConfig)
163
+
164
+ These settings are configured locally on each validator node:
165
+
166
+ Block and checkpoint validation settings are expected to be the same across all validators. Slashing relies on
167
+ validators making the same deterministic validity decisions for block and checkpoint proposals; operators should not run
168
+ with divergent validation limits.
169
+
170
+ - `slashGracePeriodL2Slots`: Number of initial L2 slots where slashing is disabled
171
+ - `slashOffenseExpirationRounds`: Number of rounds after which pending offenses expire
172
+ - `slashValidatorsAlways`: Array of validator addresses that should always be slashed
173
+ - `slashValidatorsNever`: Array of validator addresses that should never be slashed (own validator addresses are automatically added to this list)
174
+ - `slashInactivityTargetPercentage`: Percentage of misses during an epoch to be slashed for INACTIVITY
175
+ - `slashInactivityConsecutiveEpochThreshold`: How many consecutive inactive epochs are needed to trigger an INACTIVITY slash on a validator
176
+ - `slashDataWithholdingPenalty`: Penalty for DATA_WITHHOLDING
177
+ - `slashDataWithholdingToleranceSlots`: Number of full L2 slots to wait after a checkpoint's slot before declaring its txs missing
178
+ - `slashInactivityPenalty`: Penalty for INACTIVITY
179
+ - `slashBroadcastedInvalidBlockPenalty`: Penalty for BROADCASTED_INVALID_BLOCK_PROPOSAL
180
+ - `slashBroadcastedInvalidCheckpointProposalPenalty`: Penalty for BROADCASTED_INVALID_CHECKPOINT_PROPOSAL
181
+ - `slashDuplicateProposalPenalty`: Penalty for DUPLICATE_PROPOSAL
182
+ - `slashDuplicateAttestationPenalty`: Penalty for DUPLICATE_ATTESTATION
183
+ - `slashProposeInvalidAttestationsPenalty`: Penalty for PROPOSED_INSUFFICIENT_ATTESTATIONS and PROPOSED_INCORRECT_ATTESTATIONS
184
+ - `slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty`: Penalty for PROPOSED_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS
185
+ - `slashAttestInvalidCheckpointProposalPenalty`: Penalty for ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL
186
+ - `slashUnknownPenalty`: Default penalty for unknown offense types
187
+ - `slashMaxPayloadSize`: Limits the number of **unique validators** (across all committees and epochs in a round) that receive non-zero votes. When this cap is hit, the lowest-severity validator-epoch pairs are zeroed out first, so the most severe slashes are always preserved. Note that multiple offenses for the same validator in the same epoch are summed and counted as a single validator entry against this limit.
188
+
189
+ Considerations:
190
+
191
+ - All penalties should map to one of the `slashingAmounts`. A penalty lower than the smallest slashing amount will not be executable, and a penalty greater than the maximum will be capped at the maximum value.
192
+ - The `slashOffenseExpirationRounds` should be strictly larger than the `slashingOffsetInRounds`. This can be a relatively large value, as it's used only for data store cleanup.
193
+
194
+ ## Offenses In-Depth
195
+
196
+ Details about specific offenses in the system:
197
+
198
+ ### Inactivity
199
+
200
+ Inactivity slashing is one of the most critical, since it allows purging validators that are not fulfilling their duties, which could potentially bring the chain to a halt. This slashing must be aggressive enough to balance out the rate of the entry queue, in case the queue is filled with inactive validators. Furthermore, if enough inactive validators join the system, it may become impossible to gather enough quorum to pass any governance proposal.
201
+
202
+ Inactivity slashing is handled by the `Sentinel` (in `aztec-node/src/sentinel/`), which monitors performance of all validators slot-by-slot. With the multiple-blocks-per-slot model, block proposals and checkpoints are distinct concepts: proposers build multiple blocks per slot, but attestations are only for checkpoints. After each slot, the sentinel assigns one of the following to the proposer for the slot, in highest-confidence order:
203
+
204
+ - `checkpoint-mined` — a checkpoint covering this slot has landed on L1
205
+ - `checkpoint-valid` — the local node re-executed a checkpoint proposal for this slot successfully
206
+ - `checkpoint-invalid` — the local node re-executed a checkpoint proposal for this slot and rejected it (header / archive / out-hash mismatch, limit breach, etc.). Proposer-fault
207
+ - `checkpoint-unvalidated` — a checkpoint proposal arrived but the local node could not validate it (missing blocks/txs, timeout). Treated as proposer-fault
208
+ - `checkpoint-missed` — block proposals seen on P2P but no checkpoint proposal at all
209
+ - `blocks-missed` — no block proposals seen for this slot at all
210
+
211
+ Re-execution outcomes are read from the `CheckpointReexecutionTracker`, which the validator client populates at every early-return in `validateCheckpointProposal`. The same tracker is consumed by the data-withholding watcher via `hasReexecuted(checkpointNumber, archiveRoot)`.
212
+
213
+ Each non-proposer committee member is assigned one of:
214
+ - `attestation-sent` if their checkpoint attestation was seen on L1 or on the P2P network
215
+ - `attestation-missed` if the proposer status was `checkpoint-mined` or `checkpoint-valid` but no checkpoint attestation was seen
216
+ - none in any other case
217
+
218
+ `blocks-missed`, `checkpoint-missed`, `checkpoint-invalid`, and `checkpoint-unvalidated` all count as proposer inactivity for the slot.
219
+
220
+ The sentinel evaluates an epoch once `sentinelEpochEndBufferSlots` (default 2) L2 slots have elapsed past the epoch's last slot AND the per-slot recorder has covered that last slot. Epoch evaluation does not wait for an L1 proof — it relies on local-state evidence (the re-execution tracker plus L1 checkpoint landings) — so inactive validators are slashed promptly regardless of prover availability.
221
+
222
+ At end-of-epoch evaluation, for each validator such that:
223
+
224
+ ```
225
+ total_failures = count(blocks-missed) + count(checkpoint-missed)
226
+ + count(checkpoint-invalid) + count(checkpoint-unvalidated)
227
+ + count(attestation-missed)
228
+ total = count(checkpoint-*) + count(blocks-*) + count(attestation-*)
229
+ total_failures / total >= slashInactivityTargetPercentage
230
+ ```
231
+
232
+ they are voted to be slashed for inactivity. If `slashInactivityConsecutiveEpochThreshold` is greater than one, the above must also hold for the last `threshold` times the validator was part of a committee.
@@ -0,0 +1,6 @@
1
+ import type { ConfigMappingsType } from '@aztec-labs/foundation/config';
2
+ import type { SlasherConfig } from '@aztec-labs/stdlib/interfaces/server';
3
+ export type { SlasherConfig };
4
+ export declare const DefaultSlasherConfig: SlasherConfig;
5
+ export declare const slasherConfigMappings: ConfigMappingsType<SlasherConfig>;
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFReEUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFJMUUsWUFBWSxFQUFFLGFBQWEsRUFBRSxDQUFDO0FBRTlCLGVBQU8sTUFBTSxvQkFBb0IsRUFBRSxhQTBCbEMsQ0FBQztBQUVGLGVBQU8sTUFBTSxxQkFBcUIsRUFBRSxrQkFBa0IsQ0FBQyxhQUFhLENBc0luRSxDQUFDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAQxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAI1E,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,eAAO,MAAM,oBAAoB,EAAE,aA0BlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,aAAa,CAsInE,CAAC"}
package/dest/config.js ADDED
@@ -0,0 +1,146 @@
1
+ import { bigintConfigHelper, booleanConfigHelper, floatConfigHelper, numberConfigHelper } from '@aztec-labs/foundation/config';
2
+ import { EthAddress } from '@aztec-labs/foundation/eth-address';
3
+ import { slasherDefaultEnv } from './generated/slasher-defaults.js';
4
+ export const DefaultSlasherConfig = {
5
+ slashOverridePayload: undefined,
6
+ slashValidatorsAlways: [],
7
+ slashValidatorsNever: [],
8
+ slashDataWithholdingPenalty: BigInt(slasherDefaultEnv.SLASH_DATA_WITHHOLDING_PENALTY),
9
+ slashDataWithholdingToleranceSlots: slasherDefaultEnv.SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS,
10
+ slashInactivityTargetPercentage: slasherDefaultEnv.SLASH_INACTIVITY_TARGET_PERCENTAGE,
11
+ slashInactivityConsecutiveEpochThreshold: slasherDefaultEnv.SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD,
12
+ slashBroadcastedInvalidBlockPenalty: BigInt(slasherDefaultEnv.SLASH_INVALID_BLOCK_PENALTY),
13
+ slashBroadcastedInvalidCheckpointProposalPenalty: BigInt(slasherDefaultEnv.SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY),
14
+ slashDuplicateProposalPenalty: BigInt(slasherDefaultEnv.SLASH_DUPLICATE_PROPOSAL_PENALTY),
15
+ slashDuplicateAttestationPenalty: BigInt(slasherDefaultEnv.SLASH_DUPLICATE_ATTESTATION_PENALTY),
16
+ slashInactivityPenalty: BigInt(slasherDefaultEnv.SLASH_INACTIVITY_PENALTY),
17
+ slashProposeInvalidAttestationsPenalty: BigInt(slasherDefaultEnv.SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY),
18
+ slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty: BigInt(slasherDefaultEnv.SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY),
19
+ slashAttestInvalidCheckpointProposalPenalty: BigInt(slasherDefaultEnv.SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY),
20
+ slashUnknownPenalty: BigInt(slasherDefaultEnv.SLASH_UNKNOWN_PENALTY),
21
+ slashOffenseExpirationRounds: slasherDefaultEnv.SLASH_OFFENSE_EXPIRATION_ROUNDS,
22
+ slashMaxPayloadSize: slasherDefaultEnv.SLASH_MAX_PAYLOAD_SIZE,
23
+ slashGracePeriodL2Slots: slasherDefaultEnv.SLASH_GRACE_PERIOD_L2_SLOTS,
24
+ slashExecuteRoundsLookBack: slasherDefaultEnv.SLASH_EXECUTE_ROUNDS_LOOK_BACK,
25
+ slashSelfAllowed: false
26
+ };
27
+ export const slasherConfigMappings = {
28
+ slashOverridePayload: {
29
+ env: 'SLASH_OVERRIDE_PAYLOAD',
30
+ description: 'An Ethereum address for a slash payload to vote for unconditionally.',
31
+ parseEnv: (val)=>EthAddress.fromString(val),
32
+ defaultValue: DefaultSlasherConfig.slashOverridePayload
33
+ },
34
+ slashValidatorsAlways: {
35
+ env: 'SLASH_VALIDATORS_ALWAYS',
36
+ description: 'Comma-separated list of validator addresses that should always be slashed.',
37
+ parseEnv: (val)=>val.split(',').map((addr)=>addr.trim()).filter((addr)=>addr.length > 0).map((addr)=>EthAddress.fromString(addr)),
38
+ defaultValue: DefaultSlasherConfig.slashValidatorsAlways
39
+ },
40
+ slashValidatorsNever: {
41
+ env: 'SLASH_VALIDATORS_NEVER',
42
+ description: 'Comma-separated list of validator addresses that should never be slashed.',
43
+ parseEnv: (val)=>val.split(',').map((addr)=>addr.trim()).filter((addr)=>addr.length > 0).map((addr)=>EthAddress.fromString(addr)),
44
+ defaultValue: DefaultSlasherConfig.slashValidatorsNever
45
+ },
46
+ slashDataWithholdingPenalty: {
47
+ env: 'SLASH_DATA_WITHHOLDING_PENALTY',
48
+ description: 'Penalty for data withholding (0 records offenses without slash votes).',
49
+ ...bigintConfigHelper(DefaultSlasherConfig.slashDataWithholdingPenalty)
50
+ },
51
+ slashDataWithholdingToleranceSlots: {
52
+ env: 'SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS',
53
+ description: 'Number of full L2 slots that must elapse after a checkpoint slot before declaring its txs missing and slashing its attesters for data withholding.',
54
+ ...numberConfigHelper(DefaultSlasherConfig.slashDataWithholdingToleranceSlots)
55
+ },
56
+ slashBroadcastedInvalidBlockPenalty: {
57
+ env: 'SLASH_INVALID_BLOCK_PENALTY',
58
+ description: 'Penalty amount for slashing a validator for an invalid block proposed via p2p.',
59
+ ...bigintConfigHelper(DefaultSlasherConfig.slashBroadcastedInvalidBlockPenalty)
60
+ },
61
+ slashBroadcastedInvalidCheckpointProposalPenalty: {
62
+ env: 'SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY',
63
+ description: 'Penalty amount for slashing a validator for an invalid checkpoint proposal proposed via p2p.',
64
+ ...bigintConfigHelper(DefaultSlasherConfig.slashBroadcastedInvalidCheckpointProposalPenalty)
65
+ },
66
+ slashDuplicateProposalPenalty: {
67
+ env: 'SLASH_DUPLICATE_PROPOSAL_PENALTY',
68
+ description: 'Penalty amount for slashing a validator for sending duplicate proposals.',
69
+ ...bigintConfigHelper(DefaultSlasherConfig.slashDuplicateProposalPenalty)
70
+ },
71
+ slashDuplicateAttestationPenalty: {
72
+ env: 'SLASH_DUPLICATE_ATTESTATION_PENALTY',
73
+ description: 'Penalty amount for slashing a validator for signing attestations for different proposals at the same slot.',
74
+ ...bigintConfigHelper(DefaultSlasherConfig.slashDuplicateAttestationPenalty)
75
+ },
76
+ slashInactivityTargetPercentage: {
77
+ env: 'SLASH_INACTIVITY_TARGET_PERCENTAGE',
78
+ description: 'Missed attestation percentage to trigger creation of inactivity slash payload (0, 1]. Must be greater than 0',
79
+ ...floatConfigHelper(DefaultSlasherConfig.slashInactivityTargetPercentage, (v)=>{
80
+ if (v <= 0 || v > 1) {
81
+ throw new RangeError(`SLASH_INACTIVITY_TARGET_PERCENTAGE out of range. Expected (0, 1] got ${v}`);
82
+ }
83
+ })
84
+ },
85
+ slashInactivityConsecutiveEpochThreshold: {
86
+ env: 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD',
87
+ description: 'Number of consecutive epochs a validator must be inactive before slashing (minimum 1).',
88
+ ...numberConfigHelper(DefaultSlasherConfig.slashInactivityConsecutiveEpochThreshold),
89
+ parseEnv: (val)=>{
90
+ const parsed = parseInt(val, 10);
91
+ if (parsed < 1) {
92
+ throw new RangeError(`SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD must be at least 1 (got ${parsed})`);
93
+ }
94
+ return parsed;
95
+ }
96
+ },
97
+ slashInactivityPenalty: {
98
+ env: 'SLASH_INACTIVITY_PENALTY',
99
+ description: 'Penalty for an inactive validator (0 records offenses without slash votes).',
100
+ ...bigintConfigHelper(DefaultSlasherConfig.slashInactivityPenalty)
101
+ },
102
+ slashProposeInvalidAttestationsPenalty: {
103
+ env: 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY',
104
+ description: 'Penalty for proposing invalid attestations (0 records offenses without slash votes).',
105
+ ...bigintConfigHelper(DefaultSlasherConfig.slashProposeInvalidAttestationsPenalty)
106
+ },
107
+ slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty: {
108
+ env: 'SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY',
109
+ description: 'Penalty for publishing a checkpoint building on an invalid checkpoint (0 records offenses without slash votes).',
110
+ ...bigintConfigHelper(DefaultSlasherConfig.slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty)
111
+ },
112
+ slashAttestInvalidCheckpointProposalPenalty: {
113
+ env: 'SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY',
114
+ description: 'Penalty for attesting to an invalid checkpoint proposal (0 records offenses without slash votes).',
115
+ ...bigintConfigHelper(DefaultSlasherConfig.slashAttestInvalidCheckpointProposalPenalty)
116
+ },
117
+ slashUnknownPenalty: {
118
+ env: 'SLASH_UNKNOWN_PENALTY',
119
+ description: 'Penalty for an unknown offense (0 records offenses without slash votes).',
120
+ ...bigintConfigHelper(DefaultSlasherConfig.slashUnknownPenalty)
121
+ },
122
+ slashOffenseExpirationRounds: {
123
+ env: 'SLASH_OFFENSE_EXPIRATION_ROUNDS',
124
+ description: 'Number of rounds after which pending offenses expire.',
125
+ ...numberConfigHelper(DefaultSlasherConfig.slashOffenseExpirationRounds)
126
+ },
127
+ slashMaxPayloadSize: {
128
+ env: 'SLASH_MAX_PAYLOAD_SIZE',
129
+ description: 'Maximum number of offenses to include in a single slash payload.',
130
+ ...numberConfigHelper(DefaultSlasherConfig.slashMaxPayloadSize)
131
+ },
132
+ slashGracePeriodL2Slots: {
133
+ description: 'Number of L2 slots after the network upgrade during which slashing offenses are ignored. The upgrade time is determined from the CanonicalRollupUpdated event.',
134
+ env: 'SLASH_GRACE_PERIOD_L2_SLOTS',
135
+ ...numberConfigHelper(DefaultSlasherConfig.slashGracePeriodL2Slots)
136
+ },
137
+ slashExecuteRoundsLookBack: {
138
+ env: 'SLASH_EXECUTE_ROUNDS_LOOK_BACK',
139
+ description: 'How many rounds to look back when searching for a round to execute.',
140
+ ...numberConfigHelper(DefaultSlasherConfig.slashExecuteRoundsLookBack)
141
+ },
142
+ slashSelfAllowed: {
143
+ description: 'Whether to allow slashes to own validators',
144
+ ...booleanConfigHelper(DefaultSlasherConfig.slashSelfAllowed)
145
+ }
146
+ };
@@ -0,0 +1,19 @@
1
+ import { EpochCache } from '@aztec-labs/epoch-cache';
2
+ import type { L1ReaderConfig } from '@aztec-labs/ethereum/l1-reader';
3
+ import type { ViemClient } from '@aztec-labs/ethereum/types';
4
+ import { EthAddress } from '@aztec-labs/foundation/eth-address';
5
+ import { DateProvider } from '@aztec-labs/foundation/timer';
6
+ import type { SlasherConfig } from '@aztec-labs/stdlib/interfaces/server';
7
+ import type { DataStoreConfig } from '@aztec-labs/stdlib/kv-store';
8
+ import type { SlasherClientInterface } from '../slasher_client_interface.js';
9
+ import type { Watcher } from '../watcher.js';
10
+ /** Creates a slasher client facade that updates itself whenever the rollup slasher changes */
11
+ export declare function createSlasherFacade(config: SlasherConfig & DataStoreConfig & {
12
+ ethereumSlotDuration: number;
13
+ }, l1Contracts: Pick<L1ReaderConfig, 'rollupAddress' | 'registryAddress'>, l1Client: ViemClient, watchers: Watcher[], dateProvider: DateProvider, epochCache: EpochCache,
14
+ /**
15
+ * List of own validator addresses. Added to the slashValidatorNever list unless slashSelfAllowed is true, and used
16
+ * (independently of slashSelfAllowed) to warn and record metrics when they are targeted by onchain slashing.
17
+ */
18
+ validatorAddresses?: EthAddress[], logger?: import("@aztec-labs/foundation/log").Logger): Promise<SlasherClientInterface>;
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2ZhY2FkZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZhY3RvcnkvY3JlYXRlX2ZhY2FkZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDckUsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFHN0QsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBRWhFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUc1RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUMxRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUduRSxPQUFPLEtBQUssRUFBRSxzQkFBc0IsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRTdFLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUU3Qyw4RkFBOEY7QUFDOUYsd0JBQXNCLG1CQUFtQixDQUN2QyxNQUFNLEVBQUUsYUFBYSxHQUFHLGVBQWUsR0FBRztJQUFFLG9CQUFvQixFQUFFLE1BQU0sQ0FBQTtDQUFFLEVBQzFFLFdBQVcsRUFBRSxJQUFJLENBQUMsY0FBYyxFQUFFLGVBQWUsR0FBRyxpQkFBaUIsQ0FBQyxFQUN0RSxRQUFRLEVBQUUsVUFBVSxFQUNwQixRQUFRLEVBQUUsT0FBTyxFQUFFLEVBQ25CLFlBQVksRUFBRSxZQUFZLEVBQzFCLFVBQVUsRUFBRSxVQUFVO0FBQ3RCOzs7R0FHRztBQUNILGtCQUFrQixHQUFFLFVBQVUsRUFBTyxFQUNyQyxNQUFNLDhDQUEwQixHQUMvQixPQUFPLENBQUMsc0JBQXNCLENBQUMsQ0FtRGpDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_facade.d.ts","sourceRoot":"","sources":["../../src/factory/create_facade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,8FAA8F;AAC9F,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GAAG,eAAe,GAAG;IAAE,oBAAoB,EAAE,MAAM,CAAA;CAAE,EAC1E,WAAW,EAAE,IAAI,CAAC,cAAc,EAAE,eAAe,GAAG,iBAAiB,CAAC,EACtE,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,OAAO,EAAE,EACnB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU;AACtB;;;GAGG;AACH,kBAAkB,GAAE,UAAU,EAAO,EACrC,MAAM,8CAA0B,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAmDjC"}
@@ -0,0 +1,49 @@
1
+ import { RegistryContract, RollupContract } from '@aztec-labs/ethereum/contracts';
2
+ import { SlotNumber } from '@aztec-labs/foundation/branded-types';
3
+ import { unique } from '@aztec-labs/foundation/collection';
4
+ import { EthAddress } from '@aztec-labs/foundation/eth-address';
5
+ import { createLogger } from '@aztec-labs/foundation/log';
6
+ import { createStore } from '@aztec-labs/kv-store/lmdb-v2';
7
+ import { getSlotAtTimestamp } from '@aztec-labs/stdlib/epoch-helpers';
8
+ import { SlasherClientFacade } from '../slasher_client_facade.js';
9
+ import { SCHEMA_VERSION } from '../stores/schema_version.js';
10
+ /** Creates a slasher client facade that updates itself whenever the rollup slasher changes */ export async function createSlasherFacade(config, l1Contracts, l1Client, watchers, dateProvider, epochCache, /**
11
+ * List of own validator addresses. Added to the slashValidatorNever list unless slashSelfAllowed is true, and used
12
+ * (independently of slashSelfAllowed) to warn and record metrics when they are targeted by onchain slashing.
13
+ */ validatorAddresses = [], logger = createLogger('slasher')) {
14
+ if (!l1Contracts.rollupAddress || l1Contracts.rollupAddress.equals(EthAddress.ZERO)) {
15
+ throw new Error('Cannot initialize SlasherClient without a Rollup address');
16
+ }
17
+ const kvStore = await createStore('slasher', SCHEMA_VERSION, config, logger.getBindings());
18
+ const rollup = new RollupContract(l1Client, l1Contracts.rollupAddress);
19
+ // Compute and cache the L2 slot at which the rollup was registered as canonical
20
+ const settingsMap = kvStore.openMap('slasher-settings');
21
+ const cacheKey = `registeredSlot:${l1Contracts.rollupAddress}`;
22
+ let rollupRegisteredAtL2Slot = await settingsMap.getAsync(cacheKey);
23
+ if (rollupRegisteredAtL2Slot === undefined) {
24
+ const registry = new RegistryContract(l1Client, l1Contracts.registryAddress);
25
+ const l1StartBlock = await rollup.getL1StartBlock();
26
+ const registrationTimestamp = await registry.getCanonicalRollupRegistrationTimestamp(l1Contracts.rollupAddress, l1StartBlock);
27
+ if (registrationTimestamp !== undefined) {
28
+ const l1GenesisTime = await rollup.getL1GenesisTime();
29
+ const slotDuration = await rollup.getSlotDuration();
30
+ rollupRegisteredAtL2Slot = getSlotAtTimestamp(registrationTimestamp, {
31
+ l1GenesisTime,
32
+ slotDuration: Number(slotDuration)
33
+ });
34
+ } else {
35
+ rollupRegisteredAtL2Slot = SlotNumber(0);
36
+ }
37
+ await settingsMap.set(cacheKey, rollupRegisteredAtL2Slot);
38
+ logger.info(`Canonical rollup registered at L2 slot ${rollupRegisteredAtL2Slot}`);
39
+ }
40
+ const slashValidatorsNever = config.slashSelfAllowed ? config.slashValidatorsNever : unique([
41
+ ...config.slashValidatorsNever,
42
+ ...validatorAddresses
43
+ ].map((a)=>a.toString())).map(EthAddress.fromString);
44
+ const updatedConfig = {
45
+ ...config,
46
+ slashValidatorsNever
47
+ };
48
+ return new SlasherClientFacade(updatedConfig, rollup, l1Client, watchers, epochCache, dateProvider, kvStore, rollupRegisteredAtL2Slot, validatorAddresses, logger);
49
+ }
@@ -0,0 +1,17 @@
1
+ import { EpochCache } from '@aztec-labs/epoch-cache';
2
+ import { RollupContract } from '@aztec-labs/ethereum/contracts';
3
+ import type { ViemClient } from '@aztec-labs/ethereum/types';
4
+ import type { SlotNumber } from '@aztec-labs/foundation/branded-types';
5
+ import type { EthAddress } from '@aztec-labs/foundation/eth-address';
6
+ import { DateProvider } from '@aztec-labs/foundation/timer';
7
+ import { AztecLMDBStoreV2 } from '@aztec-labs/kv-store/lmdb-v2';
8
+ import type { SlasherConfig } from '@aztec-labs/stdlib/interfaces/server';
9
+ import type { DataStoreConfig } from '@aztec-labs/stdlib/kv-store';
10
+ import { NullSlasherClient } from '../null_slasher_client.js';
11
+ import { SlasherClient } from '../slasher_client.js';
12
+ import type { Watcher } from '../watcher.js';
13
+ /** Creates a slasher client implementation based on the slasher proposer type in the rollup */
14
+ export declare function createSlasherImplementation(config: SlasherConfig & DataStoreConfig & {
15
+ ethereumSlotDuration: number;
16
+ }, rollup: RollupContract, l1Client: ViemClient, watchers: Watcher[], epochCache: EpochCache, dateProvider: DateProvider, kvStore: AztecLMDBStoreV2, rollupRegisteredAtL2Slot: SlotNumber, ownValidators?: EthAddress[], logger?: import("@aztec-labs/foundation/log").Logger): Promise<NullSlasherClient | SlasherClient>;
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2ltcGxlbWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZmFjdG9yeS9jcmVhdGVfaW1wbGVtZW50YXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3JELE9BQU8sRUFBRSxjQUFjLEVBQTRCLE1BQU0sZ0NBQWdDLENBQUM7QUFDMUYsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFDdkUsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFFckUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQzVELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRW5FLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQzlELE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUVyRCxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFHN0MsK0ZBQStGO0FBQy9GLHdCQUFzQiwyQkFBMkIsQ0FDL0MsTUFBTSxFQUFFLGFBQWEsR0FBRyxlQUFlLEdBQUc7SUFBRSxvQkFBb0IsRUFBRSxNQUFNLENBQUE7Q0FBRSxFQUMxRSxNQUFNLEVBQUUsY0FBYyxFQUN0QixRQUFRLEVBQUUsVUFBVSxFQUNwQixRQUFRLEVBQUUsT0FBTyxFQUFFLEVBQ25CLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFlBQVksRUFBRSxZQUFZLEVBQzFCLE9BQU8sRUFBRSxnQkFBZ0IsRUFDekIsd0JBQXdCLEVBQUUsVUFBVSxFQUNwQyxhQUFhLEdBQUUsVUFBVSxFQUFPLEVBQ2hDLE1BQU0sOENBQTBCLDhDQW1CakMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_implementation.d.ts","sourceRoot":"","sources":["../../src/factory/create_implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAA4B,MAAM,gCAAgC,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,+FAA+F;AAC/F,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,aAAa,GAAG,eAAe,GAAG;IAAE,oBAAoB,EAAE,MAAM,CAAA;CAAE,EAC1E,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,gBAAgB,EACzB,wBAAwB,EAAE,UAAU,EACpC,aAAa,GAAE,UAAU,EAAO,EAChC,MAAM,8CAA0B,8CAmBjC"}
@@ -0,0 +1,25 @@
1
+ import { createLogger } from '@aztec-labs/foundation/log';
2
+ import { NullSlasherClient } from '../null_slasher_client.js';
3
+ import { SlasherClient } from '../slasher_client.js';
4
+ import { SlasherOffensesStore } from '../stores/offenses_store.js';
5
+ import { getSlasherSettings } from './get_settings.js';
6
+ /** Creates a slasher client implementation based on the slasher proposer type in the rollup */ export async function createSlasherImplementation(config, rollup, l1Client, watchers, epochCache, dateProvider, kvStore, rollupRegisteredAtL2Slot, ownValidators = [], logger = createLogger('slasher')) {
7
+ const proposer = await rollup.getSlashingProposer();
8
+ if (!proposer) {
9
+ return new NullSlasherClient(config);
10
+ } else {
11
+ return createSlasher(config, rollup, proposer, watchers, dateProvider, epochCache, kvStore, rollupRegisteredAtL2Slot, ownValidators, logger);
12
+ }
13
+ }
14
+ async function createSlasher(config, rollup, slashingProposer, watchers, dateProvider, epochCache, kvStore, rollupRegisteredAtL2Slot, ownValidators = [], logger = createLogger('slasher')) {
15
+ const settings = {
16
+ ...await getSlasherSettings(rollup, slashingProposer),
17
+ rollupRegisteredAtL2Slot
18
+ };
19
+ const slasher = await rollup.getSlasherContract();
20
+ const offensesStore = new SlasherOffensesStore(kvStore, {
21
+ ...settings,
22
+ slashOffenseExpirationRounds: config.slashOffenseExpirationRounds
23
+ });
24
+ return new SlasherClient(config, settings, slashingProposer, slasher, rollup, watchers, epochCache, dateProvider, offensesStore, ownValidators, logger);
25
+ }
@@ -0,0 +1,4 @@
1
+ import type { RollupContract, SlashingProposerContract } from '@aztec-labs/ethereum/contracts';
2
+ import type { SlasherSettings } from '../slasher_client.js';
3
+ export declare function getSlasherSettings(rollup: RollupContract, slashingProposer?: SlashingProposerContract): Promise<Omit<SlasherSettings, 'rollupRegisteredAtL2Slot'>>;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3NldHRpbmdzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZmFjdG9yeS9nZXRfc2V0dGluZ3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFL0YsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFNUQsd0JBQXNCLGtCQUFrQixDQUN0QyxNQUFNLEVBQUUsY0FBYyxFQUN0QixnQkFBZ0IsQ0FBQyxFQUFFLHdCQUF3QixHQUMxQyxPQUFPLENBQUMsSUFBSSxDQUFDLGVBQWUsRUFBRSwwQkFBMEIsQ0FBQyxDQUFDLENBa0Q1RCJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_settings.d.ts","sourceRoot":"","sources":["../../src/factory/get_settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,gBAAgB,CAAC,EAAE,wBAAwB,GAC1C,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC,CAkD5D"}
@@ -0,0 +1,36 @@
1
+ export async function getSlasherSettings(rollup, slashingProposer) {
2
+ if (!slashingProposer) {
3
+ const rollupSlashingProposer = await rollup.getSlashingProposer();
4
+ if (!rollupSlashingProposer) {
5
+ throw new Error('Rollup slashing proposer not found');
6
+ }
7
+ slashingProposer = rollupSlashingProposer;
8
+ }
9
+ const [slashingExecutionDelayInRounds, slashingRoundSize, slashingRoundSizeInEpochs, slashingLifetimeInRounds, slashingOffsetInRounds, slashingAmounts, slashingQuorumSize, epochDuration, l1GenesisTime, slotDuration, targetCommitteeSize] = await Promise.all([
10
+ slashingProposer.getExecutionDelayInRounds(),
11
+ slashingProposer.getRoundSize(),
12
+ slashingProposer.getRoundSizeInEpochs(),
13
+ slashingProposer.getLifetimeInRounds(),
14
+ slashingProposer.getSlashOffsetInRounds(),
15
+ slashingProposer.getSlashingAmounts(),
16
+ slashingProposer.getQuorumSize(),
17
+ rollup.getEpochDuration(),
18
+ rollup.getL1GenesisTime(),
19
+ rollup.getSlotDuration(),
20
+ rollup.getTargetCommitteeSize()
21
+ ]);
22
+ const settings = {
23
+ slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
24
+ slashingRoundSize: Number(slashingRoundSize),
25
+ slashingRoundSizeInEpochs: Number(slashingRoundSizeInEpochs),
26
+ slashingLifetimeInRounds: Number(slashingLifetimeInRounds),
27
+ slashingQuorumSize: Number(slashingQuorumSize),
28
+ epochDuration: Number(epochDuration),
29
+ l1GenesisTime: l1GenesisTime,
30
+ slotDuration: Number(slotDuration),
31
+ slashingOffsetInRounds: Number(slashingOffsetInRounds),
32
+ slashingAmounts,
33
+ targetCommitteeSize: Number(targetCommitteeSize)
34
+ };
35
+ return settings;
36
+ }
@@ -0,0 +1,3 @@
1
+ export { createSlasherFacade as createSlasher } from './create_facade.js';
2
+ export { getSlasherSettings } from './get_settings.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9mYWN0b3J5L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxtQkFBbUIsSUFBSSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUMxRSxPQUFPLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQyJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createSlasherFacade as createSlasher } from './create_facade.js';
2
+ export { getSlasherSettings } from './get_settings.js';
@@ -0,0 +1,21 @@
1
+ /** Default slasher configuration values from network-defaults.yml */
2
+ export declare const slasherDefaultEnv: {
3
+ readonly SLASH_OFFENSE_EXPIRATION_ROUNDS: 4;
4
+ readonly SLASH_MAX_PAYLOAD_SIZE: 80;
5
+ readonly SLASH_EXECUTE_ROUNDS_LOOK_BACK: 4;
6
+ readonly SLASH_DATA_WITHHOLDING_PENALTY: 10000000000000000000;
7
+ readonly SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS: 3;
8
+ readonly SLASH_INACTIVITY_TARGET_PERCENTAGE: 0.9;
9
+ readonly SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD: 1;
10
+ readonly SLASH_INACTIVITY_PENALTY: 10000000000000000000;
11
+ readonly SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY: 10000000000000000000;
12
+ readonly SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY: 10000000000000000000;
13
+ readonly SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY: 10000000000000000000;
14
+ readonly SLASH_DUPLICATE_PROPOSAL_PENALTY: 0;
15
+ readonly SLASH_DUPLICATE_ATTESTATION_PENALTY: 0;
16
+ readonly SLASH_UNKNOWN_PENALTY: 10000000000000000000;
17
+ readonly SLASH_INVALID_BLOCK_PENALTY: 10000000000000000000;
18
+ readonly SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY: 0;
19
+ readonly SLASH_GRACE_PERIOD_L2_SLOTS: 0;
20
+ };
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhc2hlci1kZWZhdWx0cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2dlbmVyYXRlZC9zbGFzaGVyLWRlZmF1bHRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLHFFQUFxRTtBQUNyRSxlQUFPLE1BQU0saUJBQWlCOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Q0FrQnBCLENBQUMifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slasher-defaults.d.ts","sourceRoot":"","sources":["../../src/generated/slasher-defaults.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;CAkBpB,CAAC"}