@aztec/world-state 0.0.1-commit.3469e52 → 0.0.1-commit.350e0a4d

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 (68) hide show
  1. package/dest/instrumentation/instrumentation.d.ts +4 -3
  2. package/dest/instrumentation/instrumentation.d.ts.map +1 -1
  3. package/dest/instrumentation/instrumentation.js +13 -11
  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 +89 -0
  8. package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
  9. package/dest/native/ipc_world_state_instance.js +662 -0
  10. package/dest/native/merkle_trees_facade.d.ts +12 -8
  11. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  12. package/dest/native/merkle_trees_facade.js +63 -115
  13. package/dest/native/message.d.ts +14 -221
  14. package/dest/native/message.d.ts.map +1 -1
  15. package/dest/native/message.js +0 -42
  16. package/dest/native/native_world_state.d.ts +22 -10
  17. package/dest/native/native_world_state.d.ts.map +1 -1
  18. package/dest/native/native_world_state.js +118 -59
  19. package/dest/native/native_world_state_instance.d.ts +60 -41
  20. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  21. package/dest/native/native_world_state_instance.js +5 -202
  22. package/dest/native/world_state_operation.d.ts +7 -0
  23. package/dest/native/world_state_operation.d.ts.map +1 -0
  24. package/dest/native/world_state_operation.js +5 -0
  25. package/dest/synchronizer/config.d.ts +3 -5
  26. package/dest/synchronizer/config.d.ts.map +1 -1
  27. package/dest/synchronizer/config.js +15 -18
  28. package/dest/synchronizer/errors.d.ts +8 -1
  29. package/dest/synchronizer/errors.d.ts.map +1 -1
  30. package/dest/synchronizer/errors.js +8 -1
  31. package/dest/synchronizer/factory.d.ts +6 -5
  32. package/dest/synchronizer/factory.d.ts.map +1 -1
  33. package/dest/synchronizer/factory.js +7 -6
  34. package/dest/synchronizer/index.d.ts +2 -1
  35. package/dest/synchronizer/index.d.ts.map +1 -1
  36. package/dest/synchronizer/index.js +1 -0
  37. package/dest/synchronizer/server_world_state_synchronizer.d.ts +13 -8
  38. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  39. package/dest/synchronizer/server_world_state_synchronizer.js +134 -49
  40. package/dest/test/utils.d.ts +6 -6
  41. package/dest/test/utils.d.ts.map +1 -1
  42. package/dest/test/utils.js +9 -4
  43. package/dest/testing.d.ts +4 -3
  44. package/dest/testing.d.ts.map +1 -1
  45. package/dest/testing.js +14 -7
  46. package/dest/world-state-db/merkle_tree_db.d.ts +3 -12
  47. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  48. package/package.json +14 -11
  49. package/src/instrumentation/instrumentation.ts +15 -19
  50. package/src/native/fork_checkpoint.ts +19 -3
  51. package/src/native/ipc_world_state_instance.ts +834 -0
  52. package/src/native/merkle_trees_facade.ts +89 -109
  53. package/src/native/message.ts +13 -286
  54. package/src/native/native_world_state.ts +140 -93
  55. package/src/native/native_world_state_instance.ts +98 -278
  56. package/src/native/world_state_operation.ts +33 -0
  57. package/src/synchronizer/config.ts +16 -23
  58. package/src/synchronizer/errors.ts +8 -0
  59. package/src/synchronizer/factory.ts +18 -11
  60. package/src/synchronizer/index.ts +1 -0
  61. package/src/synchronizer/server_world_state_synchronizer.ts +156 -51
  62. package/src/test/utils.ts +14 -5
  63. package/src/testing.ts +12 -10
  64. package/src/world-state-db/merkle_tree_db.ts +2 -12
  65. package/dest/native/world_state_ops_queue.d.ts +0 -19
  66. package/dest/native/world_state_ops_queue.d.ts.map +0 -1
  67. package/dest/native/world_state_ops_queue.js +0 -146
  68. package/src/native/world_state_ops_queue.ts +0 -190
@@ -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
  }