@aztec/world-state 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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/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 +2 -1
  11. package/dest/native/index.d.ts.map +1 -1
  12. package/dest/native/index.js +1 -0
  13. package/dest/native/ipc_world_state_instance.d.ts +89 -0
  14. package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
  15. package/dest/native/ipc_world_state_instance.js +661 -0
  16. package/dest/native/merkle_trees_facade.d.ts +18 -9
  17. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  18. package/dest/native/merkle_trees_facade.js +90 -113
  19. package/dest/native/message.d.ts +15 -222
  20. package/dest/native/message.d.ts.map +1 -1
  21. package/dest/native/message.js +1 -43
  22. package/dest/native/native_world_state.d.ts +26 -12
  23. package/dest/native/native_world_state.d.ts.map +1 -1
  24. package/dest/native/native_world_state.js +126 -62
  25. package/dest/native/native_world_state_instance.d.ts +56 -42
  26. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  27. package/dest/native/native_world_state_instance.js +1 -203
  28. package/dest/native/world_state_operation.d.ts +7 -0
  29. package/dest/native/world_state_operation.d.ts.map +1 -0
  30. package/dest/native/world_state_operation.js +5 -0
  31. package/dest/synchronizer/config.d.ts +3 -5
  32. package/dest/synchronizer/config.d.ts.map +1 -1
  33. package/dest/synchronizer/config.js +15 -18
  34. package/dest/synchronizer/errors.d.ts +8 -1
  35. package/dest/synchronizer/errors.d.ts.map +1 -1
  36. package/dest/synchronizer/errors.js +8 -1
  37. package/dest/synchronizer/factory.d.ts +6 -5
  38. package/dest/synchronizer/factory.d.ts.map +1 -1
  39. package/dest/synchronizer/factory.js +7 -6
  40. package/dest/synchronizer/index.d.ts +2 -1
  41. package/dest/synchronizer/index.d.ts.map +1 -1
  42. package/dest/synchronizer/index.js +1 -0
  43. package/dest/synchronizer/server_world_state_synchronizer.d.ts +16 -10
  44. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  45. package/dest/synchronizer/server_world_state_synchronizer.js +170 -57
  46. package/dest/test/utils.d.ts +11 -17
  47. package/dest/test/utils.d.ts.map +1 -1
  48. package/dest/test/utils.js +49 -81
  49. package/dest/testing.d.ts +5 -4
  50. package/dest/testing.d.ts.map +1 -1
  51. package/dest/testing.js +15 -8
  52. package/dest/world-state-db/merkle_tree_db.d.ts +7 -18
  53. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  54. package/package.json +14 -12
  55. package/src/index.ts +1 -0
  56. package/src/instrumentation/instrumentation.ts +23 -59
  57. package/src/native/fork_checkpoint.ts +19 -3
  58. package/src/native/index.ts +1 -0
  59. package/src/native/ipc_world_state_instance.ts +834 -0
  60. package/src/native/merkle_trees_facade.ts +119 -106
  61. package/src/native/message.ts +14 -287
  62. package/src/native/native_world_state.ts +159 -99
  63. package/src/native/native_world_state_instance.ts +94 -279
  64. package/src/native/world_state_operation.ts +33 -0
  65. package/src/synchronizer/config.ts +16 -23
  66. package/src/synchronizer/errors.ts +8 -0
  67. package/src/synchronizer/factory.ts +18 -11
  68. package/src/synchronizer/index.ts +1 -0
  69. package/src/synchronizer/server_world_state_synchronizer.ts +203 -78
  70. package/src/test/utils.ts +79 -128
  71. package/src/testing.ts +13 -11
  72. package/src/world-state-db/merkle_tree_db.ts +10 -22
  73. package/dest/native/world_state_ops_queue.d.ts +0 -19
  74. package/dest/native/world_state_ops_queue.d.ts.map +0 -1
  75. package/dest/native/world_state_ops_queue.js +0 -146
  76. package/dest/synchronizer/utils.d.ts +0 -11
  77. package/dest/synchronizer/utils.d.ts.map +0 -1
  78. package/dest/synchronizer/utils.js +0 -59
  79. package/src/native/world_state_ops_queue.ts +0 -190
  80. package/src/synchronizer/utils.ts +0 -83
package/dest/testing.js CHANGED
@@ -1,16 +1,19 @@
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
- // Create a temporary world state to compute the genesis values.
13
- const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */ , true, prefilledPublicData);
12
+ // Compute the genesis values on a throwaway world state. The archive root derives only from the
13
+ // prefilled public data and the genesis timestamp, so the fsync-off ephemeral store (no version
14
+ // manager, no crash-recoverability) produces an identical root while skipping the fsync overhead
15
+ // that `tmp` pays. close() removes the tmpdir.
16
+ const ws = await NativeWorldStateService.ephemeral(genesis);
14
17
  const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
15
18
  await ws.close();
16
19
  return {
@@ -18,16 +21,20 @@ async function generateGenesisValues(prefilledPublicData) {
18
21
  };
19
22
  }
20
23
  export const defaultInitialAccountFeeJuice = new Fr(10n ** 22n);
21
- export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = []) {
24
+ export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = [], genesisTimestamp = 0n) {
22
25
  // Top up the accounts with fee juice.
23
26
  let prefilledPublicData = await Promise.all(initialAccounts.map(async (address)=>new PublicDataTreeLeaf(await computeFeePayerBalanceLeafSlot(address), initialAccountFeeJuice)));
24
27
  // Add user-defined public data
25
28
  prefilledPublicData = prefilledPublicData.concat(genesisPublicData);
26
29
  prefilledPublicData.sort((a, b)=>b.slot.lt(a.slot) ? 1 : -1);
27
- const { genesisArchiveRoot } = await generateGenesisValues(prefilledPublicData);
30
+ const genesis = {
31
+ prefilledPublicData,
32
+ genesisTimestamp
33
+ };
34
+ const { genesisArchiveRoot } = await generateGenesisValues(genesis);
28
35
  return {
29
36
  genesisArchiveRoot,
30
- prefilledPublicData,
37
+ genesis,
31
38
  fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt()
32
39
  };
33
40
  }
@@ -1,9 +1,7 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { Fr } from '@aztec/foundation/fields';
3
- import type { IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree';
4
- import type { L2BlockNew } from '@aztec/stdlib/block';
5
- import type { ForkMerkleTreeOperations, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
6
- import type { MerkleTreeId } from '@aztec/stdlib/trees';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { L2Block } from '@aztec/stdlib/block';
4
+ import type { ForkMerkleTreeOperations, MerkleTreeReadOperations, ReadonlyWorldStateAccess } from '@aztec/stdlib/interfaces/server';
7
5
  import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
8
6
  /**
9
7
  *
@@ -22,22 +20,13 @@ import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/me
22
20
  */
23
21
  export declare const INITIAL_NULLIFIER_TREE_SIZE: number;
24
22
  export declare const INITIAL_PUBLIC_DATA_TREE_SIZE: number;
25
- export type TreeSnapshots = {
26
- [MerkleTreeId.NULLIFIER_TREE]: IndexedTreeSnapshot;
27
- [MerkleTreeId.NOTE_HASH_TREE]: TreeSnapshot<Fr>;
28
- [MerkleTreeId.PUBLIC_DATA_TREE]: IndexedTreeSnapshot;
29
- [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: TreeSnapshot<Fr>;
30
- [MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
31
- };
32
- export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
23
+ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, ReadonlyWorldStateAccess {
33
24
  /**
34
25
  * Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
35
26
  * @param block - The L2 block to handle.
36
27
  * @param l1ToL2Messages - The L1 to L2 messages for the block.
37
- * @param isFirstBlock - Whether the block is the first block in a checkpoint. The messages are padded and inserted
38
- * to the tree for the first block in a checkpoint.
39
28
  */
40
- handleL2BlockAndMessages(block: L2BlockNew, l1ToL2Messages: Fr[], isFirstBlock: boolean): Promise<WorldStateStatusFull>;
29
+ handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
41
30
  /**
42
31
  * Gets a handle that allows reading the latest committed state
43
32
  */
@@ -70,4 +59,4 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
70
59
  /** Deletes the db. */
71
60
  clear(): Promise<void>;
72
61
  }
73
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVya2xlX3RyZWVfZGIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93b3JsZC1zdGF0ZS1kYi9tZXJrbGVfdHJlZV9kYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU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AA6B,QAAmD,CAAC;AAE9F,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB,EAAE,wBAAwB;IACjG;;;;OAIG;IACH,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE9F;;OAEG;IACH,YAAY,IAAI,wBAAwB,CAAC;IAEzC;;;;OAIG;IACH,sBAAsB,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAElF;;;;OAIG;IACH,YAAY,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAExE;;;;OAIG;IACH,YAAY,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE3E;;;OAGG;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.d3ec352c",
3
+ "version": "0.0.1-commit.d58ff9d0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -64,23 +64,25 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/constants": "0.0.1-commit.d3ec352c",
68
- "@aztec/foundation": "0.0.1-commit.d3ec352c",
69
- "@aztec/kv-store": "0.0.1-commit.d3ec352c",
70
- "@aztec/merkle-tree": "0.0.1-commit.d3ec352c",
71
- "@aztec/native": "0.0.1-commit.d3ec352c",
72
- "@aztec/protocol-contracts": "0.0.1-commit.d3ec352c",
73
- "@aztec/stdlib": "0.0.1-commit.d3ec352c",
74
- "@aztec/telemetry-client": "0.0.1-commit.d3ec352c",
67
+ "@aztec/bb.js": "0.0.1-commit.d58ff9d0",
68
+ "@aztec/constants": "0.0.1-commit.d58ff9d0",
69
+ "@aztec/foundation": "0.0.1-commit.d58ff9d0",
70
+ "@aztec/kv-store": "0.0.1-commit.d58ff9d0",
71
+ "@aztec/protocol-contracts": "0.0.1-commit.d58ff9d0",
72
+ "@aztec/stdlib": "0.0.1-commit.d58ff9d0",
73
+ "@aztec/telemetry-client": "0.0.1-commit.d58ff9d0",
74
+ "@aztec/wsdb": "0.0.1-commit.d58ff9d0",
75
+ "msgpackr": "^1.11.2",
75
76
  "tslib": "^2.4.0",
76
- "zod": "^3.23.8"
77
+ "zod": "^4"
77
78
  },
78
79
  "devDependencies": {
79
- "@aztec/archiver": "0.0.1-commit.d3ec352c",
80
+ "@aztec/archiver": "0.0.1-commit.d58ff9d0",
81
+ "@aztec/ipc-runtime": "0.0.1-commit.d58ff9d0",
80
82
  "@jest/globals": "^30.0.0",
81
83
  "@types/jest": "^30.0.0",
82
84
  "@types/node": "^22.15.17",
83
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
85
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
84
86
  "jest": "^30.0.0",
85
87
  "jest-mock-extended": "^4.0.0",
86
88
  "ts-node": "^10.9.1",
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from './synchronizer/index.js';
2
2
  export * from './world-state-db/index.js';
3
3
  export * from './synchronizer/config.js';
4
4
  export * from './native/index.js';
5
+ export { WorldStateInstrumentation } from './instrumentation/instrumentation.js';
@@ -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
  }
@@ -1,2 +1,3 @@
1
1
  export * from './native_world_state.js';
2
2
  export * from './fork_checkpoint.js';
3
+ export { IpcWorldState, getWsdbOptions } from './ipc_world_state_instance.js';