@aztec/validator-client 0.0.1-commit.c7c42ec → 0.0.1-commit.c949de6bc

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 (57) hide show
  1. package/README.md +285 -0
  2. package/dest/block_proposal_handler.d.ts +21 -11
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +327 -85
  5. package/dest/checkpoint_builder.d.ts +69 -0
  6. package/dest/checkpoint_builder.d.ts.map +1 -0
  7. package/dest/checkpoint_builder.js +180 -0
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +16 -8
  11. package/dest/duties/validation_service.d.ts +41 -12
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +109 -26
  14. package/dest/factory.d.ts +13 -10
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +2 -2
  17. package/dest/index.d.ts +2 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +1 -0
  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 +4 -3
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +34 -30
  40. package/dest/validator.d.ts +73 -24
  41. package/dest/validator.d.ts.map +1 -1
  42. package/dest/validator.js +452 -91
  43. package/package.json +21 -13
  44. package/src/block_proposal_handler.ts +246 -57
  45. package/src/checkpoint_builder.ts +328 -0
  46. package/src/config.ts +15 -7
  47. package/src/duties/validation_service.ts +160 -31
  48. package/src/factory.ts +17 -11
  49. package/src/index.ts +1 -0
  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 +45 -33
  57. package/src/validator.ts +615 -120
package/src/metrics.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import type { BlockProposal } from '@aztec/stdlib/p2p';
2
2
  import {
3
3
  Attributes,
4
+ type Gauge,
4
5
  type Histogram,
5
6
  Metrics,
6
7
  type TelemetryClient,
7
8
  type UpDownCounter,
8
- ValueType,
9
+ createUpDownCounterWithDefault,
9
10
  } from '@aztec/telemetry-client';
10
11
 
12
+ import type { BlockProposalValidationFailureReason } from './block_proposal_handler.js';
13
+
11
14
  export class ValidatorMetrics {
12
15
  private failedReexecutionCounter: UpDownCounter;
13
16
  private successfulAttestationsCount: UpDownCounter;
@@ -16,55 +19,56 @@ export class ValidatorMetrics {
16
19
 
17
20
  private reexMana: Histogram;
18
21
  private reexTx: Histogram;
19
- private reexDuration: Histogram;
22
+ private reexDuration: Gauge;
20
23
 
21
24
  constructor(telemetryClient: TelemetryClient) {
22
25
  const meter = telemetryClient.getMeter('Validator');
23
26
 
24
- this.failedReexecutionCounter = meter.createUpDownCounter(Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
25
- description: 'The number of failed re-executions',
26
- unit: 'count',
27
- valueType: ValueType.INT,
27
+ this.failedReexecutionCounter = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
28
+ [Attributes.STATUS]: ['failed'],
28
29
  });
29
30
 
30
- this.successfulAttestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT, {
31
- description: 'The number of successful attestations',
32
- valueType: ValueType.INT,
33
- });
31
+ this.successfulAttestationsCount = createUpDownCounterWithDefault(
32
+ meter,
33
+ Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT,
34
+ );
34
35
 
35
- this.failedAttestationsBadProposalCount = meter.createUpDownCounter(
36
+ this.failedAttestationsBadProposalCount = createUpDownCounterWithDefault(
37
+ meter,
36
38
  Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT,
37
39
  {
38
- description: 'The number of failed attestations due to invalid block proposals',
39
- valueType: ValueType.INT,
40
+ [Attributes.ERROR_TYPE]: [
41
+ 'invalid_proposal',
42
+ 'state_mismatch',
43
+ 'failed_txs',
44
+ 'in_hash_mismatch',
45
+ 'parent_block_wrong_slot',
46
+ ],
47
+ [Attributes.IS_COMMITTEE_MEMBER]: [true, false],
40
48
  },
41
49
  );
42
50
 
43
- this.failedAttestationsNodeIssueCount = meter.createUpDownCounter(
51
+ this.failedAttestationsNodeIssueCount = createUpDownCounterWithDefault(
52
+ meter,
44
53
  Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT,
45
54
  {
46
- description: 'The number of failed attestations due to node issues (timeout, missing data, etc.)',
47
- valueType: ValueType.INT,
55
+ [Attributes.ERROR_TYPE]: [
56
+ 'parent_block_not_found',
57
+ 'global_variables_mismatch',
58
+ 'block_number_already_exists',
59
+ 'txs_not_available',
60
+ 'timeout',
61
+ 'unknown_error',
62
+ ],
63
+ [Attributes.IS_COMMITTEE_MEMBER]: [true, false],
48
64
  },
49
65
  );
50
66
 
51
- this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA, {
52
- description: 'The mana consumed by blocks',
53
- valueType: ValueType.DOUBLE,
54
- unit: 'Mmana',
55
- });
67
+ this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
56
68
 
57
- this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT, {
58
- description: 'The number of txs in a block proposal',
59
- valueType: ValueType.INT,
60
- unit: 'tx',
61
- });
69
+ this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
62
70
 
63
- this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME, {
64
- description: 'The time taken to re-execute a transaction',
65
- unit: 'ms',
66
- valueType: ValueType.INT,
67
- });
71
+ this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME);
68
72
  }
69
73
 
70
74
  public recordReex(time: number, txs: number, mManaTotal: number) {
@@ -85,14 +89,22 @@ export class ValidatorMetrics {
85
89
  this.successfulAttestationsCount.add(num);
86
90
  }
87
91
 
88
- public incFailedAttestationsBadProposal(num: number, reason: string, inCommittee: boolean) {
92
+ public incFailedAttestationsBadProposal(
93
+ num: number,
94
+ reason: BlockProposalValidationFailureReason,
95
+ inCommittee: boolean,
96
+ ) {
89
97
  this.failedAttestationsBadProposalCount.add(num, {
90
98
  [Attributes.ERROR_TYPE]: reason,
91
99
  [Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
92
100
  });
93
101
  }
94
102
 
95
- public incFailedAttestationsNodeIssue(num: number, reason: string, inCommittee: boolean) {
103
+ public incFailedAttestationsNodeIssue(
104
+ num: number,
105
+ reason: BlockProposalValidationFailureReason,
106
+ inCommittee: boolean,
107
+ ) {
96
108
  this.failedAttestationsNodeIssueCount.add(num, {
97
109
  [Attributes.ERROR_TYPE]: reason,
98
110
  [Attributes.IS_COMMITTEE_MEMBER]: inCommittee,