@aztec/world-state 0.0.1-commit.001888fc → 0.0.1-commit.017a351

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 (38) hide show
  1. package/dest/native/ipc_world_state_instance.d.ts +45 -0
  2. package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
  3. package/dest/native/ipc_world_state_instance.js +750 -0
  4. package/dest/native/merkle_trees_facade.d.ts +8 -4
  5. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  6. package/dest/native/merkle_trees_facade.js +34 -15
  7. package/dest/native/message.d.ts +7 -8
  8. package/dest/native/message.d.ts.map +1 -1
  9. package/dest/native/native_world_state.d.ts +19 -7
  10. package/dest/native/native_world_state.d.ts.map +1 -1
  11. package/dest/native/native_world_state.js +89 -24
  12. package/dest/native/native_world_state_instance.d.ts +21 -39
  13. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  14. package/dest/native/native_world_state_instance.js +8 -202
  15. package/dest/native/world_state_ops_queue.js +5 -5
  16. package/dest/synchronizer/config.d.ts +1 -1
  17. package/dest/synchronizer/config.d.ts.map +1 -1
  18. package/dest/synchronizer/config.js +9 -10
  19. package/dest/synchronizer/factory.d.ts +4 -4
  20. package/dest/synchronizer/factory.d.ts.map +1 -1
  21. package/dest/synchronizer/factory.js +7 -6
  22. package/dest/synchronizer/server_world_state_synchronizer.d.ts +1 -1
  23. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  24. package/dest/synchronizer/server_world_state_synchronizer.js +40 -11
  25. package/dest/testing.d.ts +4 -3
  26. package/dest/testing.d.ts.map +1 -1
  27. package/dest/testing.js +10 -6
  28. package/package.json +13 -10
  29. package/src/native/ipc_world_state_instance.ts +863 -0
  30. package/src/native/merkle_trees_facade.ts +41 -19
  31. package/src/native/message.ts +6 -7
  32. package/src/native/native_world_state.ts +98 -35
  33. package/src/native/native_world_state_instance.ts +28 -276
  34. package/src/native/world_state_ops_queue.ts +5 -5
  35. package/src/synchronizer/config.ts +14 -10
  36. package/src/synchronizer/factory.ts +11 -10
  37. package/src/synchronizer/server_world_state_synchronizer.ts +35 -13
  38. package/src/testing.ts +8 -9
@@ -1,55 +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';
2
3
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
4
  import { fromEntries, padArrayEnd } from '@aztec/foundation/collection';
4
5
  import { Fr } from '@aztec/foundation/curves/bn254';
5
- import { EthAddress } from '@aztec/foundation/eth-address';
6
- import { tryRmDir } from '@aztec/foundation/fs';
7
6
  import { createLogger } from '@aztec/foundation/log';
8
7
  import { DatabaseVersionManager } from '@aztec/stdlib/database-version/manager';
9
8
  import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
10
- import { BlockHeader, PartialStateReference, StateReference } from '@aztec/stdlib/tx';
11
- 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';
12
11
  import { getTelemetryClient } from '@aztec/telemetry-client';
13
12
  import assert from 'assert/strict';
14
- import { mkdtemp, rm } from 'fs/promises';
13
+ import { mkdir, mkdtemp, rm } from 'fs/promises';
15
14
  import { tmpdir } from 'os';
16
15
  import { join } from 'path';
17
16
  import { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
17
+ import { IpcWorldState } from './ipc_world_state_instance.js';
18
18
  import { MerkleTreesFacade, MerkleTreesForkFacade, serializeLeaf } from './merkle_trees_facade.js';
19
19
  import { WorldStateMessageType, blockStateReference, sanitizeFullStatus, sanitizeSummary, treeStateReferenceToSnapshot } from './message.js';
20
- import { NativeWorldState } from './native_world_state_instance.js';
21
20
  // The current version of the world state database schema
22
21
  // Increment this when making incompatible changes to the database schema
23
22
  export const WORLD_STATE_DB_VERSION = 2; // The initial version
24
23
  export const WORLD_STATE_DIR = 'world_state';
24
+ _computedKey = Symbol.asyncDispose;
25
25
  export class NativeWorldStateService {
26
26
  instance;
27
27
  worldStateInstrumentation;
28
28
  log;
29
+ genesis;
29
30
  cleanup;
31
+ recreateInstance;
30
32
  initialHeader;
31
33
  // This is read heavily and only changes when data is persisted, so we cache it
32
34
  cachedStatusSummary;
33
- constructor(instance, worldStateInstrumentation, log, cleanup = ()=>Promise.resolve()){
35
+ constructor(instance, worldStateInstrumentation, log, genesis = EMPTY_GENESIS_DATA, cleanup = ()=>Promise.resolve(), /** Factory to recreate a fresh IpcWorldState after clear(). */ recreateInstance){
34
36
  this.instance = instance;
35
37
  this.worldStateInstrumentation = worldStateInstrumentation;
36
38
  this.log = log;
39
+ this.genesis = genesis;
37
40
  this.cleanup = cleanup;
41
+ this.recreateInstance = recreateInstance;
38
42
  }
39
- static async new(rollupAddress, dataDir, wsTreeMapSizes, prefilledPublicData = [], instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings, 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
+ }
40
49
  const log = createLogger('world-state:database', bindings);
41
50
  const worldStateDirectory = join(dataDir, WORLD_STATE_DIR);
42
- // Create a version manager to handle versioning
43
51
  const versionManager = new DatabaseVersionManager({
44
52
  schemaVersion: WORLD_STATE_DB_VERSION,
45
53
  rollupAddress,
46
54
  dataDirectory: worldStateDirectory,
47
- onOpen: (dir)=>{
48
- return Promise.resolve(new NativeWorldState(dir, wsTreeMapSizes, prefilledPublicData, instrumentation, bindings));
49
- }
55
+ onOpen: (dir)=>IpcWorldState.spawn(dir, wsTreeMapSizes, genesis, instrumentation, bindings)
50
56
  });
51
57
  const [instance] = await versionManager.open();
52
- 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);
53
70
  try {
54
71
  await worldState.init();
55
72
  } catch (e) {
@@ -58,7 +75,7 @@ export class NativeWorldStateService {
58
75
  }
59
76
  return worldState;
60
77
  }
61
- static async tmp(rollupAddress = EthAddress.ZERO, cleanupTmpDir = true, prefilledPublicData = [], instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings) {
78
+ static async tmp(cleanupTmpDir = true, genesis = EMPTY_GENESIS_DATA, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings) {
62
79
  const log = createLogger('world-state:database', bindings);
63
80
  const dataDir = await mkdtemp(join(tmpdir(), 'aztec-world-state-'));
64
81
  const dbMapSizeKb = 10 * 1024 * 1024;
@@ -70,7 +87,7 @@ export class NativeWorldStateService {
70
87
  publicDataTreeMapSizeKb: dbMapSizeKb
71
88
  };
72
89
  log.debug(`Created temporary world state database at: ${dataDir} with tree map size: ${dbMapSizeKb}`);
73
- // pass a cleanup callback because process.on('beforeExit', cleanup) does not work under Jest
90
+ const instance = await IpcWorldState.spawn(dataDir, worldStateTreeMapSizes, genesis, instrumentation, bindings);
74
91
  const cleanup = async ()=>{
75
92
  if (cleanupTmpDir) {
76
93
  await rm(dataDir, {
@@ -83,7 +100,35 @@ export class NativeWorldStateService {
83
100
  log.debug(`Leaving temporary world state database: ${dataDir}`);
84
101
  }
85
102
  };
86
- return this.new(rollupAddress, dataDir, worldStateTreeMapSizes, prefilledPublicData, instrumentation, bindings, cleanup);
103
+ const recreateInstance = async ()=>{
104
+ await rm(dataDir, {
105
+ recursive: true,
106
+ force: true,
107
+ maxRetries: 3
108
+ });
109
+ await mkdir(dataDir, {
110
+ recursive: true
111
+ });
112
+ return IpcWorldState.spawn(dataDir, worldStateTreeMapSizes, genesis, instrumentation, bindings);
113
+ };
114
+ const worldState = new this(instance, instrumentation, log, genesis, cleanup, recreateInstance);
115
+ try {
116
+ await worldState.init();
117
+ } catch (e) {
118
+ log.error(`Error initializing tmp world state: ${e}`);
119
+ throw e;
120
+ }
121
+ return worldState;
122
+ }
123
+ static ephemeral(genesis = EMPTY_GENESIS_DATA, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings) {
124
+ return this.tmp(/*cleanupTmpDir=*/ true, genesis, instrumentation, bindings);
125
+ }
126
+ static async fromIpc(wsdbBackend, instrumentation = new WorldStateInstrumentation(getTelemetryClient()), bindings, genesis = EMPTY_GENESIS_DATA, cleanup = ()=>Promise.resolve(), recreateInstance) {
127
+ const log = createLogger('world-state:database', bindings);
128
+ const instance = new IpcWorldState(wsdbBackend, instrumentation, bindings);
129
+ const worldState = new this(instance, instrumentation, log, genesis, cleanup, recreateInstance);
130
+ await worldState.init();
131
+ return worldState;
87
132
  }
88
133
  async init() {
89
134
  const status = await this.getStatusSummary();
@@ -100,16 +145,27 @@ export class NativeWorldStateService {
100
145
  // the initial header _must_ be the first element in the archive tree
101
146
  // if this assertion fails, check that the hashing done in Header in yarn-project matches the initial header hash done in world_state.cpp
102
147
  const indices = await committed.findLeafIndices(MerkleTreeId.ARCHIVE, [
103
- (await this.initialHeader.hash()).toFr()
148
+ await this.initialHeader.hash()
104
149
  ]);
105
150
  const initialHeaderIndex = indices[0];
106
151
  assert.strictEqual(initialHeaderIndex, 0n, 'Invalid initial archive state');
107
152
  }
108
153
  async clear() {
154
+ if (!this.recreateInstance) {
155
+ throw new Error('clear() is not available for externally-managed IPC backends');
156
+ }
157
+ this.log.warn('Clearing world state: shutting down WSDB, deleting data, and recreating');
109
158
  await this.instance.close();
110
159
  this.cachedStatusSummary = undefined;
111
- await tryRmDir(this.instance.getDataDir(), this.log);
112
- this.instance = this.instance.clone();
160
+ this.instance = await this.recreateInstance();
161
+ await this.init();
162
+ this.log.info('World state cleared and reinitialized from genesis');
163
+ }
164
+ /** Returns the socket path of the underlying IPC backend, if available. */ getSocketPath() {
165
+ if (this.instance instanceof IpcWorldState) {
166
+ return this.instance.getSocketPath();
167
+ }
168
+ throw new Error('getSocketPath() is only available with IPC world state');
113
169
  }
114
170
  getCommitted() {
115
171
  return new MerkleTreesFacade(this.instance, this.initialHeader, WorldStateRevision.empty());
@@ -123,7 +179,7 @@ export class NativeWorldStateService {
123
179
  blockNumber: blockNumber ?? BlockNumber.ZERO,
124
180
  canonical: true
125
181
  });
126
- return new MerkleTreesForkFacade(this.instance, this.initialHeader, new WorldStateRevision(/*forkId=*/ resp.forkId, /* blockNumber=*/ BlockNumber.ZERO, /* includeUncommitted=*/ true), opts);
182
+ return new MerkleTreesForkFacade(this.instance, this.initialHeader, new WorldStateRevision(/*forkId=*/ resp.forkId, /* blockNumber=*/ WorldStateRevision.LATEST, /* includeUncommitted=*/ true), opts);
127
183
  }
128
184
  getInitialHeader() {
129
185
  return this.initialHeader;
@@ -149,7 +205,7 @@ export class NativeWorldStateService {
149
205
  try {
150
206
  return await this.instance.call(WorldStateMessageType.SYNC_BLOCK, {
151
207
  blockNumber: l2Block.number,
152
- blockHeaderHash: await l2Block.hash(),
208
+ blockHeaderHash: (await l2Block.hash()).toBuffer(),
153
209
  paddedL1ToL2Messages: paddedL1ToL2Messages.map(serializeLeaf),
154
210
  paddedNoteHashes: paddedNoteHashes.map(serializeLeaf),
155
211
  paddedNullifiers: paddedNullifiers.map(serializeLeaf),
@@ -163,13 +219,22 @@ export class NativeWorldStateService {
163
219
  }
164
220
  }
165
221
  async close() {
166
- await this.instance.close();
167
- await this.cleanup();
222
+ try {
223
+ await this.instance.close();
224
+ } finally{
225
+ await this.cleanup();
226
+ }
227
+ }
228
+ async [_computedKey]() {
229
+ await this.close();
168
230
  }
169
231
  async buildInitialHeader() {
170
232
  const state = await this.getInitialStateReference();
171
233
  return BlockHeader.empty({
172
- state
234
+ state,
235
+ globalVariables: GlobalVariables.empty({
236
+ timestamp: this.genesis.genesisTimestamp
237
+ })
173
238
  });
174
239
  }
175
240
  sanitizeAndCacheSummaryFromFull(response) {
@@ -1,49 +1,31 @@
1
- import { type Logger, type LoggerBindings } 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';
6
- export interface NativeWorldStateInstance {
7
- call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories): Promise<WorldStateResponse[T]>;
8
- getHandle(): any;
9
- }
1
+ import type { WorldStateMessageType, WorldStateRequest, WorldStateRequestCategories, WorldStateResponse } from './message.js';
10
2
  /**
11
- * Strongly-typed interface to access the WorldState class in the native world_state_napi module.
3
+ * Backend-agnostic handle to a running aztec-wsdb world state, accessed by the TS layer.
4
+ *
5
+ * Two implementations exist:
6
+ * - {@link IpcWorldState} — talks to a standalone aztec-wsdb process over UDS or shared memory.
7
+ *
8
+ * The legacy in-process NAPI implementation has been removed; the C++ AVM (NAPI) now connects to
9
+ * the same aztec-wsdb process via UDS using the socket path returned by {@link getSocketPath}.
12
10
  */
13
- export declare class NativeWorldState implements NativeWorldStateInstance {
14
- private readonly dataDir;
15
- private readonly wsTreeMapSizes;
16
- private readonly prefilledPublicData;
17
- private readonly instrumentation;
18
- private readonly log;
19
- private open;
20
- private queues;
21
- private instance;
22
- /** Creates a new native WorldState instance */
23
- constructor(dataDir: string, wsTreeMapSizes: WorldStateTreeMapSizes, prefilledPublicData: PublicDataTreeLeaf[] | undefined, instrumentation: WorldStateInstrumentation, bindings?: LoggerBindings, log?: Logger);
24
- getDataDir(): string;
25
- clone(): NativeWorldState;
11
+ export interface NativeWorldStateInstance {
26
12
  /**
27
- * Gets the native WorldState handle from the underlying native instance.
28
- * We call the getHandle() method on the native WorldState to get a NAPI External
29
- * that wraps the underlying C++ WorldState pointer.
30
- * @returns The NAPI External handle to the native WorldState instance,since
31
- * the NAPI external type is opaque, we return any (we could also use an opaque symbol type)
13
+ * Send a typed msgpack message to the backing world state and await its response.
14
+ *
15
+ * @param responseHandler — optional pre-resolution hook executed on the per-fork queue, useful
16
+ * for caching responses while the queue still holds the fork lock.
17
+ * @param errorHandler optional pre-rejection hook executed on the per-fork queue.
32
18
  */
33
- getHandle(): any;
19
+ call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories, responseHandler?: (response: WorldStateResponse[T]) => WorldStateResponse[T], errorHandler?: (error: string) => void): Promise<WorldStateResponse[T]>;
34
20
  /**
35
- * Sends a message to the native instance and returns the response.
36
- * @param messageType - The type of message to send
37
- * @param body - The message body
38
- * @param responseHandler - A callback accepting the response, executed on the job queue
39
- * @param errorHandler - A callback called on request error, executed on the job queue
40
- * @returns The response to the message
21
+ * UDS path the underlying aztec-wsdb process listens on. The C++ AVM uses this to attach to the
22
+ * same world state instance the TS layer is using.
41
23
  */
42
- call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories, responseHandler?: (response: WorldStateResponse[T]) => WorldStateResponse[T], errorHandler?: (_: string) => void): Promise<WorldStateResponse[T]>;
24
+ getSocketPath(): string;
43
25
  /**
44
- * Stops the native instance.
26
+ * Shut down the world state instance. Cancels any in-flight queues, closes the IPC channel, and
27
+ * terminates the underlying aztec-wsdb process. Idempotent.
45
28
  */
46
29
  close(): Promise<void>;
47
- private _sendMessage;
48
30
  }
49
- //# sourceMappingURL=data:application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WyIuLi8uLi9zcmMvbmF0aXZlL25hdGl2ZV93b3JsZF9zdGF0ZV9pbnN0YW5jZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFDVixxQkFBcUIsRUFDckIsaUJBQWlCLEVBQ2pCLDJCQUEyQixFQUMzQixrQkFBa0IsRUFDbkIsTUFBTSxjQUFjLENBQUM7QUFFdEI7Ozs7Ozs7O0dBUUc7QUFDSCxNQUFNLFdBQVcsd0JBQXdCO0lBQ3ZDOzs7Ozs7T0FNRztJQUNILElBQUksQ0FBQyxDQUFDLFNBQVMscUJBQXFCLEVBQ2xDLFdBQVcsRUFBRSxDQUFDLEVBQ2QsSUFBSSxFQUFFLGlCQUFpQixDQUFDLENBQUMsQ0FBQyxHQUFHLDJCQUEyQixFQUN4RCxlQUFlLENBQUMsRUFBRSxDQUFDLFFBQVEsRUFBRSxrQkFBa0IsQ0FBQyxDQUFDLENBQUMsS0FBSyxrQkFBa0IsQ0FBQyxDQUFDLENBQUMsRUFDNUUsWUFBWSxDQUFDLEVBQUUsQ0FBQyxLQUFLLEVBQUUsTUFBTSxLQUFLLElBQUksR0FDckMsT0FBTyxDQUFDLGtCQUFrQixDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFFbEM7OztPQUdHO0lBQ0gsYUFBYSxJQUFJLE1BQU0sQ0FBQztJQUV4Qjs7O09BR0c7SUFDSCxLQUFLLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0NBQ3hCIn0=
@@ -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,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAGvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAK9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM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AAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAqDhC;IAED;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAelC;YAEa,YAAY;CA8D3B"}
1
+ {"version":3,"file":"native_world_state_instance.d.ts","sourceRoot":"","sources":["../../src/native/native_world_state_instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAClC,WAAW,EAAE,CAAC,EACd,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,2BAA2B,EACxD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,EAC5E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GACrC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAElC;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAC;IAExB;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -1,203 +1,9 @@
1
- import { ARCHIVE_HEIGHT, DomainSeparator, L1_TO_L2_MSG_TREE_HEIGHT, MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { NativeWorldState as BaseNativeWorldState, MsgpackChannel } from '@aztec/native';
4
- import { MerkleTreeId } from '@aztec/stdlib/trees';
5
- import assert from 'assert';
6
- import { cpus } from 'os';
7
- import { WorldStateMessageType, isWithCanonical, isWithForkId, isWithRevision } from './message.js';
8
- import { WorldStateOpsQueue } from './world_state_ops_queue.js';
9
- const MAX_WORLD_STATE_THREADS = +(process.env.HARDWARE_CONCURRENCY || '16');
10
1
  /**
11
- * Strongly-typed interface to access the WorldState class in the native world_state_napi module.
12
- */ export class NativeWorldState {
13
- dataDir;
14
- wsTreeMapSizes;
15
- prefilledPublicData;
16
- instrumentation;
17
- log;
18
- open;
19
- // We maintain a map of queue to fork
20
- queues;
21
- instance;
22
- /** Creates a new native WorldState instance */ constructor(dataDir, wsTreeMapSizes, prefilledPublicData = [], instrumentation, bindings, log = createLogger('world-state:database', bindings)){
23
- this.dataDir = dataDir;
24
- this.wsTreeMapSizes = wsTreeMapSizes;
25
- this.prefilledPublicData = prefilledPublicData;
26
- this.instrumentation = instrumentation;
27
- this.log = log;
28
- this.open = true;
29
- this.queues = new Map();
30
- const threads = Math.min(cpus().length, MAX_WORLD_STATE_THREADS);
31
- log.info(`Creating world state data store at directory ${dataDir} with map sizes ${JSON.stringify(wsTreeMapSizes)} and ${threads} threads.`);
32
- const prefilledPublicDataBufferArray = prefilledPublicData.map((d)=>[
33
- d.slot.toBuffer(),
34
- d.value.toBuffer()
35
- ]);
36
- const ws = new BaseNativeWorldState(dataDir, {
37
- [MerkleTreeId.NULLIFIER_TREE]: NULLIFIER_TREE_HEIGHT,
38
- [MerkleTreeId.NOTE_HASH_TREE]: NOTE_HASH_TREE_HEIGHT,
39
- [MerkleTreeId.PUBLIC_DATA_TREE]: PUBLIC_DATA_TREE_HEIGHT,
40
- [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: L1_TO_L2_MSG_TREE_HEIGHT,
41
- [MerkleTreeId.ARCHIVE]: ARCHIVE_HEIGHT
42
- }, {
43
- [MerkleTreeId.NULLIFIER_TREE]: 2 * MAX_NULLIFIERS_PER_TX,
44
- [MerkleTreeId.PUBLIC_DATA_TREE]: 2 * MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
45
- }, prefilledPublicDataBufferArray, DomainSeparator.BLOCK_HEADER_HASH, {
46
- [MerkleTreeId.NULLIFIER_TREE]: wsTreeMapSizes.nullifierTreeMapSizeKb,
47
- [MerkleTreeId.NOTE_HASH_TREE]: wsTreeMapSizes.noteHashTreeMapSizeKb,
48
- [MerkleTreeId.PUBLIC_DATA_TREE]: wsTreeMapSizes.publicDataTreeMapSizeKb,
49
- [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: wsTreeMapSizes.messageTreeMapSizeKb,
50
- [MerkleTreeId.ARCHIVE]: wsTreeMapSizes.archiveTreeMapSizeKb
51
- }, threads);
52
- this.instance = new MsgpackChannel(ws);
53
- // Manually create the queue for the canonical fork
54
- this.queues.set(0, new WorldStateOpsQueue());
55
- }
56
- getDataDir() {
57
- return this.dataDir;
58
- }
59
- clone() {
60
- return new NativeWorldState(this.dataDir, this.wsTreeMapSizes, this.prefilledPublicData, this.instrumentation, this.log.getBindings(), this.log);
61
- }
62
- /**
63
- * Gets the native WorldState handle from the underlying native instance.
64
- * We call the getHandle() method on the native WorldState to get a NAPI External
65
- * that wraps the underlying C++ WorldState pointer.
66
- * @returns The NAPI External handle to the native WorldState instance,since
67
- * the NAPI external type is opaque, we return any (we could also use an opaque symbol type)
68
- */ getHandle() {
69
- const worldStateWrapper = this.instance.dest;
70
- if (!worldStateWrapper) {
71
- throw new Error('No WorldStateWrapper found');
72
- }
73
- if (typeof worldStateWrapper.getHandle !== 'function') {
74
- throw new Error('WorldStateWrapper does not have getHandle method');
75
- }
76
- // Call getHandle() to get the NAPI External
77
- try {
78
- return worldStateWrapper.getHandle();
79
- } catch (error) {
80
- this.log.error('Failed to get native WorldState handle', error);
81
- }
82
- }
83
- /**
84
- * Sends a message to the native instance and returns the response.
85
- * @param messageType - The type of message to send
86
- * @param body - The message body
87
- * @param responseHandler - A callback accepting the response, executed on the job queue
88
- * @param errorHandler - A callback called on request error, executed on the job queue
89
- * @returns The response to the message
90
- */ async call(messageType, body, // allows for the pre-processing of responses on the job queue before being passed back
91
- responseHandler = (response)=>response, errorHandler = (_)=>{}) {
92
- // Here we determine which fork the request is being executed against and whether it requires uncommitted data
93
- // We use the fork Id to select the appropriate request queue and the uncommitted data flag to pass to the queue
94
- let forkId = -1;
95
- // We assume it includes uncommitted unless explicitly told otherwise
96
- let committedOnly = false;
97
- // Canonical requests ALWAYS go against the canonical fork
98
- // These include things like block syncs/unwinds etc
99
- // These requests don't contain a fork ID
100
- if (isWithCanonical(body)) {
101
- forkId = 0;
102
- } else if (isWithForkId(body)) {
103
- forkId = body.forkId;
104
- } else if (isWithRevision(body)) {
105
- forkId = body.revision.forkId;
106
- committedOnly = body.revision.includeUncommitted === false;
107
- } else {
108
- const _ = body;
109
- throw new Error(`Unable to determine forkId for message=${WorldStateMessageType[messageType]}`);
110
- }
111
- // Get the queue or create a new one
112
- let requestQueue = this.queues.get(forkId);
113
- if (requestQueue === undefined) {
114
- requestQueue = new WorldStateOpsQueue();
115
- this.queues.set(forkId, requestQueue);
116
- }
117
- // Enqueue the request and wait for the response
118
- const response = await requestQueue.execute(async ()=>{
119
- assert.notEqual(messageType, WorldStateMessageType.CLOSE, 'Use close() to close the native instance');
120
- assert.equal(this.open, true, 'Native instance is closed');
121
- let response;
122
- try {
123
- response = await this._sendMessage(messageType, body);
124
- } catch (error) {
125
- errorHandler(error.message);
126
- throw error;
127
- }
128
- return responseHandler(response);
129
- }, messageType, committedOnly);
130
- // If the request was to delete the fork then we clean it up here
131
- if (messageType === WorldStateMessageType.DELETE_FORK) {
132
- await requestQueue.stop();
133
- this.queues.delete(forkId);
134
- }
135
- return response;
136
- }
137
- /**
138
- * Stops the native instance.
139
- */ async close() {
140
- if (!this.open) {
141
- return;
142
- }
143
- this.open = false;
144
- const queue = this.queues.get(0);
145
- await queue.execute(async ()=>{
146
- await this._sendMessage(WorldStateMessageType.CLOSE, {
147
- canonical: true
148
- });
149
- }, WorldStateMessageType.CLOSE, false);
150
- await queue.stop();
151
- }
152
- async _sendMessage(messageType, body) {
153
- let logMetadata = {};
154
- if (body) {
155
- if ('treeId' in body) {
156
- logMetadata['treeId'] = MerkleTreeId[body.treeId];
157
- }
158
- if ('revision' in body) {
159
- logMetadata = {
160
- ...logMetadata,
161
- ...body.revision
162
- };
163
- }
164
- if ('forkId' in body) {
165
- logMetadata['forkId'] = body.forkId;
166
- }
167
- if ('blockNumber' in body) {
168
- logMetadata['blockNumber'] = body.blockNumber;
169
- }
170
- if ('toBlockNumber' in body) {
171
- logMetadata['toBlockNumber'] = body.toBlockNumber;
172
- }
173
- if ('leafIndex' in body) {
174
- logMetadata['leafIndex'] = body.leafIndex;
175
- }
176
- if ('blockHeaderHash' in body) {
177
- logMetadata['blockHeaderHash'] = '0x' + body.blockHeaderHash.toString('hex');
178
- }
179
- if ('leaves' in body) {
180
- logMetadata['leavesCount'] = body.leaves.length;
181
- }
182
- // sync operation
183
- if ('paddedNoteHashes' in body) {
184
- logMetadata['notesCount'] = body.paddedNoteHashes.length;
185
- logMetadata['nullifiersCount'] = body.paddedNullifiers.length;
186
- logMetadata['l1ToL2MessagesCount'] = body.paddedL1ToL2Messages.length;
187
- logMetadata['publicDataWritesCount'] = body.publicDataWrites.length;
188
- }
189
- }
190
- try {
191
- const { duration, response } = await this.instance.sendMessage(messageType, body);
192
- this.log.trace(`Call ${WorldStateMessageType[messageType]} took (ms)`, {
193
- duration,
194
- ...logMetadata
195
- });
196
- this.instrumentation.recordRoundTrip(duration.totalUs, messageType);
197
- return response;
198
- } catch (error) {
199
- this.log.error(`Call ${WorldStateMessageType[messageType]} failed: ${error}`, error, logMetadata);
200
- throw error;
201
- }
202
- }
203
- }
2
+ * Backend-agnostic handle to a running aztec-wsdb world state, accessed by the TS layer.
3
+ *
4
+ * Two implementations exist:
5
+ * - {@link IpcWorldState} — talks to a standalone aztec-wsdb process over UDS or shared memory.
6
+ *
7
+ * The legacy in-process NAPI implementation has been removed; the C++ AVM (NAPI) now connects to
8
+ * the same aztec-wsdb process via UDS using the socket path returned by {@link getSocketPath}.
9
+ */ export { };
@@ -67,7 +67,7 @@ export class WorldStateOpsQueue {
67
67
  // then send the request immediately
68
68
  // If a mutating request is in flight then we must wait
69
69
  // If a mutating request is not in flight but something is queued then it must be a mutating request
70
- if (this.inFlightMutatingCount == 0 && this.requests.length == 0) {
70
+ if (this.inFlightMutatingCount === 0 && this.requests.length === 0) {
71
71
  this.sendEnqueuedRequest(op);
72
72
  } else {
73
73
  this.requests.push(op);
@@ -88,7 +88,7 @@ export class WorldStateOpsQueue {
88
88
  }
89
89
  --this.inFlightCount;
90
90
  // If there are still requests in flight then do nothing further
91
- if (this.inFlightCount != 0) {
91
+ if (this.inFlightCount !== 0) {
92
92
  return;
93
93
  }
94
94
  // No requests in flight, send next queued requests
@@ -99,7 +99,7 @@ export class WorldStateOpsQueue {
99
99
  while(this.requests.length > 0){
100
100
  const next = this.requests[0];
101
101
  if (next.mutating) {
102
- if (this.inFlightCount == 0) {
102
+ if (this.inFlightCount === 0) {
103
103
  // send the mutating request
104
104
  this.requests.shift();
105
105
  this.sendEnqueuedRequest(next);
@@ -112,7 +112,7 @@ export class WorldStateOpsQueue {
112
112
  }
113
113
  }
114
114
  // If the queue is empty, there is nothing in flight and we have been told to stop, then resolve the stop promise
115
- if (this.inFlightCount == 0 && this.stopResolve !== undefined) {
115
+ if (this.inFlightCount === 0 && this.stopResolve !== undefined) {
116
116
  this.stopResolve();
117
117
  }
118
118
  }
@@ -138,7 +138,7 @@ export class WorldStateOpsQueue {
138
138
  this.stopResolve = resolve;
139
139
  });
140
140
  // If no outstanding requests then immediately resolve the promise
141
- if (this.requests.length == 0 && this.inFlightCount == 0 && this.stopResolve !== undefined) {
141
+ if (this.requests.length === 0 && this.inFlightCount === 0 && this.stopResolve !== undefined) {
142
142
  this.stopResolve();
143
143
  }
144
144
  return this.stopPromise;
@@ -28,4 +28,4 @@ export declare const worldStateConfigMappings: ConfigMappingsType<WorldStateConf
28
28
  * @returns The configuration values for the world state synchronizer.
29
29
  */
30
30
  export declare function getWorldStateConfigFromEnv(): WorldStateConfig;
31
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3luY2hyb25pemVyL2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxrQkFBa0IsRUFBNkMsTUFBTSwwQkFBMEIsQ0FBQztBQUU5RyxxREFBcUQ7QUFDckQsTUFBTSxXQUFXLGdCQUFnQjtJQUMvQix1Q0FBdUM7SUFDdkMsOEJBQThCLEVBQUUsTUFBTSxDQUFDO0lBRXZDLDJGQUEyRjtJQUMzRiwrQkFBK0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUV6QyxtSkFBbUo7SUFDbkoscUJBQXFCLENBQUMsRUFBRSxNQUFNLENBQUM7SUFFL0IsMkpBQTJKO0lBQzNKLG9CQUFvQixDQUFDLEVBQUUsTUFBTSxDQUFDO0lBRTlCLDZKQUE2SjtJQUM3SixzQkFBc0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUVoQyw2SkFBNko7SUFDN0oscUJBQXFCLENBQUMsRUFBRSxNQUFNLENBQUM7SUFFL0IsMkpBQTJKO0lBQzNKLG9CQUFvQixDQUFDLEVBQUUsTUFBTSxDQUFDO0lBRTlCLCtKQUErSjtJQUMvSix1QkFBdUIsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUVqQywyR0FBMkc7SUFDM0csdUJBQXVCLENBQUMsRUFBRSxNQUFNLENBQUM7SUFFakMscUVBQXFFO0lBQ3JFLDJCQUEyQixFQUFFLE1BQU0sQ0FBQztDQUNyQztBQUVELGVBQU8sTUFBTSx3QkFBd0IsRUFBRSxrQkFBa0IsQ0FBQyxnQkFBZ0IsQ0EwRHpFLENBQUM7QUFFRjs7O0dBR0c7QUFDSCx3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3QkFBZ0IsMEJBQTBCLElBQUksZ0JBQWdCLENBRTdEIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/synchronizer/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAE9G,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,8BAA8B,EAAE,MAAM,CAAC;IAEvC,2FAA2F;IAC3F,+BAA+B,CAAC,EAAE,MAAM,CAAC;IAEzC,mJAAmJ;IACnJ,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,2JAA2J;IAC3J,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,6JAA6J;IAC7J,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,6JAA6J;IAC7J,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,2JAA2J;IAC3J,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,+JAA+J;IAC/J,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,2GAA2G;IAC3G,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,qEAAqE;IACrE,2BAA2B,EAAE,MAAM,CAAC;CACrC;AAED,eAAO,MAAM,wBAAwB,EAAE,kBAAkB,CAAC,gBAAgB,CA0DzE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,gBAAgB,CAE7D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/synchronizer/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAElC,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,8BAA8B,EAAE,MAAM,CAAC;IAEvC,2FAA2F;IAC3F,+BAA+B,CAAC,EAAE,MAAM,CAAC;IAEzC,mJAAmJ;IACnJ,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,2JAA2J;IAC3J,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,6JAA6J;IAC7J,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,6JAA6J;IAC7J,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,2JAA2J;IAC3J,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,+JAA+J;IAC/J,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,2GAA2G;IAC3G,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,qEAAqE;IACrE,2BAA2B,EAAE,MAAM,CAAC;CACrC;AAED,eAAO,MAAM,wBAAwB,EAAE,kBAAkB,CAAC,gBAAgB,CAyDzE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,gBAAgB,CAE7D"}
@@ -1,44 +1,43 @@
1
- import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
1
+ import { getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper } from '@aztec/foundation/config';
2
2
  export const worldStateConfigMappings = {
3
3
  worldStateBlockCheckIntervalMS: {
4
4
  env: 'WS_BLOCK_CHECK_INTERVAL_MS',
5
- parseEnv: (val)=>+val,
6
- defaultValue: 100,
5
+ ...numberConfigHelper(100),
7
6
  description: 'The frequency in which to check.'
8
7
  },
9
8
  worldStateBlockRequestBatchSize: {
10
9
  env: 'WS_BLOCK_REQUEST_BATCH_SIZE',
11
- parseEnv: (val)=>val ? +val : undefined,
10
+ ...optionalNumberConfigHelper(),
12
11
  description: 'Size of the batch for each get-blocks request from the synchronizer to the archiver.'
13
12
  },
14
13
  worldStateDbMapSizeKb: {
15
14
  env: 'WS_DB_MAP_SIZE_KB',
16
- parseEnv: (val)=>val ? +val : undefined,
15
+ ...optionalNumberConfigHelper(),
17
16
  description: 'The maximum possible size of the world state DB in KB. Overwrites the general dataStoreMapSizeKb.'
18
17
  },
19
18
  archiveTreeMapSizeKb: {
20
19
  env: 'ARCHIVE_TREE_MAP_SIZE_KB',
21
- parseEnv: (val)=>val ? +val : undefined,
20
+ ...optionalNumberConfigHelper(),
22
21
  description: 'The maximum possible size of the world state archive tree in KB. Overwrites the general worldStateDbMapSizeKb.'
23
22
  },
24
23
  nullifierTreeMapSizeKb: {
25
24
  env: 'NULLIFIER_TREE_MAP_SIZE_KB',
26
- parseEnv: (val)=>val ? +val : undefined,
25
+ ...optionalNumberConfigHelper(),
27
26
  description: 'The maximum possible size of the world state nullifier tree in KB. Overwrites the general worldStateDbMapSizeKb.'
28
27
  },
29
28
  noteHashTreeMapSizeKb: {
30
29
  env: 'NOTE_HASH_TREE_MAP_SIZE_KB',
31
- parseEnv: (val)=>val ? +val : undefined,
30
+ ...optionalNumberConfigHelper(),
32
31
  description: 'The maximum possible size of the world state note hash tree in KB. Overwrites the general worldStateDbMapSizeKb.'
33
32
  },
34
33
  messageTreeMapSizeKb: {
35
34
  env: 'MESSAGE_TREE_MAP_SIZE_KB',
36
- parseEnv: (val)=>val ? +val : undefined,
35
+ ...optionalNumberConfigHelper(),
37
36
  description: 'The maximum possible size of the world state message tree in KB. Overwrites the general worldStateDbMapSizeKb.'
38
37
  },
39
38
  publicDataTreeMapSizeKb: {
40
39
  env: 'PUBLIC_DATA_TREE_MAP_SIZE_KB',
41
- parseEnv: (val)=>val ? +val : undefined,
40
+ ...optionalNumberConfigHelper(),
42
41
  description: 'The maximum possible size of the world state public data tree in KB. Overwrites the general worldStateDbMapSizeKb.'
43
42
  },
44
43
  worldStateDataDirectory: {