@aztec/slasher 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
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.
- package/README.md +83 -76
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +53 -41
- package/dest/factory/create_facade.d.ts +3 -3
- package/dest/factory/create_facade.d.ts.map +1 -1
- package/dest/factory/create_facade.js +26 -3
- package/dest/factory/create_implementation.d.ts +6 -7
- package/dest/factory/create_implementation.d.ts.map +1 -1
- package/dest/factory/create_implementation.js +8 -56
- package/dest/factory/get_settings.d.ts +4 -4
- package/dest/factory/get_settings.d.ts.map +1 -1
- package/dest/factory/get_settings.js +3 -3
- package/dest/factory/index.d.ts +2 -2
- package/dest/factory/index.d.ts.map +1 -1
- package/dest/factory/index.js +1 -1
- package/dest/generated/slasher-defaults.d.ts +21 -0
- package/dest/generated/slasher-defaults.d.ts.map +1 -0
- package/dest/generated/slasher-defaults.js +21 -0
- package/dest/index.d.ts +6 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -3
- package/dest/null_slasher_client.d.ts +3 -4
- package/dest/null_slasher_client.d.ts.map +1 -1
- package/dest/null_slasher_client.js +1 -4
- package/dest/slash_offenses_collector.d.ts +10 -9
- package/dest/slash_offenses_collector.d.ts.map +1 -1
- package/dest/slash_offenses_collector.js +50 -30
- package/dest/slasher_client.d.ts +112 -0
- package/dest/slasher_client.d.ts.map +1 -0
- package/dest/{tally_slasher_client.js → slasher_client.js} +50 -45
- package/dest/slasher_client_facade.d.ts +6 -8
- package/dest/slasher_client_facade.d.ts.map +1 -1
- package/dest/slasher_client_facade.js +6 -9
- package/dest/slasher_client_interface.d.ts +7 -21
- package/dest/slasher_client_interface.d.ts.map +1 -1
- package/dest/slasher_client_interface.js +1 -4
- package/dest/stores/offenses_store.d.ts +12 -12
- package/dest/stores/offenses_store.d.ts.map +1 -1
- package/dest/stores/offenses_store.js +64 -39
- package/dest/watcher.d.ts +8 -1
- package/dest/watcher.d.ts.map +1 -1
- package/dest/watcher.js +1 -0
- package/dest/watchers/attestations_block_watcher.d.ts +28 -14
- package/dest/watchers/attestations_block_watcher.d.ts.map +1 -1
- package/dest/watchers/attestations_block_watcher.js +80 -64
- package/dest/watchers/attested_invalid_proposal_watcher.d.ts +42 -0
- package/dest/watchers/attested_invalid_proposal_watcher.d.ts.map +1 -0
- package/dest/watchers/attested_invalid_proposal_watcher.js +117 -0
- package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.d.ts +38 -0
- package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.d.ts.map +1 -0
- package/dest/watchers/broadcasted_invalid_checkpoint_proposal_watcher.js +138 -0
- package/dest/watchers/checkpoint_equivocation_watcher.d.ts +30 -0
- package/dest/watchers/checkpoint_equivocation_watcher.d.ts.map +1 -0
- package/dest/watchers/checkpoint_equivocation_watcher.js +69 -0
- package/dest/watchers/data_withholding_watcher.d.ts +63 -0
- package/dest/watchers/data_withholding_watcher.d.ts.map +1 -0
- package/dest/watchers/data_withholding_watcher.js +193 -0
- package/package.json +15 -13
- package/src/config.ts +61 -41
- package/src/factory/create_facade.ts +33 -5
- package/src/factory/create_implementation.ts +24 -105
- package/src/factory/get_settings.ts +8 -8
- package/src/factory/index.ts +1 -1
- package/src/generated/slasher-defaults.ts +23 -0
- package/src/index.ts +5 -3
- package/src/null_slasher_client.ts +2 -6
- package/src/slash_offenses_collector.ts +70 -32
- package/src/{tally_slasher_client.ts → slasher_client.ts} +68 -54
- package/src/slasher_client_facade.ts +6 -11
- package/src/slasher_client_interface.ts +6 -21
- package/src/stores/offenses_store.ts +76 -48
- package/src/watcher.ts +8 -0
- package/src/watchers/attestations_block_watcher.ts +95 -84
- package/src/watchers/attested_invalid_proposal_watcher.ts +168 -0
- package/src/watchers/broadcasted_invalid_checkpoint_proposal_watcher.ts +192 -0
- package/src/watchers/checkpoint_equivocation_watcher.ts +96 -0
- package/src/watchers/data_withholding_watcher.ts +225 -0
- package/dest/empire_slasher_client.d.ts +0 -190
- package/dest/empire_slasher_client.d.ts.map +0 -1
- package/dest/empire_slasher_client.js +0 -572
- package/dest/stores/payloads_store.d.ts +0 -29
- package/dest/stores/payloads_store.d.ts.map +0 -1
- package/dest/stores/payloads_store.js +0 -125
- package/dest/tally_slasher_client.d.ts +0 -125
- package/dest/tally_slasher_client.d.ts.map +0 -1
- package/dest/watchers/epoch_prune_watcher.d.ts +0 -37
- package/dest/watchers/epoch_prune_watcher.d.ts.map +0 -1
- package/dest/watchers/epoch_prune_watcher.js +0 -137
- package/src/empire_slasher_client.ts +0 -657
- package/src/stores/payloads_store.ts +0 -146
- package/src/watchers/epoch_prune_watcher.ts +0 -194
package/README.md
CHANGED
|
@@ -16,15 +16,9 @@ No manual intervention is required for normal operation. The slasher client hand
|
|
|
16
16
|
- Generating appropriate slash actions
|
|
17
17
|
- Coordinating with the SequencerPublisher for L1 execution
|
|
18
18
|
|
|
19
|
-
## Slashing
|
|
19
|
+
## Slashing Model
|
|
20
20
|
|
|
21
|
-
The
|
|
22
|
-
|
|
23
|
-
### Tally Model
|
|
24
|
-
|
|
25
|
-
_This is the model currently in use._
|
|
26
|
-
|
|
27
|
-
The tally 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.
|
|
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.
|
|
28
22
|
|
|
29
23
|
Key characteristics:
|
|
30
24
|
- Proposers vote directly on validator offenses
|
|
@@ -34,23 +28,12 @@ Key characteristics:
|
|
|
34
28
|
- Execution happens after a delay period for review
|
|
35
29
|
- Slash payloads can be vetoed during the execution delay period
|
|
36
30
|
|
|
37
|
-
### Empire Model
|
|
38
|
-
|
|
39
|
-
_This model was developed during an earlier iteration and later modified, but never tested in a real network. It remains in the code in case we decide to switch from the tally model in the future._
|
|
40
|
-
|
|
41
|
-
The empire model piggybacks on the empire governance system and uses fixed slash payloads that are created and voted on. Proposers aggregate pending offenses and create payloads containing multiple offenses, or vote for existing payloads. The payload with the highest score (based on total offenses, votes received, and round progress) gets executed.
|
|
42
|
-
|
|
43
|
-
Key characteristics:
|
|
44
|
-
- Fixed payloads containing multiple offenses
|
|
45
|
-
- Payload scoring system for selection
|
|
46
|
-
- Requires agreement on payload contents (main reason why it was dropped in favor of the Tally model)
|
|
47
|
-
|
|
48
31
|
## Architecture
|
|
49
32
|
|
|
50
33
|
### Core Components
|
|
51
34
|
|
|
52
35
|
#### SlasherClientInterface
|
|
53
|
-
|
|
36
|
+
Interface implemented by the slasher client. Provides methods for:
|
|
54
37
|
- `getProposerActions()`: Returns actions for the current proposer
|
|
55
38
|
- `gatherOffensesForRound()`: Collects offenses for a specific round
|
|
56
39
|
|
|
@@ -73,11 +56,8 @@ Monitors slashing rounds and triggers actions on round transitions:
|
|
|
73
56
|
|
|
74
57
|
#### ProposerSlashAction
|
|
75
58
|
Actions returned by the slasher client to the SequencerPublisher:
|
|
76
|
-
- `vote-offenses`: Vote on validator offenses
|
|
77
|
-
- `execute-slash`: Execute slashing for a round that reached quorum
|
|
78
|
-
- `create-empire-payload`: Create a new slash payload (empire model)
|
|
79
|
-
- `vote-empire-payload`: Vote for an existing payload (empire model)
|
|
80
|
-
- `execute-empire-payload`: Execute a payload with sufficient votes (empire model)
|
|
59
|
+
- `vote-offenses`: Vote on validator offenses
|
|
60
|
+
- `execute-slash`: Execute slashing for a round that reached quorum
|
|
81
61
|
|
|
82
62
|
### Integration Flow
|
|
83
63
|
|
|
@@ -101,45 +81,57 @@ Key features:
|
|
|
101
81
|
List of all slashable offenses in the system:
|
|
102
82
|
|
|
103
83
|
### DATA_WITHHOLDING
|
|
104
|
-
**Description**: The data
|
|
105
|
-
**Detection**:
|
|
106
|
-
**Target**:
|
|
107
|
-
**Time Unit**:
|
|
108
|
-
|
|
109
|
-
### VALID_EPOCH_PRUNED
|
|
110
|
-
**Description**: An epoch was not successfully proven within the proof submission window.
|
|
111
|
-
**Detection**: EpochPruneWatcher monitors epochs that expire without valid proofs.
|
|
112
|
-
**Target**: Committee members of the unpruned epoch.
|
|
113
|
-
**Time Unit**: Epoch-based offense.
|
|
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).
|
|
114
88
|
|
|
115
89
|
### INACTIVITY
|
|
116
|
-
**Description**: A proposer failed to attest or propose blocks during their assigned slots.
|
|
117
|
-
**Detection**: Sentinel tracks validator performance and identifies validators who miss attestations beyond threshold.
|
|
118
|
-
**Target**: Individual inactive validator.
|
|
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.
|
|
119
93
|
**Time Unit**: Epoch-based offense.
|
|
120
94
|
|
|
121
95
|
### BROADCASTED_INVALID_BLOCK_PROPOSAL
|
|
122
|
-
**Description**: A proposer broadcast an invalid block proposal over the p2p network.
|
|
123
|
-
**Detection**: Validators detect invalid proposals during attestation validation.
|
|
124
|
-
**Target**: Proposer who broadcast the invalid block.
|
|
125
|
-
**Time Unit**: Slot-based offense.
|
|
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.
|
|
126
100
|
|
|
127
101
|
### PROPOSED_INSUFFICIENT_ATTESTATIONS
|
|
128
|
-
**Description**: A proposer submitted a block to L1 without sufficient committee attestations.
|
|
129
|
-
**Detection**: AttestationsBlockWatcher checks L1 blocks for attestation count.
|
|
130
|
-
**Target**: Block proposer.
|
|
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.
|
|
131
105
|
**Time Unit**: Slot-based offense.
|
|
132
106
|
|
|
133
107
|
### PROPOSED_INCORRECT_ATTESTATIONS
|
|
134
|
-
**Description**: A proposer submitted a block to L1 with signatures from non-committee members.
|
|
135
|
-
**Detection**: AttestationsBlockWatcher validates attestation signatures against committee membership.
|
|
136
|
-
**Target**: Block proposer.
|
|
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.
|
|
137
111
|
**Time Unit**: Slot-based offense.
|
|
138
112
|
|
|
139
|
-
###
|
|
140
|
-
**Description**: A
|
|
141
|
-
**Detection**: AttestationsBlockWatcher tracks invalid
|
|
142
|
-
**Target**:
|
|
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
|
+
### ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL
|
|
126
|
+
**Description**: A committee member attested to a checkpoint proposal in a slot where this node detected a slashable invalid block proposal.
|
|
127
|
+
**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.
|
|
128
|
+
**Target**: Committee members who attested in the invalid proposal slot.
|
|
129
|
+
**Time Unit**: Slot-based offense.
|
|
130
|
+
|
|
131
|
+
### BROADCASTED_INVALID_CHECKPOINT_PROPOSAL
|
|
132
|
+
**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.
|
|
133
|
+
**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.
|
|
134
|
+
**Target**: Proposer who broadcast the invalid checkpoint proposal.
|
|
143
135
|
**Time Unit**: Slot-based offense.
|
|
144
136
|
|
|
145
137
|
## Configuration
|
|
@@ -149,38 +141,43 @@ These settings are deployed with the L1 contracts and apply system-wide to the p
|
|
|
149
141
|
|
|
150
142
|
- `slashingQuorumSize`: Votes required to slash (defaults to half the validators in a round, plus one)
|
|
151
143
|
- `slashingRoundSizeInEpochs`: Number of epochs per slashing round
|
|
152
|
-
- `slashingOffsetInRounds`: How many rounds to look back for offenses
|
|
144
|
+
- `slashingOffsetInRounds`: How many rounds to look back for offenses
|
|
153
145
|
- `slashingExecutionDelayInRounds`: Rounds to wait before execution
|
|
154
146
|
- `slashingLifetimeInRounds`: Maximum age of executable rounds
|
|
155
|
-
- `slashingAmounts`: Valid values for each individual slash
|
|
147
|
+
- `slashingAmounts`: Valid values for each individual slash
|
|
156
148
|
|
|
157
149
|
Considerations:
|
|
158
150
|
|
|
159
151
|
- 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.
|
|
160
|
-
- 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
|
|
161
|
-
- 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
|
|
152
|
+
- 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.
|
|
153
|
+
- 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.
|
|
162
154
|
- 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.
|
|
163
155
|
|
|
164
156
|
### Local Node Configuration (SlasherConfig)
|
|
165
157
|
|
|
166
158
|
These settings are configured locally on each validator node:
|
|
167
159
|
|
|
160
|
+
Block and checkpoint validation settings are expected to be the same across all validators. Slashing relies on
|
|
161
|
+
validators making the same deterministic validity decisions for block and checkpoint proposals; operators should not run
|
|
162
|
+
with divergent validation limits.
|
|
163
|
+
|
|
168
164
|
- `slashGracePeriodL2Slots`: Number of initial L2 slots where slashing is disabled
|
|
169
165
|
- `slashOffenseExpirationRounds`: Number of rounds after which pending offenses expire
|
|
170
166
|
- `slashValidatorsAlways`: Array of validator addresses that should always be slashed
|
|
171
167
|
- `slashValidatorsNever`: Array of validator addresses that should never be slashed (own validator addresses are automatically added to this list)
|
|
172
168
|
- `slashInactivityTargetPercentage`: Percentage of misses during an epoch to be slashed for INACTIVITY
|
|
173
169
|
- `slashInactivityConsecutiveEpochThreshold`: How many consecutive inactive epochs are needed to trigger an INACTIVITY slash on a validator
|
|
174
|
-
- `slashPrunePenalty`: Penalty for VALID_EPOCH_PRUNED
|
|
175
170
|
- `slashDataWithholdingPenalty`: Penalty for DATA_WITHHOLDING
|
|
171
|
+
- `slashDataWithholdingToleranceSlots`: Number of full L2 slots to wait after a checkpoint's slot before declaring its txs missing
|
|
176
172
|
- `slashInactivityPenalty`: Penalty for INACTIVITY
|
|
177
173
|
- `slashBroadcastedInvalidBlockPenalty`: Penalty for BROADCASTED_INVALID_BLOCK_PROPOSAL
|
|
174
|
+
- `slashBroadcastedInvalidCheckpointProposalPenalty`: Penalty for BROADCASTED_INVALID_CHECKPOINT_PROPOSAL
|
|
175
|
+
- `slashDuplicateProposalPenalty`: Penalty for DUPLICATE_PROPOSAL
|
|
178
176
|
- `slashProposeInvalidAttestationsPenalty`: Penalty for PROPOSED_INSUFFICIENT_ATTESTATIONS and PROPOSED_INCORRECT_ATTESTATIONS
|
|
179
|
-
- `
|
|
177
|
+
- `slashProposeDescendantOfCheckpointWithInvalidAttestationsPenalty`: Penalty for PROPOSED_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS
|
|
178
|
+
- `slashAttestInvalidCheckpointProposalPenalty`: Penalty for ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL
|
|
180
179
|
- `slashUnknownPenalty`: Default penalty for unknown offense types
|
|
181
|
-
- `slashMaxPayloadSize`:
|
|
182
|
-
- `slashMinPenaltyPercentage`: Agree to slashes if they are at least this percentage of the configured penalty (empire model)
|
|
183
|
-
- `slashMaxPenaltyPercentage`: Agree to slashes if they are at most this percentage of the configured penalty (empire model)
|
|
180
|
+
- `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.
|
|
184
181
|
|
|
185
182
|
Considerations:
|
|
186
183
|
|
|
@@ -195,24 +192,34 @@ Details about specific offenses in the system:
|
|
|
195
192
|
|
|
196
193
|
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.
|
|
197
194
|
|
|
198
|
-
Inactivity slashing is handled by the `Sentinel` which monitors performance of all validators slot-by-slot. After each slot, the sentinel assigns one of the following to the
|
|
199
|
-
- `block-mined` if the block was added to L1
|
|
200
|
-
- `block-proposed` if the block received at least one attestation, but didn't make it to L1
|
|
201
|
-
- `block-missed` if the block received no attestations (note that we cannot rely on the P2P proposal alone since it may be invalid, unless we reexecute it)
|
|
195
|
+
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:
|
|
202
196
|
|
|
203
|
-
|
|
204
|
-
- `
|
|
205
|
-
- `
|
|
206
|
-
-
|
|
197
|
+
- `checkpoint-mined` — a checkpoint covering this slot has landed on L1
|
|
198
|
+
- `checkpoint-valid` — the local node re-executed a checkpoint proposal for this slot successfully
|
|
199
|
+
- `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
|
|
200
|
+
- `checkpoint-unvalidated` — a checkpoint proposal arrived but the local node could not validate it (missing blocks/txs, timeout). Treated as proposer-fault
|
|
201
|
+
- `checkpoint-missed` — block proposals seen on P2P but no checkpoint proposal at all
|
|
202
|
+
- `blocks-missed` — no block proposals seen for this slot at all
|
|
207
203
|
|
|
208
|
-
|
|
204
|
+
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)`.
|
|
209
205
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
206
|
+
Each non-proposer committee member is assigned one of:
|
|
207
|
+
- `attestation-sent` if their checkpoint attestation was seen on L1 or on the P2P network
|
|
208
|
+
- `attestation-missed` if the proposer status was `checkpoint-mined` or `checkpoint-valid` but no checkpoint attestation was seen
|
|
209
|
+
- none in any other case
|
|
210
|
+
|
|
211
|
+
`blocks-missed`, `checkpoint-missed`, `checkpoint-invalid`, and `checkpoint-unvalidated` all count as proposer inactivity for the slot.
|
|
215
212
|
|
|
216
|
-
|
|
213
|
+
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.
|
|
217
214
|
|
|
215
|
+
At end-of-epoch evaluation, for each validator such that:
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
total_failures = count(blocks-missed) + count(checkpoint-missed)
|
|
219
|
+
+ count(checkpoint-invalid) + count(checkpoint-unvalidated)
|
|
220
|
+
+ count(attestation-missed)
|
|
221
|
+
total = count(checkpoint-*) + count(blocks-*) + count(attestation-*)
|
|
222
|
+
total_failures / total >= slashInactivityTargetPercentage
|
|
223
|
+
```
|
|
218
224
|
|
|
225
|
+
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.
|
package/dest/config.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
|
3
3
|
export type { SlasherConfig };
|
|
4
4
|
export declare const DefaultSlasherConfig: SlasherConfig;
|
|
5
5
|
export declare const slasherConfigMappings: ConfigMappingsType<SlasherConfig>;
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFRbkUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJckUsWUFBWSxFQUFFLGFBQWEsRUFBRSxDQUFDO0FBRTlCLGVBQU8sTUFBTSxvQkFBb0IsRUFBRSxhQTBCbEMsQ0FBQztBQUVGLGVBQU8sTUFBTSxxQkFBcUIsRUFBRSxrQkFBa0IsQ0FBQyxhQUFhLENBc0luRSxDQUFDIn0=
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAQnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAIrE,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
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
|
-
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
2
1
|
import { bigintConfigHelper, booleanConfigHelper, floatConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
|
|
3
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { slasherDefaultEnv } from './generated/slasher-defaults.js';
|
|
4
4
|
export const DefaultSlasherConfig = {
|
|
5
5
|
slashOverridePayload: undefined,
|
|
6
|
-
slashMinPenaltyPercentage: 0.5,
|
|
7
|
-
slashMaxPenaltyPercentage: 2.0,
|
|
8
6
|
slashValidatorsAlways: [],
|
|
9
7
|
slashValidatorsNever: [],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
slashInactivityTargetPercentage:
|
|
13
|
-
slashInactivityConsecutiveEpochThreshold:
|
|
14
|
-
slashBroadcastedInvalidBlockPenalty:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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,
|
|
23
25
|
slashSelfAllowed: false
|
|
24
26
|
};
|
|
25
27
|
export const slasherConfigMappings = {
|
|
26
28
|
slashOverridePayload: {
|
|
27
29
|
env: 'SLASH_OVERRIDE_PAYLOAD',
|
|
28
30
|
description: 'An Ethereum address for a slash payload to vote for unconditionally.',
|
|
29
|
-
parseEnv: (val)=>
|
|
31
|
+
parseEnv: (val)=>EthAddress.fromString(val),
|
|
30
32
|
defaultValue: DefaultSlasherConfig.slashOverridePayload
|
|
31
33
|
},
|
|
32
|
-
slashMinPenaltyPercentage: {
|
|
33
|
-
env: 'SLASH_MIN_PENALTY_PERCENTAGE',
|
|
34
|
-
description: 'Minimum penalty percentage for slashing offenses (0.1 is 10%).',
|
|
35
|
-
...floatConfigHelper(DefaultSlasherConfig.slashMinPenaltyPercentage)
|
|
36
|
-
},
|
|
37
|
-
slashMaxPenaltyPercentage: {
|
|
38
|
-
env: 'SLASH_MAX_PENALTY_PERCENTAGE',
|
|
39
|
-
description: 'Maximum penalty percentage for slashing offenses (2.0 is 200%).',
|
|
40
|
-
...floatConfigHelper(DefaultSlasherConfig.slashMaxPenaltyPercentage)
|
|
41
|
-
},
|
|
42
34
|
slashValidatorsAlways: {
|
|
43
35
|
env: 'SLASH_VALIDATORS_ALWAYS',
|
|
44
36
|
description: 'Comma-separated list of validator addresses that should always be slashed.',
|
|
@@ -51,21 +43,36 @@ export const slasherConfigMappings = {
|
|
|
51
43
|
parseEnv: (val)=>val.split(',').map((addr)=>addr.trim()).filter((addr)=>addr.length > 0).map((addr)=>EthAddress.fromString(addr)),
|
|
52
44
|
defaultValue: DefaultSlasherConfig.slashValidatorsNever
|
|
53
45
|
},
|
|
54
|
-
slashPrunePenalty: {
|
|
55
|
-
env: 'SLASH_PRUNE_PENALTY',
|
|
56
|
-
description: 'Penalty amount for slashing validators of a valid pruned epoch (set to 0 to disable).',
|
|
57
|
-
...bigintConfigHelper(DefaultSlasherConfig.slashPrunePenalty)
|
|
58
|
-
},
|
|
59
46
|
slashDataWithholdingPenalty: {
|
|
60
47
|
env: 'SLASH_DATA_WITHHOLDING_PENALTY',
|
|
61
|
-
description: 'Penalty
|
|
48
|
+
description: 'Penalty for data withholding (0 records offenses without slash votes).',
|
|
62
49
|
...bigintConfigHelper(DefaultSlasherConfig.slashDataWithholdingPenalty)
|
|
63
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
|
+
},
|
|
64
56
|
slashBroadcastedInvalidBlockPenalty: {
|
|
65
57
|
env: 'SLASH_INVALID_BLOCK_PENALTY',
|
|
66
58
|
description: 'Penalty amount for slashing a validator for an invalid block proposed via p2p.',
|
|
67
59
|
...bigintConfigHelper(DefaultSlasherConfig.slashBroadcastedInvalidBlockPenalty)
|
|
68
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
|
+
},
|
|
69
76
|
slashInactivityTargetPercentage: {
|
|
70
77
|
env: 'SLASH_INACTIVITY_TARGET_PERCENTAGE',
|
|
71
78
|
description: 'Missed attestation percentage to trigger creation of inactivity slash payload (0, 1]. Must be greater than 0',
|
|
@@ -89,22 +96,27 @@ export const slasherConfigMappings = {
|
|
|
89
96
|
},
|
|
90
97
|
slashInactivityPenalty: {
|
|
91
98
|
env: 'SLASH_INACTIVITY_PENALTY',
|
|
92
|
-
description: 'Penalty
|
|
99
|
+
description: 'Penalty for an inactive validator (0 records offenses without slash votes).',
|
|
93
100
|
...bigintConfigHelper(DefaultSlasherConfig.slashInactivityPenalty)
|
|
94
101
|
},
|
|
95
102
|
slashProposeInvalidAttestationsPenalty: {
|
|
96
103
|
env: 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY',
|
|
97
|
-
description: 'Penalty
|
|
104
|
+
description: 'Penalty for proposing invalid attestations (0 records offenses without slash votes).',
|
|
98
105
|
...bigintConfigHelper(DefaultSlasherConfig.slashProposeInvalidAttestationsPenalty)
|
|
99
106
|
},
|
|
100
|
-
|
|
101
|
-
env: '
|
|
102
|
-
description: 'Penalty
|
|
103
|
-
...bigintConfigHelper(DefaultSlasherConfig.
|
|
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)
|
|
104
116
|
},
|
|
105
117
|
slashUnknownPenalty: {
|
|
106
118
|
env: 'SLASH_UNKNOWN_PENALTY',
|
|
107
|
-
description: 'Penalty
|
|
119
|
+
description: 'Penalty for an unknown offense (0 records offenses without slash votes).',
|
|
108
120
|
...bigintConfigHelper(DefaultSlasherConfig.slashUnknownPenalty)
|
|
109
121
|
},
|
|
110
122
|
slashOffenseExpirationRounds: {
|
|
@@ -118,7 +130,7 @@ export const slasherConfigMappings = {
|
|
|
118
130
|
...numberConfigHelper(DefaultSlasherConfig.slashMaxPayloadSize)
|
|
119
131
|
},
|
|
120
132
|
slashGracePeriodL2Slots: {
|
|
121
|
-
description: 'Number of L2 slots
|
|
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.',
|
|
122
134
|
env: 'SLASH_GRACE_PERIOD_L2_SLOTS',
|
|
123
135
|
...numberConfigHelper(DefaultSlasherConfig.slashGracePeriodL2Slots)
|
|
124
136
|
},
|
|
@@ -3,14 +3,14 @@ import type { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
|
|
|
3
3
|
import type { ViemClient } from '@aztec/ethereum/types';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
8
8
|
import type { SlasherClientInterface } from '../slasher_client_interface.js';
|
|
9
9
|
import type { Watcher } from '../watcher.js';
|
|
10
10
|
/** Creates a slasher client facade that updates itself whenever the rollup slasher changes */
|
|
11
11
|
export declare function createSlasherFacade(config: SlasherConfig & DataStoreConfig & {
|
|
12
12
|
ethereumSlotDuration: number;
|
|
13
|
-
}, l1Contracts: Pick<L1ReaderConfig
|
|
13
|
+
}, l1Contracts: Pick<L1ReaderConfig, 'rollupAddress' | 'registryAddress'>, l1Client: ViemClient, watchers: Watcher[], dateProvider: DateProvider, epochCache: EpochCache,
|
|
14
14
|
/** List of own validator addresses to add to the slashValidatorNever list unless slashSelfAllowed is true */
|
|
15
15
|
validatorAddresses?: EthAddress[], logger?: import("@aztec/foundation/log").Logger): Promise<SlasherClientInterface>;
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2ZhY2FkZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZhY3RvcnkvY3JlYXRlX2ZhY2FkZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHeEQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUd2RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUc5RCxPQUFPLEtBQUssRUFBRSxzQkFBc0IsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRTdFLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUU3Qyw4RkFBOEY7QUFDOUYsd0JBQXNCLG1CQUFtQixDQUN2QyxNQUFNLEVBQUUsYUFBYSxHQUFHLGVBQWUsR0FBRztJQUFFLG9CQUFvQixFQUFFLE1BQU0sQ0FBQTtDQUFFLEVBQzFFLFdBQVcsRUFBRSxJQUFJLENBQUMsY0FBYyxFQUFFLGVBQWUsR0FBRyxpQkFBaUIsQ0FBQyxFQUN0RSxRQUFRLEVBQUUsVUFBVSxFQUNwQixRQUFRLEVBQUUsT0FBTyxFQUFFLEVBQ25CLFlBQVksRUFBRSxZQUFZLEVBQzFCLFVBQVUsRUFBRSxVQUFVO0FBQ3RCLDZHQUE2RztBQUM3RyxrQkFBa0IsR0FBRSxVQUFVLEVBQU8sRUFDckMsTUFBTSx5Q0FBMEIsR0FDL0IsT0FBTyxDQUFDLHNCQUFzQixDQUFDLENBa0RqQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_facade.d.ts","sourceRoot":"","sources":["../../src/factory/create_facade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"create_facade.d.ts","sourceRoot":"","sources":["../../src/factory/create_facade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,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,6GAA6G;AAC7G,kBAAkB,GAAE,UAAU,EAAO,EACrC,MAAM,yCAA0B,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAkDjC"}
|
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
1
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { unique } from '@aztec/foundation/collection';
|
|
3
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
|
+
import { getSlotAtTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
6
8
|
import { SlasherClientFacade } from '../slasher_client_facade.js';
|
|
7
9
|
import { SCHEMA_VERSION } from '../stores/schema_version.js';
|
|
8
10
|
/** Creates a slasher client facade that updates itself whenever the rollup slasher changes */ export async function createSlasherFacade(config, l1Contracts, l1Client, watchers, dateProvider, epochCache, /** List of own validator addresses to add to the slashValidatorNever list unless slashSelfAllowed is true */ validatorAddresses = [], logger = createLogger('slasher')) {
|
|
9
11
|
if (!l1Contracts.rollupAddress || l1Contracts.rollupAddress.equals(EthAddress.ZERO)) {
|
|
10
12
|
throw new Error('Cannot initialize SlasherClient without a Rollup address');
|
|
11
13
|
}
|
|
12
|
-
const kvStore = await createStore('slasher', SCHEMA_VERSION, config,
|
|
14
|
+
const kvStore = await createStore('slasher', SCHEMA_VERSION, config, logger.getBindings());
|
|
13
15
|
const rollup = new RollupContract(l1Client, l1Contracts.rollupAddress);
|
|
16
|
+
// Compute and cache the L2 slot at which the rollup was registered as canonical
|
|
17
|
+
const settingsMap = kvStore.openMap('slasher-settings');
|
|
18
|
+
const cacheKey = `registeredSlot:${l1Contracts.rollupAddress}`;
|
|
19
|
+
let rollupRegisteredAtL2Slot = await settingsMap.getAsync(cacheKey);
|
|
20
|
+
if (rollupRegisteredAtL2Slot === undefined) {
|
|
21
|
+
const registry = new RegistryContract(l1Client, l1Contracts.registryAddress);
|
|
22
|
+
const l1StartBlock = await rollup.getL1StartBlock();
|
|
23
|
+
const registrationTimestamp = await registry.getCanonicalRollupRegistrationTimestamp(l1Contracts.rollupAddress, l1StartBlock);
|
|
24
|
+
if (registrationTimestamp !== undefined) {
|
|
25
|
+
const l1GenesisTime = await rollup.getL1GenesisTime();
|
|
26
|
+
const slotDuration = await rollup.getSlotDuration();
|
|
27
|
+
rollupRegisteredAtL2Slot = getSlotAtTimestamp(registrationTimestamp, {
|
|
28
|
+
l1GenesisTime,
|
|
29
|
+
slotDuration: Number(slotDuration)
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
rollupRegisteredAtL2Slot = SlotNumber(0);
|
|
33
|
+
}
|
|
34
|
+
await settingsMap.set(cacheKey, rollupRegisteredAtL2Slot);
|
|
35
|
+
logger.info(`Canonical rollup registered at L2 slot ${rollupRegisteredAtL2Slot}`);
|
|
36
|
+
}
|
|
14
37
|
const slashValidatorsNever = config.slashSelfAllowed ? config.slashValidatorsNever : unique([
|
|
15
38
|
...config.slashValidatorsNever,
|
|
16
39
|
...validatorAddresses
|
|
@@ -19,5 +42,5 @@ import { SCHEMA_VERSION } from '../stores/schema_version.js';
|
|
|
19
42
|
...config,
|
|
20
43
|
slashValidatorsNever
|
|
21
44
|
};
|
|
22
|
-
return new SlasherClientFacade(updatedConfig, rollup, l1Client,
|
|
45
|
+
return new SlasherClientFacade(updatedConfig, rollup, l1Client, watchers, epochCache, dateProvider, kvStore, rollupRegisteredAtL2Slot, logger);
|
|
23
46
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
2
2
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
3
|
import type { ViemClient } from '@aztec/ethereum/types';
|
|
4
|
-
import {
|
|
4
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
5
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import { AztecLMDBStoreV2 } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
9
|
-
import {
|
|
8
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
10
9
|
import { NullSlasherClient } from '../null_slasher_client.js';
|
|
11
|
-
import {
|
|
10
|
+
import { SlasherClient } from '../slasher_client.js';
|
|
12
11
|
import type { Watcher } from '../watcher.js';
|
|
13
|
-
/** Creates a slasher client implementation
|
|
12
|
+
/** Creates a slasher client implementation based on the slasher proposer type in the rollup */
|
|
14
13
|
export declare function createSlasherImplementation(config: SlasherConfig & DataStoreConfig & {
|
|
15
14
|
ethereumSlotDuration: number;
|
|
16
|
-
}, rollup: RollupContract, l1Client: ViemClient,
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
}, rollup: RollupContract, l1Client: ViemClient, watchers: Watcher[], epochCache: EpochCache, dateProvider: DateProvider, kvStore: AztecLMDBStoreV2, rollupRegisteredAtL2Slot: SlotNumber, logger?: import("@aztec/foundation/log").Logger): Promise<NullSlasherClient | SlasherClient>;
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2ltcGxlbWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZmFjdG9yeS9jcmVhdGVfaW1wbGVtZW50YXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2hELE9BQU8sRUFBRSxjQUFjLEVBQTRCLE1BQU0sMkJBQTJCLENBQUM7QUFDckYsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFbEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzNELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTlELE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQzlELE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUVyRCxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFHN0MsK0ZBQStGO0FBQy9GLHdCQUFzQiwyQkFBMkIsQ0FDL0MsTUFBTSxFQUFFLGFBQWEsR0FBRyxlQUFlLEdBQUc7SUFBRSxvQkFBb0IsRUFBRSxNQUFNLENBQUE7Q0FBRSxFQUMxRSxNQUFNLEVBQUUsY0FBYyxFQUN0QixRQUFRLEVBQUUsVUFBVSxFQUNwQixRQUFRLEVBQUUsT0FBTyxFQUFFLEVBQ25CLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFlBQVksRUFBRSxZQUFZLEVBQzFCLE9BQU8sRUFBRSxnQkFBZ0IsRUFDekIsd0JBQXdCLEVBQUUsVUFBVSxFQUNwQyxNQUFNLHlDQUEwQiw4Q0FrQmpDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_implementation.d.ts","sourceRoot":"","sources":["../../src/factory/create_implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"create_implementation.d.ts","sourceRoot":"","sources":["../../src/factory/create_implementation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAA4B,MAAM,2BAA2B,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,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,MAAM,yCAA0B,8CAkBjC"}
|