@aztec/aztec-node 0.0.1-commit.a072138 → 0.0.1-commit.a4600f49

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 (71) hide show
  1. package/dest/aztec-node/block_response_helpers.d.ts +25 -0
  2. package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
  3. package/dest/aztec-node/block_response_helpers.js +112 -0
  4. package/dest/aztec-node/config.d.ts +23 -8
  5. package/dest/aztec-node/config.d.ts.map +1 -1
  6. package/dest/aztec-node/config.js +26 -8
  7. package/dest/aztec-node/node_public_calls_simulator.d.ts +97 -0
  8. package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
  9. package/dest/aztec-node/node_public_calls_simulator.js +351 -0
  10. package/dest/aztec-node/public_data_overrides.d.ts +13 -0
  11. package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
  12. package/dest/aztec-node/public_data_overrides.js +21 -0
  13. package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
  14. package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
  15. package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
  16. package/dest/aztec-node/server.d.ts +143 -135
  17. package/dest/aztec-node/server.d.ts.map +1 -1
  18. package/dest/aztec-node/server.js +497 -730
  19. package/dest/bin/index.js +15 -10
  20. package/dest/factory.d.ts +33 -0
  21. package/dest/factory.d.ts.map +1 -0
  22. package/dest/factory.js +523 -0
  23. package/dest/index.d.ts +3 -1
  24. package/dest/index.d.ts.map +1 -1
  25. package/dest/index.js +2 -0
  26. package/dest/modules/block_parameter.d.ts +25 -0
  27. package/dest/modules/block_parameter.d.ts.map +1 -0
  28. package/dest/modules/block_parameter.js +100 -0
  29. package/dest/modules/node_block_provider.d.ts +19 -0
  30. package/dest/modules/node_block_provider.d.ts.map +1 -0
  31. package/dest/modules/node_block_provider.js +112 -0
  32. package/dest/modules/node_tx_receipt.d.ts +24 -0
  33. package/dest/modules/node_tx_receipt.d.ts.map +1 -0
  34. package/dest/modules/node_tx_receipt.js +70 -0
  35. package/dest/modules/node_world_state_queries.d.ts +65 -0
  36. package/dest/modules/node_world_state_queries.d.ts.map +1 -0
  37. package/dest/modules/node_world_state_queries.js +272 -0
  38. package/dest/sentinel/config.d.ts +3 -2
  39. package/dest/sentinel/config.d.ts.map +1 -1
  40. package/dest/sentinel/config.js +15 -5
  41. package/dest/sentinel/factory.d.ts +6 -4
  42. package/dest/sentinel/factory.d.ts.map +1 -1
  43. package/dest/sentinel/factory.js +12 -5
  44. package/dest/sentinel/sentinel.d.ts +146 -22
  45. package/dest/sentinel/sentinel.d.ts.map +1 -1
  46. package/dest/sentinel/sentinel.js +266 -118
  47. package/dest/sentinel/store.d.ts +8 -8
  48. package/dest/sentinel/store.d.ts.map +1 -1
  49. package/dest/sentinel/store.js +33 -21
  50. package/dest/test/index.d.ts +3 -3
  51. package/dest/test/index.d.ts.map +1 -1
  52. package/package.json +28 -25
  53. package/src/aztec-node/block_response_helpers.ts +161 -0
  54. package/src/aztec-node/config.ts +55 -16
  55. package/src/aztec-node/node_public_calls_simulator.ts +394 -0
  56. package/src/aztec-node/public_data_overrides.ts +35 -0
  57. package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
  58. package/src/aztec-node/server.ts +644 -939
  59. package/src/bin/index.ts +19 -12
  60. package/src/factory.ts +688 -0
  61. package/src/index.ts +2 -0
  62. package/src/modules/block_parameter.ts +93 -0
  63. package/src/modules/node_block_provider.ts +149 -0
  64. package/src/modules/node_tx_receipt.ts +115 -0
  65. package/src/modules/node_world_state_queries.ts +374 -0
  66. package/src/sentinel/README.md +103 -0
  67. package/src/sentinel/config.ts +18 -6
  68. package/src/sentinel/factory.ts +22 -7
  69. package/src/sentinel/sentinel.ts +316 -136
  70. package/src/sentinel/store.ts +35 -27
  71. package/src/test/index.ts +2 -2
@@ -9,45 +9,45 @@ import type {
9
9
  } from '@aztec/stdlib/validators';
10
10
 
11
11
  export class SentinelStore {
12
- public static readonly SCHEMA_VERSION = 2;
12
+ public static readonly SCHEMA_VERSION = 4;
13
13
 
14
14
  // a map from validator address to their ValidatorStatusHistory
15
15
  private readonly historyMap: AztecAsyncMap<`0x${string}`, Buffer>;
16
16
 
17
- // a map from validator address to their historical proven epoch performance
17
+ // a map from validator address to their historical epoch performance, evaluated at end-of-epoch.
18
18
  // e.g. { validator: [{ epoch: 1, missed: 1, total: 10 }, { epoch: 2, missed: 3, total: 7 }, ...] }
19
- private readonly provenMap: AztecAsyncMap<`0x${string}`, Buffer>;
19
+ private readonly epochMap: AztecAsyncMap<`0x${string}`, Buffer>;
20
20
 
21
21
  constructor(
22
22
  private store: AztecAsyncKVStore,
23
- private config: { historyLength: number; historicProvenPerformanceLength: number },
23
+ private config: { historyLength: number; historicEpochPerformanceLength: number },
24
24
  ) {
25
25
  this.historyMap = store.openMap('sentinel-validator-status');
26
- this.provenMap = store.openMap('sentinel-validator-proven');
26
+ this.epochMap = store.openMap('sentinel-validator-epoch');
27
27
  }
28
28
 
29
29
  public getHistoryLength() {
30
30
  return this.config.historyLength;
31
31
  }
32
32
 
33
- public getHistoricProvenPerformanceLength() {
34
- return this.config.historicProvenPerformanceLength;
33
+ public getHistoricEpochPerformanceLength() {
34
+ return this.config.historicEpochPerformanceLength;
35
35
  }
36
36
 
37
- public async updateProvenPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance) {
37
+ public async updateEpochPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance) {
38
38
  await this.store.transactionAsync(async () => {
39
39
  for (const [who, { missed, total }] of Object.entries(performance)) {
40
- await this.pushValidatorProvenPerformanceForEpoch({ who: EthAddress.fromString(who), missed, total, epoch });
40
+ await this.pushValidatorEpochPerformance({ who: EthAddress.fromString(who), missed, total, epoch });
41
41
  }
42
42
  });
43
43
  }
44
44
 
45
- public async getProvenPerformance(who: EthAddress): Promise<{ missed: number; total: number; epoch: EpochNumber }[]> {
46
- const currentPerformanceBuffer = await this.provenMap.getAsync(who.toString());
45
+ public async getEpochPerformance(who: EthAddress): Promise<{ missed: number; total: number; epoch: EpochNumber }[]> {
46
+ const currentPerformanceBuffer = await this.epochMap.getAsync(who.toString());
47
47
  return currentPerformanceBuffer ? this.deserializePerformance(currentPerformanceBuffer) : [];
48
48
  }
49
49
 
50
- private async pushValidatorProvenPerformanceForEpoch({
50
+ private async pushValidatorEpochPerformance({
51
51
  who,
52
52
  missed,
53
53
  total,
@@ -58,7 +58,7 @@ export class SentinelStore {
58
58
  total: number;
59
59
  epoch: EpochNumber;
60
60
  }) {
61
- const currentPerformance = await this.getProvenPerformance(who);
61
+ const currentPerformance = await this.getEpochPerformance(who);
62
62
  const existingIndex = currentPerformance.findIndex(p => p.epoch === epoch);
63
63
  if (existingIndex !== -1) {
64
64
  currentPerformance[existingIndex] = { missed, total, epoch };
@@ -70,10 +70,10 @@ export class SentinelStore {
70
70
  // Since we keep the size small, this is not a big deal.
71
71
  currentPerformance.sort((a, b) => Number(a.epoch - b.epoch));
72
72
 
73
- // keep the most recent `historicProvenPerformanceLength` entries.
74
- const performanceToKeep = currentPerformance.slice(-this.config.historicProvenPerformanceLength);
73
+ // keep the most recent `historicEpochPerformanceLength` entries.
74
+ const performanceToKeep = currentPerformance.slice(-this.config.historicEpochPerformanceLength);
75
75
 
76
- await this.provenMap.set(who.toString(), this.serializePerformance(performanceToKeep));
76
+ await this.epochMap.set(who.toString(), this.serializePerformance(performanceToKeep));
77
77
  }
78
78
 
79
79
  public async updateValidators(slot: SlotNumber, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>) {
@@ -86,11 +86,7 @@ export class SentinelStore {
86
86
  });
87
87
  }
88
88
 
89
- private async pushValidatorStatusForSlot(
90
- who: EthAddress,
91
- slot: SlotNumber,
92
- status: 'block-mined' | 'block-proposed' | 'block-missed' | 'attestation-sent' | 'attestation-missed',
93
- ) {
89
+ private async pushValidatorStatusForSlot(who: EthAddress, slot: SlotNumber, status: ValidatorStatusInSlot) {
94
90
  await this.store.transactionAsync(async () => {
95
91
  const currentHistory = (await this.getHistory(who)) ?? [];
96
92
  const newHistory = [...currentHistory, { slot, status }].slice(-this.config.historyLength);
@@ -149,16 +145,22 @@ export class SentinelStore {
149
145
 
150
146
  private statusToNumber(status: ValidatorStatusInSlot): number {
151
147
  switch (status) {
152
- case 'block-mined':
148
+ case 'checkpoint-mined':
153
149
  return 1;
154
- case 'block-proposed':
150
+ case 'checkpoint-valid':
155
151
  return 2;
156
- case 'block-missed':
152
+ case 'checkpoint-missed':
157
153
  return 3;
158
154
  case 'attestation-sent':
159
155
  return 4;
160
156
  case 'attestation-missed':
161
157
  return 5;
158
+ case 'blocks-missed':
159
+ return 6;
160
+ case 'checkpoint-invalid':
161
+ return 7;
162
+ case 'checkpoint-unvalidated':
163
+ return 8;
162
164
  default: {
163
165
  const _exhaustive: never = status;
164
166
  throw new Error(`Unknown status: ${status}`);
@@ -169,15 +171,21 @@ export class SentinelStore {
169
171
  private statusFromNumber(status: number): ValidatorStatusInSlot {
170
172
  switch (status) {
171
173
  case 1:
172
- return 'block-mined';
174
+ return 'checkpoint-mined';
173
175
  case 2:
174
- return 'block-proposed';
176
+ return 'checkpoint-valid';
175
177
  case 3:
176
- return 'block-missed';
178
+ return 'checkpoint-missed';
177
179
  case 4:
178
180
  return 'attestation-sent';
179
181
  case 5:
180
182
  return 'attestation-missed';
183
+ case 6:
184
+ return 'blocks-missed';
185
+ case 7:
186
+ return 'checkpoint-invalid';
187
+ case 8:
188
+ return 'checkpoint-unvalidated';
181
189
  default:
182
190
  throw new Error(`Unknown status: ${status}`);
183
191
  }
package/src/test/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
2
  import type { P2P } from '@aztec/p2p';
3
3
  import { SequencerClient } from '@aztec/sequencer-client';
4
- import { EpochPruneWatcher, type SlasherClientInterface } from '@aztec/slasher';
4
+ import { DataWithholdingWatcher, type SlasherClientInterface } from '@aztec/slasher';
5
5
  import type { L2BlockSource } from '@aztec/stdlib/block';
6
6
  import type { ContractDataSource } from '@aztec/stdlib/contract';
7
7
  import type { L2LogsSource, Service, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
@@ -23,7 +23,7 @@ export declare class TestAztecNodeService extends AztecNodeService {
23
23
  declare public sequencer: SequencerClient | undefined;
24
24
  declare public slasherClient: SlasherClientInterface | undefined;
25
25
  declare public validatorsSentinel: Sentinel | undefined;
26
- declare public epochPruneWatcher: EpochPruneWatcher | undefined;
26
+ declare public dataWithholdingWatcher: DataWithholdingWatcher | undefined;
27
27
  declare public l1ChainId: number;
28
28
  declare public version: number;
29
29
  declare public globalVariableBuilder: GlobalVariableBuilderInterface;