@aztec/validator-ha-signer 0.0.1-commit.96dac018d → 0.0.1-commit.993d52e

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.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,gCAAgC,IAAI,0CAA0C,EAC9E,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,GACxB,CAAC;AACF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,+BAA+B,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,OAAO,EAAE,0CAA0C,IAAI,gCAAgC,EAAE,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,KAAK,EAAE,OAAO,CAAC;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;;;;;OAMG;IACH,UAAU,CACR,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,CAAC;IAEpB;;;OAGG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzE;;;;;OAKG;IACH,2BAA2B,CAAC,oBAAoB,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/E;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpD;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
package/dest/types.js CHANGED
@@ -1,4 +1,21 @@
1
- import { getBlockNumberFromSigningContext as getBlockNumberFromSigningContextFromStdlib, isHAProtectedContext } from '@aztec/stdlib/ha-signing';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { DutyType } from './db/types.js';
2
3
  export { DutyStatus, DutyType, getBlockIndexFromDutyIdentifier, normalizeBlockIndex } from './db/types.js';
3
- export { isHAProtectedContext };
4
- export { getBlockNumberFromSigningContextFromStdlib as getBlockNumberFromSigningContext };
4
+ /**
5
+ * Type guard to check if a SigningContext requires HA protection.
6
+ * Returns true for contexts that need HA protection, false for AUTH_REQUEST and TXS.
7
+ */ export function isHAProtectedContext(context) {
8
+ return context.dutyType !== DutyType.AUTH_REQUEST && context.dutyType !== DutyType.TXS;
9
+ }
10
+ /**
11
+ * Gets the block number from a signing context.
12
+ * - Vote duties (GOVERNANCE_VOTE, SLASHING_VOTE): returns BlockNumber(0)
13
+ * - Other duties: returns the blockNumber from the context
14
+ */ export function getBlockNumberFromSigningContext(context) {
15
+ // Check for duty types that have blockNumber
16
+ if (context.dutyType === DutyType.BLOCK_PROPOSAL || context.dutyType === DutyType.CHECKPOINT_PROPOSAL || context.dutyType === DutyType.ATTESTATION || context.dutyType === DutyType.ATTESTATIONS_AND_SIGNERS) {
17
+ return context.blockNumber;
18
+ }
19
+ // Vote duties (GOVERNANCE_VOTE, SLASHING_VOTE) don't have blockNumber
20
+ return BlockNumber(0);
21
+ }
@@ -8,14 +8,8 @@
8
8
  import type { Buffer32 } from '@aztec/foundation/buffer';
9
9
  import { EthAddress } from '@aztec/foundation/eth-address';
10
10
  import type { Signature } from '@aztec/foundation/eth-signature';
11
- import type { DateProvider } from '@aztec/foundation/timer';
12
- import { type HAProtectedSigningContext, type ValidatorHASignerConfig } from '@aztec/stdlib/ha-signing';
13
- import type { HASignerMetrics } from './metrics.js';
14
- import type { SlashingProtectionDatabase } from './types.js';
15
- export interface ValidatorHASignerDeps {
16
- metrics: HASignerMetrics;
17
- dateProvider: DateProvider;
18
- }
11
+ import type { ValidatorHASignerConfig } from './config.js';
12
+ import { type HAProtectedSigningContext, type SlashingProtectionDatabase } from './types.js';
19
13
  /**
20
14
  * Validator High Availability Signer
21
15
  *
@@ -40,9 +34,7 @@ export declare class ValidatorHASigner {
40
34
  private readonly log;
41
35
  private readonly slashingProtection;
42
36
  private readonly rollupAddress;
43
- private readonly dateProvider;
44
- private readonly metrics;
45
- constructor(db: SlashingProtectionDatabase, config: ValidatorHASignerConfig, deps: ValidatorHASignerDeps);
37
+ constructor(db: SlashingProtectionDatabase, config: ValidatorHASignerConfig);
46
38
  /**
47
39
  * Sign a message with slashing protection.
48
40
  *
@@ -76,4 +68,4 @@ export declare class ValidatorHASigner {
76
68
  */
77
69
  stop(): Promise<void>;
78
70
  }
79
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdG9yX2hhX3NpZ25lci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3Jj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AC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAEhC,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,iBAAiB;IAO1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA4B;IAC/D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAa;IAE3C,YACE,EAAE,EAAE,0BAA0B,EACb,MAAM,EAAE,uBAAuB,EAkBjD;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,kBAAkB,CACtB,gBAAgB,EAAE,UAAU,EAC5B,WAAW,EAAE,QAAQ,EACrB,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,KAAK,OAAO,CAAC,SAAS,CAAC,GACpD,OAAO,CAAC,SAAS,CAAC,CA+CpB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;OAGG;IACG,KAAK,kBAEV;IAED;;;OAGG;IACG,IAAI,kBAGT;CACF"}
@@ -5,8 +5,9 @@
5
5
  * This ensures that even with multiple validator nodes running, only one
6
6
  * node will sign for a given duty (slot + duty type).
7
7
  */ import { createLogger } from '@aztec/foundation/log';
8
- import { DutyType, getBlockNumberFromSigningContext } from '@aztec/stdlib/ha-signing';
8
+ import { DutyType } from './db/types.js';
9
9
  import { SlashingProtectionService } from './slashing_protection_service.js';
10
+ import { getBlockNumberFromSigningContext } from './types.js';
10
11
  /**
11
12
  * Validator High Availability Signer
12
13
  *
@@ -30,13 +31,9 @@ import { SlashingProtectionService } from './slashing_protection_service.js';
30
31
  log;
31
32
  slashingProtection;
32
33
  rollupAddress;
33
- dateProvider;
34
- metrics;
35
- constructor(db, config, deps){
34
+ constructor(db, config){
36
35
  this.config = config;
37
36
  this.log = createLogger('validator-ha-signer');
38
- this.metrics = deps.metrics;
39
- this.dateProvider = deps.dateProvider;
40
37
  if (!config.haSigningEnabled) {
41
38
  // this shouldn't happen, the validator should use different signer for non-HA setups
42
39
  throw new Error('Validator HA Signer is not enabled in config');
@@ -45,10 +42,7 @@ import { SlashingProtectionService } from './slashing_protection_service.js';
45
42
  throw new Error('NODE_ID is required for high-availability setups');
46
43
  }
47
44
  this.rollupAddress = config.l1Contracts.rollupAddress;
48
- this.slashingProtection = new SlashingProtectionService(db, config, {
49
- metrics: deps.metrics,
50
- dateProvider: deps.dateProvider
51
- });
45
+ this.slashingProtection = new SlashingProtectionService(db, config);
52
46
  this.log.info('Validator HA Signer initialized with slashing protection', {
53
47
  nodeId: config.nodeId,
54
48
  rollupAddress: this.rollupAddress.toString()
@@ -71,8 +65,6 @@ import { SlashingProtectionService } from './slashing_protection_service.js';
71
65
  * @throws DutyAlreadySignedError if the duty was already signed (expected in HA)
72
66
  * @throws SlashingProtectionError if attempting to sign different data for same slot (expected in HA)
73
67
  */ async signWithProtection(validatorAddress, messageHash, context, signFn) {
74
- const startTime = this.dateProvider.now();
75
- const dutyType = context.dutyType;
76
68
  let dutyIdentifier;
77
69
  if (context.dutyType === DutyType.BLOCK_PROPOSAL) {
78
70
  dutyIdentifier = {
@@ -91,7 +83,6 @@ import { SlashingProtectionService } from './slashing_protection_service.js';
91
83
  };
92
84
  }
93
85
  // Acquire lock and get the token for ownership verification
94
- // DutyAlreadySignedError and SlashingProtectionError may be thrown here and are recorded in the service
95
86
  const blockNumber = getBlockNumberFromSigningContext(context);
96
87
  const lockToken = await this.slashingProtection.checkAndRecord({
97
88
  ...dutyIdentifier,
@@ -109,7 +100,6 @@ import { SlashingProtectionService } from './slashing_protection_service.js';
109
100
  ...dutyIdentifier,
110
101
  lockToken
111
102
  });
112
- this.metrics.recordSigningError(dutyType);
113
103
  throw error;
114
104
  }
115
105
  // Record success (only succeeds if we own the lock)
@@ -119,8 +109,6 @@ import { SlashingProtectionService } from './slashing_protection_service.js';
119
109
  nodeId: this.config.nodeId,
120
110
  lockToken
121
111
  });
122
- const duration = this.dateProvider.now() - startTime;
123
- this.metrics.recordSigningSuccess(dutyType, duration);
124
112
  return signature;
125
113
  }
126
114
  /**
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@aztec/validator-ha-signer",
3
- "version": "0.0.1-commit.96dac018d",
3
+ "version": "0.0.1-commit.993d52e",
4
4
  "type": "module",
5
5
  "exports": {
6
+ "./config": "./dest/config.js",
6
7
  "./db": "./dest/db/index.js",
7
8
  "./errors": "./dest/errors.js",
8
9
  "./factory": "./dest/factory.js",
9
- "./metrics": "./dest/metrics.js",
10
10
  "./migrations": "./dest/migrations.js",
11
11
  "./slashing-protection-service": "./dest/slashing_protection_service.js",
12
12
  "./types": "./dest/types.js",
@@ -15,10 +15,10 @@
15
15
  },
16
16
  "typedocOptions": {
17
17
  "entryPoints": [
18
+ "./src/config.ts",
18
19
  "./src/db/index.ts",
19
20
  "./src/errors.ts",
20
21
  "./src/factory.ts",
21
- "./src/metrics.ts",
22
22
  "./src/migrations.ts",
23
23
  "./src/slashing_protection_service.ts",
24
24
  "./src/types.ts",
@@ -74,10 +74,8 @@
74
74
  ]
75
75
  },
76
76
  "dependencies": {
77
- "@aztec/ethereum": "0.0.1-commit.96dac018d",
78
- "@aztec/foundation": "0.0.1-commit.96dac018d",
79
- "@aztec/stdlib": "0.0.1-commit.96dac018d",
80
- "@aztec/telemetry-client": "0.0.1-commit.96dac018d",
77
+ "@aztec/ethereum": "0.0.1-commit.993d52e",
78
+ "@aztec/foundation": "0.0.1-commit.993d52e",
81
79
  "node-pg-migrate": "^8.0.4",
82
80
  "pg": "^8.11.3",
83
81
  "tslib": "^2.4.0",
package/src/config.ts ADDED
@@ -0,0 +1,149 @@
1
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
+ import {
3
+ type ConfigMappingsType,
4
+ booleanConfigHelper,
5
+ getConfigFromMappings,
6
+ getDefaultConfig,
7
+ numberConfigHelper,
8
+ optionalNumberConfigHelper,
9
+ } from '@aztec/foundation/config';
10
+ import { EthAddress } from '@aztec/foundation/eth-address';
11
+ import type { ZodFor } from '@aztec/foundation/schemas';
12
+
13
+ import { z } from 'zod';
14
+
15
+ /**
16
+ * Configuration for the Validator HA Signer
17
+ *
18
+ * This config is used for distributed locking and slashing protection
19
+ * when running multiple validator nodes in a high-availability setup.
20
+ */
21
+ export interface ValidatorHASignerConfig {
22
+ /** Whether HA signing / slashing protection is enabled */
23
+ haSigningEnabled: boolean;
24
+ /** L1 contract addresses (rollup address required) */
25
+ l1Contracts: Pick<L1ContractAddresses, 'rollupAddress'>;
26
+ /** Unique identifier for this node */
27
+ nodeId: string;
28
+ /** How long to wait between polls when a duty is being signed (ms) */
29
+ pollingIntervalMs: number;
30
+ /** Maximum time to wait for a duty being signed to complete (ms) */
31
+ signingTimeoutMs: number;
32
+ /** Maximum age of a stuck duty in ms (defaults to 2x hardcoded Aztec slot duration if not set) */
33
+ maxStuckDutiesAgeMs?: number;
34
+ /** Optional: clean up old duties after this many hours (disabled if not set) */
35
+ cleanupOldDutiesAfterHours?: number;
36
+ /**
37
+ * PostgreSQL connection string
38
+ * Format: postgresql://user:password@host:port/database
39
+ */
40
+ databaseUrl?: string;
41
+ /**
42
+ * PostgreSQL connection pool configuration
43
+ */
44
+ /** Maximum number of clients in the pool (default: 10) */
45
+ poolMaxCount?: number;
46
+ /** Minimum number of clients in the pool (default: 0) */
47
+ poolMinCount?: number;
48
+ /** Idle timeout in milliseconds (default: 10000) */
49
+ poolIdleTimeoutMs?: number;
50
+ /** Connection timeout in milliseconds (default: 0, no timeout) */
51
+ poolConnectionTimeoutMs?: number;
52
+ }
53
+
54
+ export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASignerConfig> = {
55
+ haSigningEnabled: {
56
+ env: 'VALIDATOR_HA_SIGNING_ENABLED',
57
+ description: 'Whether HA signing / slashing protection is enabled',
58
+ ...booleanConfigHelper(false),
59
+ },
60
+ l1Contracts: {
61
+ description: 'L1 contract addresses (rollup address required)',
62
+ nested: {
63
+ rollupAddress: {
64
+ description: 'The Ethereum address of the rollup contract (must be set programmatically)',
65
+ parseEnv: (val: string) => EthAddress.fromString(val),
66
+ },
67
+ },
68
+ },
69
+ nodeId: {
70
+ env: 'VALIDATOR_HA_NODE_ID',
71
+ description: 'The unique identifier for this node',
72
+ defaultValue: '',
73
+ },
74
+ pollingIntervalMs: {
75
+ env: 'VALIDATOR_HA_POLLING_INTERVAL_MS',
76
+ description: 'The number of ms to wait between polls when a duty is being signed',
77
+ ...numberConfigHelper(100),
78
+ },
79
+ signingTimeoutMs: {
80
+ env: 'VALIDATOR_HA_SIGNING_TIMEOUT_MS',
81
+ description: 'The maximum time to wait for a duty being signed to complete',
82
+ ...numberConfigHelper(3_000),
83
+ },
84
+ maxStuckDutiesAgeMs: {
85
+ env: 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS',
86
+ description: 'The maximum age of a stuck duty in ms (defaults to 2x Aztec slot duration)',
87
+ ...optionalNumberConfigHelper(),
88
+ },
89
+ cleanupOldDutiesAfterHours: {
90
+ env: 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H',
91
+ description: 'Optional: clean up old duties after this many hours (disabled if not set)',
92
+ ...optionalNumberConfigHelper(),
93
+ },
94
+ databaseUrl: {
95
+ env: 'VALIDATOR_HA_DATABASE_URL',
96
+ description:
97
+ 'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)',
98
+ },
99
+ poolMaxCount: {
100
+ env: 'VALIDATOR_HA_POOL_MAX',
101
+ description: 'Maximum number of clients in the pool',
102
+ ...numberConfigHelper(10),
103
+ },
104
+ poolMinCount: {
105
+ env: 'VALIDATOR_HA_POOL_MIN',
106
+ description: 'Minimum number of clients in the pool',
107
+ ...numberConfigHelper(0),
108
+ },
109
+ poolIdleTimeoutMs: {
110
+ env: 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS',
111
+ description: 'Idle timeout in milliseconds',
112
+ ...numberConfigHelper(10_000),
113
+ },
114
+ poolConnectionTimeoutMs: {
115
+ env: 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS',
116
+ description: 'Connection timeout in milliseconds (0 means no timeout)',
117
+ ...numberConfigHelper(0),
118
+ },
119
+ };
120
+
121
+ export const defaultValidatorHASignerConfig: ValidatorHASignerConfig = getDefaultConfig(
122
+ validatorHASignerConfigMappings,
123
+ );
124
+
125
+ /**
126
+ * Returns the validator HA signer configuration from environment variables.
127
+ * Note: If an environment variable is not set, the default value is used.
128
+ * @returns The validator HA signer configuration.
129
+ */
130
+ export function getConfigEnvVars(): ValidatorHASignerConfig {
131
+ return getConfigFromMappings<ValidatorHASignerConfig>(validatorHASignerConfigMappings);
132
+ }
133
+
134
+ export const ValidatorHASignerConfigSchema = z.object({
135
+ haSigningEnabled: z.boolean(),
136
+ l1Contracts: z.object({
137
+ rollupAddress: z.instanceof(EthAddress),
138
+ }),
139
+ nodeId: z.string(),
140
+ pollingIntervalMs: z.number().min(0),
141
+ signingTimeoutMs: z.number().min(0),
142
+ maxStuckDutiesAgeMs: z.number().min(0).optional(),
143
+ cleanupOldDutiesAfterHours: z.number().min(0).optional(),
144
+ databaseUrl: z.string().optional(),
145
+ poolMaxCount: z.number().min(0).optional(),
146
+ poolMinCount: z.number().min(0).optional(),
147
+ poolIdleTimeoutMs: z.number().min(0).optional(),
148
+ poolConnectionTimeoutMs: z.number().min(0).optional(),
149
+ }) satisfies ZodFor<ValidatorHASignerConfig>;
package/src/db/types.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import type { Signature } from '@aztec/foundation/eth-signature';
4
- import { DutyType } from '@aztec/stdlib/ha-signing';
5
4
 
6
5
  /**
7
6
  * Row type from PostgreSQL query
@@ -30,6 +29,20 @@ export interface InsertOrGetRow extends DutyRow {
30
29
  is_new: boolean;
31
30
  }
32
31
 
32
+ /**
33
+ * Type of validator duty being performed
34
+ */
35
+ export enum DutyType {
36
+ BLOCK_PROPOSAL = 'BLOCK_PROPOSAL',
37
+ CHECKPOINT_PROPOSAL = 'CHECKPOINT_PROPOSAL',
38
+ ATTESTATION = 'ATTESTATION',
39
+ ATTESTATIONS_AND_SIGNERS = 'ATTESTATIONS_AND_SIGNERS',
40
+ GOVERNANCE_VOTE = 'GOVERNANCE_VOTE',
41
+ SLASHING_VOTE = 'SLASHING_VOTE',
42
+ AUTH_REQUEST = 'AUTH_REQUEST',
43
+ TXS = 'TXS',
44
+ }
45
+
33
46
  /**
34
47
  * Status of a duty in the database
35
48
  */
@@ -38,9 +51,6 @@ export enum DutyStatus {
38
51
  SIGNED = 'signed',
39
52
  }
40
53
 
41
- // Re-export DutyType from stdlib
42
- export { DutyType };
43
-
44
54
  /**
45
55
  * Record of a validator duty in the database
46
56
  */
package/src/factory.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  /**
2
2
  * Factory functions for creating validator HA signers
3
3
  */
4
- import { DateProvider } from '@aztec/foundation/timer';
5
- import type { ValidatorHASignerConfig } from '@aztec/stdlib/ha-signing';
6
- import { getTelemetryClient } from '@aztec/telemetry-client';
7
-
8
4
  import { Pool } from 'pg';
9
5
 
6
+ import type { ValidatorHASignerConfig } from './config.js';
10
7
  import { PostgresSlashingProtectionDatabase } from './db/postgres.js';
11
- import { HASignerMetrics } from './metrics.js';
12
8
  import type { CreateHASignerDeps, SlashingProtectionDatabase } from './types.js';
13
9
  import { ValidatorHASigner } from './validator_ha_signer.js';
14
10
 
@@ -59,10 +55,6 @@ export async function createHASigner(
59
55
  if (!databaseUrl) {
60
56
  throw new Error('databaseUrl is required for createHASigner');
61
57
  }
62
-
63
- const telemetryClient = deps?.telemetryClient ?? getTelemetryClient();
64
- const dateProvider = deps?.dateProvider ?? new DateProvider();
65
-
66
58
  // Create connection pool (or use provided pool)
67
59
  let pool: Pool;
68
60
  if (!deps?.pool) {
@@ -83,11 +75,8 @@ export async function createHASigner(
83
75
  // Verify database schema is initialized and version matches
84
76
  await db.initialize();
85
77
 
86
- // Create metrics
87
- const metrics = new HASignerMetrics(telemetryClient, signerConfig.nodeId);
88
-
89
78
  // Create signer
90
- const signer = new ValidatorHASigner(db, { ...signerConfig, databaseUrl }, { metrics, dateProvider });
79
+ const signer = new ValidatorHASigner(db, { ...signerConfig, databaseUrl });
91
80
 
92
81
  return { signer, db };
93
82
  }
@@ -7,8 +7,6 @@
7
7
  import { type Logger, createLogger } from '@aztec/foundation/log';
8
8
  import { RunningPromise } from '@aztec/foundation/promise';
9
9
  import { sleep } from '@aztec/foundation/sleep';
10
- import type { DateProvider } from '@aztec/foundation/timer';
11
- import type { ValidatorHASignerConfig } from '@aztec/stdlib/ha-signing';
12
10
 
13
11
  import {
14
12
  type CheckAndRecordParams,
@@ -18,13 +16,7 @@ import {
18
16
  getBlockIndexFromDutyIdentifier,
19
17
  } from './db/types.js';
20
18
  import { DutyAlreadySignedError, SlashingProtectionError } from './errors.js';
21
- import type { HASignerMetrics } from './metrics.js';
22
- import type { SlashingProtectionDatabase } from './types.js';
23
-
24
- export interface SlashingProtectionServiceDeps {
25
- metrics: HASignerMetrics;
26
- dateProvider: DateProvider;
27
- }
19
+ import type { SlashingProtectionDatabase, ValidatorHASignerConfig } from './types.js';
28
20
 
29
21
  /**
30
22
  * Slashing Protection Service
@@ -47,16 +39,12 @@ export class SlashingProtectionService {
47
39
  private readonly signingTimeoutMs: number;
48
40
  private readonly maxStuckDutiesAgeMs: number;
49
41
 
50
- private readonly metrics: HASignerMetrics;
51
- private readonly dateProvider: DateProvider;
52
-
53
42
  private cleanupRunningPromise: RunningPromise;
54
43
  private lastOldDutiesCleanupAtMs?: number;
55
44
 
56
45
  constructor(
57
46
  private readonly db: SlashingProtectionDatabase,
58
47
  private readonly config: ValidatorHASignerConfig,
59
- deps: SlashingProtectionServiceDeps,
60
48
  ) {
61
49
  this.log = createLogger('slashing-protection');
62
50
  this.pollingIntervalMs = config.pollingIntervalMs;
@@ -65,8 +53,6 @@ export class SlashingProtectionService {
65
53
  this.maxStuckDutiesAgeMs = config.maxStuckDutiesAgeMs ?? 144_000;
66
54
 
67
55
  this.cleanupRunningPromise = new RunningPromise(this.cleanup.bind(this), this.log, this.maxStuckDutiesAgeMs);
68
- this.metrics = deps.metrics;
69
- this.dateProvider = deps.dateProvider;
70
56
  }
71
57
 
72
58
  /**
@@ -86,7 +72,7 @@ export class SlashingProtectionService {
86
72
  */
87
73
  async checkAndRecord(params: CheckAndRecordParams): Promise<string> {
88
74
  const { validatorAddress, slot, dutyType, messageHash, nodeId } = params;
89
- const startTime = this.dateProvider.now();
75
+ const startTime = Date.now();
90
76
 
91
77
  this.log.debug(`Checking duty: ${dutyType} for slot ${slot}`, {
92
78
  validatorAddress: validatorAddress.toString(),
@@ -103,7 +89,6 @@ export class SlashingProtectionService {
103
89
  validatorAddress: validatorAddress.toString(),
104
90
  nodeId,
105
91
  });
106
- this.metrics.recordLockAcquire(true);
107
92
  return record.lockToken;
108
93
  }
109
94
 
@@ -118,7 +103,6 @@ export class SlashingProtectionService {
118
103
  existingNodeId: record.nodeId,
119
104
  attemptingNodeId: nodeId,
120
105
  });
121
- this.metrics.recordSlashingProtection(dutyType);
122
106
  throw new SlashingProtectionError(
123
107
  slot,
124
108
  dutyType,
@@ -128,17 +112,15 @@ export class SlashingProtectionService {
128
112
  record.nodeId,
129
113
  );
130
114
  }
131
- this.metrics.recordDutyAlreadySigned(dutyType);
132
115
  throw new DutyAlreadySignedError(slot, dutyType, record.blockIndexWithinCheckpoint, record.nodeId);
133
116
  } else if (record.status === DutyStatus.SIGNING) {
134
117
  // Another node is currently signing - check for timeout
135
- if (this.dateProvider.now() - startTime > this.signingTimeoutMs) {
118
+ if (Date.now() - startTime > this.signingTimeoutMs) {
136
119
  this.log.warn(`Timeout waiting for signing to complete for duty ${dutyType} at slot ${slot}`, {
137
120
  validatorAddress: validatorAddress.toString(),
138
121
  timeoutMs: this.signingTimeoutMs,
139
122
  signingNodeId: record.nodeId,
140
123
  });
141
- this.metrics.recordDutyAlreadySigned(dutyType);
142
124
  throw new DutyAlreadySignedError(slot, dutyType, record.blockIndexWithinCheckpoint, 'unknown (timeout)');
143
125
  }
144
126
 
@@ -246,7 +228,6 @@ export class SlashingProtectionService {
246
228
  this.log.info(`Cleaned up ${numOutdatedRollupDuties} duties with outdated rollup address at startup`, {
247
229
  currentRollupAddress: this.config.l1Contracts.rollupAddress.toString(),
248
230
  });
249
- this.metrics.recordCleanup('outdated_rollup', numOutdatedRollupDuties);
250
231
  }
251
232
 
252
233
  this.cleanupRunningPromise.start();
@@ -282,14 +263,13 @@ export class SlashingProtectionService {
282
263
  nodeId: this.config.nodeId,
283
264
  maxStuckDutiesAgeMs: this.maxStuckDutiesAgeMs,
284
265
  });
285
- this.metrics.recordCleanup('stuck', numStuckDuties);
286
266
  }
287
267
 
288
268
  // 2. Clean up old signed duties if configured
289
269
  // we shouldn't run this as often as stuck duty cleanup.
290
270
  if (this.config.cleanupOldDutiesAfterHours !== undefined) {
291
271
  const maxAgeMs = this.config.cleanupOldDutiesAfterHours * 60 * 60 * 1000;
292
- const nowMs = this.dateProvider.now();
272
+ const nowMs = Date.now();
293
273
  const shouldRun =
294
274
  this.lastOldDutiesCleanupAtMs === undefined || nowMs - this.lastOldDutiesCleanupAtMs >= maxAgeMs;
295
275
  if (shouldRun) {
@@ -300,7 +280,6 @@ export class SlashingProtectionService {
300
280
  cleanupOldDutiesAfterHours: this.config.cleanupOldDutiesAfterHours,
301
281
  maxAgeMs,
302
282
  });
303
- this.metrics.recordCleanup('old', numOldDuties);
304
283
  }
305
284
  }
306
285
  }