@aztec/slasher 1.1.3 → 1.2.1
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/config.d.ts +1 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/slasher_client.d.ts +3 -5
- package/dest/slasher_client.d.ts.map +1 -1
- package/dest/slasher_client.js +5 -7
- package/package.json +8 -8
- package/src/config.ts +1 -19
- package/src/slasher_client.ts +8 -16
package/dest/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
4
|
+
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
4
5
|
export declare enum Offense {
|
|
5
6
|
UNKNOWN = 0,
|
|
6
7
|
DATA_WITHHOLDING = 1,
|
|
@@ -26,22 +27,6 @@ export type Watcher = WatcherEmitter & {
|
|
|
26
27
|
start?: () => Promise<void>;
|
|
27
28
|
stop?: () => Promise<void>;
|
|
28
29
|
};
|
|
29
|
-
export interface SlasherConfig {
|
|
30
|
-
slashOverridePayload?: EthAddress;
|
|
31
|
-
slashPayloadTtlSeconds: number;
|
|
32
|
-
slashPruneEnabled: boolean;
|
|
33
|
-
slashPrunePenalty: bigint;
|
|
34
|
-
slashPruneMaxPenalty: bigint;
|
|
35
|
-
slashInvalidBlockEnabled: boolean;
|
|
36
|
-
slashInvalidBlockPenalty: bigint;
|
|
37
|
-
slashInvalidBlockMaxPenalty: bigint;
|
|
38
|
-
slashInactivityEnabled: boolean;
|
|
39
|
-
slashInactivityCreateTargetPercentage: number;
|
|
40
|
-
slashInactivitySignalTargetPercentage: number;
|
|
41
|
-
slashInactivityCreatePenalty: bigint;
|
|
42
|
-
slashInactivityMaxPenalty: bigint;
|
|
43
|
-
slashProposerRoundPollingIntervalSeconds: number;
|
|
44
|
-
}
|
|
45
30
|
export declare const DefaultSlasherConfig: SlasherConfig;
|
|
46
31
|
export declare const slasherConfigMappings: ConfigMappingsType<SlasherConfig>;
|
|
47
32
|
//# sourceMappingURL=config.d.ts.map
|
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;AAOnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAOnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,oBAAY,OAAO;IACjB,OAAO,IAAI;IACX,gBAAgB,IAAI;IACpB,kBAAkB,IAAI;IACtB,UAAU,IAAI;IACd,aAAa,IAAI;CAClB;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAMnD,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAexD;AAED,eAAO,MAAM,mBAAmB,EAAG,aAAsB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,UAAU,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,WAAW,eAAe;IAC9B,CAAC,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAC1D;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAEhE,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvE,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG;IACrC,WAAW,EAAE,YAAY,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAelC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,aAAa,CAiFnE,CAAC"}
|
package/dest/slasher_client.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { type ExtendedViemWalletClient, type L1ReaderConfig, L1TxUtils, Slashing
|
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
4
4
|
import { SlashFactoryAbi } from '@aztec/l1-artifacts';
|
|
5
|
+
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
import { type GetContractReturnType } from 'viem';
|
|
6
|
-
import { Offense, type
|
|
7
|
+
import { Offense, type Watcher } from './config.js';
|
|
7
8
|
type MonitoredSlashPayload = {
|
|
8
9
|
payloadAddress: EthAddress;
|
|
9
10
|
validators: readonly EthAddress[];
|
|
@@ -59,10 +60,7 @@ export declare class SlasherClient {
|
|
|
59
60
|
/**
|
|
60
61
|
* Update the config of the slasher client
|
|
61
62
|
*
|
|
62
|
-
* @param config - the new config.
|
|
63
|
-
* - slashOverridePayload
|
|
64
|
-
* - slashPayloadTtlSeconds
|
|
65
|
-
* - slashProposerRoundPollingIntervalSeconds
|
|
63
|
+
* @param config - the new config.
|
|
66
64
|
*/
|
|
67
65
|
updateConfig(config: Partial<SlasherConfig>): void;
|
|
68
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slasher_client.d.ts","sourceRoot":"","sources":["../src/slasher_client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,SAAS,EAGT,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"slasher_client.d.ts","sourceRoot":"","sources":["../src/slasher_client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,SAAS,EAGT,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAEL,KAAK,qBAAqB,EAK3B,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,OAAO,EAA6C,KAAK,OAAO,EAAmB,MAAM,aAAa,CAAC;AAEhH,KAAK,qBAAqB,GAAG;IAC3B,cAAc,EAAE,UAAU,CAAC;IAC3B,UAAU,EAAE,SAAS,UAAU,EAAE,CAAC;IAClC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;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AAE;IAiB1F;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA4DnB;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IAc/B;;;;;OAKG;IACH,OAAO,CAAE,gCAAgC;IAezC,OAAO,CAAC,8BAA8B;IAgBtC;;;;OAIG;YACW,mBAAmB;IAgBjC;;;;;;;OAOG;YACW,mBAAmB;IAqBjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;;;;;OAMG;YACW,mBAAmB;YAkCnB,uBAAuB;CAUtC"}
|
package/dest/slasher_client.js
CHANGED
|
@@ -108,17 +108,15 @@ import { WANT_TO_SLASH_EVENT, bigIntToOffense } from './config.js';
|
|
|
108
108
|
/**
|
|
109
109
|
* Update the config of the slasher client
|
|
110
110
|
*
|
|
111
|
-
* @param config - the new config.
|
|
112
|
-
* - slashOverridePayload
|
|
113
|
-
* - slashPayloadTtlSeconds
|
|
114
|
-
* - slashProposerRoundPollingIntervalSeconds
|
|
111
|
+
* @param config - the new config.
|
|
115
112
|
*/ updateConfig(config) {
|
|
116
113
|
const newConfig = {
|
|
117
114
|
...this.config,
|
|
118
|
-
|
|
119
|
-
slashPayloadTtlSeconds: config.slashPayloadTtlSeconds ?? this.config.slashPayloadTtlSeconds,
|
|
120
|
-
slashProposerRoundPollingIntervalSeconds: config.slashProposerRoundPollingIntervalSeconds ?? this.config.slashProposerRoundPollingIntervalSeconds
|
|
115
|
+
...config
|
|
121
116
|
};
|
|
117
|
+
// We keep this separate flag to tell us if we should be signal for the override payload: after the override payload is executed,
|
|
118
|
+
// the slasher goes back to using the monitored payloads to inform the sequencer publisher what payload to signal for.
|
|
119
|
+
// So we only want to flip back "on" the voting for override payload if config we just passed in re-set the override payload.
|
|
122
120
|
this.overridePayloadActive = config.slashOverridePayload !== undefined && !config.slashOverridePayload.isZero();
|
|
123
121
|
this.config = newConfig;
|
|
124
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/slasher",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,19 +54,19 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/epoch-cache": "1.1
|
|
58
|
-
"@aztec/ethereum": "1.1
|
|
59
|
-
"@aztec/foundation": "1.1
|
|
60
|
-
"@aztec/l1-artifacts": "1.1
|
|
61
|
-
"@aztec/stdlib": "1.1
|
|
62
|
-
"@aztec/telemetry-client": "1.1
|
|
57
|
+
"@aztec/epoch-cache": "1.2.1",
|
|
58
|
+
"@aztec/ethereum": "1.2.1",
|
|
59
|
+
"@aztec/foundation": "1.2.1",
|
|
60
|
+
"@aztec/l1-artifacts": "1.2.1",
|
|
61
|
+
"@aztec/stdlib": "1.2.1",
|
|
62
|
+
"@aztec/telemetry-client": "1.2.1",
|
|
63
63
|
"source-map-support": "^0.5.21",
|
|
64
64
|
"tslib": "^2.4.0",
|
|
65
65
|
"viem": "2.23.7",
|
|
66
66
|
"zod": "^3.23.8"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@aztec/aztec.js": "1.1
|
|
69
|
+
"@aztec/aztec.js": "1.2.1",
|
|
70
70
|
"@jest/globals": "^30.0.0",
|
|
71
71
|
"@types/jest": "^30.0.0",
|
|
72
72
|
"@types/node": "^22.15.17",
|
package/src/config.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@aztec/foundation/config';
|
|
8
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
9
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
10
|
+
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
10
11
|
|
|
11
12
|
export enum Offense {
|
|
12
13
|
UNKNOWN = 0,
|
|
@@ -64,25 +65,6 @@ export type Watcher = WatcherEmitter & {
|
|
|
64
65
|
stop?: () => Promise<void>;
|
|
65
66
|
};
|
|
66
67
|
|
|
67
|
-
export interface SlasherConfig {
|
|
68
|
-
// New configurations based on design doc
|
|
69
|
-
slashOverridePayload?: EthAddress;
|
|
70
|
-
slashPayloadTtlSeconds: number; // TTL for payloads, in seconds
|
|
71
|
-
slashPruneEnabled: boolean;
|
|
72
|
-
slashPrunePenalty: bigint;
|
|
73
|
-
slashPruneMaxPenalty: bigint;
|
|
74
|
-
slashInvalidBlockEnabled: boolean;
|
|
75
|
-
slashInvalidBlockPenalty: bigint;
|
|
76
|
-
slashInvalidBlockMaxPenalty: bigint;
|
|
77
|
-
slashInactivityEnabled: boolean;
|
|
78
|
-
slashInactivityCreateTargetPercentage: number; // 0-1, 0.9 means 90%. Must be greater than 0
|
|
79
|
-
slashInactivitySignalTargetPercentage: number; // 0-1, 0.6 means 60%. Must be greater than 0
|
|
80
|
-
slashInactivityCreatePenalty: bigint;
|
|
81
|
-
slashInactivityMaxPenalty: bigint;
|
|
82
|
-
slashProposerRoundPollingIntervalSeconds: number;
|
|
83
|
-
// Consider adding: slashInactivityCreateEnabled: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
68
|
export const DefaultSlasherConfig: SlasherConfig = {
|
|
87
69
|
slashPayloadTtlSeconds: 60 * 60 * 24, // 1 day
|
|
88
70
|
slashOverridePayload: undefined,
|
package/src/slasher_client.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
11
11
|
import { sleep } from '@aztec/foundation/sleep';
|
|
12
12
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
13
13
|
import { SlashFactoryAbi } from '@aztec/l1-artifacts';
|
|
14
|
+
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
14
15
|
|
|
15
16
|
import {
|
|
16
17
|
type GetContractEventsReturnType,
|
|
@@ -21,14 +22,7 @@ import {
|
|
|
21
22
|
getContract,
|
|
22
23
|
} from 'viem';
|
|
23
24
|
|
|
24
|
-
import {
|
|
25
|
-
Offense,
|
|
26
|
-
type SlasherConfig,
|
|
27
|
-
WANT_TO_SLASH_EVENT,
|
|
28
|
-
type WantToSlashArgs,
|
|
29
|
-
type Watcher,
|
|
30
|
-
bigIntToOffense,
|
|
31
|
-
} from './config.js';
|
|
25
|
+
import { Offense, WANT_TO_SLASH_EVENT, type WantToSlashArgs, type Watcher, bigIntToOffense } from './config.js';
|
|
32
26
|
|
|
33
27
|
type MonitoredSlashPayload = {
|
|
34
28
|
payloadAddress: EthAddress;
|
|
@@ -154,19 +148,17 @@ export class SlasherClient {
|
|
|
154
148
|
/**
|
|
155
149
|
* Update the config of the slasher client
|
|
156
150
|
*
|
|
157
|
-
* @param config - the new config.
|
|
158
|
-
* - slashOverridePayload
|
|
159
|
-
* - slashPayloadTtlSeconds
|
|
160
|
-
* - slashProposerRoundPollingIntervalSeconds
|
|
151
|
+
* @param config - the new config.
|
|
161
152
|
*/
|
|
162
153
|
public updateConfig(config: Partial<SlasherConfig>) {
|
|
163
154
|
const newConfig: SlasherConfig = {
|
|
164
155
|
...this.config,
|
|
165
|
-
|
|
166
|
-
slashPayloadTtlSeconds: config.slashPayloadTtlSeconds ?? this.config.slashPayloadTtlSeconds,
|
|
167
|
-
slashProposerRoundPollingIntervalSeconds:
|
|
168
|
-
config.slashProposerRoundPollingIntervalSeconds ?? this.config.slashProposerRoundPollingIntervalSeconds,
|
|
156
|
+
...config,
|
|
169
157
|
};
|
|
158
|
+
|
|
159
|
+
// We keep this separate flag to tell us if we should be signal for the override payload: after the override payload is executed,
|
|
160
|
+
// the slasher goes back to using the monitored payloads to inform the sequencer publisher what payload to signal for.
|
|
161
|
+
// So we only want to flip back "on" the voting for override payload if config we just passed in re-set the override payload.
|
|
170
162
|
this.overridePayloadActive = config.slashOverridePayload !== undefined && !config.slashOverridePayload.isZero();
|
|
171
163
|
this.config = newConfig;
|
|
172
164
|
}
|