@aztec/validator-ha-signer 0.0.1-commit.a072138 → 0.0.1-commit.a89ec08
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 +10 -0
- package/dest/config.d.ts +23 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +19 -0
- package/dest/db/in_memory.d.ts +20 -0
- package/dest/db/in_memory.d.ts.map +1 -0
- package/dest/db/in_memory.js +73 -0
- package/dest/db/postgres.d.ts +17 -3
- package/dest/db/postgres.d.ts.map +1 -1
- package/dest/db/postgres.js +32 -5
- package/dest/db/schema.d.ts +17 -10
- package/dest/db/schema.d.ts.map +1 -1
- package/dest/db/schema.js +39 -22
- package/dest/db/types.d.ts +7 -2
- package/dest/db/types.d.ts.map +1 -1
- package/dest/factory.d.ts +14 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +25 -0
- package/dest/slashing_protection_service.d.ts +8 -4
- package/dest/slashing_protection_service.d.ts.map +1 -1
- package/dest/slashing_protection_service.js +43 -14
- package/dest/types.d.ts +18 -5
- package/dest/types.d.ts.map +1 -1
- package/dest/validator_ha_signer.d.ts +4 -3
- package/dest/validator_ha_signer.d.ts.map +1 -1
- package/dest/validator_ha_signer.js +8 -3
- package/package.json +3 -2
- package/src/config.ts +24 -0
- package/src/db/in_memory.ts +107 -0
- package/src/db/postgres.ts +33 -2
- package/src/db/schema.ts +41 -22
- package/src/db/types.ts +6 -1
- package/src/factory.ts +32 -0
- package/src/slashing_protection_service.ts +54 -17
- package/src/types.ts +19 -0
- package/src/validator_ha_signer.ts +8 -3
package/src/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type CheckAndRecordParams,
|
|
15
15
|
type DeleteDutyParams,
|
|
16
16
|
type DutyIdentifier,
|
|
17
|
+
type DutyRow,
|
|
17
18
|
DutyType,
|
|
18
19
|
type OtherDutyIdentifier,
|
|
19
20
|
type RecordSuccessParams,
|
|
@@ -25,6 +26,7 @@ export type {
|
|
|
25
26
|
CheckAndRecordParams,
|
|
26
27
|
DeleteDutyParams,
|
|
27
28
|
DutyIdentifier,
|
|
29
|
+
DutyRow,
|
|
28
30
|
OtherDutyIdentifier,
|
|
29
31
|
RecordSuccessParams,
|
|
30
32
|
ValidatorDutyRecord,
|
|
@@ -170,6 +172,7 @@ export interface SlashingProtectionDatabase {
|
|
|
170
172
|
* @returns true if the update succeeded, false if token didn't match or duty not found
|
|
171
173
|
*/
|
|
172
174
|
updateDutySigned(
|
|
175
|
+
rollupAddress: EthAddress,
|
|
173
176
|
validatorAddress: EthAddress,
|
|
174
177
|
slot: SlotNumber,
|
|
175
178
|
dutyType: DutyType,
|
|
@@ -186,6 +189,7 @@ export interface SlashingProtectionDatabase {
|
|
|
186
189
|
* @returns true if the delete succeeded, false if token didn't match or duty not found
|
|
187
190
|
*/
|
|
188
191
|
deleteDuty(
|
|
192
|
+
rollupAddress: EthAddress,
|
|
189
193
|
validatorAddress: EthAddress,
|
|
190
194
|
slot: SlotNumber,
|
|
191
195
|
dutyType: DutyType,
|
|
@@ -199,6 +203,21 @@ export interface SlashingProtectionDatabase {
|
|
|
199
203
|
*/
|
|
200
204
|
cleanupOwnStuckDuties(nodeId: string, maxAgeMs: number): Promise<number>;
|
|
201
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Cleanup duties with outdated rollup address.
|
|
208
|
+
* Removes all duties where the rollup address doesn't match the current one.
|
|
209
|
+
* Used after a rollup upgrade to clean up duties for the old rollup.
|
|
210
|
+
* @returns the number of duties cleaned up
|
|
211
|
+
*/
|
|
212
|
+
cleanupOutdatedRollupDuties(currentRollupAddress: EthAddress): Promise<number>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Cleanup old signed duties.
|
|
216
|
+
* Removes only signed duties older than the specified age.
|
|
217
|
+
* @returns the number of duties cleaned up
|
|
218
|
+
*/
|
|
219
|
+
cleanupOldDuties(maxAgeMs: number): Promise<number>;
|
|
220
|
+
|
|
202
221
|
/**
|
|
203
222
|
* Close the database connection.
|
|
204
223
|
* Should be called during graceful shutdown.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* node will sign for a given duty (slot + duty type).
|
|
7
7
|
*/
|
|
8
8
|
import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
9
|
-
import
|
|
9
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
10
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
11
11
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
12
12
|
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
export class ValidatorHASigner {
|
|
42
42
|
private readonly log: Logger;
|
|
43
43
|
private readonly slashingProtection: SlashingProtectionService;
|
|
44
|
+
private readonly rollupAddress: EthAddress;
|
|
44
45
|
|
|
45
46
|
constructor(
|
|
46
47
|
db: SlashingProtectionDatabase,
|
|
@@ -56,9 +57,11 @@ export class ValidatorHASigner {
|
|
|
56
57
|
if (!config.nodeId || config.nodeId === '') {
|
|
57
58
|
throw new Error('NODE_ID is required for high-availability setups');
|
|
58
59
|
}
|
|
60
|
+
this.rollupAddress = config.l1Contracts.rollupAddress;
|
|
59
61
|
this.slashingProtection = new SlashingProtectionService(db, config);
|
|
60
62
|
this.log.info('Validator HA Signer initialized with slashing protection', {
|
|
61
63
|
nodeId: config.nodeId,
|
|
64
|
+
rollupAddress: this.rollupAddress.toString(),
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
67
|
|
|
@@ -88,6 +91,7 @@ export class ValidatorHASigner {
|
|
|
88
91
|
let dutyIdentifier: DutyIdentifier;
|
|
89
92
|
if (context.dutyType === DutyType.BLOCK_PROPOSAL) {
|
|
90
93
|
dutyIdentifier = {
|
|
94
|
+
rollupAddress: this.rollupAddress,
|
|
91
95
|
validatorAddress,
|
|
92
96
|
slot: context.slot,
|
|
93
97
|
blockIndexWithinCheckpoint: context.blockIndexWithinCheckpoint,
|
|
@@ -95,6 +99,7 @@ export class ValidatorHASigner {
|
|
|
95
99
|
};
|
|
96
100
|
} else {
|
|
97
101
|
dutyIdentifier = {
|
|
102
|
+
rollupAddress: this.rollupAddress,
|
|
98
103
|
validatorAddress,
|
|
99
104
|
slot: context.slot,
|
|
100
105
|
dutyType: context.dutyType,
|
|
@@ -142,8 +147,8 @@ export class ValidatorHASigner {
|
|
|
142
147
|
* Start the HA signer background tasks (cleanup of stuck duties).
|
|
143
148
|
* Should be called after construction and before signing operations.
|
|
144
149
|
*/
|
|
145
|
-
start() {
|
|
146
|
-
this.slashingProtection.start();
|
|
150
|
+
async start() {
|
|
151
|
+
await this.slashingProtection.start();
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
/**
|