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

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 (80) hide show
  1. package/dest/index.d.ts +2 -1
  2. package/dest/index.d.ts.map +1 -1
  3. package/dest/index.js +1 -0
  4. package/dest/instrumentation/instrumentation.d.ts +4 -3
  5. package/dest/instrumentation/instrumentation.d.ts.map +1 -1
  6. package/dest/instrumentation/instrumentation.js +21 -50
  7. package/dest/native/bench_metrics.d.ts +1 -1
  8. package/dest/native/bench_metrics.d.ts.map +1 -1
  9. package/dest/native/fork_checkpoint.d.ts +7 -1
  10. package/dest/native/fork_checkpoint.d.ts.map +1 -1
  11. package/dest/native/fork_checkpoint.js +15 -3
  12. package/dest/native/index.d.ts +2 -1
  13. package/dest/native/index.d.ts.map +1 -1
  14. package/dest/native/index.js +1 -0
  15. package/dest/native/ipc_world_state_instance.d.ts +89 -0
  16. package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
  17. package/dest/native/ipc_world_state_instance.js +661 -0
  18. package/dest/native/merkle_trees_facade.d.ts +18 -8
  19. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  20. package/dest/native/merkle_trees_facade.js +90 -111
  21. package/dest/native/message.d.ts +22 -228
  22. package/dest/native/message.d.ts.map +1 -1
  23. package/dest/native/message.js +14 -55
  24. package/dest/native/native_world_state.d.ts +30 -15
  25. package/dest/native/native_world_state.d.ts.map +1 -1
  26. package/dest/native/native_world_state.js +133 -66
  27. package/dest/native/native_world_state_instance.d.ts +56 -33
  28. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  29. package/dest/native/native_world_state_instance.js +1 -182
  30. package/dest/native/world_state_operation.d.ts +7 -0
  31. package/dest/native/world_state_operation.d.ts.map +1 -0
  32. package/dest/native/world_state_operation.js +5 -0
  33. package/dest/synchronizer/config.d.ts +3 -5
  34. package/dest/synchronizer/config.d.ts.map +1 -1
  35. package/dest/synchronizer/config.js +15 -18
  36. package/dest/synchronizer/errors.d.ts +8 -1
  37. package/dest/synchronizer/errors.d.ts.map +1 -1
  38. package/dest/synchronizer/errors.js +8 -1
  39. package/dest/synchronizer/factory.d.ts +6 -5
  40. package/dest/synchronizer/factory.d.ts.map +1 -1
  41. package/dest/synchronizer/factory.js +7 -6
  42. package/dest/synchronizer/index.d.ts +2 -1
  43. package/dest/synchronizer/index.d.ts.map +1 -1
  44. package/dest/synchronizer/index.js +1 -0
  45. package/dest/synchronizer/server_world_state_synchronizer.d.ts +20 -32
  46. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  47. package/dest/synchronizer/server_world_state_synchronizer.js +181 -85
  48. package/dest/test/index.d.ts +1 -1
  49. package/dest/test/utils.d.ts +12 -5
  50. package/dest/test/utils.d.ts.map +1 -1
  51. package/dest/test/utils.js +59 -50
  52. package/dest/testing.d.ts +5 -4
  53. package/dest/testing.d.ts.map +1 -1
  54. package/dest/testing.js +15 -8
  55. package/dest/world-state-db/index.d.ts +1 -1
  56. package/dest/world-state-db/merkle_tree_db.d.ts +9 -19
  57. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  58. package/package.json +16 -13
  59. package/src/index.ts +1 -0
  60. package/src/instrumentation/instrumentation.ts +23 -59
  61. package/src/native/fork_checkpoint.ts +19 -3
  62. package/src/native/index.ts +1 -0
  63. package/src/native/ipc_world_state_instance.ts +834 -0
  64. package/src/native/merkle_trees_facade.ts +118 -104
  65. package/src/native/message.ts +33 -305
  66. package/src/native/native_world_state.ts +179 -108
  67. package/src/native/native_world_state_instance.ts +94 -251
  68. package/src/native/world_state_operation.ts +33 -0
  69. package/src/synchronizer/config.ts +16 -23
  70. package/src/synchronizer/errors.ts +8 -0
  71. package/src/synchronizer/factory.ts +18 -11
  72. package/src/synchronizer/index.ts +1 -0
  73. package/src/synchronizer/server_world_state_synchronizer.ts +219 -111
  74. package/src/test/utils.ts +96 -92
  75. package/src/testing.ts +13 -11
  76. package/src/world-state-db/merkle_tree_db.ts +12 -19
  77. package/dest/native/world_state_ops_queue.d.ts +0 -19
  78. package/dest/native/world_state_ops_queue.d.ts.map +0 -1
  79. package/dest/native/world_state_ops_queue.js +0 -146
  80. package/src/native/world_state_ops_queue.ts +0 -190
@@ -1,53 +1,72 @@
1
+ var _computedKey;
1
2
  import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
3
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
4
  import { fromEntries, padArrayEnd } from '@aztec/foundation/collection';
3
- import { EthAddress } from '@aztec/foundation/eth-address';
4
- import { Fr } from '@aztec/foundation/fields';
5
- import { tryRmDir } from '@aztec/foundation/fs';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import { createLogger } from '@aztec/foundation/log';
7
- import { DatabaseVersionManager } from '@aztec/stdlib/database-version';
7
+ import { DatabaseVersionManager } from '@aztec/stdlib/database-version/manager';
8
8
  import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
9
- import { BlockHeader, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
10
- import { WorldStateRevision } from '@aztec/stdlib/world-state';
9
+ import { BlockHeader, GlobalVariables, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
10
+ import { EMPTY_GENESIS_DATA, WorldStateRevision } from '@aztec/stdlib/world-state';
11
11
  import { getTelemetryClient } from '@aztec/telemetry-client';
12
12
  import assert from 'assert/strict';
13
- import { mkdtemp, rm } from 'fs/promises';
13
+ import { mkdir, mkdtemp, rm } from 'fs/promises';
14
14
  import { tmpdir } from 'os';
15
15
  import { join } from 'path';
16
16
  import { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
17
+ import { IpcWorldState } from './ipc_world_state_instance.js';
17
18
  import { MerkleTreesFacade, MerkleTreesForkFacade, serializeLeaf } from './merkle_trees_facade.js';
18
- import { WorldStateMessageType, blockStateReference, sanitizeFullStatus, sanitizeSummary, treeStateReferenceToSnapshot } from './message.js';
19
- import { NativeWorldState } from './native_world_state_instance.js';
19
+ import { blockStateReference, sanitizeFullStatus, sanitizeSummary, treeStateReferenceToSnapshot } from './message.js';
20
20
  // The current version of the world state database schema
21
21
  // Increment this when making incompatible changes to the database schema
22
22
  export const WORLD_STATE_DB_VERSION = 2; // The initial version
23
23
  export const WORLD_STATE_DIR = 'world_state';
24
+ _computedKey = Symbol.asyncDispose;
24
25
  export class NativeWorldStateService {
25
26
  instance;
26
27
  worldStateInstrumentation;
27
28
  log;
29
+ genesis;
28
30
  cleanup;
31
+ recreateInstance;
29
32
  initialHeader;
30
33
  // This is read heavily and only changes when data is persisted, so we cache it
31
34
  cachedStatusSummary;
32
- constructor(instance, worldStateInstrumentation, log = createLogger('world-state:database'), cleanup = ()=>Promise.resolve()){
35
+ constructor(instance, worldStateInstrumentation, log, genesis = EMPTY_GENESIS_DATA, cleanup = ()=>Promise.resolve(), /** Factory to recreate a fresh IpcWorldState after clear(). */ recreateInstance){
33
36
  this.instance = instance;
34
37
  this.worldStateInstrumentation = worldStateInstrumentation;
35
38
  this.log = log;
39
+ this.genesis = genesis;
36
40
  this.cleanup = cleanup;
41
+ this.recreateInstance = recreateInstance;
37
42
  }
38
- static async new(rollupAddress, dataDir, wsTreeMapSizes, prefilledPublicData = [], instrumentation = new WorldStateInstrumentation(getTelemetryClient()), log = createLogger('world-state:database'), cleanup = ()=>Promise.resolve()) {
43
+ static async new(rollupAddress, dataDir, wsTreeMapSizes, genesis = EMPTY_GENESIS_DATA, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings, cleanup = ()=>Promise.resolve()) {
44
+ for (const [key, value] of Object.entries(wsTreeMapSizes)){
45
+ if (value <= 0) {
46
+ throw new Error(`Map size must be a positive number, got ${value} for ${key}`);
47
+ }
48
+ }
49
+ const log = createLogger('world-state:database', bindings);
39
50
  const worldStateDirectory = join(dataDir, WORLD_STATE_DIR);
40
- // Create a version manager to handle versioning
41
51
  const versionManager = new DatabaseVersionManager({
42
52
  schemaVersion: WORLD_STATE_DB_VERSION,
43
53
  rollupAddress,
44
54
  dataDirectory: worldStateDirectory,
45
- onOpen: (dir)=>{
46
- return Promise.resolve(new NativeWorldState(dir, wsTreeMapSizes, prefilledPublicData, instrumentation));
47
- }
55
+ onOpen: (dir)=>IpcWorldState.spawn(dir, wsTreeMapSizes, genesis, instrumentation, bindings)
48
56
  });
49
57
  const [instance] = await versionManager.open();
50
- const worldState = new this(instance, instrumentation, log, cleanup);
58
+ const recreateInstance = async ()=>{
59
+ await rm(worldStateDirectory, {
60
+ recursive: true,
61
+ force: true,
62
+ maxRetries: 3
63
+ });
64
+ await mkdir(worldStateDirectory, {
65
+ recursive: true
66
+ });
67
+ return IpcWorldState.spawn(worldStateDirectory, wsTreeMapSizes, genesis, instrumentation, bindings);
68
+ };
69
+ const worldState = new this(instance, instrumentation, log, genesis, cleanup, recreateInstance);
51
70
  try {
52
71
  await worldState.init();
53
72
  } catch (e) {
@@ -56,10 +75,14 @@ export class NativeWorldStateService {
56
75
  }
57
76
  return worldState;
58
77
  }
59
- static async tmp(rollupAddress = EthAddress.ZERO, cleanupTmpDir = true, prefilledPublicData = [], instrumentation = new WorldStateInstrumentation(getTelemetryClient())) {
60
- const log = createLogger('world-state:database');
78
+ static async tmp(cleanupTmpDir = true, genesis = EMPTY_GENESIS_DATA, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings, threads) {
79
+ const log = createLogger('world-state:database', bindings);
61
80
  const dataDir = await mkdtemp(join(tmpdir(), 'aztec-world-state-'));
62
- const dbMapSizeKb = 10 * 1024 * 1024;
81
+ // Temporary (test/dev) world states are small and short-lived. Keep the LMDB
82
+ // map sizes in the MB range: with the IPC backend each tmp() spawns a separate
83
+ // aztec-wsdb that maps these per tree, and oversized maps add real cold-start
84
+ // I/O under parallel CI load. 256 MB/tree is ample for tests.
85
+ const dbMapSizeKb = 256 * 1024;
63
86
  const worldStateTreeMapSizes = {
64
87
  archiveTreeMapSizeKb: dbMapSizeKb,
65
88
  nullifierTreeMapSizeKb: dbMapSizeKb,
@@ -68,7 +91,7 @@ export class NativeWorldStateService {
68
91
  publicDataTreeMapSizeKb: dbMapSizeKb
69
92
  };
70
93
  log.debug(`Created temporary world state database at: ${dataDir} with tree map size: ${dbMapSizeKb}`);
71
- // pass a cleanup callback because process.on('beforeExit', cleanup) does not work under Jest
94
+ const instance = await IpcWorldState.spawn(dataDir, worldStateTreeMapSizes, genesis, instrumentation, bindings, threads);
72
95
  const cleanup = async ()=>{
73
96
  if (cleanupTmpDir) {
74
97
  await rm(dataDir, {
@@ -81,7 +104,39 @@ export class NativeWorldStateService {
81
104
  log.debug(`Leaving temporary world state database: ${dataDir}`);
82
105
  }
83
106
  };
84
- return this.new(rollupAddress, dataDir, worldStateTreeMapSizes, prefilledPublicData, instrumentation, log, cleanup);
107
+ const recreateInstance = async ()=>{
108
+ await rm(dataDir, {
109
+ recursive: true,
110
+ force: true,
111
+ maxRetries: 3
112
+ });
113
+ await mkdir(dataDir, {
114
+ recursive: true
115
+ });
116
+ return IpcWorldState.spawn(dataDir, worldStateTreeMapSizes, genesis, instrumentation, bindings, threads);
117
+ };
118
+ const worldState = new this(instance, instrumentation, log, genesis, cleanup, recreateInstance);
119
+ try {
120
+ await worldState.init();
121
+ } catch (e) {
122
+ log.error(`Error initializing tmp world state: ${e}`);
123
+ throw e;
124
+ }
125
+ return worldState;
126
+ }
127
+ static ephemeral(genesis = EMPTY_GENESIS_DATA, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings) {
128
+ // The TXE spins up one tiny, short-lived world state per test, many concurrently. Cap the wsdb thread
129
+ // usage to the minimum: a single tree-op thread instead of one per core (the C++ IPC dispatcher pool
130
+ // still floors at 2). This avoids ~32 threads per wsdb multiplied across dozens of concurrent test
131
+ // world states — the trees are cache-sized (see tmp's map-size note), so extra threads buy nothing.
132
+ return this.tmp(/*cleanupTmpDir=*/ true, genesis, instrumentation, bindings, /*threads=*/ 1);
133
+ }
134
+ static async fromIpc(wsdbBackend, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings, genesis = EMPTY_GENESIS_DATA, cleanup = ()=>Promise.resolve(), recreateInstance) {
135
+ const log = createLogger('world-state:database', bindings);
136
+ const instance = new IpcWorldState(wsdbBackend, instrumentation, bindings);
137
+ const worldState = new this(instance, instrumentation, log, genesis, cleanup, recreateInstance);
138
+ await worldState.init();
139
+ return worldState;
85
140
  }
86
141
  async init() {
87
142
  const status = await this.getStatusSummary();
@@ -104,10 +159,21 @@ export class NativeWorldStateService {
104
159
  assert.strictEqual(initialHeaderIndex, 0n, 'Invalid initial archive state');
105
160
  }
106
161
  async clear() {
162
+ if (!this.recreateInstance) {
163
+ throw new Error('clear() is not available for externally-managed IPC backends');
164
+ }
165
+ this.log.warn('Clearing world state: shutting down WSDB, deleting data, and recreating');
107
166
  await this.instance.close();
108
167
  this.cachedStatusSummary = undefined;
109
- await tryRmDir(this.instance.getDataDir(), this.log);
110
- this.instance = this.instance.clone();
168
+ this.instance = await this.recreateInstance();
169
+ await this.init();
170
+ this.log.info('World state cleared and reinitialized from genesis');
171
+ }
172
+ /** Returns the IPC path of the underlying IPC backend, if available. */ getIpcPath() {
173
+ if (this.instance instanceof IpcWorldState) {
174
+ return this.instance.getIpcPath();
175
+ }
176
+ throw new Error('getIpcPath() is only available with IPC world state');
111
177
  }
112
178
  getCommitted() {
113
179
  return new MerkleTreesFacade(this.instance, this.initialHeader, WorldStateRevision.empty());
@@ -115,23 +181,25 @@ export class NativeWorldStateService {
115
181
  getSnapshot(blockNumber) {
116
182
  return new MerkleTreesFacade(this.instance, this.initialHeader, new WorldStateRevision(/*forkId=*/ 0, /* blockNumber=*/ blockNumber, /* includeUncommitted=*/ false));
117
183
  }
118
- async fork(blockNumber) {
119
- const resp = await this.instance.call(WorldStateMessageType.CREATE_FORK, {
184
+ async fork(blockNumber, opts = {}) {
185
+ const forkId = await this.instance.createFork({
120
186
  latest: blockNumber === undefined,
121
- blockNumber: blockNumber ?? 0,
122
- canonical: true
187
+ blockNumber: blockNumber ?? BlockNumber.ZERO
123
188
  });
124
- return new MerkleTreesForkFacade(this.instance, this.initialHeader, new WorldStateRevision(/*forkId=*/ resp.forkId, /* blockNumber=*/ 0, /* includeUncommitted=*/ true));
189
+ return new MerkleTreesForkFacade(this.instance, this.initialHeader, new WorldStateRevision(/*forkId=*/ forkId, /* blockNumber=*/ WorldStateRevision.LATEST, /* includeUncommitted=*/ true), opts);
125
190
  }
126
191
  getInitialHeader() {
127
192
  return this.initialHeader;
128
193
  }
129
- async handleL2BlockAndMessages(l2Block, l1ToL2Messages, // TODO(#17027)
130
- // Temporary hack to only insert l1 to l2 messages for the first block in a checkpoint.
131
- isFirstBlock = true) {
132
- // We have to pad both the values within tx effects because that's how the trees are built by circuits.
133
- const paddedNoteHashes = l2Block.body.txEffects.flatMap((txEffect)=>padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
194
+ async handleL2BlockAndMessages(l2Block, l1ToL2Messages) {
195
+ const isFirstBlock = l2Block.indexWithinCheckpoint === 0;
196
+ if (!isFirstBlock && l1ToL2Messages.length > 0) {
197
+ throw new Error(`L1 to L2 messages must be empty for non-first blocks, but got ${l1ToL2Messages.length} messages for block ${l2Block.number}.`);
198
+ }
199
+ // We have to pad the given l1 to l2 messages, and the note hashes and nullifiers within tx effects, because that's
200
+ // how the trees are built by circuits.
134
201
  const paddedL1ToL2Messages = isFirstBlock ? padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) : [];
202
+ const paddedNoteHashes = l2Block.body.txEffects.flatMap((txEffect)=>padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
135
203
  const paddedNullifiers = l2Block.body.txEffects.flatMap((txEffect)=>padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX)).map((nullifier)=>new NullifierLeaf(nullifier));
136
204
  const publicDataWrites = l2Block.body.txEffects.flatMap((txEffect)=>{
137
205
  return txEffect.publicDataWrites.map((write)=>{
@@ -142,29 +210,42 @@ export class NativeWorldStateService {
142
210
  });
143
211
  });
144
212
  try {
145
- return await this.instance.call(WorldStateMessageType.SYNC_BLOCK, {
213
+ const status = await this.instance.syncBlock({
146
214
  blockNumber: l2Block.number,
147
- blockHeaderHash: await l2Block.getBlockHeader().hash(),
215
+ blockHeaderHash: (await l2Block.hash()).toBuffer(),
216
+ // Forwarded so the native sync verifies the archive root against canonical and rejects a divergent tree.
217
+ expectedArchiveRoot: l2Block.archive.root.toBuffer(),
218
+ expectedPreviousArchiveRoot: l2Block.header.lastArchive.root.toBuffer(),
148
219
  paddedL1ToL2Messages: paddedL1ToL2Messages.map(serializeLeaf),
149
220
  paddedNoteHashes: paddedNoteHashes.map(serializeLeaf),
150
221
  paddedNullifiers: paddedNullifiers.map(serializeLeaf),
151
222
  publicDataWrites: publicDataWrites.map(serializeLeaf),
152
- blockStateRef: blockStateReference(l2Block.header.state),
153
- canonical: true
154
- }, this.sanitizeAndCacheSummaryFromFull.bind(this), this.deleteCachedSummary.bind(this));
223
+ blockStateRef: blockStateReference(l2Block.header.state)
224
+ });
225
+ return this.sanitizeAndCacheSummaryFromFull(status);
155
226
  } catch (err) {
227
+ this.deleteCachedSummary();
156
228
  this.worldStateInstrumentation.incCriticalErrors('synch_pending_block');
157
229
  throw err;
158
230
  }
159
231
  }
160
232
  async close() {
161
- await this.instance.close();
162
- await this.cleanup();
233
+ try {
234
+ await this.instance.close();
235
+ } finally{
236
+ await this.cleanup();
237
+ }
238
+ }
239
+ async [_computedKey]() {
240
+ await this.close();
163
241
  }
164
242
  async buildInitialHeader() {
165
243
  const state = await this.getInitialStateReference();
166
244
  return BlockHeader.empty({
167
- state
245
+ state,
246
+ globalVariables: GlobalVariables.empty({
247
+ timestamp: this.genesis.genesisTimestamp
248
+ })
168
249
  });
169
250
  }
170
251
  sanitizeAndCacheSummaryFromFull(response) {
@@ -181,7 +262,7 @@ export class NativeWorldStateService {
181
262
  };
182
263
  return sanitized;
183
264
  }
184
- deleteCachedSummary(_) {
265
+ deleteCachedSummary() {
185
266
  this.cachedStatusSummary = undefined;
186
267
  }
187
268
  /**
@@ -190,11 +271,9 @@ export class NativeWorldStateService {
190
271
  * @returns The new WorldStateStatus
191
272
  */ async setFinalized(toBlockNumber) {
192
273
  try {
193
- await this.instance.call(WorldStateMessageType.FINALIZE_BLOCKS, {
194
- toBlockNumber,
195
- canonical: true
196
- }, this.sanitizeAndCacheSummary.bind(this), this.deleteCachedSummary.bind(this));
274
+ this.sanitizeAndCacheSummary(await this.instance.finalizeBlocks(toBlockNumber));
197
275
  } catch (err) {
276
+ this.deleteCachedSummary();
198
277
  this.worldStateInstrumentation.incCriticalErrors('finalize_block');
199
278
  throw err;
200
279
  }
@@ -206,11 +285,9 @@ export class NativeWorldStateService {
206
285
  * @returns The new WorldStateStatus
207
286
  */ async removeHistoricalBlocks(toBlockNumber) {
208
287
  try {
209
- return await this.instance.call(WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS, {
210
- toBlockNumber,
211
- canonical: true
212
- }, this.sanitizeAndCacheSummaryFromFull.bind(this), this.deleteCachedSummary.bind(this));
288
+ return this.sanitizeAndCacheSummaryFromFull(await this.instance.removeHistoricalBlocks(toBlockNumber));
213
289
  } catch (err) {
290
+ this.deleteCachedSummary();
214
291
  this.worldStateInstrumentation.incCriticalErrors('prune_historical_block');
215
292
  throw err;
216
293
  }
@@ -221,11 +298,9 @@ export class NativeWorldStateService {
221
298
  * @returns The new WorldStateStatus
222
299
  */ async unwindBlocks(toBlockNumber) {
223
300
  try {
224
- return await this.instance.call(WorldStateMessageType.UNWIND_BLOCKS, {
225
- toBlockNumber,
226
- canonical: true
227
- }, this.sanitizeAndCacheSummaryFromFull.bind(this), this.deleteCachedSummary.bind(this));
301
+ return this.sanitizeAndCacheSummaryFromFull(await this.instance.unwindBlocks(toBlockNumber));
228
302
  } catch (err) {
303
+ this.deleteCachedSummary();
229
304
  this.worldStateInstrumentation.incCriticalErrors('prune_pending_block');
230
305
  throw err;
231
306
  }
@@ -236,25 +311,17 @@ export class NativeWorldStateService {
236
311
  ...this.cachedStatusSummary
237
312
  };
238
313
  }
239
- return await this.instance.call(WorldStateMessageType.GET_STATUS, {
240
- canonical: true
241
- }, this.sanitizeAndCacheSummary.bind(this));
314
+ return this.sanitizeAndCacheSummary(await this.instance.getStatus());
242
315
  }
243
316
  updateLeaf(_treeId, _leaf, _index) {
244
317
  return Promise.reject(new Error('Method not implemented'));
245
318
  }
246
319
  async getInitialStateReference() {
247
- const resp = await this.instance.call(WorldStateMessageType.GET_INITIAL_STATE_REFERENCE, {
248
- canonical: true
249
- });
250
- return new StateReference(treeStateReferenceToSnapshot(resp.state[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]), new PartialStateReference(treeStateReferenceToSnapshot(resp.state[MerkleTreeId.NOTE_HASH_TREE]), treeStateReferenceToSnapshot(resp.state[MerkleTreeId.NULLIFIER_TREE]), treeStateReferenceToSnapshot(resp.state[MerkleTreeId.PUBLIC_DATA_TREE])));
320
+ const state = await this.instance.getInitialStateReference();
321
+ return new StateReference(treeStateReferenceToSnapshot(state[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]), new PartialStateReference(treeStateReferenceToSnapshot(state[MerkleTreeId.NOTE_HASH_TREE]), treeStateReferenceToSnapshot(state[MerkleTreeId.NULLIFIER_TREE]), treeStateReferenceToSnapshot(state[MerkleTreeId.PUBLIC_DATA_TREE])));
251
322
  }
252
323
  async backupTo(dstPath, compact = true) {
253
- await this.instance.call(WorldStateMessageType.COPY_STORES, {
254
- dstPath,
255
- compact,
256
- canonical: true
257
- });
324
+ await this.instance.copyStores(dstPath, compact);
258
325
  return fromEntries(NATIVE_WORLD_STATE_DBS.map(([name, dir])=>[
259
326
  name,
260
327
  join(dstPath, dir, 'data.mdb')
@@ -1,40 +1,63 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
3
- import type { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
4
- import type { WorldStateTreeMapSizes } from '../synchronizer/factory.js';
5
- import { WorldStateMessageType, type WorldStateRequest, type WorldStateRequestCategories, type WorldStateResponse } from './message.js';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { IndexedTreeId, TreeInfo } from '@aztec/stdlib/interfaces/server';
4
+ import type { MerkleTreeId } from '@aztec/stdlib/trees';
5
+ import type { WorldStateRevision } from '@aztec/stdlib/world-state';
6
+ import type { BlockStateReference, SerializedBatchInsertionResult, SerializedIndexedLeaf, SerializedLeafValue, SerializedSequentialInsertionResult, SerializedSiblingPathAndIndex, TreeStateReference, WorldStateStatusFull, WorldStateStatusSummary } from './message.js';
7
+ /** Backend-agnostic handle to a running aztec-wsdb world state, accessed by the TS layer. */
6
8
  export interface NativeWorldStateInstance {
7
- call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories): Promise<WorldStateResponse[T]>;
8
- }
9
- /**
10
- * Strongly-typed interface to access the WorldState class in the native world_state_napi module.
11
- */
12
- export declare class NativeWorldState implements NativeWorldStateInstance {
13
- private readonly dataDir;
14
- private readonly wsTreeMapSizes;
15
- private readonly prefilledPublicData;
16
- private readonly instrumentation;
17
- private readonly log;
18
- private open;
19
- private queues;
20
- private instance;
21
- /** Creates a new native WorldState instance */
22
- constructor(dataDir: string, wsTreeMapSizes: WorldStateTreeMapSizes, prefilledPublicData: PublicDataTreeLeaf[] | undefined, instrumentation: WorldStateInstrumentation, log?: Logger);
23
- getDataDir(): string;
24
- clone(): NativeWorldState;
9
+ getTreeInfo(treeId: MerkleTreeId, revision: WorldStateRevision): Promise<TreeInfo>;
10
+ getStateReference(revision: WorldStateRevision): Promise<Record<number, TreeStateReference>>;
11
+ getInitialStateReference(): Promise<Record<number, TreeStateReference>>;
12
+ getLeafValue(treeId: MerkleTreeId, revision: WorldStateRevision, leafIndex: bigint): Promise<SerializedLeafValue | undefined>;
13
+ getLeafPreimage(treeId: IndexedTreeId, revision: WorldStateRevision, leafIndex: bigint): Promise<SerializedIndexedLeaf | undefined>;
14
+ getSiblingPath(treeId: MerkleTreeId, revision: WorldStateRevision, leafIndex: bigint): Promise<Buffer[]>;
15
+ getBlockNumbersForLeafIndices(treeId: MerkleTreeId, revision: WorldStateRevision, leafIndices: bigint[]): Promise<(bigint | undefined)[]>;
16
+ findLeafIndices(treeId: MerkleTreeId, revision: WorldStateRevision, leaves: SerializedLeafValue[], startIndex: bigint): Promise<(bigint | undefined)[]>;
17
+ findLowLeaf(treeId: IndexedTreeId, revision: WorldStateRevision, key: Fr): Promise<{
18
+ index: bigint;
19
+ alreadyPresent: boolean;
20
+ }>;
21
+ findSiblingPaths(treeId: MerkleTreeId, revision: WorldStateRevision, leaves: SerializedLeafValue[]): Promise<(SerializedSiblingPathAndIndex | undefined)[]>;
22
+ updateArchive(forkId: number, blockStateRef: BlockStateReference, blockHeaderHash: Buffer): Promise<void>;
23
+ appendLeaves(treeId: MerkleTreeId, forkId: number, leaves: SerializedLeafValue[]): Promise<void>;
24
+ batchInsert(treeId: IndexedTreeId, forkId: number, leaves: SerializedLeafValue[], subtreeDepth: number): Promise<SerializedBatchInsertionResult>;
25
+ sequentialInsert(treeId: IndexedTreeId, forkId: number, leaves: SerializedLeafValue[]): Promise<SerializedSequentialInsertionResult>;
26
+ syncBlock(input: {
27
+ blockNumber: BlockNumber;
28
+ blockStateRef: BlockStateReference;
29
+ blockHeaderHash: Buffer;
30
+ expectedArchiveRoot: Buffer;
31
+ expectedPreviousArchiveRoot: Buffer;
32
+ paddedNoteHashes: readonly SerializedLeafValue[];
33
+ paddedL1ToL2Messages: readonly SerializedLeafValue[];
34
+ paddedNullifiers: readonly SerializedLeafValue[];
35
+ publicDataWrites: readonly SerializedLeafValue[];
36
+ }): Promise<WorldStateStatusFull>;
37
+ createFork(input: {
38
+ latest: boolean;
39
+ blockNumber: BlockNumber;
40
+ }): Promise<number>;
41
+ deleteFork(forkId: number): Promise<void>;
42
+ finalizeBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusSummary>;
43
+ unwindBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
44
+ removeHistoricalBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
45
+ getStatus(): Promise<WorldStateStatusSummary>;
46
+ createCheckpoint(forkId: number): Promise<number>;
47
+ commitCheckpoint(forkId: number): Promise<void>;
48
+ revertCheckpoint(forkId: number): Promise<void>;
49
+ commitAllCheckpoints(forkId: number, depth: number): Promise<void>;
50
+ revertAllCheckpoints(forkId: number, depth: number): Promise<void>;
51
+ copyStores(dstPath: string, compact: boolean): Promise<void>;
25
52
  /**
26
- * Sends a message to the native instance and returns the response.
27
- * @param messageType - The type of message to send
28
- * @param body - The message body
29
- * @param responseHandler - A callback accepting the response, executed on the job queue
30
- * @param errorHandler - A callback called on request error, executed on the job queue
31
- * @returns The response to the message
53
+ * IPC path the underlying aztec-wsdb process listens on. The C++ AVM uses this to attach to the
54
+ * same world state instance the TS layer is using.
32
55
  */
33
- call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories, responseHandler?: (response: WorldStateResponse[T]) => WorldStateResponse[T], errorHandler?: (_: string) => void): Promise<WorldStateResponse[T]>;
56
+ getIpcPath(): string;
34
57
  /**
35
- * Stops the native instance.
58
+ * Shut down the world state instance. Cancels any in-flight queues, closes the IPC channel, and
59
+ * terminates the underlying aztec-wsdb process. Idempotent.
36
60
  */
37
61
  close(): Promise<void>;
38
- private _sendMessage;
39
62
  }
40
- //# sourceMappingURL=native_world_state_instance.d.ts.map
63
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF0aXZlX3dvcmxkX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RyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDaEQsb0JBQW9CLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNuRSxvQkFBb0IsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ25FLFVBQVUsQ0FBQyxPQUFPLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxPQUFPLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRTdEOzs7T0FHRztJQUNILFVBQVUsSUFBSSxNQUFNLENBQUM7SUFFckI7OztPQUdHO0lBQ0gsS0FBSyxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztDQUN4QiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"native_world_state_instance.d.ts","sourceRoot":"","sources":["../../src/native/native_world_state_instance.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAK9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EAIxB,MAAM,cAAc,CAAC;AAKtB,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAClC,WAAW,EAAE,CAAC,EACd,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,2BAA2B,GACvD,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CA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