@aztec/stdlib 2.0.0-nightly.20250829 → 2.0.0-nightly.20250830
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/dest/interfaces/aztec-node-admin.d.ts +36 -54
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/slasher.d.ts +31 -55
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +9 -15
- package/dest/slashing/helpers.d.ts +3 -0
- package/dest/slashing/helpers.d.ts.map +1 -1
- package/dest/slashing/helpers.js +23 -0
- package/dest/slashing/tally.d.ts +6 -3
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +24 -8
- package/dest/vks/verification_key.d.ts +0 -3
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +0 -7
- package/package.json +8 -8
- package/src/interfaces/slasher.ts +15 -27
- package/src/slashing/helpers.ts +36 -0
- package/src/slashing/tally.ts +35 -13
- package/src/vks/verification_key.ts +0 -9
|
@@ -103,58 +103,45 @@ export declare const AztecNodeAdminConfigSchema: z.ZodObject<z.objectUtil.extend
|
|
|
103
103
|
proverAgentCount: z.ZodNumber;
|
|
104
104
|
}>, {
|
|
105
105
|
slashOverridePayload: z.ZodOptional<z.ZodType<import("@aztec/foundation/schemas").EthAddress, any, string>>;
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
slashMinPenaltyPercentage: z.ZodNumber;
|
|
107
|
+
slashMaxPenaltyPercentage: z.ZodNumber;
|
|
108
|
+
slashValidatorsAlways: z.ZodArray<z.ZodType<import("@aztec/foundation/schemas").EthAddress, any, string>, "many">;
|
|
109
|
+
slashValidatorsNever: z.ZodArray<z.ZodType<import("@aztec/foundation/schemas").EthAddress, any, string>, "many">;
|
|
108
110
|
slashPrunePenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
slashBroadcastedInvalidBlockPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
112
|
-
slashBroadcastedInvalidBlockMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
113
|
-
slashInactivityEnabled: z.ZodBoolean;
|
|
114
|
-
slashInactivityCreateTargetPercentage: z.ZodNumber;
|
|
115
|
-
slashInactivitySignalTargetPercentage: z.ZodNumber;
|
|
116
|
-
slashInactivityCreatePenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
117
|
-
slashInactivityMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
111
|
+
slashInactivityTargetPercentage: z.ZodNumber;
|
|
112
|
+
slashInactivityPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
118
113
|
slashProposeInvalidAttestationsPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
119
|
-
slashProposeInvalidAttestationsMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
120
114
|
slashAttestDescendantOfInvalidPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
121
|
-
slashAttestDescendantOfInvalidMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
122
115
|
slashUnknownPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
123
|
-
slashUnknownMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
124
116
|
slashOffenseExpirationRounds: z.ZodNumber;
|
|
125
117
|
slashMaxPayloadSize: z.ZodNumber;
|
|
126
118
|
slashGracePeriodL2Slots: z.ZodNumber;
|
|
119
|
+
slashBroadcastedInvalidBlockPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
120
|
+
slashSelfAllowed: z.ZodOptional<z.ZodBoolean>;
|
|
127
121
|
}>, {
|
|
128
122
|
maxTxPoolSize: z.ZodNumber;
|
|
129
123
|
}>, "strip", z.ZodTypeAny, {
|
|
130
124
|
secondsBeforeInvalidatingBlockAsCommitteeMember: number;
|
|
131
125
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: number;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
proverAgentCount: number;
|
|
137
|
-
slashPayloadTtlSeconds: number;
|
|
138
|
-
slashPruneEnabled: boolean;
|
|
126
|
+
slashMinPenaltyPercentage: number;
|
|
127
|
+
slashMaxPenaltyPercentage: number;
|
|
128
|
+
slashValidatorsAlways: import("@aztec/foundation/schemas").EthAddress[];
|
|
129
|
+
slashValidatorsNever: import("@aztec/foundation/schemas").EthAddress[];
|
|
139
130
|
slashPrunePenalty: bigint;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
143
|
-
slashBroadcastedInvalidBlockMaxPenalty: bigint;
|
|
144
|
-
slashInactivityEnabled: boolean;
|
|
145
|
-
slashInactivityCreateTargetPercentage: number;
|
|
146
|
-
slashInactivitySignalTargetPercentage: number;
|
|
147
|
-
slashInactivityCreatePenalty: bigint;
|
|
148
|
-
slashInactivityMaxPenalty: bigint;
|
|
131
|
+
slashInactivityTargetPercentage: number;
|
|
132
|
+
slashInactivityPenalty: bigint;
|
|
149
133
|
slashProposeInvalidAttestationsPenalty: bigint;
|
|
150
|
-
slashProposeInvalidAttestationsMaxPenalty: bigint;
|
|
151
134
|
slashAttestDescendantOfInvalidPenalty: bigint;
|
|
152
|
-
slashAttestDescendantOfInvalidMaxPenalty: bigint;
|
|
153
135
|
slashUnknownPenalty: bigint;
|
|
154
|
-
slashUnknownMaxPenalty: bigint;
|
|
155
136
|
slashOffenseExpirationRounds: number;
|
|
156
137
|
slashMaxPayloadSize: number;
|
|
157
138
|
slashGracePeriodL2Slots: number;
|
|
139
|
+
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
140
|
+
realProofs: boolean;
|
|
141
|
+
proverTestDelayType: "fixed" | "realistic";
|
|
142
|
+
proverTestDelayMs: number;
|
|
143
|
+
proverTestDelayFactor: number;
|
|
144
|
+
proverAgentCount: number;
|
|
158
145
|
maxTxPoolSize: number;
|
|
159
146
|
coinbase?: import("@aztec/foundation/schemas").EthAddress | undefined;
|
|
160
147
|
feeRecipient?: import("../aztec-address/index.js").AztecAddress | undefined;
|
|
@@ -185,37 +172,31 @@ export declare const AztecNodeAdminConfigSchema: z.ZodObject<z.objectUtil.extend
|
|
|
185
172
|
attestationPropagationTime?: number | undefined;
|
|
186
173
|
skipCollectingAttestations?: boolean | undefined;
|
|
187
174
|
proverId?: import("@aztec/foundation/schemas").EthAddress | undefined;
|
|
188
|
-
nodeUrl?: string | undefined;
|
|
189
175
|
slashOverridePayload?: import("@aztec/foundation/schemas").EthAddress | undefined;
|
|
176
|
+
slashSelfAllowed?: boolean | undefined;
|
|
177
|
+
nodeUrl?: string | undefined;
|
|
190
178
|
}, {
|
|
191
179
|
secondsBeforeInvalidatingBlockAsCommitteeMember: number;
|
|
192
180
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: number;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
proverAgentCount: number;
|
|
198
|
-
slashPayloadTtlSeconds: number;
|
|
199
|
-
slashPruneEnabled: boolean;
|
|
181
|
+
slashMinPenaltyPercentage: number;
|
|
182
|
+
slashMaxPenaltyPercentage: number;
|
|
183
|
+
slashValidatorsAlways: string[];
|
|
184
|
+
slashValidatorsNever: string[];
|
|
200
185
|
slashPrunePenalty: string | number | bigint;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
slashBroadcastedInvalidBlockPenalty: string | number | bigint;
|
|
204
|
-
slashBroadcastedInvalidBlockMaxPenalty: string | number | bigint;
|
|
205
|
-
slashInactivityEnabled: boolean;
|
|
206
|
-
slashInactivityCreateTargetPercentage: number;
|
|
207
|
-
slashInactivitySignalTargetPercentage: number;
|
|
208
|
-
slashInactivityCreatePenalty: string | number | bigint;
|
|
209
|
-
slashInactivityMaxPenalty: string | number | bigint;
|
|
186
|
+
slashInactivityTargetPercentage: number;
|
|
187
|
+
slashInactivityPenalty: string | number | bigint;
|
|
210
188
|
slashProposeInvalidAttestationsPenalty: string | number | bigint;
|
|
211
|
-
slashProposeInvalidAttestationsMaxPenalty: string | number | bigint;
|
|
212
189
|
slashAttestDescendantOfInvalidPenalty: string | number | bigint;
|
|
213
|
-
slashAttestDescendantOfInvalidMaxPenalty: string | number | bigint;
|
|
214
190
|
slashUnknownPenalty: string | number | bigint;
|
|
215
|
-
slashUnknownMaxPenalty: string | number | bigint;
|
|
216
191
|
slashOffenseExpirationRounds: number;
|
|
217
192
|
slashMaxPayloadSize: number;
|
|
218
193
|
slashGracePeriodL2Slots: number;
|
|
194
|
+
slashBroadcastedInvalidBlockPenalty: string | number | bigint;
|
|
195
|
+
realProofs: boolean;
|
|
196
|
+
proverTestDelayType: "fixed" | "realistic";
|
|
197
|
+
proverTestDelayMs: number;
|
|
198
|
+
proverTestDelayFactor: number;
|
|
199
|
+
proverAgentCount: number;
|
|
219
200
|
maxTxPoolSize: number;
|
|
220
201
|
coinbase?: any;
|
|
221
202
|
feeRecipient?: any;
|
|
@@ -246,8 +227,9 @@ export declare const AztecNodeAdminConfigSchema: z.ZodObject<z.objectUtil.extend
|
|
|
246
227
|
attestationPropagationTime?: number | undefined;
|
|
247
228
|
skipCollectingAttestations?: boolean | undefined;
|
|
248
229
|
proverId?: any;
|
|
249
|
-
nodeUrl?: string | undefined;
|
|
250
230
|
slashOverridePayload?: string | undefined;
|
|
231
|
+
slashSelfAllowed?: boolean | undefined;
|
|
232
|
+
nodeUrl?: string | undefined;
|
|
251
233
|
}>;
|
|
252
234
|
export declare const AztecNodeAdminApiSchema: ApiSchemaFor<AztecNodeAdmin>;
|
|
253
235
|
export declare function createAztecNodeAdminClient(url: string, versions?: Partial<ComponentsVersions>, fetch?: typeof defaultFetch): AztecNodeAdmin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec-node-admin.d.ts","sourceRoot":"","sources":["../../src/interfaces/aztec-node-admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE1F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,EAAiB,KAAK,iBAAiB,EAA2B,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,KAAK,kBAAkB,EAAgC,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,cAAc,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE3C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;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AG,EAAE,MAAM,EACX,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,EAC1C,KAAK,sBAAe,GACnB,cAAc,CAMhB"}
|
|
@@ -3,96 +3,72 @@ import { z } from 'zod';
|
|
|
3
3
|
export type SlasherClientType = 'empire' | 'tally';
|
|
4
4
|
export interface SlasherConfig {
|
|
5
5
|
slashOverridePayload?: EthAddress;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
slashMinPenaltyPercentage: number;
|
|
7
|
+
slashMaxPenaltyPercentage: number;
|
|
8
|
+
slashSelfAllowed?: boolean;
|
|
9
|
+
slashValidatorsAlways: EthAddress[];
|
|
10
|
+
slashValidatorsNever: EthAddress[];
|
|
11
|
+
slashInactivityTargetPercentage: number;
|
|
8
12
|
slashPrunePenalty: bigint;
|
|
9
|
-
|
|
10
|
-
slashBroadcastedInvalidBlockEnabled: boolean;
|
|
13
|
+
slashInactivityPenalty: bigint;
|
|
11
14
|
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
12
|
-
slashBroadcastedInvalidBlockMaxPenalty: bigint;
|
|
13
|
-
slashInactivityEnabled: boolean;
|
|
14
|
-
slashInactivityCreateTargetPercentage: number;
|
|
15
|
-
slashInactivitySignalTargetPercentage: number;
|
|
16
|
-
slashInactivityCreatePenalty: bigint;
|
|
17
|
-
slashInactivityMaxPenalty: bigint;
|
|
18
15
|
slashProposeInvalidAttestationsPenalty: bigint;
|
|
19
|
-
slashProposeInvalidAttestationsMaxPenalty: bigint;
|
|
20
16
|
slashAttestDescendantOfInvalidPenalty: bigint;
|
|
21
|
-
slashAttestDescendantOfInvalidMaxPenalty: bigint;
|
|
22
17
|
slashUnknownPenalty: bigint;
|
|
23
|
-
slashUnknownMaxPenalty: bigint;
|
|
24
18
|
slashOffenseExpirationRounds: number;
|
|
25
19
|
slashMaxPayloadSize: number;
|
|
26
20
|
slashGracePeriodL2Slots: number;
|
|
27
21
|
}
|
|
28
22
|
export declare const SlasherConfigSchema: z.ZodObject<{
|
|
29
23
|
slashOverridePayload: z.ZodOptional<z.ZodType<EthAddress, any, string>>;
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
slashMinPenaltyPercentage: z.ZodNumber;
|
|
25
|
+
slashMaxPenaltyPercentage: z.ZodNumber;
|
|
26
|
+
slashValidatorsAlways: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
27
|
+
slashValidatorsNever: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
32
28
|
slashPrunePenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
slashBroadcastedInvalidBlockPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
36
|
-
slashBroadcastedInvalidBlockMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
37
|
-
slashInactivityEnabled: z.ZodBoolean;
|
|
38
|
-
slashInactivityCreateTargetPercentage: z.ZodNumber;
|
|
39
|
-
slashInactivitySignalTargetPercentage: z.ZodNumber;
|
|
40
|
-
slashInactivityCreatePenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
41
|
-
slashInactivityMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
29
|
+
slashInactivityTargetPercentage: z.ZodNumber;
|
|
30
|
+
slashInactivityPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
42
31
|
slashProposeInvalidAttestationsPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
43
|
-
slashProposeInvalidAttestationsMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
44
32
|
slashAttestDescendantOfInvalidPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
45
|
-
slashAttestDescendantOfInvalidMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
46
33
|
slashUnknownPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
47
|
-
slashUnknownMaxPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
48
34
|
slashOffenseExpirationRounds: z.ZodNumber;
|
|
49
35
|
slashMaxPayloadSize: z.ZodNumber;
|
|
50
36
|
slashGracePeriodL2Slots: z.ZodNumber;
|
|
37
|
+
slashBroadcastedInvalidBlockPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
38
|
+
slashSelfAllowed: z.ZodOptional<z.ZodBoolean>;
|
|
51
39
|
}, "strip", z.ZodTypeAny, {
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
slashMinPenaltyPercentage: number;
|
|
41
|
+
slashMaxPenaltyPercentage: number;
|
|
42
|
+
slashValidatorsAlways: EthAddress[];
|
|
43
|
+
slashValidatorsNever: EthAddress[];
|
|
54
44
|
slashPrunePenalty: bigint;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
58
|
-
slashBroadcastedInvalidBlockMaxPenalty: bigint;
|
|
59
|
-
slashInactivityEnabled: boolean;
|
|
60
|
-
slashInactivityCreateTargetPercentage: number;
|
|
61
|
-
slashInactivitySignalTargetPercentage: number;
|
|
62
|
-
slashInactivityCreatePenalty: bigint;
|
|
63
|
-
slashInactivityMaxPenalty: bigint;
|
|
45
|
+
slashInactivityTargetPercentage: number;
|
|
46
|
+
slashInactivityPenalty: bigint;
|
|
64
47
|
slashProposeInvalidAttestationsPenalty: bigint;
|
|
65
|
-
slashProposeInvalidAttestationsMaxPenalty: bigint;
|
|
66
48
|
slashAttestDescendantOfInvalidPenalty: bigint;
|
|
67
|
-
slashAttestDescendantOfInvalidMaxPenalty: bigint;
|
|
68
49
|
slashUnknownPenalty: bigint;
|
|
69
|
-
slashUnknownMaxPenalty: bigint;
|
|
70
50
|
slashOffenseExpirationRounds: number;
|
|
71
51
|
slashMaxPayloadSize: number;
|
|
72
52
|
slashGracePeriodL2Slots: number;
|
|
53
|
+
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
73
54
|
slashOverridePayload?: EthAddress | undefined;
|
|
55
|
+
slashSelfAllowed?: boolean | undefined;
|
|
74
56
|
}, {
|
|
75
|
-
|
|
76
|
-
|
|
57
|
+
slashMinPenaltyPercentage: number;
|
|
58
|
+
slashMaxPenaltyPercentage: number;
|
|
59
|
+
slashValidatorsAlways: string[];
|
|
60
|
+
slashValidatorsNever: string[];
|
|
77
61
|
slashPrunePenalty: string | number | bigint;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
slashBroadcastedInvalidBlockPenalty: string | number | bigint;
|
|
81
|
-
slashBroadcastedInvalidBlockMaxPenalty: string | number | bigint;
|
|
82
|
-
slashInactivityEnabled: boolean;
|
|
83
|
-
slashInactivityCreateTargetPercentage: number;
|
|
84
|
-
slashInactivitySignalTargetPercentage: number;
|
|
85
|
-
slashInactivityCreatePenalty: string | number | bigint;
|
|
86
|
-
slashInactivityMaxPenalty: string | number | bigint;
|
|
62
|
+
slashInactivityTargetPercentage: number;
|
|
63
|
+
slashInactivityPenalty: string | number | bigint;
|
|
87
64
|
slashProposeInvalidAttestationsPenalty: string | number | bigint;
|
|
88
|
-
slashProposeInvalidAttestationsMaxPenalty: string | number | bigint;
|
|
89
65
|
slashAttestDescendantOfInvalidPenalty: string | number | bigint;
|
|
90
|
-
slashAttestDescendantOfInvalidMaxPenalty: string | number | bigint;
|
|
91
66
|
slashUnknownPenalty: string | number | bigint;
|
|
92
|
-
slashUnknownMaxPenalty: string | number | bigint;
|
|
93
67
|
slashOffenseExpirationRounds: number;
|
|
94
68
|
slashMaxPayloadSize: number;
|
|
95
69
|
slashGracePeriodL2Slots: number;
|
|
70
|
+
slashBroadcastedInvalidBlockPenalty: string | number | bigint;
|
|
96
71
|
slashOverridePayload?: string | undefined;
|
|
72
|
+
slashSelfAllowed?: boolean | undefined;
|
|
97
73
|
}>;
|
|
98
74
|
//# sourceMappingURL=slasher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slasher.d.ts","sourceRoot":"","sources":["../../src/interfaces/slasher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,oBAAoB,CAAC,EAAE,UAAU,CAAC;IAClC,
|
|
1
|
+
{"version":3,"file":"slasher.d.ts","sourceRoot":"","sources":["../../src/interfaces/slasher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,oBAAoB,CAAC,EAAE,UAAU,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,UAAU,EAAE,CAAC;IACpC,oBAAoB,EAAE,UAAU,EAAE,CAAC;IACnC,+BAA+B,EAAE,MAAM,CAAC;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,mCAAmC,EAAE,MAAM,CAAC;IAC5C,sCAAsC,EAAE,MAAM,CAAC;IAC/C,qCAAqC,EAAE,MAAM,CAAC;IAC9C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,4BAA4B,EAAE,MAAM,CAAC;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBE,CAAC"}
|
|
@@ -2,25 +2,19 @@ import { schemas } from '@aztec/foundation/schemas';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export const SlasherConfigSchema = z.object({
|
|
4
4
|
slashOverridePayload: schemas.EthAddress.optional(),
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
slashMinPenaltyPercentage: z.number(),
|
|
6
|
+
slashMaxPenaltyPercentage: z.number(),
|
|
7
|
+
slashValidatorsAlways: z.array(schemas.EthAddress),
|
|
8
|
+
slashValidatorsNever: z.array(schemas.EthAddress),
|
|
7
9
|
slashPrunePenalty: schemas.BigInt,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
|
|
11
|
-
slashBroadcastedInvalidBlockMaxPenalty: schemas.BigInt,
|
|
12
|
-
slashInactivityEnabled: z.boolean(),
|
|
13
|
-
slashInactivityCreateTargetPercentage: z.number(),
|
|
14
|
-
slashInactivitySignalTargetPercentage: z.number(),
|
|
15
|
-
slashInactivityCreatePenalty: schemas.BigInt,
|
|
16
|
-
slashInactivityMaxPenalty: schemas.BigInt,
|
|
10
|
+
slashInactivityTargetPercentage: z.number(),
|
|
11
|
+
slashInactivityPenalty: schemas.BigInt,
|
|
17
12
|
slashProposeInvalidAttestationsPenalty: schemas.BigInt,
|
|
18
|
-
slashProposeInvalidAttestationsMaxPenalty: schemas.BigInt,
|
|
19
13
|
slashAttestDescendantOfInvalidPenalty: schemas.BigInt,
|
|
20
|
-
slashAttestDescendantOfInvalidMaxPenalty: schemas.BigInt,
|
|
21
14
|
slashUnknownPenalty: schemas.BigInt,
|
|
22
|
-
slashUnknownMaxPenalty: schemas.BigInt,
|
|
23
15
|
slashOffenseExpirationRounds: z.number(),
|
|
24
16
|
slashMaxPayloadSize: z.number(),
|
|
25
|
-
slashGracePeriodL2Slots: z.number()
|
|
17
|
+
slashGracePeriodL2Slots: z.number(),
|
|
18
|
+
slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
|
|
19
|
+
slashSelfAllowed: z.boolean().optional()
|
|
26
20
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type L1RollupConstants } from '../epoch-helpers/index.js';
|
|
2
|
+
import type { SlasherConfig } from '../interfaces/slasher.js';
|
|
2
3
|
import { type Offense, OffenseType } from './types.js';
|
|
3
4
|
/** Returns the voting round number and voting slot within the round for a given L2 slot. */
|
|
4
5
|
export declare function getRoundForSlot(slot: bigint, constants: {
|
|
@@ -17,6 +18,8 @@ export declare function getEpochsForRound(round: bigint, constants: {
|
|
|
17
18
|
slashingRoundSize: number;
|
|
18
19
|
epochDuration: number;
|
|
19
20
|
}): bigint[];
|
|
21
|
+
/** Reads the configured penalty for a given offense type from a slasher config struct */
|
|
22
|
+
export declare function getPenaltyForOffense(offense: OffenseType, config: Pick<SlasherConfig, 'slashAttestDescendantOfInvalidPenalty' | 'slashBroadcastedInvalidBlockPenalty' | 'slashPrunePenalty' | 'slashUnknownPenalty' | 'slashInactivityPenalty' | 'slashProposeInvalidAttestationsPenalty'>): bigint;
|
|
20
23
|
/** Returns whether the `epochOrSlot` field for an offense references an epoch or a slot */
|
|
21
24
|
export declare function getTimeUnitForOffense(offense: OffenseType): 'epoch' | 'slot';
|
|
22
25
|
/** Returns the slot for a given offense. If the offense references an epoch, returns the first slot of the epoch. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/slashing/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAwC,MAAM,2BAA2B,CAAC;AACzG,OAAO,EAAE,KAAK,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvD,4FAA4F;AAC5F,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKvC;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAC9D,CAAC,MAAM,EAAE,MAAM,CAAC,CAKlB;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAC9D,MAAM,EAAE,CAUV;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAiB5E;AAED,qHAAqH;AACrH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAAC,EACrD,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAClD,MAAM,CAGR;AAED,6CAA6C;AAC7C,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,G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uCAAuC,GACvC,qCAAqC,GACrC,mBAAmB,GACnB,qBAAqB,GACrB,wBAAwB,GACxB,wCAAwC,CAC3C,UAsBF;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAiB5E;AAED,qHAAqH;AACrH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAAC,EACrD,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAClD,MAAM,CAGR;AAED,6CAA6C;AAC7C,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAAC,EACrD,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAClD,MAAM,CAGR;AAED,oEAAoE;AACpE,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAAC,EACrD,SAAS,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAC9D,MAAM,CAGR"}
|
package/dest/slashing/helpers.js
CHANGED
|
@@ -29,6 +29,29 @@ import { OffenseType } from './types.js';
|
|
|
29
29
|
}
|
|
30
30
|
return epochs;
|
|
31
31
|
}
|
|
32
|
+
/** Reads the configured penalty for a given offense type from a slasher config struct */ export function getPenaltyForOffense(offense, config) {
|
|
33
|
+
switch(offense){
|
|
34
|
+
case OffenseType.VALID_EPOCH_PRUNED:
|
|
35
|
+
case OffenseType.DATA_WITHHOLDING:
|
|
36
|
+
return config.slashPrunePenalty;
|
|
37
|
+
case OffenseType.INACTIVITY:
|
|
38
|
+
return config.slashInactivityPenalty;
|
|
39
|
+
case OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS:
|
|
40
|
+
case OffenseType.PROPOSED_INCORRECT_ATTESTATIONS:
|
|
41
|
+
return config.slashProposeInvalidAttestationsPenalty;
|
|
42
|
+
case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
|
|
43
|
+
return config.slashAttestDescendantOfInvalidPenalty;
|
|
44
|
+
case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
|
|
45
|
+
return config.slashBroadcastedInvalidBlockPenalty;
|
|
46
|
+
case OffenseType.UNKNOWN:
|
|
47
|
+
return config.slashUnknownPenalty;
|
|
48
|
+
default:
|
|
49
|
+
{
|
|
50
|
+
const _ = offense;
|
|
51
|
+
throw new Error(`Unknown offense type: ${offense}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
32
55
|
/** Returns whether the `epochOrSlot` field for an offense references an epoch or a slot */ export function getTimeUnitForOffense(offense) {
|
|
33
56
|
switch(offense){
|
|
34
57
|
case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
|
package/dest/slashing/tally.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { Offense, ValidatorSlashVote } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a consensus-slash vote for a given set of committees based on a set of Offenses
|
|
5
|
+
* @param offenses - Array of offenses to consider
|
|
6
|
+
* @param committees - Array of committees (each containing array of validator addresses)
|
|
7
|
+
* @param settings - Settings including slashingAmounts and optional validator override lists
|
|
5
8
|
* @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
|
|
6
9
|
*/
|
|
7
|
-
export declare function getSlashConsensusVotesFromOffenses(offenses: Offense[], committees: EthAddress[][], settings: {
|
|
8
|
-
|
|
10
|
+
export declare function getSlashConsensusVotesFromOffenses(offenses: Pick<Offense, 'validator' | 'amount'>[], committees: EthAddress[][], settings: {
|
|
11
|
+
slashingAmounts: [bigint, bigint, bigint];
|
|
9
12
|
}): ValidatorSlashVote[];
|
|
10
13
|
/**
|
|
11
14
|
* Encodes a set of slash votes into a Buffer for use in a consensus slashing vote transaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tally.d.ts","sourceRoot":"","sources":["../../src/slashing/tally.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"tally.d.ts","sourceRoot":"","sources":["../../src/slashing/tally.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,QAAQ,CAAC,EAAE,EACjD,UAAU,EAAE,UAAU,EAAE,EAAE,EAC1B,QAAQ,EAAE;IACR,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C,GACA,kBAAkB,EAAE,CAuBtB;AAeD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAe7E"}
|
package/dest/slashing/tally.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/** How many slashing units a validator can be slashed in consensus-based slashing */ const MAX_SLASH_UNITS_PER_VALIDATOR = 3n;
|
|
1
|
+
import { sumBigint } from '@aztec/foundation/bigint';
|
|
3
2
|
/**
|
|
4
3
|
* Creates a consensus-slash vote for a given set of committees based on a set of Offenses
|
|
4
|
+
* @param offenses - Array of offenses to consider
|
|
5
|
+
* @param committees - Array of committees (each containing array of validator addresses)
|
|
6
|
+
* @param settings - Settings including slashingAmounts and optional validator override lists
|
|
5
7
|
* @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
|
|
6
8
|
*/ export function getSlashConsensusVotesFromOffenses(offenses, committees, settings) {
|
|
7
|
-
const {
|
|
8
|
-
const
|
|
9
|
+
const { slashingAmounts } = settings;
|
|
10
|
+
const slashedSet = new Set();
|
|
9
11
|
const votes = committees.flatMap((committee)=>committee.map((validator)=>{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const validatorStr = validator.toString();
|
|
13
|
+
// If already voted for slashing this validator, skip
|
|
14
|
+
if (slashedSet.has(validatorStr)) {
|
|
15
|
+
return 0;
|
|
12
16
|
}
|
|
17
|
+
// Normal offense-based slashing logic
|
|
13
18
|
const validatorOffenses = offenses.filter((o)=>o.validator.equals(validator));
|
|
14
19
|
const slashAmount = sumBigint(validatorOffenses.map((o)=>o.amount));
|
|
15
|
-
const slashUnits =
|
|
16
|
-
|
|
20
|
+
const slashUnits = getSlashUnitsForAmount(slashAmount, slashingAmounts);
|
|
21
|
+
slashedSet.add(validatorStr);
|
|
17
22
|
return Number(slashUnits);
|
|
18
23
|
}));
|
|
19
24
|
return votes;
|
|
20
25
|
}
|
|
26
|
+
/** Returns the slash vote for the given amount to slash. */ function getSlashUnitsForAmount(amountToSlash, slashingAmounts) {
|
|
27
|
+
if (amountToSlash >= slashingAmounts[2]) {
|
|
28
|
+
return 3;
|
|
29
|
+
} else if (amountToSlash >= slashingAmounts[1]) {
|
|
30
|
+
return 2;
|
|
31
|
+
} else if (amountToSlash >= slashingAmounts[0]) {
|
|
32
|
+
return 1;
|
|
33
|
+
} else {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
21
37
|
/**
|
|
22
38
|
* Encodes a set of slash votes into a Buffer for use in a consensus slashing vote transaction.
|
|
23
39
|
* Each vote is represented as a 2-bit value, which represents how many slashing units the validator should be slashed.
|
|
@@ -58,7 +58,6 @@ export declare class CommitmentMap {
|
|
|
58
58
|
}
|
|
59
59
|
export declare const CIRCUIT_SIZE_INDEX = 0;
|
|
60
60
|
export declare const CIRCUIT_PUBLIC_INPUTS_INDEX = 1;
|
|
61
|
-
export declare const CIRCUIT_RECURSIVE_INDEX = 3;
|
|
62
61
|
/**
|
|
63
62
|
* Provides a 'fields' representation of a circuit's verification key
|
|
64
63
|
*/
|
|
@@ -69,7 +68,6 @@ export declare class VerificationKeyAsFields {
|
|
|
69
68
|
static fromKey(key: Fr[]): Promise<VerificationKeyAsFields>;
|
|
70
69
|
get numPublicInputs(): number;
|
|
71
70
|
get circuitSize(): number;
|
|
72
|
-
get isRecursive(): boolean;
|
|
73
71
|
static get schema(): import("zod").ZodType<VerificationKeyAsFields, any, string>;
|
|
74
72
|
toJSON(): Buffer<ArrayBufferLike>;
|
|
75
73
|
/**
|
|
@@ -174,7 +172,6 @@ export declare class VerificationKeyData {
|
|
|
174
172
|
constructor(keyAsFields: VerificationKeyAsFields, keyAsBytes: Buffer);
|
|
175
173
|
get numPublicInputs(): number;
|
|
176
174
|
get circuitSize(): number;
|
|
177
|
-
get isRecursive(): boolean;
|
|
178
175
|
static empty(): VerificationKeyData;
|
|
179
176
|
static makeFakeHonk(): VerificationKeyData;
|
|
180
177
|
static makeFakeRollupHonk(): VerificationKeyData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification_key.d.ts","sourceRoot":"","sources":["../../src/vks/verification_key.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAI9E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACI,CAAC,EAAE,EAAE,CAAC;IACb;;OAEG;IACI,CAAC,EAAE,EAAE,CAAC;gBAED,CAAC,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM;IAI1C;;;OAGG;IACH,QAAQ;IAIR;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,eAAe;CAIlE;AAED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;;OAEG;IACI,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IACnD;;OAEG;IACI,sBAAsB,EAAE,OAAO;IACtC;;OAEG;IACI,gCAAgC,EAAE,MAAM,EAAE;IAGnD;;;OAGG;IACH,QAAQ;IAWR;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,eAAe;IAYjE;;;OAGG;IACH,MAAM,CAAC,cAAc,IAAI,eAAe;IAWxC;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI,eAAe;CAUnC;AAED,qBAAa,mBAAmB;aAEZ,WAAW,EAAE,uBAAuB;aACpC,UAAU,EAAE,MAAM;gBADlB,WAAW,EAAE,uBAAuB,EACpC,UAAU,EAAE,MAAM;IAGpC,IAAW,eAAe,WAEzB;IAED,IAAW,WAAW,WAErB;IAED,MAAM,CAAC,KAAK;IAIZ,MAAM,CAAC,YAAY,IAAI,mBAAmB;IAI1C,MAAM,CAAC,kBAAkB,IAAI,mBAAmB;IAOhD,MAAM,CAAC,QAAQ,CAAC,GAAG,SAA4B,GAAG,mBAAmB;IAIrE;;;OAGG;IACH,QAAQ;IAIR,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,mBAAmB;IAQrE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB;IAI5C,KAAK;IAIZ,2DAA2D;IAC3D,MAAM;IAIN,6CAA6C;IAC7C,MAAM,KAAK,MAAM,4DAEhB;CACF"}
|
|
@@ -64,7 +64,6 @@ import { CircuitType } from '../types/shared.js';
|
|
|
64
64
|
// TODO: find better home for these constants
|
|
65
65
|
export const CIRCUIT_SIZE_INDEX = 0;
|
|
66
66
|
export const CIRCUIT_PUBLIC_INPUTS_INDEX = 1;
|
|
67
|
-
export const CIRCUIT_RECURSIVE_INDEX = 3;
|
|
68
67
|
/**
|
|
69
68
|
* Provides a 'fields' representation of a circuit's verification key
|
|
70
69
|
*/ export class VerificationKeyAsFields {
|
|
@@ -84,9 +83,6 @@ export const CIRCUIT_RECURSIVE_INDEX = 3;
|
|
|
84
83
|
get circuitSize() {
|
|
85
84
|
return Number(this.key[CIRCUIT_SIZE_INDEX]);
|
|
86
85
|
}
|
|
87
|
-
get isRecursive() {
|
|
88
|
-
return this.key[CIRCUIT_RECURSIVE_INDEX].equals(Fr.ONE);
|
|
89
|
-
}
|
|
90
86
|
static get schema() {
|
|
91
87
|
// TODO(palla/schemas): Should we verify the hash matches the key when deserializing?
|
|
92
88
|
return bufferSchemaFor(VerificationKeyAsFields);
|
|
@@ -200,9 +196,6 @@ export class VerificationKeyData {
|
|
|
200
196
|
get circuitSize() {
|
|
201
197
|
return this.keyAsFields.circuitSize;
|
|
202
198
|
}
|
|
203
|
-
get isRecursive() {
|
|
204
|
-
return this.keyAsFields.isRecursive;
|
|
205
|
-
}
|
|
206
199
|
static empty() {
|
|
207
200
|
return new VerificationKeyData(VerificationKeyAsFields.makeEmpty(0), Buffer.alloc(0));
|
|
208
201
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "2.0.0-nightly.
|
|
3
|
+
"version": "2.0.0-nightly.20250830",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@aztec/bb.js": "2.0.0-nightly.
|
|
73
|
-
"@aztec/blob-lib": "2.0.0-nightly.
|
|
74
|
-
"@aztec/constants": "2.0.0-nightly.
|
|
75
|
-
"@aztec/ethereum": "2.0.0-nightly.
|
|
76
|
-
"@aztec/foundation": "2.0.0-nightly.
|
|
77
|
-
"@aztec/l1-artifacts": "2.0.0-nightly.
|
|
78
|
-
"@aztec/noir-noirc_abi": "2.0.0-nightly.
|
|
72
|
+
"@aztec/bb.js": "2.0.0-nightly.20250830",
|
|
73
|
+
"@aztec/blob-lib": "2.0.0-nightly.20250830",
|
|
74
|
+
"@aztec/constants": "2.0.0-nightly.20250830",
|
|
75
|
+
"@aztec/ethereum": "2.0.0-nightly.20250830",
|
|
76
|
+
"@aztec/foundation": "2.0.0-nightly.20250830",
|
|
77
|
+
"@aztec/l1-artifacts": "2.0.0-nightly.20250830",
|
|
78
|
+
"@aztec/noir-noirc_abi": "2.0.0-nightly.20250830",
|
|
79
79
|
"@google-cloud/storage": "^7.15.0",
|
|
80
80
|
"axios": "^1.9.0",
|
|
81
81
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -7,24 +7,18 @@ export type SlasherClientType = 'empire' | 'tally';
|
|
|
7
7
|
|
|
8
8
|
export interface SlasherConfig {
|
|
9
9
|
slashOverridePayload?: EthAddress;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
slashMinPenaltyPercentage: number;
|
|
11
|
+
slashMaxPenaltyPercentage: number;
|
|
12
|
+
slashSelfAllowed?: boolean; // Whether to allow slashes to own validators
|
|
13
|
+
slashValidatorsAlways: EthAddress[]; // Array of validator addresses
|
|
14
|
+
slashValidatorsNever: EthAddress[]; // Array of validator addresses
|
|
15
|
+
slashInactivityTargetPercentage: number; // 0-1, 0.9 means 90%. Must be greater than 0
|
|
12
16
|
slashPrunePenalty: bigint;
|
|
13
|
-
|
|
14
|
-
slashBroadcastedInvalidBlockEnabled: boolean;
|
|
17
|
+
slashInactivityPenalty: bigint;
|
|
15
18
|
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
16
|
-
slashBroadcastedInvalidBlockMaxPenalty: bigint;
|
|
17
|
-
slashInactivityEnabled: boolean;
|
|
18
|
-
slashInactivityCreateTargetPercentage: number; // 0-1, 0.9 means 90%. Must be greater than 0
|
|
19
|
-
slashInactivitySignalTargetPercentage: number; // 0-1, 0.6 means 60%. Must be greater than 0
|
|
20
|
-
slashInactivityCreatePenalty: bigint;
|
|
21
|
-
slashInactivityMaxPenalty: bigint;
|
|
22
19
|
slashProposeInvalidAttestationsPenalty: bigint;
|
|
23
|
-
slashProposeInvalidAttestationsMaxPenalty: bigint;
|
|
24
20
|
slashAttestDescendantOfInvalidPenalty: bigint;
|
|
25
|
-
slashAttestDescendantOfInvalidMaxPenalty: bigint;
|
|
26
21
|
slashUnknownPenalty: bigint;
|
|
27
|
-
slashUnknownMaxPenalty: bigint;
|
|
28
22
|
slashOffenseExpirationRounds: number; // Number of rounds after which pending offenses expire
|
|
29
23
|
slashMaxPayloadSize: number; // Maximum number of offenses to include in a single slash payload
|
|
30
24
|
slashGracePeriodL2Slots: number; // Number of L2 slots to wait after genesis before slashing for most offenses
|
|
@@ -32,25 +26,19 @@ export interface SlasherConfig {
|
|
|
32
26
|
|
|
33
27
|
export const SlasherConfigSchema = z.object({
|
|
34
28
|
slashOverridePayload: schemas.EthAddress.optional(),
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
slashMinPenaltyPercentage: z.number(),
|
|
30
|
+
slashMaxPenaltyPercentage: z.number(),
|
|
31
|
+
slashValidatorsAlways: z.array(schemas.EthAddress),
|
|
32
|
+
slashValidatorsNever: z.array(schemas.EthAddress),
|
|
37
33
|
slashPrunePenalty: schemas.BigInt,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
|
|
41
|
-
slashBroadcastedInvalidBlockMaxPenalty: schemas.BigInt,
|
|
42
|
-
slashInactivityEnabled: z.boolean(),
|
|
43
|
-
slashInactivityCreateTargetPercentage: z.number(),
|
|
44
|
-
slashInactivitySignalTargetPercentage: z.number(),
|
|
45
|
-
slashInactivityCreatePenalty: schemas.BigInt,
|
|
46
|
-
slashInactivityMaxPenalty: schemas.BigInt,
|
|
34
|
+
slashInactivityTargetPercentage: z.number(),
|
|
35
|
+
slashInactivityPenalty: schemas.BigInt,
|
|
47
36
|
slashProposeInvalidAttestationsPenalty: schemas.BigInt,
|
|
48
|
-
slashProposeInvalidAttestationsMaxPenalty: schemas.BigInt,
|
|
49
37
|
slashAttestDescendantOfInvalidPenalty: schemas.BigInt,
|
|
50
|
-
slashAttestDescendantOfInvalidMaxPenalty: schemas.BigInt,
|
|
51
38
|
slashUnknownPenalty: schemas.BigInt,
|
|
52
|
-
slashUnknownMaxPenalty: schemas.BigInt,
|
|
53
39
|
slashOffenseExpirationRounds: z.number(),
|
|
54
40
|
slashMaxPayloadSize: z.number(),
|
|
55
41
|
slashGracePeriodL2Slots: z.number(),
|
|
42
|
+
slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
|
|
43
|
+
slashSelfAllowed: z.boolean().optional(),
|
|
56
44
|
}) satisfies ZodFor<SlasherConfig>;
|
package/src/slashing/helpers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type L1RollupConstants, getEpochAtSlot, getSlotRangeForEpoch } from '../epoch-helpers/index.js';
|
|
2
|
+
import type { SlasherConfig } from '../interfaces/slasher.js';
|
|
2
3
|
import { type Offense, OffenseType } from './types.js';
|
|
3
4
|
|
|
4
5
|
/** Returns the voting round number and voting slot within the round for a given L2 slot. */
|
|
@@ -39,6 +40,41 @@ export function getEpochsForRound(
|
|
|
39
40
|
return epochs;
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/** Reads the configured penalty for a given offense type from a slasher config struct */
|
|
44
|
+
export function getPenaltyForOffense(
|
|
45
|
+
offense: OffenseType,
|
|
46
|
+
config: Pick<
|
|
47
|
+
SlasherConfig,
|
|
48
|
+
| 'slashAttestDescendantOfInvalidPenalty'
|
|
49
|
+
| 'slashBroadcastedInvalidBlockPenalty'
|
|
50
|
+
| 'slashPrunePenalty'
|
|
51
|
+
| 'slashUnknownPenalty'
|
|
52
|
+
| 'slashInactivityPenalty'
|
|
53
|
+
| 'slashProposeInvalidAttestationsPenalty'
|
|
54
|
+
>,
|
|
55
|
+
) {
|
|
56
|
+
switch (offense) {
|
|
57
|
+
case OffenseType.VALID_EPOCH_PRUNED:
|
|
58
|
+
case OffenseType.DATA_WITHHOLDING:
|
|
59
|
+
return config.slashPrunePenalty;
|
|
60
|
+
case OffenseType.INACTIVITY:
|
|
61
|
+
return config.slashInactivityPenalty;
|
|
62
|
+
case OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS:
|
|
63
|
+
case OffenseType.PROPOSED_INCORRECT_ATTESTATIONS:
|
|
64
|
+
return config.slashProposeInvalidAttestationsPenalty;
|
|
65
|
+
case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
|
|
66
|
+
return config.slashAttestDescendantOfInvalidPenalty;
|
|
67
|
+
case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
|
|
68
|
+
return config.slashBroadcastedInvalidBlockPenalty;
|
|
69
|
+
case OffenseType.UNKNOWN:
|
|
70
|
+
return config.slashUnknownPenalty;
|
|
71
|
+
default: {
|
|
72
|
+
const _: never = offense;
|
|
73
|
+
throw new Error(`Unknown offense type: ${offense}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
42
78
|
/** Returns whether the `epochOrSlot` field for an offense references an epoch or a slot */
|
|
43
79
|
export function getTimeUnitForOffense(offense: OffenseType): 'epoch' | 'slot' {
|
|
44
80
|
switch (offense) {
|
package/src/slashing/tally.ts
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { sumBigint } from '@aztec/foundation/bigint';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
|
|
4
4
|
import type { Offense, ValidatorSlashVote } from './types.js';
|
|
5
5
|
|
|
6
|
-
/** How many slashing units a validator can be slashed in consensus-based slashing */
|
|
7
|
-
const MAX_SLASH_UNITS_PER_VALIDATOR = 3n;
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* Creates a consensus-slash vote for a given set of committees based on a set of Offenses
|
|
8
|
+
* @param offenses - Array of offenses to consider
|
|
9
|
+
* @param committees - Array of committees (each containing array of validator addresses)
|
|
10
|
+
* @param settings - Settings including slashingAmounts and optional validator override lists
|
|
11
11
|
* @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
|
|
12
12
|
*/
|
|
13
13
|
export function getSlashConsensusVotesFromOffenses(
|
|
14
|
-
offenses: Offense[],
|
|
14
|
+
offenses: Pick<Offense, 'validator' | 'amount'>[],
|
|
15
15
|
committees: EthAddress[][],
|
|
16
|
-
settings: {
|
|
16
|
+
settings: {
|
|
17
|
+
slashingAmounts: [bigint, bigint, bigint];
|
|
18
|
+
},
|
|
17
19
|
): ValidatorSlashVote[] {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
+
const { slashingAmounts } = settings;
|
|
21
|
+
|
|
22
|
+
const slashedSet: Set<string> = new Set();
|
|
23
|
+
|
|
20
24
|
const votes = committees.flatMap(committee =>
|
|
21
25
|
committee.map(validator => {
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const validatorStr = validator.toString();
|
|
27
|
+
|
|
28
|
+
// If already voted for slashing this validator, skip
|
|
29
|
+
if (slashedSet.has(validatorStr)) {
|
|
30
|
+
return 0;
|
|
24
31
|
}
|
|
32
|
+
|
|
33
|
+
// Normal offense-based slashing logic
|
|
25
34
|
const validatorOffenses = offenses.filter(o => o.validator.equals(validator));
|
|
26
35
|
const slashAmount = sumBigint(validatorOffenses.map(o => o.amount));
|
|
27
|
-
const slashUnits =
|
|
28
|
-
|
|
36
|
+
const slashUnits = getSlashUnitsForAmount(slashAmount, slashingAmounts);
|
|
37
|
+
slashedSet.add(validatorStr);
|
|
29
38
|
return Number(slashUnits);
|
|
30
39
|
}),
|
|
31
40
|
);
|
|
32
41
|
return votes;
|
|
33
42
|
}
|
|
34
43
|
|
|
44
|
+
/** Returns the slash vote for the given amount to slash. */
|
|
45
|
+
function getSlashUnitsForAmount(amountToSlash: bigint, slashingAmounts: [bigint, bigint, bigint]): number {
|
|
46
|
+
if (amountToSlash >= slashingAmounts[2]) {
|
|
47
|
+
return 3;
|
|
48
|
+
} else if (amountToSlash >= slashingAmounts[1]) {
|
|
49
|
+
return 2;
|
|
50
|
+
} else if (amountToSlash >= slashingAmounts[0]) {
|
|
51
|
+
return 1;
|
|
52
|
+
} else {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
35
57
|
/**
|
|
36
58
|
* Encodes a set of slash votes into a Buffer for use in a consensus slashing vote transaction.
|
|
37
59
|
* Each vote is represented as a 2-bit value, which represents how many slashing units the validator should be slashed.
|
|
@@ -80,7 +80,6 @@ export class CommitmentMap {
|
|
|
80
80
|
// TODO: find better home for these constants
|
|
81
81
|
export const CIRCUIT_SIZE_INDEX = 0;
|
|
82
82
|
export const CIRCUIT_PUBLIC_INPUTS_INDEX = 1;
|
|
83
|
-
export const CIRCUIT_RECURSIVE_INDEX = 3;
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* Provides a 'fields' representation of a circuit's verification key
|
|
@@ -104,10 +103,6 @@ export class VerificationKeyAsFields {
|
|
|
104
103
|
return Number(this.key[CIRCUIT_SIZE_INDEX]);
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
public get isRecursive() {
|
|
108
|
-
return this.key[CIRCUIT_RECURSIVE_INDEX].equals(Fr.ONE);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
106
|
static get schema() {
|
|
112
107
|
// TODO(palla/schemas): Should we verify the hash matches the key when deserializing?
|
|
113
108
|
return bufferSchemaFor(VerificationKeyAsFields);
|
|
@@ -271,10 +266,6 @@ export class VerificationKeyData {
|
|
|
271
266
|
return this.keyAsFields.circuitSize;
|
|
272
267
|
}
|
|
273
268
|
|
|
274
|
-
public get isRecursive() {
|
|
275
|
-
return this.keyAsFields.isRecursive;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
269
|
static empty() {
|
|
279
270
|
return new VerificationKeyData(VerificationKeyAsFields.makeEmpty(0), Buffer.alloc(0));
|
|
280
271
|
}
|