@aztec/slasher 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec7ac5448
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 +51 -65
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +13 -13
- 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 +3 -3
- package/dest/generated/slasher-defaults.js +3 -3
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- 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 +5 -8
- package/dest/slash_offenses_collector.d.ts.map +1 -1
- package/dest/slash_offenses_collector.js +9 -18
- 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} +30 -39
- 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 +6 -12
- package/dest/stores/offenses_store.d.ts.map +1 -1
- package/dest/stores/offenses_store.js +8 -25
- package/dest/watchers/epoch_prune_watcher.d.ts +6 -5
- package/dest/watchers/epoch_prune_watcher.d.ts.map +1 -1
- package/dest/watchers/epoch_prune_watcher.js +47 -26
- package/package.json +9 -9
- package/src/config.ts +15 -13
- 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 +3 -3
- package/src/index.ts +1 -2
- package/src/null_slasher_client.ts +2 -6
- package/src/slash_offenses_collector.ts +16 -20
- package/src/{tally_slasher_client.ts → slasher_client.ts} +37 -48
- package/src/slasher_client_facade.ts +6 -11
- package/src/slasher_client_interface.ts +6 -21
- package/src/stores/offenses_store.ts +11 -34
- package/src/watchers/epoch_prune_watcher.ts +62 -26
- 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/src/empire_slasher_client.ts +0 -657
- package/src/stores/payloads_store.ts +0 -146
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,51 @@ Key features:
|
|
|
101
81
|
List of all slashable offenses in the system:
|
|
102
82
|
|
|
103
83
|
### DATA_WITHHOLDING
|
|
104
|
-
**Description**: The data required for proving an epoch was not made publicly available.
|
|
105
|
-
**Detection**: EpochPruneWatcher detects when an epoch cannot be proven due to missing data.
|
|
106
|
-
**Target**: Committee members of the affected epoch.
|
|
84
|
+
**Description**: The data required for proving an epoch was not made publicly available.
|
|
85
|
+
**Detection**: EpochPruneWatcher detects when an epoch cannot be proven due to missing data.
|
|
86
|
+
**Target**: Committee members of the affected epoch.
|
|
107
87
|
**Time Unit**: Epoch-based offense.
|
|
108
88
|
|
|
109
89
|
### 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.
|
|
90
|
+
**Description**: An epoch was not successfully proven within the proof submission window.
|
|
91
|
+
**Detection**: EpochPruneWatcher monitors epochs that expire without valid proofs.
|
|
92
|
+
**Target**: Committee members of the unpruned epoch.
|
|
113
93
|
**Time Unit**: Epoch-based offense.
|
|
114
94
|
|
|
115
95
|
### 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.
|
|
96
|
+
**Description**: A proposer failed to attest or propose blocks during their assigned slots.
|
|
97
|
+
**Detection**: Sentinel tracks validator performance and identifies validators who miss attestations beyond threshold.
|
|
98
|
+
**Target**: Individual inactive validator.
|
|
119
99
|
**Time Unit**: Epoch-based offense.
|
|
120
100
|
|
|
121
101
|
### 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.
|
|
102
|
+
**Description**: A proposer broadcast an invalid block proposal over the p2p network.
|
|
103
|
+
**Detection**: Validators detect invalid proposals during attestation validation.
|
|
104
|
+
**Target**: Proposer who broadcast the invalid block.
|
|
105
|
+
**Time Unit**: Slot-based offense.
|
|
126
106
|
|
|
127
107
|
### 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.
|
|
108
|
+
**Description**: A proposer submitted a block to L1 without sufficient committee attestations.
|
|
109
|
+
**Detection**: AttestationsBlockWatcher checks L1 blocks for attestation count.
|
|
110
|
+
**Target**: Block proposer.
|
|
131
111
|
**Time Unit**: Slot-based offense.
|
|
132
112
|
|
|
133
113
|
### 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.
|
|
114
|
+
**Description**: A proposer submitted a block to L1 with signatures from non-committee members.
|
|
115
|
+
**Detection**: AttestationsBlockWatcher validates attestation signatures against committee membership.
|
|
116
|
+
**Target**: Block proposer.
|
|
137
117
|
**Time Unit**: Slot-based offense.
|
|
138
118
|
|
|
139
119
|
### ATTESTED_DESCENDANT_OF_INVALID
|
|
140
|
-
**Description**: A committee member attested to a block built on top of an invalid ancestor.
|
|
141
|
-
**Detection**: AttestationsBlockWatcher tracks invalid blocks and their descendants.
|
|
142
|
-
**Target**: Committee members who attested to the descendant block.
|
|
120
|
+
**Description**: A committee member attested to a block built on top of an invalid ancestor.
|
|
121
|
+
**Detection**: AttestationsBlockWatcher tracks invalid blocks and their descendants.
|
|
122
|
+
**Target**: Committee members who attested to the descendant block.
|
|
123
|
+
**Time Unit**: Slot-based offense.
|
|
124
|
+
|
|
125
|
+
### DUPLICATE_PROPOSAL
|
|
126
|
+
**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.
|
|
127
|
+
**Detection**: Detected in the P2P layer when proposals are received. The AttestationPool tracks proposals by position; when a second proposal arrives for the same position with a different archive, it flags the duplicate. The first duplicate is propagated (Accept) so other validators can witness the offense.
|
|
128
|
+
**Target**: Proposer who broadcast the duplicate proposal.
|
|
143
129
|
**Time Unit**: Slot-based offense.
|
|
144
130
|
|
|
145
131
|
## Configuration
|
|
@@ -149,15 +135,15 @@ These settings are deployed with the L1 contracts and apply system-wide to the p
|
|
|
149
135
|
|
|
150
136
|
- `slashingQuorumSize`: Votes required to slash (defaults to half the validators in a round, plus one)
|
|
151
137
|
- `slashingRoundSizeInEpochs`: Number of epochs per slashing round
|
|
152
|
-
- `slashingOffsetInRounds`: How many rounds to look back for offenses
|
|
138
|
+
- `slashingOffsetInRounds`: How many rounds to look back for offenses
|
|
153
139
|
- `slashingExecutionDelayInRounds`: Rounds to wait before execution
|
|
154
140
|
- `slashingLifetimeInRounds`: Maximum age of executable rounds
|
|
155
|
-
- `slashingAmounts`: Valid values for each individual slash
|
|
141
|
+
- `slashingAmounts`: Valid values for each individual slash
|
|
156
142
|
|
|
157
143
|
Considerations:
|
|
158
144
|
|
|
159
145
|
- 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
|
|
146
|
+
- 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
147
|
- 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 proof submission window in order to be able to slash for epoch prunes or data withholding.
|
|
162
148
|
- 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
149
|
|
|
@@ -175,12 +161,11 @@ These settings are configured locally on each validator node:
|
|
|
175
161
|
- `slashDataWithholdingPenalty`: Penalty for DATA_WITHHOLDING
|
|
176
162
|
- `slashInactivityPenalty`: Penalty for INACTIVITY
|
|
177
163
|
- `slashBroadcastedInvalidBlockPenalty`: Penalty for BROADCASTED_INVALID_BLOCK_PROPOSAL
|
|
164
|
+
- `slashDuplicateProposalPenalty`: Penalty for DUPLICATE_PROPOSAL
|
|
178
165
|
- `slashProposeInvalidAttestationsPenalty`: Penalty for PROPOSED_INSUFFICIENT_ATTESTATIONS and PROPOSED_INCORRECT_ATTESTATIONS
|
|
179
166
|
- `slashAttestDescendantOfInvalidPenalty`: Penalty for ATTESTED_DESCENDANT_OF_INVALID
|
|
180
167
|
- `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)
|
|
168
|
+
- `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
169
|
|
|
185
170
|
Considerations:
|
|
186
171
|
|
|
@@ -195,24 +180,25 @@ Details about specific offenses in the system:
|
|
|
195
180
|
|
|
196
181
|
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
182
|
|
|
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
|
-
- `
|
|
200
|
-
- `
|
|
201
|
-
- `
|
|
183
|
+
Inactivity slashing is handled by the `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:
|
|
184
|
+
- `checkpoint-mined` if the checkpoint was added to L1
|
|
185
|
+
- `checkpoint-proposed` if the checkpoint received at least one attestation, but didn't make it to L1
|
|
186
|
+
- `checkpoint-missed` if blocks were proposed but the checkpoint received no attestations
|
|
187
|
+
- `blocks-missed` if no block proposals were sent for this slot at all
|
|
202
188
|
|
|
203
|
-
And assigns one of the following to each validator:
|
|
204
|
-
- `attestation-sent` if there was a `
|
|
205
|
-
- `attestation-missed` if there was a `
|
|
206
|
-
- none if the slot was a `
|
|
189
|
+
And assigns one of the following to each validator (these refer to checkpoint attestations):
|
|
190
|
+
- `attestation-sent` if there was a `checkpoint-proposed` or `checkpoint-mined` and a checkpoint attestation from this validator was seen on either on L1 or on the P2P network
|
|
191
|
+
- `attestation-missed` if there was a `checkpoint-proposed` or `checkpoint-mined` but no checkpoint attestation was seen
|
|
192
|
+
- none if the slot was a `blocks-missed`
|
|
193
|
+
|
|
194
|
+
Both `blocks-missed` and `checkpoint-missed` count as proposer inactivity.
|
|
207
195
|
|
|
208
196
|
Once an epoch is proven, the sentinel computes the _proven performance_ for the epoch for each validator. Note that we wait until the epoch is proven so we know that the data for all blocks in the epoch was available, and validators who did not attest were effectively inactive. Then, for each validator such that:
|
|
209
197
|
|
|
210
198
|
```
|
|
211
|
-
total_failures = count(
|
|
212
|
-
total = count(
|
|
199
|
+
total_failures = count(blocks-missed) + count(checkpoint-missed) + count(attestation-missed)
|
|
200
|
+
total = count(checkpoint-*) + count(blocks-*) + count(attestation-*)
|
|
213
201
|
total_failures / total >= slash_inactivity_target_percentage
|
|
214
202
|
```
|
|
215
203
|
|
|
216
204
|
They are voted to be slashed for inactivity. Note that, if `slashInactivityConsecutiveEpochThreshold` is greater than one, we first check if the above is true for the last `threshold` times the given validator was part of a committee, and only then trigger the offense.
|
|
217
|
-
|
|
218
|
-
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFRbkUsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJckUsWUFBWSxFQUFFLGFBQWEsRUFBRSxDQUFDO0FBRTlCLGVBQU8sTUFBTSxvQkFBb0IsRUFBRSxhQW9CbEMsQ0FBQztBQUVGLGVBQU8sTUFBTSxxQkFBcUIsRUFBRSxrQkFBa0IsQ0FBQyxhQUFhLENBMkhuRSxDQUFDIn0=
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,aAoBlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,aAAa,
|
|
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,aAoBlC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,aAAa,CA2HnE,CAAC"}
|
package/dest/config.js
CHANGED
|
@@ -3,8 +3,6 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import { slasherDefaultEnv } from './generated/slasher-defaults.js';
|
|
4
4
|
export const DefaultSlasherConfig = {
|
|
5
5
|
slashOverridePayload: undefined,
|
|
6
|
-
slashMinPenaltyPercentage: slasherDefaultEnv.SLASH_MIN_PENALTY_PERCENTAGE,
|
|
7
|
-
slashMaxPenaltyPercentage: slasherDefaultEnv.SLASH_MAX_PENALTY_PERCENTAGE,
|
|
8
6
|
slashValidatorsAlways: [],
|
|
9
7
|
slashValidatorsNever: [],
|
|
10
8
|
slashPrunePenalty: BigInt(slasherDefaultEnv.SLASH_PRUNE_PENALTY),
|
|
@@ -12,6 +10,8 @@ export const DefaultSlasherConfig = {
|
|
|
12
10
|
slashInactivityTargetPercentage: slasherDefaultEnv.SLASH_INACTIVITY_TARGET_PERCENTAGE,
|
|
13
11
|
slashInactivityConsecutiveEpochThreshold: slasherDefaultEnv.SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD,
|
|
14
12
|
slashBroadcastedInvalidBlockPenalty: BigInt(slasherDefaultEnv.SLASH_INVALID_BLOCK_PENALTY),
|
|
13
|
+
slashDuplicateProposalPenalty: BigInt(slasherDefaultEnv.SLASH_DUPLICATE_PROPOSAL_PENALTY),
|
|
14
|
+
slashDuplicateAttestationPenalty: BigInt(slasherDefaultEnv.SLASH_DUPLICATE_ATTESTATION_PENALTY),
|
|
15
15
|
slashInactivityPenalty: BigInt(slasherDefaultEnv.SLASH_INACTIVITY_PENALTY),
|
|
16
16
|
slashProposeInvalidAttestationsPenalty: BigInt(slasherDefaultEnv.SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY),
|
|
17
17
|
slashAttestDescendantOfInvalidPenalty: BigInt(slasherDefaultEnv.SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY),
|
|
@@ -29,16 +29,6 @@ export const slasherConfigMappings = {
|
|
|
29
29
|
parseEnv: (val)=>val ? EthAddress.fromString(val) : undefined,
|
|
30
30
|
defaultValue: DefaultSlasherConfig.slashOverridePayload
|
|
31
31
|
},
|
|
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
32
|
slashValidatorsAlways: {
|
|
43
33
|
env: 'SLASH_VALIDATORS_ALWAYS',
|
|
44
34
|
description: 'Comma-separated list of validator addresses that should always be slashed.',
|
|
@@ -66,6 +56,16 @@ export const slasherConfigMappings = {
|
|
|
66
56
|
description: 'Penalty amount for slashing a validator for an invalid block proposed via p2p.',
|
|
67
57
|
...bigintConfigHelper(DefaultSlasherConfig.slashBroadcastedInvalidBlockPenalty)
|
|
68
58
|
},
|
|
59
|
+
slashDuplicateProposalPenalty: {
|
|
60
|
+
env: 'SLASH_DUPLICATE_PROPOSAL_PENALTY',
|
|
61
|
+
description: 'Penalty amount for slashing a validator for sending duplicate proposals.',
|
|
62
|
+
...bigintConfigHelper(DefaultSlasherConfig.slashDuplicateProposalPenalty)
|
|
63
|
+
},
|
|
64
|
+
slashDuplicateAttestationPenalty: {
|
|
65
|
+
env: 'SLASH_DUPLICATE_ATTESTATION_PENALTY',
|
|
66
|
+
description: 'Penalty amount for slashing a validator for signing attestations for different proposals at the same slot.',
|
|
67
|
+
...bigintConfigHelper(DefaultSlasherConfig.slashDuplicateAttestationPenalty)
|
|
68
|
+
},
|
|
69
69
|
slashInactivityTargetPercentage: {
|
|
70
70
|
env: 'SLASH_INACTIVITY_TARGET_PERCENTAGE',
|
|
71
71
|
description: 'Missed attestation percentage to trigger creation of inactivity slash payload (0, 1]. Must be greater than 0',
|
|
@@ -118,7 +118,7 @@ export const slasherConfigMappings = {
|
|
|
118
118
|
...numberConfigHelper(DefaultSlasherConfig.slashMaxPayloadSize)
|
|
119
119
|
},
|
|
120
120
|
slashGracePeriodL2Slots: {
|
|
121
|
-
description: 'Number of L2 slots
|
|
121
|
+
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
122
|
env: 'SLASH_GRACE_PERIOD_L2_SLOTS',
|
|
123
123
|
...numberConfigHelper(DefaultSlasherConfig.slashGracePeriodL2Slots)
|
|
124
124
|
},
|
|
@@ -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['l1Contracts'], 'rollupAddress' | '
|
|
13
|
+
}, l1Contracts: Pick<L1ReaderConfig['l1Contracts'], '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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2ZhY2FkZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ZhY3RvcnkvY3JlYXRlX2ZhY2FkZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHeEQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUd2RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUc5RCxPQUFPLEtBQUssRUFBRSxzQkFBc0IsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRTdFLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUU3Qyw4RkFBOEY7QUFDOUYsd0JBQXNCLG1CQUFtQixDQUN2QyxNQUFNLEVBQUUsYUFBYSxHQUFHLGVBQWUsR0FBRztJQUFFLG9CQUFvQixFQUFFLE1BQU0sQ0FBQTtDQUFFLEVBQzFFLFdBQVcsRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLGFBQWEsQ0FBQyxFQUFFLGVBQWUsR0FBRyxpQkFBaUIsQ0FBQyxFQUNyRixRQUFRLEVBQUUsVUFBVSxFQUNwQixRQUFRLEVBQUUsT0FBTyxFQUFFLEVBQ25CLFlBQVksRUFBRSxZQUFZLEVBQzFCLFVBQVUsRUFBRSxVQUFVO0FBQ3RCLDZHQUE2RztBQUM3RyxrQkFBa0IsR0FBRSxVQUFVLEVBQU8sRUFDckMsTUFBTSx5Q0FBMEIsR0FDL0IsT0FBTyxDQUFDLHNCQUFzQixDQUFDLENBa0RqQyJ9
|
|
@@ -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,CAAC,aAAa,CAAC,EAAE,eAAe,GAAG,iBAAiB,CAAC,EACrF,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"}
|
|
@@ -1,73 +1,25 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
4
|
-
import { EmpireSlasherClient } from '../empire_slasher_client.js';
|
|
5
2
|
import { NullSlasherClient } from '../null_slasher_client.js';
|
|
3
|
+
import { SlasherClient } from '../slasher_client.js';
|
|
6
4
|
import { SlasherOffensesStore } from '../stores/offenses_store.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { getTallySlasherSettings } from './get_settings.js';
|
|
10
|
-
/** Creates a slasher client implementation (either tally or empire) based on the slasher proposer type in the rollup */ export async function createSlasherImplementation(config, rollup, l1Client, slashFactoryAddress, watchers, epochCache, dateProvider, kvStore, logger = createLogger('slasher')) {
|
|
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, logger = createLogger('slasher')) {
|
|
11
7
|
const proposer = await rollup.getSlashingProposer();
|
|
12
8
|
if (!proposer) {
|
|
13
9
|
return new NullSlasherClient(config);
|
|
14
|
-
} else if (proposer.type === 'tally') {
|
|
15
|
-
return createTallySlasher(config, rollup, proposer, watchers, dateProvider, epochCache, kvStore, logger);
|
|
16
10
|
} else {
|
|
17
|
-
|
|
18
|
-
throw new Error('Cannot initialize an empire-based SlasherClient without a SlashFactory address');
|
|
19
|
-
}
|
|
20
|
-
const slashFactory = new SlashFactoryContract(l1Client, slashFactoryAddress.toString());
|
|
21
|
-
return createEmpireSlasher(config, rollup, proposer, slashFactory, watchers, dateProvider, kvStore, logger);
|
|
11
|
+
return createSlasher(config, rollup, proposer, watchers, dateProvider, epochCache, kvStore, rollupRegisteredAtL2Slot, logger);
|
|
22
12
|
}
|
|
23
13
|
}
|
|
24
|
-
async function
|
|
25
|
-
if (slashingProposer.type !== 'empire') {
|
|
26
|
-
throw new Error('Slashing proposer contract is not of type Empire');
|
|
27
|
-
}
|
|
28
|
-
const [slashingExecutionDelayInRounds, slashingPayloadLifetimeInRounds, slashingRoundSize, slashingQuorumSize, epochDuration, proofSubmissionEpochs, l1GenesisTime, slotDuration, l1StartBlock, slasher] = await Promise.all([
|
|
29
|
-
slashingProposer.getExecutionDelayInRounds(),
|
|
30
|
-
slashingProposer.getLifetimeInRounds(),
|
|
31
|
-
slashingProposer.getRoundSize(),
|
|
32
|
-
slashingProposer.getQuorumSize(),
|
|
33
|
-
rollup.getEpochDuration(),
|
|
34
|
-
rollup.getProofSubmissionEpochs(),
|
|
35
|
-
rollup.getL1GenesisTime(),
|
|
36
|
-
rollup.getSlotDuration(),
|
|
37
|
-
rollup.getL1StartBlock(),
|
|
38
|
-
rollup.getSlasherContract()
|
|
39
|
-
]);
|
|
14
|
+
async function createSlasher(config, rollup, slashingProposer, watchers, dateProvider, epochCache, kvStore, rollupRegisteredAtL2Slot, logger = createLogger('slasher')) {
|
|
40
15
|
const settings = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
slashingRoundSize: Number(slashingRoundSize),
|
|
44
|
-
slashingQuorumSize: Number(slashingQuorumSize),
|
|
45
|
-
epochDuration: Number(epochDuration),
|
|
46
|
-
proofSubmissionEpochs: Number(proofSubmissionEpochs),
|
|
47
|
-
l1GenesisTime: l1GenesisTime,
|
|
48
|
-
slotDuration: Number(slotDuration),
|
|
49
|
-
l1StartBlock,
|
|
50
|
-
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
51
|
-
slashingAmounts: undefined
|
|
16
|
+
...await getSlasherSettings(rollup, slashingProposer),
|
|
17
|
+
rollupRegisteredAtL2Slot
|
|
52
18
|
};
|
|
53
|
-
const payloadsStore = new SlasherPayloadsStore(kvStore, {
|
|
54
|
-
slashingPayloadLifetimeInRounds: settings.slashingPayloadLifetimeInRounds
|
|
55
|
-
});
|
|
56
|
-
const offensesStore = new SlasherOffensesStore(kvStore, {
|
|
57
|
-
...settings,
|
|
58
|
-
slashOffenseExpirationRounds: config.slashOffenseExpirationRounds
|
|
59
|
-
});
|
|
60
|
-
return new EmpireSlasherClient(config, settings, slashFactoryContract, slashingProposer, slasher, rollup, watchers, dateProvider, offensesStore, payloadsStore, logger);
|
|
61
|
-
}
|
|
62
|
-
async function createTallySlasher(config, rollup, slashingProposer, watchers, dateProvider, epochCache, kvStore, logger = createLogger('slasher')) {
|
|
63
|
-
if (slashingProposer.type !== 'tally') {
|
|
64
|
-
throw new Error('Slashing proposer contract is not of type tally');
|
|
65
|
-
}
|
|
66
|
-
const settings = await getTallySlasherSettings(rollup, slashingProposer);
|
|
67
19
|
const slasher = await rollup.getSlasherContract();
|
|
68
20
|
const offensesStore = new SlasherOffensesStore(kvStore, {
|
|
69
21
|
...settings,
|
|
70
22
|
slashOffenseExpirationRounds: config.slashOffenseExpirationRounds
|
|
71
23
|
});
|
|
72
|
-
return new
|
|
24
|
+
return new SlasherClient(config, settings, slashingProposer, slasher, rollup, watchers, epochCache, dateProvider, offensesStore, logger);
|
|
73
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RollupContract,
|
|
2
|
-
import type {
|
|
3
|
-
export declare function
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
1
|
+
import type { RollupContract, SlashingProposerContract } from '@aztec/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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3NldHRpbmdzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZmFjdG9yeS9nZXRfc2V0dGluZ3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFFMUYsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFNUQsd0JBQXNCLGtCQUFrQixDQUN0QyxNQUFNLEVBQUUsY0FBYyxFQUN0QixnQkFBZ0IsQ0FBQyxFQUFFLHdCQUF3QixHQUMxQyxPQUFPLENBQUMsSUFBSSxDQUFDLGVBQWUsRUFBRSwwQkFBMEIsQ0FBQyxDQUFDLENBa0Q1RCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_settings.d.ts","sourceRoot":"","sources":["../../src/factory/get_settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
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,2BAA2B,CAAC;AAE1F,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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export async function
|
|
1
|
+
export async function getSlasherSettings(rollup, slashingProposer) {
|
|
2
2
|
if (!slashingProposer) {
|
|
3
3
|
const rollupSlashingProposer = await rollup.getSlashingProposer();
|
|
4
|
-
if (!rollupSlashingProposer
|
|
5
|
-
throw new Error('Rollup slashing proposer
|
|
4
|
+
if (!rollupSlashingProposer) {
|
|
5
|
+
throw new Error('Rollup slashing proposer not found');
|
|
6
6
|
}
|
|
7
7
|
slashingProposer = rollupSlashingProposer;
|
|
8
8
|
}
|
package/dest/factory/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createSlasherFacade as createSlasher } from './create_facade.js';
|
|
2
|
-
export {
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
export { getSlasherSettings } from './get_settings.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9mYWN0b3J5L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxtQkFBbUIsSUFBSSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUMxRSxPQUFPLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQyJ9
|
|
@@ -1 +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,
|
|
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"}
|
package/dest/factory/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createSlasherFacade as createSlasher } from './create_facade.js';
|
|
2
|
-
export {
|
|
2
|
+
export { getSlasherSettings } from './get_settings.js';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/** Default slasher configuration values from network-defaults.yml */
|
|
2
2
|
export declare const slasherDefaultEnv: {
|
|
3
|
-
readonly SLASH_MIN_PENALTY_PERCENTAGE: 0.5;
|
|
4
|
-
readonly SLASH_MAX_PENALTY_PERCENTAGE: 2;
|
|
5
3
|
readonly SLASH_OFFENSE_EXPIRATION_ROUNDS: 4;
|
|
6
|
-
readonly SLASH_MAX_PAYLOAD_SIZE:
|
|
4
|
+
readonly SLASH_MAX_PAYLOAD_SIZE: 80;
|
|
7
5
|
readonly SLASH_EXECUTE_ROUNDS_LOOK_BACK: 4;
|
|
8
6
|
readonly SLASH_PRUNE_PENALTY: 10000000000000000000;
|
|
9
7
|
readonly SLASH_DATA_WITHHOLDING_PENALTY: 10000000000000000000;
|
|
@@ -12,6 +10,8 @@ export declare const slasherDefaultEnv: {
|
|
|
12
10
|
readonly SLASH_INACTIVITY_PENALTY: 10000000000000000000;
|
|
13
11
|
readonly SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY: 10000000000000000000;
|
|
14
12
|
readonly SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY: 10000000000000000000;
|
|
13
|
+
readonly SLASH_DUPLICATE_PROPOSAL_PENALTY: 0;
|
|
14
|
+
readonly SLASH_DUPLICATE_ATTESTATION_PENALTY: 0;
|
|
15
15
|
readonly SLASH_UNKNOWN_PENALTY: 10000000000000000000;
|
|
16
16
|
readonly SLASH_INVALID_BLOCK_PENALTY: 10000000000000000000;
|
|
17
17
|
readonly SLASH_GRACE_PERIOD_L2_SLOTS: 0;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// Auto-generated from spartan/environments/network-defaults.yml
|
|
2
2
|
// Do not edit manually - run yarn generate to regenerate
|
|
3
3
|
/** Default slasher configuration values from network-defaults.yml */ export const slasherDefaultEnv = {
|
|
4
|
-
SLASH_MIN_PENALTY_PERCENTAGE: 0.5,
|
|
5
|
-
SLASH_MAX_PENALTY_PERCENTAGE: 2,
|
|
6
4
|
SLASH_OFFENSE_EXPIRATION_ROUNDS: 4,
|
|
7
|
-
SLASH_MAX_PAYLOAD_SIZE:
|
|
5
|
+
SLASH_MAX_PAYLOAD_SIZE: 80,
|
|
8
6
|
SLASH_EXECUTE_ROUNDS_LOOK_BACK: 4,
|
|
9
7
|
SLASH_PRUNE_PENALTY: 10000000000000000000,
|
|
10
8
|
SLASH_DATA_WITHHOLDING_PENALTY: 10000000000000000000,
|
|
@@ -13,6 +11,8 @@
|
|
|
13
11
|
SLASH_INACTIVITY_PENALTY: 10000000000000000000,
|
|
14
12
|
SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY: 10000000000000000000,
|
|
15
13
|
SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY: 10000000000000000000,
|
|
14
|
+
SLASH_DUPLICATE_PROPOSAL_PENALTY: 0,
|
|
15
|
+
SLASH_DUPLICATE_ATTESTATION_PENALTY: 0,
|
|
16
16
|
SLASH_UNKNOWN_PENALTY: 10000000000000000000,
|
|
17
17
|
SLASH_INVALID_BLOCK_PENALTY: 10000000000000000000,
|
|
18
18
|
SLASH_GRACE_PERIOD_L2_SLOTS: 0
|
package/dest/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export * from './config.js';
|
|
2
2
|
export * from './watchers/epoch_prune_watcher.js';
|
|
3
3
|
export * from './watchers/attestations_block_watcher.js';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './tally_slasher_client.js';
|
|
4
|
+
export * from './slasher_client.js';
|
|
6
5
|
export * from './slash_offenses_collector.js';
|
|
7
6
|
export * from './slasher_client_interface.js';
|
|
8
7
|
export * from './factory/index.js';
|
|
9
8
|
export * from './watcher.js';
|
|
10
9
|
export * from '@aztec/stdlib/slashing';
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLG1DQUFtQyxDQUFDO0FBQ2xELGNBQWMsMENBQTBDLENBQUM7QUFDekQsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLCtCQUErQixDQUFDO0FBQzlDLGNBQWMsK0JBQStCLENBQUM7QUFDOUMsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLHdCQUF3QixDQUFDIn0=
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mCAAmC,CAAC;AAClD,cAAc,0CAA0C,CAAC;AACzD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mCAAmC,CAAC;AAClD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from './config.js';
|
|
2
2
|
export * from './watchers/epoch_prune_watcher.js';
|
|
3
3
|
export * from './watchers/attestations_block_watcher.js';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './tally_slasher_client.js';
|
|
4
|
+
export * from './slasher_client.js';
|
|
6
5
|
export * from './slash_offenses_collector.js';
|
|
7
6
|
export * from './slasher_client_interface.js';
|
|
8
7
|
export * from './factory/index.js';
|