@aztec/world-state 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f

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 (53) hide show
  1. package/dest/instrumentation/instrumentation.d.ts +1 -1
  2. package/dest/instrumentation/instrumentation.d.ts.map +1 -1
  3. package/dest/instrumentation/instrumentation.js +17 -41
  4. package/dest/native/fork_checkpoint.d.ts +7 -1
  5. package/dest/native/fork_checkpoint.d.ts.map +1 -1
  6. package/dest/native/fork_checkpoint.js +15 -3
  7. package/dest/native/ipc_world_state_instance.d.ts +50 -0
  8. package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
  9. package/dest/native/ipc_world_state_instance.js +628 -0
  10. package/dest/native/merkle_trees_facade.d.ts +9 -6
  11. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  12. package/dest/native/merkle_trees_facade.js +47 -16
  13. package/dest/native/message.d.ts +13 -5
  14. package/dest/native/message.d.ts.map +1 -1
  15. package/dest/native/native_world_state.d.ts +34 -8
  16. package/dest/native/native_world_state.d.ts.map +1 -1
  17. package/dest/native/native_world_state.js +81 -27
  18. package/dest/native/native_world_state_instance.d.ts +6 -5
  19. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  20. package/dest/native/native_world_state_instance.js +33 -26
  21. package/dest/native/world_state_ops_queue.js +5 -5
  22. package/dest/synchronizer/config.d.ts +3 -5
  23. package/dest/synchronizer/config.d.ts.map +1 -1
  24. package/dest/synchronizer/config.js +15 -18
  25. package/dest/synchronizer/factory.d.ts +6 -5
  26. package/dest/synchronizer/factory.d.ts.map +1 -1
  27. package/dest/synchronizer/factory.js +7 -6
  28. package/dest/synchronizer/server_world_state_synchronizer.d.ts +4 -5
  29. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  30. package/dest/synchronizer/server_world_state_synchronizer.js +139 -39
  31. package/dest/test/utils.d.ts +7 -7
  32. package/dest/test/utils.d.ts.map +1 -1
  33. package/dest/test/utils.js +5 -5
  34. package/dest/testing.d.ts +4 -3
  35. package/dest/testing.d.ts.map +1 -1
  36. package/dest/testing.js +10 -6
  37. package/dest/world-state-db/merkle_tree_db.d.ts +5 -14
  38. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  39. package/package.json +13 -12
  40. package/src/instrumentation/instrumentation.ts +17 -41
  41. package/src/native/fork_checkpoint.ts +19 -3
  42. package/src/native/ipc_world_state_instance.ts +717 -0
  43. package/src/native/merkle_trees_facade.ts +51 -17
  44. package/src/native/message.ts +14 -4
  45. package/src/native/native_world_state.ts +108 -32
  46. package/src/native/native_world_state_instance.ts +44 -32
  47. package/src/native/world_state_ops_queue.ts +5 -5
  48. package/src/synchronizer/config.ts +16 -23
  49. package/src/synchronizer/factory.ts +19 -11
  50. package/src/synchronizer/server_world_state_synchronizer.ts +142 -53
  51. package/src/test/utils.ts +6 -6
  52. package/src/testing.ts +8 -9
  53. package/src/world-state-db/merkle_tree_db.ts +8 -14
@@ -7,7 +7,7 @@ import {
7
7
  Metrics,
8
8
  type TelemetryClient,
9
9
  type UpDownCounter,
10
- ValueType,
10
+ createUpDownCounterWithDefault,
11
11
  } from '@aztec/telemetry-client';
12
12
 
13
13
  import {
@@ -46,55 +46,31 @@ export class WorldStateInstrumentation {
46
46
  private log: Logger = createLogger('world-state:instrumentation'),
47
47
  ) {
48
48
  const meter = telemetry.getMeter('World State');
49
- this.dbMapSize = meter.createGauge(Metrics.WORLD_STATE_DB_MAP_SIZE, {
50
- description: `The current configured map size for each merkle tree`,
51
- valueType: ValueType.INT,
52
- });
49
+ this.dbMapSize = meter.createGauge(Metrics.WORLD_STATE_DB_MAP_SIZE);
53
50
 
54
- this.dbPhysicalSize = meter.createGauge(Metrics.WORLD_STATE_DB_PHYSICAL_SIZE, {
55
- description: `The current physical disk space used for each database`,
56
- valueType: ValueType.INT,
57
- });
51
+ this.dbPhysicalSize = meter.createGauge(Metrics.WORLD_STATE_DB_PHYSICAL_SIZE);
58
52
 
59
- this.treeSize = meter.createGauge(Metrics.WORLD_STATE_TREE_SIZE, {
60
- description: `The current number of leaves in each merkle tree`,
61
- valueType: ValueType.INT,
62
- });
53
+ this.treeSize = meter.createGauge(Metrics.WORLD_STATE_TREE_SIZE);
63
54
 
64
- this.unfinalizedHeight = meter.createGauge(Metrics.WORLD_STATE_UNFINALIZED_HEIGHT, {
65
- description: `The unfinalized block height of each merkle tree`,
66
- valueType: ValueType.INT,
67
- });
55
+ this.unfinalizedHeight = meter.createGauge(Metrics.WORLD_STATE_UNFINALIZED_HEIGHT);
68
56
 
69
- this.finalizedHeight = meter.createGauge(Metrics.WORLD_STATE_FINALIZED_HEIGHT, {
70
- description: `The finalized block height of each merkle tree`,
71
- valueType: ValueType.INT,
72
- });
57
+ this.finalizedHeight = meter.createGauge(Metrics.WORLD_STATE_FINALIZED_HEIGHT);
73
58
 
74
- this.oldestBlock = meter.createGauge(Metrics.WORLD_STATE_OLDEST_BLOCK, {
75
- description: `The oldest historical block of each merkle tree`,
76
- valueType: ValueType.INT,
77
- });
59
+ this.oldestBlock = meter.createGauge(Metrics.WORLD_STATE_OLDEST_BLOCK);
78
60
 
79
- this.dbUsedSize = meter.createGauge(Metrics.WORLD_STATE_DB_USED_SIZE, {
80
- description: `The current used database size for each db of each merkle tree`,
81
- valueType: ValueType.INT,
82
- });
61
+ this.dbUsedSize = meter.createGauge(Metrics.WORLD_STATE_DB_USED_SIZE);
83
62
 
84
- this.dbNumItems = meter.createGauge(Metrics.WORLD_STATE_DB_NUM_ITEMS, {
85
- description: `The current number of items in each database of each merkle tree`,
86
- valueType: ValueType.INT,
87
- });
63
+ this.dbNumItems = meter.createGauge(Metrics.WORLD_STATE_DB_NUM_ITEMS);
88
64
 
89
- this.requestHistogram = meter.createHistogram(Metrics.WORLD_STATE_REQUEST_TIME, {
90
- description: 'The round trip time of world state requests',
91
- unit: 'us',
92
- valueType: ValueType.INT,
93
- });
65
+ this.requestHistogram = meter.createHistogram(Metrics.WORLD_STATE_REQUEST_TIME);
94
66
 
95
- this.criticalErrors = meter.createUpDownCounter(Metrics.WORLD_STATE_CRITICAL_ERROR_COUNT, {
96
- description: 'The number of critical errors in the world state',
97
- valueType: ValueType.INT,
67
+ this.criticalErrors = createUpDownCounterWithDefault(meter, Metrics.WORLD_STATE_CRITICAL_ERROR_COUNT, {
68
+ [Attributes.ERROR_TYPE]: [
69
+ 'synch_pending_block',
70
+ 'finalize_block',
71
+ 'prune_pending_block',
72
+ 'prune_historical_block',
73
+ ],
98
74
  });
99
75
  }
100
76
 
@@ -3,11 +3,14 @@ import type { MerkleTreeCheckpointOperations } from '@aztec/stdlib/interfaces/se
3
3
  export class ForkCheckpoint {
4
4
  private completed = false;
5
5
 
6
- private constructor(private readonly fork: MerkleTreeCheckpointOperations) {}
6
+ private constructor(
7
+ private readonly fork: MerkleTreeCheckpointOperations,
8
+ public readonly depth: number,
9
+ ) {}
7
10
 
8
11
  static async new(fork: MerkleTreeCheckpointOperations): Promise<ForkCheckpoint> {
9
- await fork.createCheckpoint();
10
- return new ForkCheckpoint(fork);
12
+ const depth = await fork.createCheckpoint();
13
+ return new ForkCheckpoint(fork, depth);
11
14
  }
12
15
 
13
16
  async commit(): Promise<void> {
@@ -27,4 +30,17 @@ export class ForkCheckpoint {
27
30
  await this.fork.revertCheckpoint();
28
31
  this.completed = true;
29
32
  }
33
+
34
+ /**
35
+ * Reverts this checkpoint and any nested checkpoints created on top of it,
36
+ * leaving the checkpoint depth at the level it was before this checkpoint was created.
37
+ */
38
+ async revertToCheckpoint(): Promise<void> {
39
+ if (this.completed) {
40
+ return;
41
+ }
42
+
43
+ await this.fork.revertAllCheckpointsTo(this.depth - 1);
44
+ this.completed = true;
45
+ }
30
46
  }