@aztec/validator-ha-signer 0.0.1-commit.ff7989d6c → 0.0.1-commit.fff30aa

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/metrics.js DELETED
@@ -1,103 +0,0 @@
1
- import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
2
- /**
3
- * Metrics for HA signer tracking signing operations, lock acquisition, and cleanup.
4
- */ export class HASignerMetrics {
5
- nodeId;
6
- // Signing lifecycle metrics
7
- signingDuration;
8
- signingSuccessCount;
9
- dutyAlreadySignedCount;
10
- slashingProtectionCount;
11
- signingErrorCount;
12
- // Lock acquisition metrics
13
- lockAcquiredCount;
14
- // Cleanup metrics
15
- cleanupStuckDutiesCount;
16
- cleanupOldDutiesCount;
17
- cleanupOutdatedRollupDutiesCount;
18
- constructor(client, nodeId, name = 'HASignerMetrics'){
19
- this.nodeId = nodeId;
20
- const meter = client.getMeter(name);
21
- // Signing lifecycle
22
- this.signingDuration = meter.createHistogram(Metrics.HA_SIGNER_SIGNING_DURATION);
23
- this.signingSuccessCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_SIGNING_SUCCESS_COUNT);
24
- this.dutyAlreadySignedCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_DUTY_ALREADY_SIGNED_COUNT);
25
- this.slashingProtectionCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_SLASHING_PROTECTION_COUNT);
26
- this.signingErrorCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_SIGNING_ERROR_COUNT);
27
- // Lock acquisition
28
- this.lockAcquiredCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_LOCK_ACQUIRED_COUNT);
29
- // Cleanup
30
- this.cleanupStuckDutiesCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_CLEANUP_STUCK_DUTIES_COUNT);
31
- this.cleanupOldDutiesCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_CLEANUP_OLD_DUTIES_COUNT);
32
- this.cleanupOutdatedRollupDutiesCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_CLEANUP_OUTDATED_ROLLUP_DUTIES_COUNT);
33
- }
34
- /**
35
- * Record a successful signing operation.
36
- * @param dutyType - The type of duty signed
37
- * @param durationMs - Duration from start of signWithProtection to completion
38
- */ recordSigningSuccess(dutyType, durationMs) {
39
- const attributes = {
40
- [Attributes.HA_DUTY_TYPE]: dutyType,
41
- [Attributes.HA_NODE_ID]: this.nodeId
42
- };
43
- this.signingSuccessCount.add(1, attributes);
44
- this.signingDuration.record(durationMs, attributes);
45
- }
46
- /**
47
- * Record a DutyAlreadySignedError (expected in HA; another node signed first).
48
- * @param dutyType - The type of duty
49
- */ recordDutyAlreadySigned(dutyType) {
50
- const attributes = {
51
- [Attributes.HA_DUTY_TYPE]: dutyType,
52
- [Attributes.HA_NODE_ID]: this.nodeId
53
- };
54
- this.dutyAlreadySignedCount.add(1, attributes);
55
- }
56
- /**
57
- * Record a SlashingProtectionError (attempted to sign different data for same duty).
58
- * @param dutyType - The type of duty
59
- */ recordSlashingProtection(dutyType) {
60
- const attributes = {
61
- [Attributes.HA_DUTY_TYPE]: dutyType,
62
- [Attributes.HA_NODE_ID]: this.nodeId
63
- };
64
- this.slashingProtectionCount.add(1, attributes);
65
- }
66
- /**
67
- * Record a signing function failure (lock will be deleted for retry).
68
- * @param dutyType - The type of duty
69
- */ recordSigningError(dutyType) {
70
- const attributes = {
71
- [Attributes.HA_DUTY_TYPE]: dutyType,
72
- [Attributes.HA_NODE_ID]: this.nodeId
73
- };
74
- this.signingErrorCount.add(1, attributes);
75
- }
76
- /**
77
- * Record lock acquisition.
78
- * @param acquired - Whether a new lock was acquired (true) or existing record found (false)
79
- */ recordLockAcquire(acquired) {
80
- if (acquired) {
81
- const attributes = {
82
- [Attributes.HA_NODE_ID]: this.nodeId
83
- };
84
- this.lockAcquiredCount.add(1, attributes);
85
- }
86
- }
87
- /**
88
- * Record cleanup metrics.
89
- * @param type - Type of cleanup
90
- * @param count - Number of duties cleaned up
91
- */ recordCleanup(type, count) {
92
- const attributes = {
93
- [Attributes.HA_NODE_ID]: this.nodeId
94
- };
95
- if (type === 'stuck') {
96
- this.cleanupStuckDutiesCount.add(count, attributes);
97
- } else if (type === 'old') {
98
- this.cleanupOldDutiesCount.add(count, attributes);
99
- } else if (type === 'outdated_rollup') {
100
- this.cleanupOutdatedRollupDutiesCount.add(count, attributes);
101
- }
102
- }
103
- }
package/src/metrics.ts DELETED
@@ -1,138 +0,0 @@
1
- import {
2
- Attributes,
3
- type Histogram,
4
- Metrics,
5
- type TelemetryClient,
6
- type UpDownCounter,
7
- createUpDownCounterWithDefault,
8
- } from '@aztec/telemetry-client';
9
-
10
- export type HACleanupType = 'stuck' | 'old' | 'outdated_rollup';
11
-
12
- /**
13
- * Metrics for HA signer tracking signing operations, lock acquisition, and cleanup.
14
- */
15
- export class HASignerMetrics {
16
- // Signing lifecycle metrics
17
- private signingDuration: Histogram;
18
- private signingSuccessCount: UpDownCounter;
19
- private dutyAlreadySignedCount: UpDownCounter;
20
- private slashingProtectionCount: UpDownCounter;
21
- private signingErrorCount: UpDownCounter;
22
-
23
- // Lock acquisition metrics
24
- private lockAcquiredCount: UpDownCounter;
25
-
26
- // Cleanup metrics
27
- private cleanupStuckDutiesCount: UpDownCounter;
28
- private cleanupOldDutiesCount: UpDownCounter;
29
- private cleanupOutdatedRollupDutiesCount: UpDownCounter;
30
-
31
- constructor(
32
- client: TelemetryClient,
33
- private nodeId: string,
34
- name = 'HASignerMetrics',
35
- ) {
36
- const meter = client.getMeter(name);
37
-
38
- // Signing lifecycle
39
- this.signingDuration = meter.createHistogram(Metrics.HA_SIGNER_SIGNING_DURATION);
40
- this.signingSuccessCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_SIGNING_SUCCESS_COUNT);
41
- this.dutyAlreadySignedCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_DUTY_ALREADY_SIGNED_COUNT);
42
- this.slashingProtectionCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_SLASHING_PROTECTION_COUNT);
43
- this.signingErrorCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_SIGNING_ERROR_COUNT);
44
-
45
- // Lock acquisition
46
- this.lockAcquiredCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_LOCK_ACQUIRED_COUNT);
47
-
48
- // Cleanup
49
- this.cleanupStuckDutiesCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_CLEANUP_STUCK_DUTIES_COUNT);
50
- this.cleanupOldDutiesCount = createUpDownCounterWithDefault(meter, Metrics.HA_SIGNER_CLEANUP_OLD_DUTIES_COUNT);
51
- this.cleanupOutdatedRollupDutiesCount = createUpDownCounterWithDefault(
52
- meter,
53
- Metrics.HA_SIGNER_CLEANUP_OUTDATED_ROLLUP_DUTIES_COUNT,
54
- );
55
- }
56
-
57
- /**
58
- * Record a successful signing operation.
59
- * @param dutyType - The type of duty signed
60
- * @param durationMs - Duration from start of signWithProtection to completion
61
- */
62
- public recordSigningSuccess(dutyType: string, durationMs: number): void {
63
- const attributes = {
64
- [Attributes.HA_DUTY_TYPE]: dutyType,
65
- [Attributes.HA_NODE_ID]: this.nodeId,
66
- };
67
- this.signingSuccessCount.add(1, attributes);
68
- this.signingDuration.record(durationMs, attributes);
69
- }
70
-
71
- /**
72
- * Record a DutyAlreadySignedError (expected in HA; another node signed first).
73
- * @param dutyType - The type of duty
74
- */
75
- public recordDutyAlreadySigned(dutyType: string): void {
76
- const attributes = {
77
- [Attributes.HA_DUTY_TYPE]: dutyType,
78
- [Attributes.HA_NODE_ID]: this.nodeId,
79
- };
80
- this.dutyAlreadySignedCount.add(1, attributes);
81
- }
82
-
83
- /**
84
- * Record a SlashingProtectionError (attempted to sign different data for same duty).
85
- * @param dutyType - The type of duty
86
- */
87
- public recordSlashingProtection(dutyType: string): void {
88
- const attributes = {
89
- [Attributes.HA_DUTY_TYPE]: dutyType,
90
- [Attributes.HA_NODE_ID]: this.nodeId,
91
- };
92
- this.slashingProtectionCount.add(1, attributes);
93
- }
94
-
95
- /**
96
- * Record a signing function failure (lock will be deleted for retry).
97
- * @param dutyType - The type of duty
98
- */
99
- public recordSigningError(dutyType: string): void {
100
- const attributes = {
101
- [Attributes.HA_DUTY_TYPE]: dutyType,
102
- [Attributes.HA_NODE_ID]: this.nodeId,
103
- };
104
- this.signingErrorCount.add(1, attributes);
105
- }
106
-
107
- /**
108
- * Record lock acquisition.
109
- * @param acquired - Whether a new lock was acquired (true) or existing record found (false)
110
- */
111
- public recordLockAcquire(acquired: boolean): void {
112
- if (acquired) {
113
- const attributes = {
114
- [Attributes.HA_NODE_ID]: this.nodeId,
115
- };
116
- this.lockAcquiredCount.add(1, attributes);
117
- }
118
- }
119
-
120
- /**
121
- * Record cleanup metrics.
122
- * @param type - Type of cleanup
123
- * @param count - Number of duties cleaned up
124
- */
125
- public recordCleanup(type: HACleanupType, count: number): void {
126
- const attributes = {
127
- [Attributes.HA_NODE_ID]: this.nodeId,
128
- };
129
-
130
- if (type === 'stuck') {
131
- this.cleanupStuckDutiesCount.add(count, attributes);
132
- } else if (type === 'old') {
133
- this.cleanupOldDutiesCount.add(count, attributes);
134
- } else if (type === 'outdated_rollup') {
135
- this.cleanupOutdatedRollupDutiesCount.add(count, attributes);
136
- }
137
- }
138
- }