@aztec/validator-ha-signer 0.0.1-commit.7d4e6cd → 0.0.1-commit.7ffbba4

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.
Files changed (58) hide show
  1. package/README.md +50 -37
  2. package/dest/db/index.d.ts +2 -1
  3. package/dest/db/index.d.ts.map +1 -1
  4. package/dest/db/index.js +1 -0
  5. package/dest/db/lmdb.d.ts +66 -0
  6. package/dest/db/lmdb.d.ts.map +1 -0
  7. package/dest/db/lmdb.js +188 -0
  8. package/dest/db/postgres.d.ts +37 -6
  9. package/dest/db/postgres.d.ts.map +1 -1
  10. package/dest/db/postgres.js +86 -28
  11. package/dest/db/schema.d.ts +21 -10
  12. package/dest/db/schema.d.ts.map +1 -1
  13. package/dest/db/schema.js +49 -20
  14. package/dest/db/types.d.ts +109 -33
  15. package/dest/db/types.d.ts.map +1 -1
  16. package/dest/db/types.js +57 -8
  17. package/dest/errors.d.ts +9 -5
  18. package/dest/errors.d.ts.map +1 -1
  19. package/dest/errors.js +7 -4
  20. package/dest/factory.d.ts +25 -15
  21. package/dest/factory.d.ts.map +1 -1
  22. package/dest/factory.js +55 -15
  23. package/dest/metrics.d.ts +51 -0
  24. package/dest/metrics.d.ts.map +1 -0
  25. package/dest/metrics.js +103 -0
  26. package/dest/migrations.d.ts +1 -1
  27. package/dest/migrations.d.ts.map +1 -1
  28. package/dest/migrations.js +13 -2
  29. package/dest/slashing_protection_service.d.ts +25 -6
  30. package/dest/slashing_protection_service.d.ts.map +1 -1
  31. package/dest/slashing_protection_service.js +72 -20
  32. package/dest/test/pglite_pool.d.ts +92 -0
  33. package/dest/test/pglite_pool.d.ts.map +1 -0
  34. package/dest/test/pglite_pool.js +210 -0
  35. package/dest/types.d.ts +40 -16
  36. package/dest/types.d.ts.map +1 -1
  37. package/dest/types.js +4 -1
  38. package/dest/validator_ha_signer.d.ts +18 -13
  39. package/dest/validator_ha_signer.d.ts.map +1 -1
  40. package/dest/validator_ha_signer.js +45 -36
  41. package/package.json +15 -10
  42. package/src/db/index.ts +1 -0
  43. package/src/db/lmdb.ts +264 -0
  44. package/src/db/postgres.ts +109 -27
  45. package/src/db/schema.ts +51 -20
  46. package/src/db/types.ts +166 -32
  47. package/src/errors.ts +7 -2
  48. package/src/factory.ts +67 -15
  49. package/src/metrics.ts +138 -0
  50. package/src/migrations.ts +17 -1
  51. package/src/slashing_protection_service.ts +117 -25
  52. package/src/test/pglite_pool.ts +256 -0
  53. package/src/types.ts +65 -16
  54. package/src/validator_ha_signer.ts +64 -45
  55. package/dest/config.d.ts +0 -47
  56. package/dest/config.d.ts.map +0 -1
  57. package/dest/config.js +0 -64
  58. package/src/config.ts +0 -116
package/README.md CHANGED
@@ -9,39 +9,21 @@ Distributed locking and slashing protection for Aztec validators running in high
9
9
  - **Automatic Retry**: Failed signing attempts are cleared, allowing other nodes to retry
10
10
  - **PostgreSQL Backend**: Shared database for coordination across nodes
11
11
 
12
- ## Quick Start
12
+ ## Integration with Validator Client
13
13
 
14
- ### Option 1: Automatic Migrations (Simplest)
14
+ The HA signer is automatically integrated into the validator client when `VALIDATOR_HA_SIGNING_ENABLED=true` is set. The validator client will:
15
15
 
16
- ```typescript
17
- import { createHASigner } from '@aztec/validator-ha-signer/factory';
18
-
19
- // Migrations run automatically on startup
20
- const { signer, db } = await createHASigner({
21
- databaseUrl: process.env.DATABASE_URL,
22
- enabled: true,
23
- nodeId: 'validator-node-1',
24
- pollingIntervalMs: 100,
25
- signingTimeoutMs: 3000,
26
- });
16
+ 1. Create the HA signer using `createHASigner()` from the factory
17
+ 2. Wrap the base keystore with `HAKeyStore` to provide HA-protected signing
18
+ 3. Automatically start/stop the signer lifecycle
27
19
 
28
- // Start background cleanup tasks
29
- signer.start();
20
+ No manual integration is required when using the validator client.
30
21
 
31
- // Sign with protection
32
- const signature = await signer.signWithProtection(
33
- validatorAddress,
34
- messageHash,
35
- { slot: 100n, blockNumber: 50n, dutyType: 'BLOCK_PROPOSAL' },
36
- async root => localSigner.signMessage(root),
37
- );
22
+ ## Manual Usage
38
23
 
39
- // Cleanup on shutdown
40
- await signer.stop();
41
- await db.close();
42
- ```
24
+ For advanced use cases or testing, you can use the HA signer directly. **Note**: Database migrations must be run separately before creating the signer (see [Database Migrations](#database-migrations) below).
43
25
 
44
- ### Option 2: Manual Migrations (Recommended for Production)
26
+ ### Basic Usage
45
27
 
46
28
  ```bash
47
29
  # 1. Run migrations separately (once per deployment)
@@ -54,7 +36,6 @@ import { createHASigner } from '@aztec/validator-ha-signer/factory';
54
36
 
55
37
  const { signer, db } = await createHASigner({
56
38
  databaseUrl: process.env.DATABASE_URL,
57
- enabled: true,
58
39
  nodeId: 'validator-node-1',
59
40
  pollingIntervalMs: 100,
60
41
  signingTimeoutMs: 3000,
@@ -63,6 +44,14 @@ const { signer, db } = await createHASigner({
63
44
  // Start background cleanup tasks
64
45
  signer.start();
65
46
 
47
+ // Sign with protection
48
+ const signature = await signer.signWithProtection(
49
+ validatorAddress,
50
+ messageHash,
51
+ { slot: 100n, blockNumber: 50n, blockIndexWithinCheckpoint: 0, dutyType: 'BLOCK_PROPOSAL' },
52
+ async root => localSigner.signMessage(root),
53
+ );
54
+
66
55
  // On shutdown
67
56
  await signer.stop();
68
57
  await db.close();
@@ -73,7 +62,7 @@ await db.close();
73
62
  If you need custom pool configuration (e.g., max connections, idle timeout) or want to share a connection pool across multiple components:
74
63
 
75
64
  > **Note**: You still need to run migrations separately before using this approach.
76
- > See [Option 2](#option-2-manual-migrations-recommended-for-production) above.
65
+ > See [Database Migrations](#database-migrations) below.
77
66
 
78
67
  ```typescript
79
68
  import { PostgresSlashingProtectionDatabase } from '@aztec/validator-ha-signer/db';
@@ -91,11 +80,10 @@ const db = new PostgresSlashingProtectionDatabase(pool);
91
80
  await db.initialize();
92
81
 
93
82
  const signer = new ValidatorHASigner(db, {
94
- enabled: true,
95
83
  nodeId: 'validator-node-1',
96
84
  pollingIntervalMs: 100,
97
85
  signingTimeoutMs: 3000,
98
- maxStuckDutiesAgeMs: 72000,
86
+ maxStuckDutiesAgeMs: 144000,
99
87
  });
100
88
 
101
89
  // Start background cleanup tasks
@@ -111,11 +99,15 @@ await pool.end(); // You manage the pool lifecycle
111
99
  Set via environment variables or config object:
112
100
 
113
101
  - `VALIDATOR_HA_DATABASE_URL`: PostgreSQL connection string (e.g., `postgresql://user:pass@host:port/db`)
114
- - `SLASHING_PROTECTION_ENABLED`: Whether slashing protection is enabled (default: true)
115
- - `SLASHING_PROTECTION_NODE_ID`: Unique identifier for this validator node
116
- - `SLASHING_PROTECTION_POLLING_INTERVAL_MS`: How often to check duty status (default: 100)
117
- - `SLASHING_PROTECTION_SIGNING_TIMEOUT_MS`: Max wait for in-progress signing (default: 3000)
118
- - `SLASHING_PROTECTION_MAX_STUCK_DUTIES_AGE_MS`: Max age of stuck duties before cleanup (default: 72000)
102
+ - `VALIDATOR_HA_SIGNING_ENABLED`: Whether HA signing / slashing protection is enabled (default: false)
103
+ - `VALIDATOR_HA_NODE_ID`: Unique identifier for this validator node (required when enabled)
104
+ - `VALIDATOR_HA_POLLING_INTERVAL_MS`: How often to check duty status (default: 100)
105
+ - `VALIDATOR_HA_SIGNING_TIMEOUT_MS`: Max wait for in-progress signing (default: 3000)
106
+ - `VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS`: Max age of stuck duties before cleanup (default: 2 \* aztecSlotDuration)
107
+ - `VALIDATOR_HA_POOL_MAX`: Maximum number of connections in the pool (default: 10)
108
+ - `VALIDATOR_HA_POOL_MIN`: Minimum number of connections in the pool (default: 0)
109
+ - `VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS`: Idle timeout for pool connections (default: 10000)
110
+ - `VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS`: Connection timeout (default: 0, no timeout)
119
111
 
120
112
  ## Database Migrations
121
113
 
@@ -170,9 +162,30 @@ When multiple validator nodes attempt to sign:
170
162
 
171
163
  1. First node acquires lock and signs
172
164
  2. Other nodes receive `DutyAlreadySignedError` (expected)
173
- 3. If different data detected: `SlashingProtectionError` (likely for block builder signing)
165
+ 3. If different data detected: `SlashingProtectionError` (prevents slashing)
174
166
  4. Failed attempts are auto-cleaned, allowing retry
175
167
 
168
+ ### Signing Context
169
+
170
+ All signing operations require a `SigningContext` that includes:
171
+
172
+ - `slot`: The slot number
173
+ - `blockNumber`: The block number within the checkpoint
174
+ - `blockIndexWithinCheckpoint`: The index of the block within the checkpoint (use `-1` for N/A contexts)
175
+ - `dutyType`: The type of duty (e.g., `BLOCK_PROPOSAL`, `CHECKPOINT_ATTESTATION`, `AUTH_REQUEST`)
176
+
177
+ Note: `AUTH_REQUEST` duties bypass HA protection since signing multiple times is safe for authentication requests.
178
+
179
+ ## Important Limitations
180
+
181
+ ### Database Isolation Per Rollup Version
182
+
183
+ **You cannot use the same database to provide slashing protection for validator nodes running on different rollup versions** (e.g., current rollup and old rollup simultaneously).
184
+
185
+ When the HA signer performs background cleanup via `cleanupOutdatedRollupDuties()`, it removes all duties where the rollup address doesn't match the current rollup address. If two validators running on different rollup versions share the same database, they will delete each other's duties during cleanup.
186
+
187
+ **Solution**: Use separate databases for validators running on different rollup versions. Each rollup version requires its own isolated slashing protection database.
188
+
176
189
  ## Development
177
190
 
178
191
  ```bash
@@ -1,4 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './schema.js';
3
3
  export * from './postgres.js';
4
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGVBQWUsQ0FBQyJ9
4
+ export * from './lmdb.js';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLFdBQVcsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
package/dest/db/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './types.js';
2
2
  export * from './schema.js';
3
3
  export * from './postgres.js';
4
+ export * from './lmdb.js';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * LMDB implementation of SlashingProtectionDatabase
3
+ *
4
+ * Provides local (single-node) double-signing protection using LMDB as the backend.
5
+ * Suitable for nodes that do NOT run in a high-availability multi-node setup.
6
+ *
7
+ * The LMDB store is single-writer, making setIfNotExists inherently atomic.
8
+ * This means we get crash-restart protection without needing an external database.
9
+ */
10
+ import { SlotNumber } from '@aztec/foundation/branded-types';
11
+ import { EthAddress } from '@aztec/foundation/eth-address';
12
+ import type { DateProvider } from '@aztec/foundation/timer';
13
+ import type { AztecAsyncKVStore } from '@aztec/kv-store';
14
+ import type { SlashingProtectionDatabase, TryInsertOrGetResult } from '../types.js';
15
+ import { type CheckAndRecordParams, DutyType } from './types.js';
16
+ /**
17
+ * LMDB-backed implementation of SlashingProtectionDatabase.
18
+ *
19
+ * Provides single-node double-signing protection that survives crashes and restarts.
20
+ * Does not provide cross-node coordination (that requires the PostgreSQL implementation).
21
+ */
22
+ export declare class LmdbSlashingProtectionDatabase implements SlashingProtectionDatabase {
23
+ private readonly store;
24
+ private readonly dateProvider;
25
+ static readonly SCHEMA_VERSION = 1;
26
+ private readonly duties;
27
+ private readonly log;
28
+ constructor(store: AztecAsyncKVStore, dateProvider: DateProvider);
29
+ /**
30
+ * Atomically try to insert a new duty record, or get the existing one if present.
31
+ *
32
+ * LMDB is single-writer so the read-then-write inside transactionAsync is naturally atomic.
33
+ */
34
+ tryInsertOrGetExisting(params: CheckAndRecordParams): Promise<TryInsertOrGetResult>;
35
+ /**
36
+ * Update a duty to 'signed' status with the signature.
37
+ * Only succeeds if the lockToken matches.
38
+ */
39
+ updateDutySigned(rollupAddress: EthAddress, validatorAddress: EthAddress, slot: SlotNumber, dutyType: DutyType, signature: string, lockToken: string, blockIndexWithinCheckpoint: number): Promise<boolean>;
40
+ /**
41
+ * Delete a duty record.
42
+ * Only succeeds if the lockToken matches.
43
+ */
44
+ deleteDuty(rollupAddress: EthAddress, validatorAddress: EthAddress, slot: SlotNumber, dutyType: DutyType, lockToken: string, blockIndexWithinCheckpoint: number): Promise<boolean>;
45
+ /**
46
+ * Cleanup own stuck duties (SIGNING status older than maxAgeMs).
47
+ */
48
+ cleanupOwnStuckDuties(nodeId: string, maxAgeMs: number): Promise<number>;
49
+ /**
50
+ * Cleanup duties with outdated rollup address.
51
+ *
52
+ * This is always a no-op for the LMDB implementation: the underlying store is created via
53
+ * DatabaseVersionManager (in factory.ts), which already resets the entire data directory at
54
+ * startup whenever the rollup address changes.
55
+ */
56
+ cleanupOutdatedRollupDuties(_currentRollupAddress: EthAddress): Promise<number>;
57
+ /**
58
+ * Cleanup old signed duties older than maxAgeMs.
59
+ */
60
+ cleanupOldDuties(maxAgeMs: number): Promise<number>;
61
+ /**
62
+ * Close the underlying LMDB store.
63
+ */
64
+ close(): Promise<void>;
65
+ }
66
+ //# sour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,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAe9E;IAED;;;;;;OAMG;IACI,2BAA2B,CAAC,qBAAqB,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAErF;IAED;;OAEG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBzD;IAED;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAGlC;CACF"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * LMDB implementation of SlashingProtectionDatabase
3
+ *
4
+ * Provides local (single-node) double-signing protection using LMDB as the backend.
5
+ * Suitable for nodes that do NOT run in a high-availability multi-node setup.
6
+ *
7
+ * The LMDB store is single-writer, making setIfNotExists inherently atomic.
8
+ * This means we get crash-restart protection without needing an external database.
9
+ */ import { randomBytes } from '@aztec/foundation/crypto/random';
10
+ import { createLogger } from '@aztec/foundation/log';
11
+ import { DutyStatus, getBlockIndexFromDutyIdentifier, recordFromFields } from './types.js';
12
+ function dutyKey(rollupAddress, validatorAddress, slot, dutyType, blockIndexWithinCheckpoint) {
13
+ return `${rollupAddress}:${validatorAddress}:${slot}:${dutyType}:${blockIndexWithinCheckpoint}`;
14
+ }
15
+ /**
16
+ * LMDB-backed implementation of SlashingProtectionDatabase.
17
+ *
18
+ * Provides single-node double-signing protection that survives crashes and restarts.
19
+ * Does not provide cross-node coordination (that requires the PostgreSQL implementation).
20
+ */ export class LmdbSlashingProtectionDatabase {
21
+ store;
22
+ dateProvider;
23
+ static SCHEMA_VERSION = 1;
24
+ duties;
25
+ log;
26
+ constructor(store, dateProvider){
27
+ this.store = store;
28
+ this.dateProvider = dateProvider;
29
+ this.log = createLogger('slashing-protection:lmdb');
30
+ this.duties = store.openMap('signing-protection-duties');
31
+ }
32
+ /**
33
+ * Atomically try to insert a new duty record, or get the existing one if present.
34
+ *
35
+ * LMDB is single-writer so the read-then-write inside transactionAsync is naturally atomic.
36
+ */ async tryInsertOrGetExisting(params) {
37
+ const blockIndexWithinCheckpoint = getBlockIndexFromDutyIdentifier(params);
38
+ const key = dutyKey(params.rollupAddress.toString(), params.validatorAddress.toString(), params.slot.toString(), params.dutyType, blockIndexWithinCheckpoint);
39
+ const lockToken = randomBytes(16).toString('hex');
40
+ const now = this.dateProvider.now();
41
+ const result = await this.store.transactionAsync(async ()=>{
42
+ const existing = await this.duties.getAsync(key);
43
+ if (existing) {
44
+ return {
45
+ isNew: false,
46
+ record: {
47
+ ...existing,
48
+ lockToken: ''
49
+ }
50
+ };
51
+ }
52
+ const newRecord = {
53
+ rollupAddress: params.rollupAddress.toString(),
54
+ validatorAddress: params.validatorAddress.toString(),
55
+ slot: params.slot.toString(),
56
+ blockNumber: params.blockNumber.toString(),
57
+ blockIndexWithinCheckpoint,
58
+ dutyType: params.dutyType,
59
+ status: DutyStatus.SIGNING,
60
+ messageHash: params.messageHash,
61
+ nodeId: params.nodeId,
62
+ lockToken,
63
+ startedAtMs: now
64
+ };
65
+ await this.duties.set(key, newRecord);
66
+ return {
67
+ isNew: true,
68
+ record: newRecord
69
+ };
70
+ });
71
+ if (result.isNew) {
72
+ this.log.debug(`Acquired lock for duty ${params.dutyType} at slot ${params.slot}`, {
73
+ validatorAddress: params.validatorAddress.toString(),
74
+ nodeId: params.nodeId
75
+ });
76
+ }
77
+ return {
78
+ isNew: result.isNew,
79
+ record: recordFromFields(result.record)
80
+ };
81
+ }
82
+ /**
83
+ * Update a duty to 'signed' status with the signature.
84
+ * Only succeeds if the lockToken matches.
85
+ */ updateDutySigned(rollupAddress, validatorAddress, slot, dutyType, signature, lockToken, blockIndexWithinCheckpoint) {
86
+ const key = dutyKey(rollupAddress.toString(), validatorAddress.toString(), slot.toString(), dutyType, blockIndexWithinCheckpoint);
87
+ return this.store.transactionAsync(async ()=>{
88
+ const existing = await this.duties.getAsync(key);
89
+ if (!existing) {
90
+ this.log.warn('Failed to update duty to signed: duty not found', {
91
+ rollupAddress: rollupAddress.toString(),
92
+ validatorAddress: validatorAddress.toString(),
93
+ slot: slot.toString(),
94
+ dutyType,
95
+ blockIndexWithinCheckpoint
96
+ });
97
+ return false;
98
+ }
99
+ if (existing.lockToken !== lockToken) {
100
+ this.log.warn('Failed to update duty to signed: invalid token', {
101
+ rollupAddress: rollupAddress.toString(),
102
+ validatorAddress: validatorAddress.toString(),
103
+ slot: slot.toString(),
104
+ dutyType,
105
+ blockIndexWithinCheckpoint
106
+ });
107
+ return false;
108
+ }
109
+ await this.duties.set(key, {
110
+ ...existing,
111
+ status: DutyStatus.SIGNED,
112
+ signature,
113
+ completedAtMs: this.dateProvider.now()
114
+ });
115
+ return true;
116
+ });
117
+ }
118
+ /**
119
+ * Delete a duty record.
120
+ * Only succeeds if the lockToken matches.
121
+ */ deleteDuty(rollupAddress, validatorAddress, slot, dutyType, lockToken, blockIndexWithinCheckpoint) {
122
+ const key = dutyKey(rollupAddress.toString(), validatorAddress.toString(), slot.toString(), dutyType, blockIndexWithinCheckpoint);
123
+ return this.store.transactionAsync(async ()=>{
124
+ const existing = await this.duties.getAsync(key);
125
+ if (!existing || existing.lockToken !== lockToken) {
126
+ this.log.warn('Failed to delete duty: invalid token or duty not found', {
127
+ rollupAddress: rollupAddress.toString(),
128
+ validatorAddress: validatorAddress.toString(),
129
+ slot: slot.toString(),
130
+ dutyType,
131
+ blockIndexWithinCheckpoint
132
+ });
133
+ return false;
134
+ }
135
+ await this.duties.delete(key);
136
+ return true;
137
+ });
138
+ }
139
+ /**
140
+ * Cleanup own stuck duties (SIGNING status older than maxAgeMs).
141
+ */ cleanupOwnStuckDuties(nodeId, maxAgeMs) {
142
+ const cutoffMs = this.dateProvider.now() - maxAgeMs;
143
+ return this.store.transactionAsync(async ()=>{
144
+ const keysToDelete = [];
145
+ for await (const [key, record] of this.duties.entriesAsync()){
146
+ if (record.nodeId === nodeId && record.status === DutyStatus.SIGNING && record.startedAtMs < cutoffMs) {
147
+ keysToDelete.push(key);
148
+ }
149
+ }
150
+ for (const key of keysToDelete){
151
+ await this.duties.delete(key);
152
+ }
153
+ return keysToDelete.length;
154
+ });
155
+ }
156
+ /**
157
+ * Cleanup duties with outdated rollup address.
158
+ *
159
+ * This is always a no-op for the LMDB implementation: the underlying store is created via
160
+ * DatabaseVersionManager (in factory.ts), which already resets the entire data directory at
161
+ * startup whenever the rollup address changes.
162
+ */ cleanupOutdatedRollupDuties(_currentRollupAddress) {
163
+ return Promise.resolve(0);
164
+ }
165
+ /**
166
+ * Cleanup old signed duties older than maxAgeMs.
167
+ */ cleanupOldDuties(maxAgeMs) {
168
+ const cutoffMs = this.dateProvider.now() - maxAgeMs;
169
+ return this.store.transactionAsync(async ()=>{
170
+ const keysToDelete = [];
171
+ for await (const [key, record] of this.duties.entriesAsync()){
172
+ if (record.status === DutyStatus.SIGNED && record.completedAtMs !== undefined && record.completedAtMs < cutoffMs) {
173
+ keysToDelete.push(key);
174
+ }
175
+ }
176
+ for (const key of keysToDelete){
177
+ await this.duties.delete(key);
178
+ }
179
+ return keysToDelete.length;
180
+ });
181
+ }
182
+ /**
183
+ * Close the underlying LMDB store.
184
+ */ async close() {
185
+ await this.store.close();
186
+ this.log.debug('LMDB slashing protection database closed');
187
+ }
188
+ }
@@ -1,14 +1,26 @@
1
+ /**
2
+ * PostgreSQL implementation of SlashingProtectionDatabase
3
+ */
4
+ import { SlotNumber } from '@aztec/foundation/branded-types';
1
5
  import { EthAddress } from '@aztec/foundation/eth-address';
2
- import type { Pool } from 'pg';
6
+ import type { QueryResult, QueryResultRow } from 'pg';
3
7
  import type { SlashingProtectionDatabase, TryInsertOrGetResult } from '../types.js';
4
8
  import type { CheckAndRecordParams, DutyType } from './types.js';
9
+ /**
10
+ * Minimal pool interface for database operations.
11
+ * Both pg.Pool and test adapters (e.g., PGlite) satisfy this interface.
12
+ */
13
+ export interface QueryablePool {
14
+ query<R extends QueryResultRow = any>(text: string, values?: any[]): Promise<QueryResult<R>>;
15
+ end(): Promise<void>;
16
+ }
5
17
  /**
6
18
  * PostgreSQL implementation of the slashing protection database
7
19
  */
8
20
  export declare class PostgresSlashingProtectionDatabase implements SlashingProtectionDatabase {
9
21
  private readonly pool;
10
22
  private readonly log;
11
- constructor(pool: Pool);
23
+ constructor(pool: QueryablePool);
12
24
  /**
13
25
  * Verify that database migrations have been run and schema version matches.
14
26
  * Should be called once at startup.
@@ -21,6 +33,9 @@ export declare class PostgresSlashingProtectionDatabase implements SlashingProte
21
33
  *
22
34
  * @returns { isNew: true, record } if we successfully inserted and acquired the lock
23
35
  * @returns { isNew: false, record } if a record already exists. lock_token is empty if the record already exists.
36
+ *
37
+ * Retries if no rows are returned, which can happen under high concurrency
38
+ * when another transaction just committed the row but it's not yet visible.
24
39
  */
25
40
  tryInsertOrGetExisting(params: CheckAndRecordParams): Promise<TryInsertOrGetResult>;
26
41
  /**
@@ -29,7 +44,7 @@ export declare class PostgresSlashingProtectionDatabase implements SlashingProte
29
44
  *
30
45
  * @returns true if the update succeeded, false if token didn't match or duty not found
31
46
  */
32
- updateDutySigned(validatorAddress: EthAddress, slot: bigint, dutyType: DutyType, signature: string, lockToken: string): Promise<boolean>;
47
+ updateDutySigned(rollupAddress: EthAddress, validatorAddress: EthAddress, slot: SlotNumber, dutyType: DutyType, signature: string, lockToken: string, blockIndexWithinCheckpoint: number): Promise<boolean>;
33
48
  /**
34
49
  * Delete a duty record.
35
50
  * Only succeeds if the lockToken matches (caller must be the one who created the duty).
@@ -37,9 +52,11 @@ export declare class PostgresSlashingProtectionDatabase implements SlashingProte
37
52
  *
38
53
  * @returns true if the delete succeeded, false if token didn't match or duty not found
39
54
  */
40
- deleteDuty(validatorAddress: EthAddress, slot: bigint, dutyType: DutyType, lockToken: string): Promise<boolean>;
55
+ deleteDuty(rollupAddress: EthAddress, validatorAddress: EthAddress, slot: SlotNumber, dutyType: DutyType, lockToken: string, blockIndexWithinCheckpoint: number): Promise<boolean>;
41
56
  /**
42
- * Convert a database row to a ValidatorDutyRecord
57
+ * Convert a database row to a ValidatorDutyRecord.
58
+ * Maps snake_case column names to StoredDutyRecord (camelCase, ms timestamps),
59
+ * then delegates to the shared recordFromFields() converter.
43
60
  */
44
61
  private rowToRecord;
45
62
  /**
@@ -51,5 +68,19 @@ export declare class PostgresSlashingProtectionDatabase implements SlashingProte
51
68
  * @returns the number of duties cleaned up
52
69
  */
53
70
  cleanupOwnStuckDuties(nodeId: string, maxAgeMs: number): Promise<number>;
71
+ /**
72
+ * Cleanup duties with outdated rollup address.
73
+ * Removes all duties where the rollup address doesn't match the current one.
74
+ * Used after a rollup upgrade to clean up duties for the old rollup.
75
+ * @returns the number of duties cleaned up
76
+ */
77
+ cleanupOutdatedRollupDuties(currentRollupAddress: EthAddress): Promise<number>;
78
+ /**
79
+ * Cleanup old signed duties.
80
+ * Removes only signed duties older than the specified age.
81
+ * Does not remove 'signing' duties as they may be in progress.
82
+ * @returns the number of duties cleaned up
83
+ */
84
+ cleanupOldDuties(maxAgeMs: number): Promise<number>;
54
85
  }
55
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9zdGdyZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYi9wb3N0Z3Jlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFHM0QsT0FBTyxLQUFLLEVBQUUsSUFBSSxFQUFlLE1BQU0sSUFBSSxDQUFDO0FBRTVDLE9BQU8sS0FBSyxFQUFFLDBCQUEwQixFQUFFLG9CQUFvQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBUXBGLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFXLFFBQVEsRUFBdUMsTUFBTSxZQUFZLENBQUM7QUFFL0c7O0dBRUc7QUFDSCxxQkFBYSxrQ0FBbUMsWUFBVywwQkFBMEI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