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

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 (50) hide show
  1. package/README.md +52 -37
  2. package/dest/db/postgres.d.ts +34 -5
  3. package/dest/db/postgres.d.ts.map +1 -1
  4. package/dest/db/postgres.js +80 -22
  5. package/dest/db/schema.d.ts +21 -10
  6. package/dest/db/schema.d.ts.map +1 -1
  7. package/dest/db/schema.js +49 -20
  8. package/dest/db/types.d.ts +76 -31
  9. package/dest/db/types.d.ts.map +1 -1
  10. package/dest/db/types.js +32 -8
  11. package/dest/errors.d.ts +9 -5
  12. package/dest/errors.d.ts.map +1 -1
  13. package/dest/errors.js +7 -4
  14. package/dest/factory.d.ts +6 -14
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +17 -12
  17. package/dest/metrics.d.ts +51 -0
  18. package/dest/metrics.d.ts.map +1 -0
  19. package/dest/metrics.js +103 -0
  20. package/dest/migrations.d.ts +1 -1
  21. package/dest/migrations.d.ts.map +1 -1
  22. package/dest/migrations.js +13 -2
  23. package/dest/slashing_protection_service.d.ts +25 -6
  24. package/dest/slashing_protection_service.d.ts.map +1 -1
  25. package/dest/slashing_protection_service.js +72 -20
  26. package/dest/test/pglite_pool.d.ts +92 -0
  27. package/dest/test/pglite_pool.d.ts.map +1 -0
  28. package/dest/test/pglite_pool.js +210 -0
  29. package/dest/types.d.ts +38 -18
  30. package/dest/types.d.ts.map +1 -1
  31. package/dest/types.js +4 -1
  32. package/dest/validator_ha_signer.d.ts +18 -13
  33. package/dest/validator_ha_signer.d.ts.map +1 -1
  34. package/dest/validator_ha_signer.js +46 -33
  35. package/package.json +13 -10
  36. package/src/db/postgres.ts +101 -21
  37. package/src/db/schema.ts +51 -20
  38. package/src/db/types.ts +110 -31
  39. package/src/errors.ts +7 -2
  40. package/src/factory.ts +20 -14
  41. package/src/metrics.ts +138 -0
  42. package/src/migrations.ts +17 -1
  43. package/src/slashing_protection_service.ts +117 -25
  44. package/src/test/pglite_pool.ts +256 -0
  45. package/src/types.ts +63 -19
  46. package/src/validator_ha_signer.ts +66 -42
  47. package/dest/config.d.ts +0 -47
  48. package/dest/config.d.ts.map +0 -1
  49. package/dest/config.js +0 -64
  50. package/src/config.ts +0 -116
package/src/config.ts DELETED
@@ -1,116 +0,0 @@
1
- import {
2
- type ConfigMappingsType,
3
- booleanConfigHelper,
4
- getConfigFromMappings,
5
- getDefaultConfig,
6
- numberConfigHelper,
7
- } from '@aztec/foundation/config';
8
-
9
- /**
10
- * Configuration for the slashing protection service
11
- */
12
- export interface SlashingProtectionConfig {
13
- /** Whether slashing protection is enabled */
14
- enabled: boolean;
15
- /** Unique identifier for this node */
16
- nodeId: string;
17
- /** How long to wait between polls when a duty is being signed (ms) */
18
- pollingIntervalMs: number;
19
- /** Maximum time to wait for a duty being signed to complete (ms) */
20
- signingTimeoutMs: number;
21
- /** Maximum age of a stuck duty in ms */
22
- maxStuckDutiesAgeMs: number;
23
- }
24
-
25
- export const slashingProtectionConfigMappings: ConfigMappingsType<SlashingProtectionConfig> = {
26
- enabled: {
27
- env: 'SLASHING_PROTECTION_ENABLED',
28
- description: 'Whether slashing protection is enabled',
29
- ...booleanConfigHelper(true),
30
- },
31
- nodeId: {
32
- env: 'SLASHING_PROTECTION_NODE_ID',
33
- description: 'The unique identifier for this node',
34
- defaultValue: '',
35
- },
36
- pollingIntervalMs: {
37
- env: 'SLASHING_PROTECTION_POLLING_INTERVAL_MS',
38
- description: 'The number of ms to wait between polls when a duty is being signed',
39
- ...numberConfigHelper(100),
40
- },
41
- signingTimeoutMs: {
42
- env: 'SLASHING_PROTECTION_SIGNING_TIMEOUT_MS',
43
- description: 'The maximum time to wait for a duty being signed to complete',
44
- ...numberConfigHelper(3_000),
45
- },
46
- maxStuckDutiesAgeMs: {
47
- env: 'SLASHING_PROTECTION_MAX_STUCK_DUTIES_AGE_MS',
48
- description: 'The maximum age of a stuck duty in ms',
49
- // hard-coding at current 2 slot duration. This should be set by the validator on init
50
- ...numberConfigHelper(72_000),
51
- },
52
- };
53
-
54
- export const defaultSlashingProtectionConfig: SlashingProtectionConfig = getDefaultConfig(
55
- slashingProtectionConfigMappings,
56
- );
57
-
58
- /**
59
- * Configuration for creating an HA signer with PostgreSQL backend
60
- */
61
- export interface CreateHASignerConfig extends SlashingProtectionConfig {
62
- /**
63
- * PostgreSQL connection string
64
- * Format: postgresql://user:password@host:port/database
65
- */
66
- databaseUrl: string;
67
- /**
68
- * PostgreSQL connection pool configuration
69
- */
70
- /** Maximum number of clients in the pool (default: 10) */
71
- poolMaxCount?: number;
72
- /** Minimum number of clients in the pool (default: 0) */
73
- poolMinCount?: number;
74
- /** Idle timeout in milliseconds (default: 10000) */
75
- poolIdleTimeoutMs?: number;
76
- /** Connection timeout in milliseconds (default: 0, no timeout) */
77
- poolConnectionTimeoutMs?: number;
78
- }
79
-
80
- export const createHASignerConfigMappings: ConfigMappingsType<CreateHASignerConfig> = {
81
- ...slashingProtectionConfigMappings,
82
- databaseUrl: {
83
- env: 'VALIDATOR_HA_DATABASE_URL',
84
- description:
85
- 'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)',
86
- },
87
- poolMaxCount: {
88
- env: 'VALIDATOR_HA_POOL_MAX',
89
- description: 'Maximum number of clients in the pool',
90
- ...numberConfigHelper(10),
91
- },
92
- poolMinCount: {
93
- env: 'VALIDATOR_HA_POOL_MIN',
94
- description: 'Minimum number of clients in the pool',
95
- ...numberConfigHelper(0),
96
- },
97
- poolIdleTimeoutMs: {
98
- env: 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS',
99
- description: 'Idle timeout in milliseconds',
100
- ...numberConfigHelper(10_000),
101
- },
102
- poolConnectionTimeoutMs: {
103
- env: 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS',
104
- description: 'Connection timeout in milliseconds (0 means no timeout)',
105
- ...numberConfigHelper(0),
106
- },
107
- };
108
-
109
- /**
110
- * Returns the validator HA signer configuration from environment variables.
111
- * Note: If an environment variable is not set, the default value is used.
112
- * @returns The validator HA signer configuration.
113
- */
114
- export function getConfigEnvVars(): CreateHASignerConfig {
115
- return getConfigFromMappings<CreateHASignerConfig>(createHASignerConfigMappings);
116
- }