@aztec/validator-ha-signer 0.0.1-commit.001888fc
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 +195 -0
- package/dest/db/index.d.ts +5 -0
- package/dest/db/index.d.ts.map +1 -0
- package/dest/db/index.js +4 -0
- package/dest/db/lmdb.d.ts +66 -0
- package/dest/db/lmdb.d.ts.map +1 -0
- package/dest/db/lmdb.js +188 -0
- package/dest/db/migrations/1_initial-schema.d.ts +9 -0
- package/dest/db/migrations/1_initial-schema.d.ts.map +1 -0
- package/dest/db/migrations/1_initial-schema.js +20 -0
- package/dest/db/postgres.d.ts +86 -0
- package/dest/db/postgres.d.ts.map +1 -0
- package/dest/db/postgres.js +208 -0
- package/dest/db/schema.d.ts +96 -0
- package/dest/db/schema.d.ts.map +1 -0
- package/dest/db/schema.js +230 -0
- package/dest/db/test_helper.d.ts +10 -0
- package/dest/db/test_helper.d.ts.map +1 -0
- package/dest/db/test_helper.js +14 -0
- package/dest/db/types.d.ts +185 -0
- package/dest/db/types.d.ts.map +1 -0
- package/dest/db/types.js +64 -0
- package/dest/errors.d.ts +34 -0
- package/dest/errors.d.ts.map +1 -0
- package/dest/errors.js +34 -0
- package/dest/factory.d.ts +60 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +115 -0
- package/dest/metrics.d.ts +51 -0
- package/dest/metrics.d.ts.map +1 -0
- package/dest/metrics.js +103 -0
- package/dest/migrations.d.ts +15 -0
- package/dest/migrations.d.ts.map +1 -0
- package/dest/migrations.js +53 -0
- package/dest/slashing_protection_service.d.ts +93 -0
- package/dest/slashing_protection_service.d.ts.map +1 -0
- package/dest/slashing_protection_service.js +236 -0
- package/dest/test/pglite_pool.d.ts +92 -0
- package/dest/test/pglite_pool.d.ts.map +1 -0
- package/dest/test/pglite_pool.js +210 -0
- package/dest/types.d.ts +99 -0
- package/dest/types.d.ts.map +1 -0
- package/dest/types.js +4 -0
- package/dest/validator_ha_signer.d.ts +79 -0
- package/dest/validator_ha_signer.d.ts.map +1 -0
- package/dest/validator_ha_signer.js +140 -0
- package/package.json +110 -0
- package/src/db/index.ts +4 -0
- package/src/db/lmdb.ts +264 -0
- package/src/db/migrations/1_initial-schema.ts +26 -0
- package/src/db/postgres.ts +284 -0
- package/src/db/schema.ts +267 -0
- package/src/db/test_helper.ts +17 -0
- package/src/db/types.ts +251 -0
- package/src/errors.ts +47 -0
- package/src/factory.ts +139 -0
- package/src/metrics.ts +138 -0
- package/src/migrations.ts +75 -0
- package/src/slashing_protection_service.ts +308 -0
- package/src/test/pglite_pool.ts +256 -0
- package/src/types.ts +154 -0
- package/src/validator_ha_signer.ts +183 -0
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Validator HA Signer
|
|
2
|
+
|
|
3
|
+
Distributed locking and slashing protection for Aztec validators running in high-availability configurations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Distributed Locking**: Prevents multiple validator nodes from signing the same duty
|
|
8
|
+
- **Slashing Protection**: Blocks attempts to sign conflicting data for the same slot
|
|
9
|
+
- **Automatic Retry**: Failed signing attempts are cleared, allowing other nodes to retry
|
|
10
|
+
- **PostgreSQL Backend**: Shared database for coordination across nodes
|
|
11
|
+
|
|
12
|
+
## Integration with Validator Client
|
|
13
|
+
|
|
14
|
+
The HA signer is automatically integrated into the validator client when `VALIDATOR_HA_SIGNING_ENABLED=true` is set. The validator client will:
|
|
15
|
+
|
|
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
|
|
19
|
+
|
|
20
|
+
No manual integration is required when using the validator client.
|
|
21
|
+
|
|
22
|
+
## Manual Usage
|
|
23
|
+
|
|
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).
|
|
25
|
+
|
|
26
|
+
### Basic Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# 1. Run migrations separately (once per deployment)
|
|
30
|
+
aztec migrate-ha-db up --database-url postgresql://user:pass@host:port/db
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// 2. Create signer (migrations already applied)
|
|
35
|
+
import { createHASigner } from '@aztec/validator-ha-signer/factory';
|
|
36
|
+
|
|
37
|
+
const { signer, db } = await createHASigner({
|
|
38
|
+
databaseUrl: process.env.DATABASE_URL,
|
|
39
|
+
nodeId: 'validator-node-1',
|
|
40
|
+
pollingIntervalMs: 100,
|
|
41
|
+
signingTimeoutMs: 3000,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Start background cleanup tasks
|
|
45
|
+
signer.start();
|
|
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
|
+
|
|
55
|
+
// On shutdown
|
|
56
|
+
await signer.stop();
|
|
57
|
+
await db.close();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Advanced: Custom Connection Pool
|
|
61
|
+
|
|
62
|
+
If you need custom pool configuration (e.g., max connections, idle timeout) or want to share a connection pool across multiple components:
|
|
63
|
+
|
|
64
|
+
> **Note**: You still need to run migrations separately before using this approach.
|
|
65
|
+
> See [Database Migrations](#database-migrations) below.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { PostgresSlashingProtectionDatabase } from '@aztec/validator-ha-signer/db';
|
|
69
|
+
import { ValidatorHASigner } from '@aztec/validator-ha-signer/validator-ha-signer';
|
|
70
|
+
|
|
71
|
+
import { Pool } from 'pg';
|
|
72
|
+
|
|
73
|
+
// Custom pool configuration
|
|
74
|
+
const pool = new Pool({
|
|
75
|
+
connectionString: process.env.DATABASE_URL,
|
|
76
|
+
max: 20, // Maximum connections
|
|
77
|
+
idleTimeoutMillis: 30000,
|
|
78
|
+
});
|
|
79
|
+
const db = new PostgresSlashingProtectionDatabase(pool);
|
|
80
|
+
await db.initialize();
|
|
81
|
+
|
|
82
|
+
const signer = new ValidatorHASigner(db, {
|
|
83
|
+
nodeId: 'validator-node-1',
|
|
84
|
+
pollingIntervalMs: 100,
|
|
85
|
+
signingTimeoutMs: 3000,
|
|
86
|
+
maxStuckDutiesAgeMs: 144000,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Start background cleanup tasks
|
|
90
|
+
signer.start();
|
|
91
|
+
|
|
92
|
+
// On shutdown
|
|
93
|
+
await signer.stop();
|
|
94
|
+
await pool.end(); // You manage the pool lifecycle
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
Set via environment variables or config object:
|
|
100
|
+
|
|
101
|
+
- `VALIDATOR_HA_DATABASE_URL`: PostgreSQL connection string (e.g., `postgresql://user:pass@host:port/db`)
|
|
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)
|
|
111
|
+
|
|
112
|
+
## Database Migrations
|
|
113
|
+
|
|
114
|
+
This package uses `node-pg-migrate` for database schema management.
|
|
115
|
+
|
|
116
|
+
### Migration Commands
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Run pending migrations
|
|
120
|
+
aztec migrate-ha-db up --database-url postgresql://...
|
|
121
|
+
|
|
122
|
+
# Rollback last migration
|
|
123
|
+
aztec migrate-ha-db down --database-url postgresql://...
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Creating New Migrations
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Generate a new migration file
|
|
130
|
+
npx node-pg-migrate create my-migration-name
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Production Deployment
|
|
134
|
+
|
|
135
|
+
Run migrations before starting your application:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
# Kubernetes example
|
|
139
|
+
apiVersion: batch/v1
|
|
140
|
+
kind: Job
|
|
141
|
+
metadata:
|
|
142
|
+
name: validator-db-migrate
|
|
143
|
+
spec:
|
|
144
|
+
template:
|
|
145
|
+
spec:
|
|
146
|
+
containers:
|
|
147
|
+
- name: migrate
|
|
148
|
+
image: aztecprotocol/aztec:<image_tag>
|
|
149
|
+
command: ['node', '--no-warnings', '/usr/src/yarn-project/aztec/dest/bin/index.js', 'migrate-ha-db', 'up']
|
|
150
|
+
env:
|
|
151
|
+
- name: DATABASE_URL
|
|
152
|
+
valueFrom:
|
|
153
|
+
secretKeyRef:
|
|
154
|
+
name: db-secret
|
|
155
|
+
key: url
|
|
156
|
+
restartPolicy: OnFailure
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## How It Works
|
|
160
|
+
|
|
161
|
+
When multiple validator nodes attempt to sign:
|
|
162
|
+
|
|
163
|
+
1. First node acquires lock and signs
|
|
164
|
+
2. Other nodes receive `DutyAlreadySignedError` (expected)
|
|
165
|
+
3. If different data detected: `SlashingProtectionError` (prevents slashing)
|
|
166
|
+
4. Failed attempts are auto-cleaned, allowing retry
|
|
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
|
+
|
|
189
|
+
## Development
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
yarn build # Build package
|
|
193
|
+
yarn test # Run tests
|
|
194
|
+
yarn clean # Clean build artifacts
|
|
195
|
+
```
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './schema.js';
|
|
3
|
+
export * from './postgres.js';
|
|
4
|
+
export * from './lmdb.js';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLFdBQVcsQ0FBQyJ9
|
|
@@ -0,0 +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;AAC9B,cAAc,WAAW,CAAC"}
|
package/dest/db/index.js
ADDED
|
@@ -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
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG1kYi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2RiL2xtZGIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7O0dBUUc7QUFDSCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFN0QsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBRXhFLE9BQU8sS0FBSyxFQUFFLDBCQUEwQixFQUFFLG9CQUFvQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQ3BGLE9BQU8sRUFDTCxLQUFLLG9CQUFvQixFQUV6QixRQUFRLEVBSVQsTUFBTSxZQUFZLENBQUM7QUFZcEI7Ozs7O0dBS0c7QUFDSCxxQkFBYSw4QkFBK0IsWUFBVywwQkFBMEI7SUFPN0UsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBQ3RCLE9BQU8sQ0FBQyxRQUFRLENBQUMsWUFBWTtJQVAvQixnQkFBdUIsY0FBYyxLQUFLO0lBRTFDLE9BQU8sQ0FBQyxR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B,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,MAAM,GACjC,OAAO,CAAC,OAAO,CAAC,CA0ClB;IAED;;;OAGG;IACI,UAAU,CACf,aAAa,EAAE,UAAU,EACzB,gBAAgB,EAAE,UAAU,EAC5B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,MAAM,GACjC,OAAO,CAAC,OAAO,CAAC,CAyBlB;IAED;;OAEG;IACI,qBAAqB,CAAC,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"}
|
package/dest/db/lmdb.js
ADDED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial schema for validator HA slashing protection
|
|
3
|
+
*
|
|
4
|
+
* This migration imports SQL from the schema.ts file to ensure a single source of truth.
|
|
5
|
+
*/
|
|
6
|
+
import type { MigrationBuilder } from 'node-pg-migrate';
|
|
7
|
+
export declare function up(pgm: MigrationBuilder): void;
|
|
8
|
+
export declare function down(pgm: MigrationBuilder): void;
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMV9pbml0aWFsLXNjaGVtYS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2RiL21pZ3JhdGlvbnMvMV9pbml0aWFsLXNjaGVtYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7OztHQUlHO0FBQ0gsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUl4RCx3QkFBZ0IsRUFBRSxDQUFDLEdBQUcsRUFBRSxnQkFBZ0IsR0FBRyxJQUFJLENBVzlDO0FBRUQsd0JBQWdCLElBQUksQ0FBQyxHQUFHLEVBQUUsZ0JBQWdCLEdBQUcsSUFBSSxDQUdoRCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_initial-schema.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/1_initial-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD,wBAAgB,EAAE,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAW9C;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAGhD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initial schema for validator HA slashing protection
|
|
3
|
+
*
|
|
4
|
+
* This migration imports SQL from the schema.ts file to ensure a single source of truth.
|
|
5
|
+
*/ import { DROP_SCHEMA_VERSION_TABLE, DROP_VALIDATOR_DUTIES_TABLE, SCHEMA_SETUP, SCHEMA_VERSION } from '../schema.js';
|
|
6
|
+
export function up(pgm) {
|
|
7
|
+
for (const statement of SCHEMA_SETUP){
|
|
8
|
+
pgm.sql(statement);
|
|
9
|
+
}
|
|
10
|
+
// Insert initial schema version
|
|
11
|
+
pgm.sql(`
|
|
12
|
+
INSERT INTO schema_version (version)
|
|
13
|
+
VALUES (${SCHEMA_VERSION})
|
|
14
|
+
ON CONFLICT (version) DO NOTHING;
|
|
15
|
+
`);
|
|
16
|
+
}
|
|
17
|
+
export function down(pgm) {
|
|
18
|
+
pgm.sql(DROP_VALIDATOR_DUTIES_TABLE);
|
|
19
|
+
pgm.sql(DROP_SCHEMA_VERSION_TABLE);
|
|
20
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL implementation of SlashingProtectionDatabase
|
|
3
|
+
*/
|
|
4
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import type { QueryResult, QueryResultRow } from 'pg';
|
|
7
|
+
import type { SlashingProtectionDatabase, TryInsertOrGetResult } from '../types.js';
|
|
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
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* PostgreSQL implementation of the slashing protection database
|
|
19
|
+
*/
|
|
20
|
+
export declare class PostgresSlashingProtectionDatabase implements SlashingProtectionDatabase {
|
|
21
|
+
private readonly pool;
|
|
22
|
+
private readonly log;
|
|
23
|
+
constructor(pool: QueryablePool);
|
|
24
|
+
/**
|
|
25
|
+
* Verify that database migrations have been run and schema version matches.
|
|
26
|
+
* Should be called once at startup.
|
|
27
|
+
*
|
|
28
|
+
* @throws Error if migrations haven't been run or schema version is outdated
|
|
29
|
+
*/
|
|
30
|
+
initialize(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Atomically try to insert a new duty record, or get the existing one if present.
|
|
33
|
+
*
|
|
34
|
+
* @returns { isNew: true, record } if we successfully inserted and acquired the lock
|
|
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.
|
|
39
|
+
*/
|
|
40
|
+
tryInsertOrGetExisting(params: CheckAndRecordParams): Promise<TryInsertOrGetResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Update a duty to 'signed' status with the signature.
|
|
43
|
+
* Only succeeds if the lockToken matches (caller must be the one who created the duty).
|
|
44
|
+
*
|
|
45
|
+
* @returns true if the update succeeded, false if token didn't match or duty not found
|
|
46
|
+
*/
|
|
47
|
+
updateDutySigned(rollupAddress: EthAddress, validatorAddress: EthAddress, slot: SlotNumber, dutyType: DutyType, signature: string, lockToken: string, blockIndexWithinCheckpoint: number): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Delete a duty record.
|
|
50
|
+
* Only succeeds if the lockToken matches (caller must be the one who created the duty).
|
|
51
|
+
* Used when signing fails to allow another node/attempt to retry.
|
|
52
|
+
*
|
|
53
|
+
* @returns true if the delete succeeded, false if token didn't match or duty not found
|
|
54
|
+
*/
|
|
55
|
+
deleteDuty(rollupAddress: EthAddress, validatorAddress: EthAddress, slot: SlotNumber, dutyType: DutyType, lockToken: string, blockIndexWithinCheckpoint: number): Promise<boolean>;
|
|
56
|
+
/**
|
|
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.
|
|
60
|
+
*/
|
|
61
|
+
private rowToRecord;
|
|
62
|
+
/**
|
|
63
|
+
* Close the database connection pool
|
|
64
|
+
*/
|
|
65
|
+
close(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Cleanup own stuck duties
|
|
68
|
+
* @returns the number of duties cleaned up
|
|
69
|
+
*/
|
|
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>;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9zdGdyZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYi9wb3N0Z3Jlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUNILE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU3RCxPQUFPLEVBQU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