@aztec/validator-ha-signer 0.0.1-commit.023c3e5

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 +187 -0
  2. package/dest/config.d.ts +79 -0
  3. package/dest/config.d.ts.map +1 -0
  4. package/dest/config.js +73 -0
  5. package/dest/db/index.d.ts +4 -0
  6. package/dest/db/index.d.ts.map +1 -0
  7. package/dest/db/index.js +3 -0
  8. package/dest/db/migrations/1_initial-schema.d.ts +9 -0
  9. package/dest/db/migrations/1_initial-schema.d.ts.map +1 -0
  10. package/dest/db/migrations/1_initial-schema.js +20 -0
  11. package/dest/db/postgres.d.ts +70 -0
  12. package/dest/db/postgres.d.ts.map +1 -0
  13. package/dest/db/postgres.js +181 -0
  14. package/dest/db/schema.d.ts +89 -0
  15. package/dest/db/schema.d.ts.map +1 -0
  16. package/dest/db/schema.js +213 -0
  17. package/dest/db/test_helper.d.ts +10 -0
  18. package/dest/db/test_helper.d.ts.map +1 -0
  19. package/dest/db/test_helper.js +14 -0
  20. package/dest/db/types.d.ts +161 -0
  21. package/dest/db/types.d.ts.map +1 -0
  22. package/dest/db/types.js +49 -0
  23. package/dest/errors.d.ts +34 -0
  24. package/dest/errors.d.ts.map +1 -0
  25. package/dest/errors.js +34 -0
  26. package/dest/factory.d.ts +42 -0
  27. package/dest/factory.d.ts.map +1 -0
  28. package/dest/factory.js +70 -0
  29. package/dest/migrations.d.ts +15 -0
  30. package/dest/migrations.d.ts.map +1 -0
  31. package/dest/migrations.js +53 -0
  32. package/dest/slashing_protection_service.d.ts +80 -0
  33. package/dest/slashing_protection_service.d.ts.map +1 -0
  34. package/dest/slashing_protection_service.js +196 -0
  35. package/dest/test/pglite_pool.d.ts +92 -0
  36. package/dest/test/pglite_pool.d.ts.map +1 -0
  37. package/dest/test/pglite_pool.js +210 -0
  38. package/dest/types.d.ts +139 -0
  39. package/dest/types.d.ts.map +1 -0
  40. package/dest/types.js +21 -0
  41. package/dest/validator_ha_signer.d.ts +70 -0
  42. package/dest/validator_ha_signer.d.ts.map +1 -0
  43. package/dest/validator_ha_signer.js +127 -0
  44. package/package.json +105 -0
  45. package/src/config.ts +125 -0
  46. package/src/db/index.ts +3 -0
  47. package/src/db/migrations/1_initial-schema.ts +26 -0
  48. package/src/db/postgres.ts +251 -0
  49. package/src/db/schema.ts +248 -0
  50. package/src/db/test_helper.ts +17 -0
  51. package/src/db/types.ts +201 -0
  52. package/src/errors.ts +47 -0
  53. package/src/factory.ts +82 -0
  54. package/src/migrations.ts +75 -0
  55. package/src/slashing_protection_service.ts +250 -0
  56. package/src/test/pglite_pool.ts +256 -0
  57. package/src/types.ts +207 -0
  58. package/src/validator_ha_signer.ts +157 -0
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "@aztec/validator-ha-signer",
3
+ "version": "0.0.1-commit.023c3e5",
4
+ "type": "module",
5
+ "exports": {
6
+ "./config": "./dest/config.js",
7
+ "./db": "./dest/db/index.js",
8
+ "./errors": "./dest/errors.js",
9
+ "./factory": "./dest/factory.js",
10
+ "./migrations": "./dest/migrations.js",
11
+ "./slashing-protection-service": "./dest/slashing_protection_service.js",
12
+ "./types": "./dest/types.js",
13
+ "./validator-ha-signer": "./dest/validator_ha_signer.js",
14
+ "./test": "./dest/test/pglite_pool.js"
15
+ },
16
+ "typedocOptions": {
17
+ "entryPoints": [
18
+ "./src/config.ts",
19
+ "./src/db/index.ts",
20
+ "./src/errors.ts",
21
+ "./src/factory.ts",
22
+ "./src/migrations.ts",
23
+ "./src/slashing_protection_service.ts",
24
+ "./src/types.ts",
25
+ "./src/validator_ha_signer.ts"
26
+ ],
27
+ "name": "Validator High-Availability Signer",
28
+ "tsconfig": "./tsconfig.json"
29
+ },
30
+ "scripts": {
31
+ "build": "yarn clean && ../scripts/tsc.sh",
32
+ "build:dev": "../scripts/tsc.sh --watch",
33
+ "clean": "rm -rf ./dest .tsbuildinfo",
34
+ "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
35
+ },
36
+ "inherits": [
37
+ "../package.common.json"
38
+ ],
39
+ "jest": {
40
+ "moduleNameMapper": {
41
+ "^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
42
+ },
43
+ "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
44
+ "rootDir": "./src",
45
+ "transform": {
46
+ "^.+\\.tsx?$": [
47
+ "@swc/jest",
48
+ {
49
+ "jsc": {
50
+ "parser": {
51
+ "syntax": "typescript",
52
+ "decorators": true
53
+ },
54
+ "transform": {
55
+ "decoratorVersion": "2022-03"
56
+ }
57
+ }
58
+ }
59
+ ]
60
+ },
61
+ "extensionsToTreatAsEsm": [
62
+ ".ts"
63
+ ],
64
+ "reporters": [
65
+ "default"
66
+ ],
67
+ "testTimeout": 120000,
68
+ "setupFiles": [
69
+ "../../foundation/src/jest/setup.mjs"
70
+ ],
71
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
72
+ "setupFilesAfterEnv": [
73
+ "../../foundation/src/jest/setupAfterEnv.mjs"
74
+ ]
75
+ },
76
+ "dependencies": {
77
+ "@aztec/foundation": "0.0.1-commit.023c3e5",
78
+ "node-pg-migrate": "^8.0.4",
79
+ "pg": "^8.11.3",
80
+ "tslib": "^2.4.0",
81
+ "zod": "^3.23.8"
82
+ },
83
+ "devDependencies": {
84
+ "@electric-sql/pglite": "^0.3.14",
85
+ "@jest/globals": "^30.0.0",
86
+ "@types/jest": "^30.0.0",
87
+ "@types/node": "^22.15.17",
88
+ "@types/node-pg-migrate": "^2.3.1",
89
+ "@types/pg": "^8.10.9",
90
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
91
+ "jest": "^30.0.0",
92
+ "jest-mock-extended": "^4.0.0",
93
+ "ts-node": "^10.9.1",
94
+ "typescript": "^5.3.3"
95
+ },
96
+ "types": "./dest/types.d.ts",
97
+ "files": [
98
+ "dest",
99
+ "src",
100
+ "!*.test.*"
101
+ ],
102
+ "engines": {
103
+ "node": ">=20.10"
104
+ }
105
+ }
package/src/config.ts ADDED
@@ -0,0 +1,125 @@
1
+ import {
2
+ type ConfigMappingsType,
3
+ booleanConfigHelper,
4
+ getConfigFromMappings,
5
+ getDefaultConfig,
6
+ numberConfigHelper,
7
+ optionalNumberConfigHelper,
8
+ } from '@aztec/foundation/config';
9
+ import type { ZodFor } from '@aztec/foundation/schemas';
10
+
11
+ import { z } from 'zod';
12
+
13
+ /**
14
+ * Configuration for the Validator HA Signer
15
+ *
16
+ * This config is used for distributed locking and slashing protection
17
+ * when running multiple validator nodes in a high-availability setup.
18
+ */
19
+ export interface ValidatorHASignerConfig {
20
+ /** Whether HA signing / slashing protection is enabled */
21
+ haSigningEnabled: boolean;
22
+ /** Unique identifier for this node */
23
+ nodeId: string;
24
+ /** How long to wait between polls when a duty is being signed (ms) */
25
+ pollingIntervalMs: number;
26
+ /** Maximum time to wait for a duty being signed to complete (ms) */
27
+ signingTimeoutMs: number;
28
+ /** Maximum age of a stuck duty in ms (defaults to 2x hardcoded Aztec slot duration if not set) */
29
+ maxStuckDutiesAgeMs?: number;
30
+ /**
31
+ * PostgreSQL connection string
32
+ * Format: postgresql://user:password@host:port/database
33
+ */
34
+ databaseUrl?: string;
35
+ /**
36
+ * PostgreSQL connection pool configuration
37
+ */
38
+ /** Maximum number of clients in the pool (default: 10) */
39
+ poolMaxCount?: number;
40
+ /** Minimum number of clients in the pool (default: 0) */
41
+ poolMinCount?: number;
42
+ /** Idle timeout in milliseconds (default: 10000) */
43
+ poolIdleTimeoutMs?: number;
44
+ /** Connection timeout in milliseconds (default: 0, no timeout) */
45
+ poolConnectionTimeoutMs?: number;
46
+ }
47
+
48
+ export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASignerConfig> = {
49
+ haSigningEnabled: {
50
+ env: 'VALIDATOR_HA_SIGNING_ENABLED',
51
+ description: 'Whether HA signing / slashing protection is enabled',
52
+ ...booleanConfigHelper(false),
53
+ },
54
+ nodeId: {
55
+ env: 'VALIDATOR_HA_NODE_ID',
56
+ description: 'The unique identifier for this node',
57
+ defaultValue: '',
58
+ },
59
+ pollingIntervalMs: {
60
+ env: 'VALIDATOR_HA_POLLING_INTERVAL_MS',
61
+ description: 'The number of ms to wait between polls when a duty is being signed',
62
+ ...numberConfigHelper(100),
63
+ },
64
+ signingTimeoutMs: {
65
+ env: 'VALIDATOR_HA_SIGNING_TIMEOUT_MS',
66
+ description: 'The maximum time to wait for a duty being signed to complete',
67
+ ...numberConfigHelper(3_000),
68
+ },
69
+ maxStuckDutiesAgeMs: {
70
+ env: 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS',
71
+ description: 'The maximum age of a stuck duty in ms (defaults to 2x Aztec slot duration)',
72
+ ...optionalNumberConfigHelper(),
73
+ },
74
+ databaseUrl: {
75
+ env: 'VALIDATOR_HA_DATABASE_URL',
76
+ description:
77
+ 'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)',
78
+ },
79
+ poolMaxCount: {
80
+ env: 'VALIDATOR_HA_POOL_MAX',
81
+ description: 'Maximum number of clients in the pool',
82
+ ...numberConfigHelper(10),
83
+ },
84
+ poolMinCount: {
85
+ env: 'VALIDATOR_HA_POOL_MIN',
86
+ description: 'Minimum number of clients in the pool',
87
+ ...numberConfigHelper(0),
88
+ },
89
+ poolIdleTimeoutMs: {
90
+ env: 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS',
91
+ description: 'Idle timeout in milliseconds',
92
+ ...numberConfigHelper(10_000),
93
+ },
94
+ poolConnectionTimeoutMs: {
95
+ env: 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS',
96
+ description: 'Connection timeout in milliseconds (0 means no timeout)',
97
+ ...numberConfigHelper(0),
98
+ },
99
+ };
100
+
101
+ export const defaultValidatorHASignerConfig: ValidatorHASignerConfig = getDefaultConfig(
102
+ validatorHASignerConfigMappings,
103
+ );
104
+
105
+ /**
106
+ * Returns the validator HA signer configuration from environment variables.
107
+ * Note: If an environment variable is not set, the default value is used.
108
+ * @returns The validator HA signer configuration.
109
+ */
110
+ export function getConfigEnvVars(): ValidatorHASignerConfig {
111
+ return getConfigFromMappings<ValidatorHASignerConfig>(validatorHASignerConfigMappings);
112
+ }
113
+
114
+ export const ValidatorHASignerConfigSchema = z.object({
115
+ haSigningEnabled: z.boolean(),
116
+ nodeId: z.string(),
117
+ pollingIntervalMs: z.number().min(0),
118
+ signingTimeoutMs: z.number().min(0),
119
+ maxStuckDutiesAgeMs: z.number().min(0).optional(),
120
+ databaseUrl: z.string().optional(),
121
+ poolMaxCount: z.number().min(0).optional(),
122
+ poolMinCount: z.number().min(0).optional(),
123
+ poolIdleTimeoutMs: z.number().min(0).optional(),
124
+ poolConnectionTimeoutMs: z.number().min(0).optional(),
125
+ }) satisfies ZodFor<ValidatorHASignerConfig>;
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './schema.js';
3
+ export * from './postgres.js';
@@ -0,0 +1,26 @@
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
+
8
+ import { DROP_SCHEMA_VERSION_TABLE, DROP_VALIDATOR_DUTIES_TABLE, SCHEMA_SETUP, SCHEMA_VERSION } from '../schema.js';
9
+
10
+ export function up(pgm: MigrationBuilder): void {
11
+ for (const statement of SCHEMA_SETUP) {
12
+ pgm.sql(statement);
13
+ }
14
+
15
+ // Insert initial schema version
16
+ pgm.sql(`
17
+ INSERT INTO schema_version (version)
18
+ VALUES (${SCHEMA_VERSION})
19
+ ON CONFLICT (version) DO NOTHING;
20
+ `);
21
+ }
22
+
23
+ export function down(pgm: MigrationBuilder): void {
24
+ pgm.sql(DROP_VALIDATOR_DUTIES_TABLE);
25
+ pgm.sql(DROP_SCHEMA_VERSION_TABLE);
26
+ }
@@ -0,0 +1,251 @@
1
+ /**
2
+ * PostgreSQL implementation of SlashingProtectionDatabase
3
+ */
4
+ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
5
+ import { randomBytes } from '@aztec/foundation/crypto/random';
6
+ import { EthAddress } from '@aztec/foundation/eth-address';
7
+ import { type Logger, createLogger } from '@aztec/foundation/log';
8
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
9
+
10
+ import type { QueryResult, QueryResultRow } from 'pg';
11
+
12
+ import type { SlashingProtectionDatabase, TryInsertOrGetResult } from '../types.js';
13
+ import {
14
+ CLEANUP_OWN_STUCK_DUTIES,
15
+ DELETE_DUTY,
16
+ INSERT_OR_GET_DUTY,
17
+ SCHEMA_VERSION,
18
+ UPDATE_DUTY_SIGNED,
19
+ } from './schema.js';
20
+ import type { CheckAndRecordParams, DutyRow, DutyType, InsertOrGetRow, ValidatorDutyRecord } from './types.js';
21
+ import { getBlockIndexFromDutyIdentifier } from './types.js';
22
+
23
+ /**
24
+ * Minimal pool interface for database operations.
25
+ * Both pg.Pool and test adapters (e.g., PGlite) satisfy this interface.
26
+ */
27
+ export interface QueryablePool {
28
+ query<R extends QueryResultRow = any>(text: string, values?: any[]): Promise<QueryResult<R>>;
29
+ end(): Promise<void>;
30
+ }
31
+
32
+ /**
33
+ * PostgreSQL implementation of the slashing protection database
34
+ */
35
+ export class PostgresSlashingProtectionDatabase implements SlashingProtectionDatabase {
36
+ private readonly log: Logger;
37
+
38
+ constructor(private readonly pool: QueryablePool) {
39
+ this.log = createLogger('slashing-protection:postgres');
40
+ }
41
+
42
+ /**
43
+ * Verify that database migrations have been run and schema version matches.
44
+ * Should be called once at startup.
45
+ *
46
+ * @throws Error if migrations haven't been run or schema version is outdated
47
+ */
48
+ async initialize(): Promise<void> {
49
+ let dbVersion: number;
50
+
51
+ try {
52
+ const result = await this.pool.query<{ version: number }>(
53
+ `SELECT version FROM schema_version ORDER BY version DESC LIMIT 1`,
54
+ );
55
+
56
+ if (result.rows.length === 0) {
57
+ throw new Error('No version found');
58
+ }
59
+
60
+ dbVersion = result.rows[0].version;
61
+ } catch {
62
+ throw new Error(
63
+ 'Database schema not initialized. Please run migrations first: aztec migrate-ha-db up --database-url <url>',
64
+ );
65
+ }
66
+
67
+ if (dbVersion < SCHEMA_VERSION) {
68
+ throw new Error(
69
+ `Database schema version ${dbVersion} is outdated (expected ${SCHEMA_VERSION}). Please run migrations: aztec migrate-ha-db up --database-url <url>`,
70
+ );
71
+ }
72
+
73
+ if (dbVersion > SCHEMA_VERSION) {
74
+ throw new Error(
75
+ `Database schema version ${dbVersion} is newer than expected (${SCHEMA_VERSION}). Please update your application.`,
76
+ );
77
+ }
78
+
79
+ this.log.info('Database schema verified', { version: dbVersion });
80
+ }
81
+
82
+ /**
83
+ * Atomically try to insert a new duty record, or get the existing one if present.
84
+ *
85
+ * @returns { isNew: true, record } if we successfully inserted and acquired the lock
86
+ * @returns { isNew: false, record } if a record already exists. lock_token is empty if the record already exists.
87
+ *
88
+ * Retries if no rows are returned, which can happen under high concurrency
89
+ * when another transaction just committed the row but it's not yet visible.
90
+ */
91
+ async tryInsertOrGetExisting(params: CheckAndRecordParams): Promise<TryInsertOrGetResult> {
92
+ // create a token for ownership verification
93
+ const lockToken = randomBytes(16).toString('hex');
94
+
95
+ // Use fast retries with custom backoff: 10ms, 20ms, 30ms (then stop)
96
+ const fastBackoff = makeBackoff([0.01, 0.02, 0.03]);
97
+
98
+ // Get the normalized block index using type-safe helper
99
+ const blockIndexWithinCheckpoint = getBlockIndexFromDutyIdentifier(params);
100
+
101
+ const result = await retry<QueryResult<InsertOrGetRow>>(
102
+ async () => {
103
+ const queryResult: QueryResult<InsertOrGetRow> = await this.pool.query(INSERT_OR_GET_DUTY, [
104
+ params.validatorAddress.toString(),
105
+ params.slot.toString(),
106
+ params.blockNumber.toString(),
107
+ blockIndexWithinCheckpoint,
108
+ params.dutyType,
109
+ params.messageHash,
110
+ params.nodeId,
111
+ lockToken,
112
+ ]);
113
+
114
+ // Throw error if no rows to trigger retry
115
+ if (queryResult.rows.length === 0) {
116
+ throw new Error('INSERT_OR_GET_DUTY returned no rows');
117
+ }
118
+
119
+ return queryResult;
120
+ },
121
+ `INSERT_OR_GET_DUTY for node ${params.nodeId}`,
122
+ fastBackoff,
123
+ this.log,
124
+ true,
125
+ );
126
+
127
+ if (result.rows.length === 0) {
128
+ // this should never happen as the retry function should throw if it still fails after retries
129
+ throw new Error('INSERT_OR_GET_DUTY returned no rows after retries');
130
+ }
131
+
132
+ if (result.rows.length > 1) {
133
+ // this should never happen if database constraints are correct (PRIMARY KEY should prevent duplicates)
134
+ throw new Error(`INSERT_OR_GET_DUTY returned ${result.rows.length} rows (expected exactly 1).`);
135
+ }
136
+
137
+ const row = result.rows[0];
138
+ return {
139
+ isNew: row.is_new,
140
+ record: this.rowToRecord(row),
141
+ };
142
+ }
143
+
144
+ /**
145
+ * Update a duty to 'signed' status with the signature.
146
+ * Only succeeds if the lockToken matches (caller must be the one who created the duty).
147
+ *
148
+ * @returns true if the update succeeded, false if token didn't match or duty not found
149
+ */
150
+ async updateDutySigned(
151
+ validatorAddress: EthAddress,
152
+ slot: SlotNumber,
153
+ dutyType: DutyType,
154
+ signature: string,
155
+ lockToken: string,
156
+ blockIndexWithinCheckpoint: number,
157
+ ): Promise<boolean> {
158
+ const result = await this.pool.query(UPDATE_DUTY_SIGNED, [
159
+ signature,
160
+ validatorAddress.toString(),
161
+ slot.toString(),
162
+ dutyType,
163
+ blockIndexWithinCheckpoint,
164
+ lockToken,
165
+ ]);
166
+
167
+ if (result.rowCount === 0) {
168
+ this.log.warn('Failed to update duty to signed status: invalid token or duty not found', {
169
+ validatorAddress: validatorAddress.toString(),
170
+ slot: slot.toString(),
171
+ dutyType,
172
+ blockIndexWithinCheckpoint,
173
+ });
174
+ return false;
175
+ }
176
+ return true;
177
+ }
178
+
179
+ /**
180
+ * Delete a duty record.
181
+ * Only succeeds if the lockToken matches (caller must be the one who created the duty).
182
+ * Used when signing fails to allow another node/attempt to retry.
183
+ *
184
+ * @returns true if the delete succeeded, false if token didn't match or duty not found
185
+ */
186
+ async deleteDuty(
187
+ validatorAddress: EthAddress,
188
+ slot: SlotNumber,
189
+ dutyType: DutyType,
190
+ lockToken: string,
191
+ blockIndexWithinCheckpoint: number,
192
+ ): Promise<boolean> {
193
+ const result = await this.pool.query(DELETE_DUTY, [
194
+ validatorAddress.toString(),
195
+ slot.toString(),
196
+ dutyType,
197
+ blockIndexWithinCheckpoint,
198
+ lockToken,
199
+ ]);
200
+
201
+ if (result.rowCount === 0) {
202
+ this.log.warn('Failed to delete duty: invalid token or duty not found', {
203
+ validatorAddress: validatorAddress.toString(),
204
+ slot: slot.toString(),
205
+ dutyType,
206
+ blockIndexWithinCheckpoint,
207
+ });
208
+ return false;
209
+ }
210
+ return true;
211
+ }
212
+
213
+ /**
214
+ * Convert a database row to a ValidatorDutyRecord
215
+ */
216
+ private rowToRecord(row: DutyRow): ValidatorDutyRecord {
217
+ return {
218
+ validatorAddress: EthAddress.fromString(row.validator_address),
219
+ slot: SlotNumber.fromString(row.slot),
220
+ blockNumber: BlockNumber.fromString(row.block_number),
221
+ blockIndexWithinCheckpoint: row.block_index_within_checkpoint,
222
+ dutyType: row.duty_type,
223
+ status: row.status,
224
+ messageHash: row.message_hash,
225
+ signature: row.signature ?? undefined,
226
+ nodeId: row.node_id,
227
+ lockToken: row.lock_token,
228
+ startedAt: row.started_at,
229
+ completedAt: row.completed_at ?? undefined,
230
+ errorMessage: row.error_message ?? undefined,
231
+ };
232
+ }
233
+
234
+ /**
235
+ * Close the database connection pool
236
+ */
237
+ async close(): Promise<void> {
238
+ await this.pool.end();
239
+ this.log.info('Database connection pool closed');
240
+ }
241
+
242
+ /**
243
+ * Cleanup own stuck duties
244
+ * @returns the number of duties cleaned up
245
+ */
246
+ async cleanupOwnStuckDuties(nodeId: string, maxAgeMs: number): Promise<number> {
247
+ const cutoff = new Date(Date.now() - maxAgeMs);
248
+ const result = await this.pool.query(CLEANUP_OWN_STUCK_DUTIES, [nodeId, cutoff]);
249
+ return result.rowCount ?? 0;
250
+ }
251
+ }