@aztec/validator-ha-signer 0.0.1-commit.e61ad554 → 0.0.1-commit.ec5f612

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/dest/config.js DELETED
@@ -1,73 +0,0 @@
1
- import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper } from '@aztec/foundation/config';
2
- import { z } from 'zod';
3
- export const validatorHASignerConfigMappings = {
4
- haSigningEnabled: {
5
- env: 'VALIDATOR_HA_SIGNING_ENABLED',
6
- description: 'Whether HA signing / slashing protection is enabled',
7
- ...booleanConfigHelper(false)
8
- },
9
- nodeId: {
10
- env: 'VALIDATOR_HA_NODE_ID',
11
- description: 'The unique identifier for this node',
12
- defaultValue: ''
13
- },
14
- pollingIntervalMs: {
15
- env: 'VALIDATOR_HA_POLLING_INTERVAL_MS',
16
- description: 'The number of ms to wait between polls when a duty is being signed',
17
- ...numberConfigHelper(100)
18
- },
19
- signingTimeoutMs: {
20
- env: 'VALIDATOR_HA_SIGNING_TIMEOUT_MS',
21
- description: 'The maximum time to wait for a duty being signed to complete',
22
- ...numberConfigHelper(3_000)
23
- },
24
- maxStuckDutiesAgeMs: {
25
- env: 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS',
26
- description: 'The maximum age of a stuck duty in ms (defaults to 2x Aztec slot duration)',
27
- ...optionalNumberConfigHelper()
28
- },
29
- databaseUrl: {
30
- env: 'VALIDATOR_HA_DATABASE_URL',
31
- description: 'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)'
32
- },
33
- poolMaxCount: {
34
- env: 'VALIDATOR_HA_POOL_MAX',
35
- description: 'Maximum number of clients in the pool',
36
- ...numberConfigHelper(10)
37
- },
38
- poolMinCount: {
39
- env: 'VALIDATOR_HA_POOL_MIN',
40
- description: 'Minimum number of clients in the pool',
41
- ...numberConfigHelper(0)
42
- },
43
- poolIdleTimeoutMs: {
44
- env: 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS',
45
- description: 'Idle timeout in milliseconds',
46
- ...numberConfigHelper(10_000)
47
- },
48
- poolConnectionTimeoutMs: {
49
- env: 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS',
50
- description: 'Connection timeout in milliseconds (0 means no timeout)',
51
- ...numberConfigHelper(0)
52
- }
53
- };
54
- export const defaultValidatorHASignerConfig = getDefaultConfig(validatorHASignerConfigMappings);
55
- /**
56
- * Returns the validator HA signer configuration from environment variables.
57
- * Note: If an environment variable is not set, the default value is used.
58
- * @returns The validator HA signer configuration.
59
- */ export function getConfigEnvVars() {
60
- return getConfigFromMappings(validatorHASignerConfigMappings);
61
- }
62
- export const ValidatorHASignerConfigSchema = z.object({
63
- haSigningEnabled: z.boolean(),
64
- nodeId: z.string(),
65
- pollingIntervalMs: z.number().min(0),
66
- signingTimeoutMs: z.number().min(0),
67
- maxStuckDutiesAgeMs: z.number().min(0).optional(),
68
- databaseUrl: z.string().optional(),
69
- poolMaxCount: z.number().min(0).optional(),
70
- poolMinCount: z.number().min(0).optional(),
71
- poolIdleTimeoutMs: z.number().min(0).optional(),
72
- poolConnectionTimeoutMs: z.number().min(0).optional()
73
- });
package/src/config.ts DELETED
@@ -1,125 +0,0 @@
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>;