@aztec/world-state 3.0.3 → 3.9.9-nightly.20260312

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 (39) hide show
  1. package/dest/instrumentation/instrumentation.d.ts +1 -1
  2. package/dest/instrumentation/instrumentation.d.ts.map +1 -1
  3. package/dest/instrumentation/instrumentation.js +17 -41
  4. package/dest/native/merkle_trees_facade.d.ts +7 -2
  5. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  6. package/dest/native/merkle_trees_facade.js +34 -5
  7. package/dest/native/message.d.ts +3 -2
  8. package/dest/native/message.d.ts.map +1 -1
  9. package/dest/native/native_world_state.d.ts +10 -8
  10. package/dest/native/native_world_state.d.ts.map +1 -1
  11. package/dest/native/native_world_state.js +11 -10
  12. package/dest/native/native_world_state_instance.d.ts +3 -3
  13. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  14. package/dest/native/native_world_state_instance.js +4 -4
  15. package/dest/synchronizer/config.d.ts +3 -5
  16. package/dest/synchronizer/config.d.ts.map +1 -1
  17. package/dest/synchronizer/config.js +7 -9
  18. package/dest/synchronizer/factory.d.ts +4 -3
  19. package/dest/synchronizer/factory.d.ts.map +1 -1
  20. package/dest/synchronizer/factory.js +5 -5
  21. package/dest/synchronizer/server_world_state_synchronizer.d.ts +5 -4
  22. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  23. package/dest/synchronizer/server_world_state_synchronizer.js +84 -36
  24. package/dest/test/utils.d.ts +7 -7
  25. package/dest/test/utils.d.ts.map +1 -1
  26. package/dest/test/utils.js +10 -6
  27. package/dest/world-state-db/merkle_tree_db.d.ts +5 -5
  28. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  29. package/package.json +11 -11
  30. package/src/instrumentation/instrumentation.ts +17 -41
  31. package/src/native/merkle_trees_facade.ts +35 -2
  32. package/src/native/message.ts +2 -1
  33. package/src/native/native_world_state.ts +27 -11
  34. package/src/native/native_world_state_instance.ts +6 -4
  35. package/src/synchronizer/config.ts +8 -19
  36. package/src/synchronizer/factory.ts +7 -1
  37. package/src/synchronizer/server_world_state_synchronizer.ts +86 -47
  38. package/src/test/utils.ts +8 -7
  39. package/src/world-state-db/merkle_tree_db.ts +8 -4
package/src/test/utils.ts CHANGED
@@ -5,10 +5,10 @@ import {
5
5
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
6
6
  } from '@aztec/constants';
7
7
  import { asyncMap } from '@aztec/foundation/async-map';
8
- import { BlockNumber, type CheckpointNumber } from '@aztec/foundation/branded-types';
8
+ import { BlockNumber, type CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
9
9
  import { padArrayEnd } from '@aztec/foundation/collection';
10
10
  import { Fr } from '@aztec/foundation/curves/bn254';
11
- import { L2BlockNew } from '@aztec/stdlib/block';
11
+ import { L2Block } from '@aztec/stdlib/block';
12
12
  import type {
13
13
  IndexedTreeId,
14
14
  MerkleTreeReadOperations,
@@ -16,10 +16,11 @@ import type {
16
16
  } from '@aztec/stdlib/interfaces/server';
17
17
  import { mockCheckpointAndMessages, mockL1ToL2Messages } from '@aztec/stdlib/testing';
18
18
  import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
19
+ import { BlockHeader } from '@aztec/stdlib/tx';
19
20
 
20
21
  import type { NativeWorldStateService } from '../native/native_world_state.js';
21
22
 
22
- export async function updateBlockState(block: L2BlockNew, l1ToL2Messages: Fr[], fork: MerkleTreeWriteOperations) {
23
+ export async function updateBlockState(block: L2Block, l1ToL2Messages: Fr[], fork: MerkleTreeWriteOperations) {
23
24
  const insertData = async (
24
25
  treeId: IndexedTreeId,
25
26
  data: Buffer[][],
@@ -59,7 +60,7 @@ export async function updateBlockState(block: L2BlockNew, l1ToL2Messages: Fr[],
59
60
  await Promise.all([publicDataInsert, nullifierInsert, noteHashInsert, messageInsert]);
60
61
 
61
62
  const state = await fork.getStateReference();
62
- block.header.state = state;
63
+ block.header = BlockHeader.from({ ...block.header, state });
63
64
  await fork.updateArchive(block.header);
64
65
 
65
66
  const archiveState = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
@@ -75,8 +76,8 @@ export async function mockBlock(
75
76
  numL1ToL2Messages: number = NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
76
77
  isFirstBlockInCheckpoint: boolean = true,
77
78
  ) {
78
- const block = await L2BlockNew.random(blockNum, {
79
- indexWithinCheckpoint: isFirstBlockInCheckpoint ? 0 : 1,
79
+ const block = await L2Block.random(blockNum, {
80
+ indexWithinCheckpoint: isFirstBlockInCheckpoint ? IndexWithinCheckpoint(0) : IndexWithinCheckpoint(1),
80
81
  txsPerBlock: size,
81
82
  txOptions: { maxEffects },
82
83
  });
@@ -91,7 +92,7 @@ export async function mockBlock(
91
92
  }
92
93
 
93
94
  export async function mockEmptyBlock(blockNum: BlockNumber, fork: MerkleTreeWriteOperations) {
94
- const l2Block = L2BlockNew.empty();
95
+ const l2Block = L2Block.empty();
95
96
  const l1ToL2Messages = Array(16).fill(0).map(Fr.zero);
96
97
 
97
98
  l2Block.header.globalVariables.blockNumber = blockNum;
@@ -2,8 +2,12 @@ import { MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } f
2
2
  import type { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree';
5
- import type { L2BlockNew } from '@aztec/stdlib/block';
6
- import type { ForkMerkleTreeOperations, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
5
+ import type { L2Block } from '@aztec/stdlib/block';
6
+ import type {
7
+ ForkMerkleTreeOperations,
8
+ MerkleTreeReadOperations,
9
+ ReadonlyWorldStateAccess,
10
+ } from '@aztec/stdlib/interfaces/server';
7
11
  import type { MerkleTreeId } from '@aztec/stdlib/trees';
8
12
 
9
13
  import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
@@ -35,13 +39,13 @@ export type TreeSnapshots = {
35
39
  [MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
36
40
  };
37
41
 
38
- export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
42
+ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, ReadonlyWorldStateAccess {
39
43
  /**
40
44
  * Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
41
45
  * @param block - The L2 block to handle.
42
46
  * @param l1ToL2Messages - The L1 to L2 messages for the block.
43
47
  */
44
- handleL2BlockAndMessages(block: L2BlockNew, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
48
+ handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
45
49
 
46
50
  /**
47
51
  * Gets a handle that allows reading the latest committed state