@aztec/world-state 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97

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/dest/index.d.ts +1 -1
  2. package/dest/instrumentation/instrumentation.d.ts +4 -3
  3. package/dest/instrumentation/instrumentation.d.ts.map +1 -1
  4. package/dest/instrumentation/instrumentation.js +21 -50
  5. package/dest/native/bench_metrics.d.ts +1 -1
  6. package/dest/native/bench_metrics.d.ts.map +1 -1
  7. package/dest/native/fork_checkpoint.d.ts +7 -1
  8. package/dest/native/fork_checkpoint.d.ts.map +1 -1
  9. package/dest/native/fork_checkpoint.js +15 -3
  10. package/dest/native/index.d.ts +1 -1
  11. package/dest/native/ipc_world_state_instance.d.ts +87 -0
  12. package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
  13. package/dest/native/ipc_world_state_instance.js +660 -0
  14. package/dest/native/merkle_trees_facade.d.ts +18 -8
  15. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  16. package/dest/native/merkle_trees_facade.js +90 -111
  17. package/dest/native/message.d.ts +22 -228
  18. package/dest/native/message.d.ts.map +1 -1
  19. package/dest/native/message.js +14 -55
  20. package/dest/native/native_world_state.d.ts +30 -15
  21. package/dest/native/native_world_state.d.ts.map +1 -1
  22. package/dest/native/native_world_state.js +126 -66
  23. package/dest/native/native_world_state_instance.d.ts +58 -32
  24. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  25. package/dest/native/native_world_state_instance.js +5 -181
  26. package/dest/native/world_state_operation.d.ts +7 -0
  27. package/dest/native/world_state_operation.d.ts.map +1 -0
  28. package/dest/native/world_state_operation.js +5 -0
  29. package/dest/synchronizer/config.d.ts +3 -5
  30. package/dest/synchronizer/config.d.ts.map +1 -1
  31. package/dest/synchronizer/config.js +15 -18
  32. package/dest/synchronizer/errors.d.ts +1 -1
  33. package/dest/synchronizer/errors.d.ts.map +1 -1
  34. package/dest/synchronizer/factory.d.ts +6 -5
  35. package/dest/synchronizer/factory.d.ts.map +1 -1
  36. package/dest/synchronizer/factory.js +7 -6
  37. package/dest/synchronizer/index.d.ts +1 -1
  38. package/dest/synchronizer/server_world_state_synchronizer.d.ts +11 -28
  39. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  40. package/dest/synchronizer/server_world_state_synchronizer.js +165 -81
  41. package/dest/test/index.d.ts +1 -1
  42. package/dest/test/utils.d.ts +12 -5
  43. package/dest/test/utils.d.ts.map +1 -1
  44. package/dest/test/utils.js +54 -50
  45. package/dest/testing.d.ts +5 -4
  46. package/dest/testing.d.ts.map +1 -1
  47. package/dest/testing.js +11 -7
  48. package/dest/world-state-db/index.d.ts +1 -1
  49. package/dest/world-state-db/merkle_tree_db.d.ts +9 -19
  50. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  51. package/package.json +17 -13
  52. package/src/instrumentation/instrumentation.ts +23 -59
  53. package/src/native/fork_checkpoint.ts +19 -3
  54. package/src/native/ipc_world_state_instance.ts +830 -0
  55. package/src/native/merkle_trees_facade.ts +118 -104
  56. package/src/native/message.ts +33 -305
  57. package/src/native/native_world_state.ts +164 -108
  58. package/src/native/native_world_state_instance.ts +96 -250
  59. package/src/native/world_state_operation.ts +33 -0
  60. package/src/synchronizer/config.ts +16 -23
  61. package/src/synchronizer/factory.ts +18 -11
  62. package/src/synchronizer/server_world_state_synchronizer.ts +181 -106
  63. package/src/test/utils.ts +87 -92
  64. package/src/testing.ts +9 -10
  65. package/src/world-state-db/merkle_tree_db.ts +12 -19
  66. package/dest/native/world_state_ops_queue.d.ts +0 -19
  67. package/dest/native/world_state_ops_queue.d.ts.map +0 -1
  68. package/dest/native/world_state_ops_queue.js +0 -146
  69. package/src/native/world_state_ops_queue.ts +0 -190
package/dest/testing.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
4
4
  import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
5
5
  import { NativeWorldStateService } from './native/index.js';
6
- async function generateGenesisValues(prefilledPublicData) {
7
- if (!prefilledPublicData.length) {
6
+ async function generateGenesisValues(genesis) {
7
+ if (!genesis.prefilledPublicData.length && genesis.genesisTimestamp === 0n) {
8
8
  return {
9
9
  genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
10
10
  };
11
11
  }
12
12
  // Create a temporary world state to compute the genesis values.
13
- const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */ , true, prefilledPublicData);
13
+ const ws = await NativeWorldStateService.tmp(/*cleanupTmpDir=*/ true, genesis);
14
14
  const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
15
15
  await ws.close();
16
16
  return {
@@ -18,16 +18,20 @@ async function generateGenesisValues(prefilledPublicData) {
18
18
  };
19
19
  }
20
20
  export const defaultInitialAccountFeeJuice = new Fr(10n ** 22n);
21
- export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = []) {
21
+ export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = [], genesisTimestamp = 0n) {
22
22
  // Top up the accounts with fee juice.
23
23
  let prefilledPublicData = await Promise.all(initialAccounts.map(async (address)=>new PublicDataTreeLeaf(await computeFeePayerBalanceLeafSlot(address), initialAccountFeeJuice)));
24
24
  // Add user-defined public data
25
25
  prefilledPublicData = prefilledPublicData.concat(genesisPublicData);
26
26
  prefilledPublicData.sort((a, b)=>b.slot.lt(a.slot) ? 1 : -1);
27
- const { genesisArchiveRoot } = await generateGenesisValues(prefilledPublicData);
27
+ const genesis = {
28
+ prefilledPublicData,
29
+ genesisTimestamp
30
+ };
31
+ const { genesisArchiveRoot } = await generateGenesisValues(genesis);
28
32
  return {
29
33
  genesisArchiveRoot,
30
- prefilledPublicData,
34
+ genesis,
31
35
  fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt()
32
36
  };
33
37
  }
@@ -1,3 +1,3 @@
1
1
  export * from './merkle_tree_db.js';
2
2
  export type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93b3JsZC1zdGF0ZS1kYi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHFCQUFxQixDQUFDO0FBRXBDLFlBQVksRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDIn0=
@@ -1,8 +1,7 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import type { IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { L2Block } from '@aztec/stdlib/block';
4
- import type { ForkMerkleTreeOperations, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
5
- import type { MerkleTreeId } from '@aztec/stdlib/trees';
4
+ import type { ForkMerkleTreeOperations, MerkleTreeReadOperations, ReadonlyWorldStateAccess } from '@aztec/stdlib/interfaces/server';
6
5
  import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
7
6
  /**
8
7
  *
@@ -21,22 +20,13 @@ import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/me
21
20
  */
22
21
  export declare const INITIAL_NULLIFIER_TREE_SIZE: number;
23
22
  export declare const INITIAL_PUBLIC_DATA_TREE_SIZE: number;
24
- export type TreeSnapshots = {
25
- [MerkleTreeId.NULLIFIER_TREE]: IndexedTreeSnapshot;
26
- [MerkleTreeId.NOTE_HASH_TREE]: TreeSnapshot<Fr>;
27
- [MerkleTreeId.PUBLIC_DATA_TREE]: IndexedTreeSnapshot;
28
- [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: TreeSnapshot<Fr>;
29
- [MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
30
- };
31
- export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
23
+ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, ReadonlyWorldStateAccess {
32
24
  /**
33
25
  * Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
34
26
  * @param block - The L2 block to handle.
35
27
  * @param l1ToL2Messages - The L1 to L2 messages for the block.
36
- * @param isFirstBlock - Whether the block is the first block in a checkpoint. Temporary hack to only insert l1 to l2
37
- * messages for the first block in a checkpoint. TODO(#17027) Remove this.
38
28
  */
39
- handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[], isFirstBlock?: boolean): Promise<WorldStateStatusFull>;
29
+ handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
40
30
  /**
41
31
  * Gets a handle that allows reading the latest committed state
42
32
  */
@@ -46,19 +36,19 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
46
36
  * @param toBlockNumber The block number of the new oldest historical block
47
37
  * @returns The new WorldStateStatus
48
38
  */
49
- removeHistoricalBlocks(toBlockNumber: bigint): Promise<WorldStateStatusFull>;
39
+ removeHistoricalBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
50
40
  /**
51
41
  * Removes all pending blocks down to but not including the given block number
52
42
  * @param toBlockNumber The block number of the new tip of the pending chain,
53
43
  * @returns The new WorldStateStatus
54
44
  */
55
- unwindBlocks(toBlockNumber: bigint): Promise<WorldStateStatusFull>;
45
+ unwindBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
56
46
  /**
57
47
  * Advances the finalized block number to be the number provided
58
48
  * @param toBlockNumber The block number that is now the tip of the finalized chain
59
49
  * @returns The new WorldStateStatus
60
50
  */
61
- setFinalized(toBlockNumber: bigint): Promise<WorldStateStatusSummary>;
51
+ setFinalized(toBlockNumber: BlockNumber): Promise<WorldStateStatusSummary>;
62
52
  /**
63
53
  * Gets the current status summary of the database.
64
54
  * @returns The current WorldStateStatus.
@@ -69,4 +59,4 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
69
59
  /** Deletes the db. */
70
60
  clear(): Promise<void>;
71
61
  }
72
- //# sourceMappingURL=merkle_tree_db.d.ts.map
62
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVya2xlX3RyZWVfZGIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93b3JsZC1zdGF0ZS1kYi9tZXJrbGVfdHJlZV9kYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssRUFDVix3QkFBd0IsRUFDeEIsd0JBQXdCLEVBQ3hCLHdCQUF3QixFQUN6QixNQUFNLGlDQUFpQyxDQUFDO0FBRXpDLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLHVCQUF1QixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFMUY7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFDSCxlQUFPLE1BQU0sMkJBQTJCLFFBQTRCLENBQUM7QUFFckUsZUFBTyxNQUFN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;IACH,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAErD,yBAAyB;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,sBAAsB;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/world-state",
3
- "version": "0.0.1-commit.b655e406",
3
+ "version": "0.0.1-commit.b9865e97",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -18,8 +18,8 @@
18
18
  "tsconfig": "./tsconfig.json"
19
19
  },
20
20
  "scripts": {
21
- "build": "yarn clean && tsc -b",
22
- "build:dev": "tsc -b --watch",
21
+ "build": "yarn clean && ../scripts/tsc.sh",
22
+ "build:dev": "../scripts/tsc.sh --watch",
23
23
  "clean": "rm -rf ./dest .tsbuildinfo",
24
24
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
25
25
  },
@@ -64,22 +64,26 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/constants": "0.0.1-commit.b655e406",
68
- "@aztec/foundation": "0.0.1-commit.b655e406",
69
- "@aztec/kv-store": "0.0.1-commit.b655e406",
70
- "@aztec/merkle-tree": "0.0.1-commit.b655e406",
71
- "@aztec/native": "0.0.1-commit.b655e406",
72
- "@aztec/protocol-contracts": "0.0.1-commit.b655e406",
73
- "@aztec/stdlib": "0.0.1-commit.b655e406",
74
- "@aztec/telemetry-client": "0.0.1-commit.b655e406",
67
+ "@aztec/bb.js": "0.0.1-commit.b9865e97",
68
+ "@aztec/constants": "0.0.1-commit.b9865e97",
69
+ "@aztec/foundation": "0.0.1-commit.b9865e97",
70
+ "@aztec/kv-store": "0.0.1-commit.b9865e97",
71
+ "@aztec/native": "0.0.1-commit.b9865e97",
72
+ "@aztec/protocol-contracts": "0.0.1-commit.b9865e97",
73
+ "@aztec/stdlib": "0.0.1-commit.b9865e97",
74
+ "@aztec/telemetry-client": "0.0.1-commit.b9865e97",
75
+ "@aztec/wsdb": "0.0.1-commit.b9865e97",
76
+ "msgpackr": "^1.11.2",
75
77
  "tslib": "^2.4.0",
76
- "zod": "^3.23.8"
78
+ "zod": "^4"
77
79
  },
78
80
  "devDependencies": {
79
- "@aztec/archiver": "0.0.1-commit.b655e406",
81
+ "@aztec/archiver": "0.0.1-commit.b9865e97",
82
+ "@aztec/ipc-runtime": "0.0.1-commit.b9865e97",
80
83
  "@jest/globals": "^30.0.0",
81
84
  "@types/jest": "^30.0.0",
82
85
  "@types/node": "^22.15.17",
86
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
83
87
  "jest": "^30.0.0",
84
88
  "jest-mock-extended": "^4.0.0",
85
89
  "ts-node": "^10.9.1",
@@ -7,27 +7,15 @@ 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
- import {
14
- type DBStats,
15
- type TreeDBStats,
16
- type TreeMeta,
17
- WorldStateMessageType,
18
- type WorldStateStatusFull,
19
- } from '../native/message.js';
13
+ import type { DBStats, TreeDBStats, TreeMeta, WorldStateStatusFull } from '../native/message.js';
14
+ import type { WorldStateOperationName } from '../native/world_state_operation.js';
20
15
 
21
16
  type DBTypeString = 'leaf_preimage' | 'leaf_indices' | 'nodes' | 'blocks' | 'block_indices';
22
17
 
23
- const durationTrackDenylist = new Set<WorldStateMessageType>([
24
- WorldStateMessageType.GET_INITIAL_STATE_REFERENCE,
25
- WorldStateMessageType.CLOSE,
26
-
27
- // these aren't used anymore, should be removed from the API
28
- WorldStateMessageType.COMMIT,
29
- WorldStateMessageType.ROLLBACK,
30
- ]);
18
+ const durationTrackDenylist = new Set<WorldStateOperationName>(['getInitialStateReference']);
31
19
 
32
20
  export class WorldStateInstrumentation {
33
21
  private dbMapSize: Gauge;
@@ -46,55 +34,31 @@ export class WorldStateInstrumentation {
46
34
  private log: Logger = createLogger('world-state:instrumentation'),
47
35
  ) {
48
36
  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
- });
37
+ this.dbMapSize = meter.createGauge(Metrics.WORLD_STATE_DB_MAP_SIZE);
53
38
 
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
- });
39
+ this.dbPhysicalSize = meter.createGauge(Metrics.WORLD_STATE_DB_PHYSICAL_SIZE);
58
40
 
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
- });
41
+ this.treeSize = meter.createGauge(Metrics.WORLD_STATE_TREE_SIZE);
63
42
 
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
- });
43
+ this.unfinalizedHeight = meter.createGauge(Metrics.WORLD_STATE_UNFINALIZED_HEIGHT);
68
44
 
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
- });
45
+ this.finalizedHeight = meter.createGauge(Metrics.WORLD_STATE_FINALIZED_HEIGHT);
73
46
 
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
- });
47
+ this.oldestBlock = meter.createGauge(Metrics.WORLD_STATE_OLDEST_BLOCK);
78
48
 
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
- });
49
+ this.dbUsedSize = meter.createGauge(Metrics.WORLD_STATE_DB_USED_SIZE);
83
50
 
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
- });
51
+ this.dbNumItems = meter.createGauge(Metrics.WORLD_STATE_DB_NUM_ITEMS);
88
52
 
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
- });
53
+ this.requestHistogram = meter.createHistogram(Metrics.WORLD_STATE_REQUEST_TIME);
94
54
 
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,
55
+ this.criticalErrors = createUpDownCounterWithDefault(meter, Metrics.WORLD_STATE_CRITICAL_ERROR_COUNT, {
56
+ [Attributes.ERROR_TYPE]: [
57
+ 'synch_pending_block',
58
+ 'finalize_block',
59
+ 'prune_pending_block',
60
+ 'prune_historical_block',
61
+ ],
98
62
  });
99
63
  }
100
64
 
@@ -168,10 +132,10 @@ export class WorldStateInstrumentation {
168
132
  );
169
133
  }
170
134
 
171
- public recordRoundTrip(timeUs: number, request: WorldStateMessageType) {
172
- if (!durationTrackDenylist.has(request)) {
135
+ public recordRoundTrip(timeUs: number, operation: WorldStateOperationName) {
136
+ if (!durationTrackDenylist.has(operation)) {
173
137
  this.requestHistogram.record(Math.ceil(timeUs), {
174
- [Attributes.WORLD_STATE_REQUEST_TYPE]: WorldStateMessageType[request],
138
+ [Attributes.WORLD_STATE_REQUEST_TYPE]: operation,
175
139
  });
176
140
  }
177
141
  }
@@ -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
  }