@aztec/validator-client 0.0.1-commit.7d4e6cd → 0.0.1-commit.7ffbba4

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 (69) hide show
  1. package/README.md +95 -24
  2. package/dest/block_proposal_handler.d.ts +10 -10
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +76 -76
  5. package/dest/checkpoint_builder.d.ts +31 -25
  6. package/dest/checkpoint_builder.d.ts.map +1 -1
  7. package/dest/checkpoint_builder.js +114 -41
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +33 -14
  11. package/dest/duties/validation_service.d.ts +20 -7
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +69 -22
  14. package/dest/factory.d.ts +2 -2
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +3 -2
  17. package/dest/index.d.ts +1 -2
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +0 -1
  20. package/dest/key_store/ha_key_store.d.ts +99 -0
  21. package/dest/key_store/ha_key_store.d.ts.map +1 -0
  22. package/dest/key_store/ha_key_store.js +208 -0
  23. package/dest/key_store/index.d.ts +2 -1
  24. package/dest/key_store/index.d.ts.map +1 -1
  25. package/dest/key_store/index.js +1 -0
  26. package/dest/key_store/interface.d.ts +36 -6
  27. package/dest/key_store/interface.d.ts.map +1 -1
  28. package/dest/key_store/local_key_store.d.ts +10 -5
  29. package/dest/key_store/local_key_store.d.ts.map +1 -1
  30. package/dest/key_store/local_key_store.js +8 -4
  31. package/dest/key_store/node_keystore_adapter.d.ts +18 -5
  32. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
  33. package/dest/key_store/node_keystore_adapter.js +18 -4
  34. package/dest/key_store/web3signer_key_store.d.ts +10 -5
  35. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  36. package/dest/key_store/web3signer_key_store.js +8 -4
  37. package/dest/metrics.d.ts +12 -3
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +46 -5
  40. package/dest/validator.d.ts +45 -18
  41. package/dest/validator.d.ts.map +1 -1
  42. package/dest/validator.js +262 -98
  43. package/package.json +21 -17
  44. package/src/block_proposal_handler.ts +93 -95
  45. package/src/checkpoint_builder.ts +171 -48
  46. package/src/config.ts +32 -13
  47. package/src/duties/validation_service.ts +94 -25
  48. package/src/factory.ts +2 -0
  49. package/src/index.ts +0 -1
  50. package/src/key_store/ha_key_store.ts +269 -0
  51. package/src/key_store/index.ts +1 -0
  52. package/src/key_store/interface.ts +44 -5
  53. package/src/key_store/local_key_store.ts +13 -4
  54. package/src/key_store/node_keystore_adapter.ts +27 -4
  55. package/src/key_store/web3signer_key_store.ts +17 -4
  56. package/src/metrics.ts +63 -6
  57. package/src/validator.ts +326 -116
  58. package/dest/tx_validator/index.d.ts +0 -3
  59. package/dest/tx_validator/index.d.ts.map +0 -1
  60. package/dest/tx_validator/index.js +0 -2
  61. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  62. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  63. package/dest/tx_validator/nullifier_cache.js +0 -24
  64. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  65. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  66. package/dest/tx_validator/tx_validator_factory.js +0 -53
  67. package/src/tx_validator/index.ts +0 -2
  68. package/src/tx_validator/nullifier_cache.ts +0 -30
  69. package/src/tx_validator/tx_validator_factory.ts +0 -133
package/src/metrics.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
1
3
  import type { BlockProposal } from '@aztec/stdlib/p2p';
2
4
  import {
3
5
  Attributes,
@@ -6,13 +8,18 @@ import {
6
8
  Metrics,
7
9
  type TelemetryClient,
8
10
  type UpDownCounter,
11
+ createUpDownCounterWithDefault,
9
12
  } from '@aztec/telemetry-client';
10
13
 
14
+ import type { BlockProposalValidationFailureReason } from './block_proposal_handler.js';
15
+
11
16
  export class ValidatorMetrics {
12
17
  private failedReexecutionCounter: UpDownCounter;
13
18
  private successfulAttestationsCount: UpDownCounter;
14
19
  private failedAttestationsBadProposalCount: UpDownCounter;
15
20
  private failedAttestationsNodeIssueCount: UpDownCounter;
21
+ private currentEpoch: Gauge;
22
+ private attestedEpochCount: UpDownCounter;
16
23
 
17
24
  private reexMana: Histogram;
18
25
  private reexTx: Histogram;
@@ -21,18 +28,50 @@ export class ValidatorMetrics {
21
28
  constructor(telemetryClient: TelemetryClient) {
22
29
  const meter = telemetryClient.getMeter('Validator');
23
30
 
24
- this.failedReexecutionCounter = meter.createUpDownCounter(Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT);
31
+ this.failedReexecutionCounter = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
32
+ [Attributes.STATUS]: ['failed'],
33
+ });
25
34
 
26
- this.successfulAttestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT);
35
+ this.successfulAttestationsCount = createUpDownCounterWithDefault(
36
+ meter,
37
+ Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT,
38
+ );
27
39
 
28
- this.failedAttestationsBadProposalCount = meter.createUpDownCounter(
40
+ this.failedAttestationsBadProposalCount = createUpDownCounterWithDefault(
41
+ meter,
29
42
  Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT,
43
+ {
44
+ [Attributes.ERROR_TYPE]: [
45
+ 'invalid_proposal',
46
+ 'state_mismatch',
47
+ 'failed_txs',
48
+ 'in_hash_mismatch',
49
+ 'parent_block_wrong_slot',
50
+ ],
51
+ [Attributes.IS_COMMITTEE_MEMBER]: [true, false],
52
+ },
30
53
  );
31
54
 
32
- this.failedAttestationsNodeIssueCount = meter.createUpDownCounter(
55
+ this.failedAttestationsNodeIssueCount = createUpDownCounterWithDefault(
56
+ meter,
33
57
  Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT,
58
+ {
59
+ [Attributes.ERROR_TYPE]: [
60
+ 'parent_block_not_found',
61
+ 'global_variables_mismatch',
62
+ 'block_number_already_exists',
63
+ 'txs_not_available',
64
+ 'timeout',
65
+ 'unknown_error',
66
+ ],
67
+ [Attributes.IS_COMMITTEE_MEMBER]: [true, false],
68
+ },
34
69
  );
35
70
 
71
+ this.currentEpoch = meter.createGauge(Metrics.VALIDATOR_CURRENT_EPOCH);
72
+
73
+ this.attestedEpochCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTED_EPOCH_COUNT);
74
+
36
75
  this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
37
76
 
38
77
  this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
@@ -58,17 +97,35 @@ export class ValidatorMetrics {
58
97
  this.successfulAttestationsCount.add(num);
59
98
  }
60
99
 
61
- public incFailedAttestationsBadProposal(num: number, reason: string, inCommittee: boolean) {
100
+ public incFailedAttestationsBadProposal(
101
+ num: number,
102
+ reason: BlockProposalValidationFailureReason,
103
+ inCommittee: boolean,
104
+ ) {
62
105
  this.failedAttestationsBadProposalCount.add(num, {
63
106
  [Attributes.ERROR_TYPE]: reason,
64
107
  [Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
65
108
  });
66
109
  }
67
110
 
68
- public incFailedAttestationsNodeIssue(num: number, reason: string, inCommittee: boolean) {
111
+ public incFailedAttestationsNodeIssue(
112
+ num: number,
113
+ reason: BlockProposalValidationFailureReason,
114
+ inCommittee: boolean,
115
+ ) {
69
116
  this.failedAttestationsNodeIssueCount.add(num, {
70
117
  [Attributes.ERROR_TYPE]: reason,
71
118
  [Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
72
119
  });
73
120
  }
121
+
122
+ /** Update the gauge tracking the current epoch number (proxy for total epochs elapsed). */
123
+ public setCurrentEpoch(epoch: EpochNumber) {
124
+ this.currentEpoch.record(Number(epoch));
125
+ }
126
+
127
+ /** Increment the count of epochs in which the given attester submitted at least one attestation. */
128
+ public incAttestedEpochCount(attester: EthAddress) {
129
+ this.attestedEpochCount.add(1, { [Attributes.ATTESTER_ADDRESS]: attester.toString() });
130
+ }
74
131
  }