@aztec/world-state 0.0.0-test.0 → 0.0.1-commit.023c3e5

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 (63) hide show
  1. package/dest/index.d.ts +1 -1
  2. package/dest/instrumentation/instrumentation.d.ts +6 -4
  3. package/dest/instrumentation/instrumentation.d.ts.map +1 -1
  4. package/dest/instrumentation/instrumentation.js +25 -41
  5. package/dest/native/bench_metrics.d.ts +23 -0
  6. package/dest/native/bench_metrics.d.ts.map +1 -0
  7. package/dest/native/bench_metrics.js +81 -0
  8. package/dest/native/fork_checkpoint.d.ts +1 -1
  9. package/dest/native/fork_checkpoint.d.ts.map +1 -1
  10. package/dest/native/index.d.ts +1 -1
  11. package/dest/native/merkle_trees_facade.d.ts +19 -7
  12. package/dest/native/merkle_trees_facade.d.ts.map +1 -1
  13. package/dest/native/merkle_trees_facade.js +76 -14
  14. package/dest/native/message.d.ts +74 -52
  15. package/dest/native/message.d.ts.map +1 -1
  16. package/dest/native/message.js +61 -61
  17. package/dest/native/native_world_state.d.ts +27 -19
  18. package/dest/native/native_world_state.d.ts.map +1 -1
  19. package/dest/native/native_world_state.js +103 -41
  20. package/dest/native/native_world_state_instance.d.ts +20 -4
  21. package/dest/native/native_world_state_instance.d.ts.map +1 -1
  22. package/dest/native/native_world_state_instance.js +42 -3
  23. package/dest/native/world_state_ops_queue.d.ts +1 -1
  24. package/dest/native/world_state_ops_queue.d.ts.map +1 -1
  25. package/dest/native/world_state_ops_queue.js +1 -1
  26. package/dest/synchronizer/config.d.ts +12 -4
  27. package/dest/synchronizer/config.d.ts.map +1 -1
  28. package/dest/synchronizer/config.js +27 -7
  29. package/dest/synchronizer/errors.d.ts +4 -0
  30. package/dest/synchronizer/errors.d.ts.map +1 -0
  31. package/dest/synchronizer/errors.js +5 -0
  32. package/dest/synchronizer/factory.d.ts +11 -3
  33. package/dest/synchronizer/factory.d.ts.map +1 -1
  34. package/dest/synchronizer/factory.js +13 -8
  35. package/dest/synchronizer/index.d.ts +1 -1
  36. package/dest/synchronizer/server_world_state_synchronizer.d.ts +21 -31
  37. package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
  38. package/dest/synchronizer/server_world_state_synchronizer.js +144 -92
  39. package/dest/test/index.d.ts +1 -1
  40. package/dest/test/utils.d.ts +12 -5
  41. package/dest/test/utils.d.ts.map +1 -1
  42. package/dest/test/utils.js +54 -47
  43. package/dest/testing.d.ts +3 -3
  44. package/dest/testing.d.ts.map +1 -1
  45. package/dest/testing.js +7 -11
  46. package/dest/world-state-db/index.d.ts +1 -1
  47. package/dest/world-state-db/merkle_tree_db.d.ts +12 -9
  48. package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
  49. package/package.json +24 -24
  50. package/src/instrumentation/instrumentation.ts +31 -43
  51. package/src/native/bench_metrics.ts +91 -0
  52. package/src/native/merkle_trees_facade.ts +83 -18
  53. package/src/native/message.ts +94 -74
  54. package/src/native/native_world_state.ts +132 -52
  55. package/src/native/native_world_state_instance.ts +62 -9
  56. package/src/native/world_state_ops_queue.ts +1 -1
  57. package/src/synchronizer/config.ts +48 -16
  58. package/src/synchronizer/errors.ts +5 -0
  59. package/src/synchronizer/factory.ts +38 -9
  60. package/src/synchronizer/server_world_state_synchronizer.ts +170 -117
  61. package/src/test/utils.ts +92 -82
  62. package/src/testing.ts +4 -8
  63. package/src/world-state-db/merkle_tree_db.ts +16 -8
package/src/testing.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
@@ -10,7 +10,6 @@ async function generateGenesisValues(prefilledPublicData: PublicDataTreeLeaf[])
10
10
  if (!prefilledPublicData.length) {
11
11
  return {
12
12
  genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT),
13
- genesisBlockHash: new Fr(GENESIS_BLOCK_HASH),
14
13
  };
15
14
  }
16
15
 
@@ -20,14 +19,11 @@ async function generateGenesisValues(prefilledPublicData: PublicDataTreeLeaf[])
20
19
  true /* cleanupTmpDir */,
21
20
  prefilledPublicData,
22
21
  );
23
- const initialHeader = ws.getInitialHeader();
24
- const genesisBlockHash = await initialHeader.hash();
25
22
  const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
26
23
  await ws.close();
27
24
 
28
25
  return {
29
26
  genesisArchiveRoot,
30
- genesisBlockHash,
31
27
  };
32
28
  }
33
29
 
@@ -50,11 +46,11 @@ export async function getGenesisValues(
50
46
 
51
47
  prefilledPublicData.sort((a, b) => (b.slot.lt(a.slot) ? 1 : -1));
52
48
 
53
- const { genesisBlockHash, genesisArchiveRoot } = await generateGenesisValues(prefilledPublicData);
49
+ const { genesisArchiveRoot } = await generateGenesisValues(prefilledPublicData);
54
50
 
55
51
  return {
56
52
  genesisArchiveRoot,
57
- genesisBlockHash,
58
53
  prefilledPublicData,
54
+ fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt(),
59
55
  };
60
56
  }
@@ -1,8 +1,13 @@
1
1
  import { MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/fields';
2
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import type { IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree';
4
5
  import type { L2Block } from '@aztec/stdlib/block';
5
- import type { ForkMerkleTreeOperations, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
6
+ import type {
7
+ ForkMerkleTreeOperations,
8
+ MerkleTreeReadOperations,
9
+ ReadonlyWorldStateAccess,
10
+ } from '@aztec/stdlib/interfaces/server';
6
11
  import type { MerkleTreeId } from '@aztec/stdlib/trees';
7
12
 
8
13
  import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
@@ -34,7 +39,7 @@ export type TreeSnapshots = {
34
39
  [MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
35
40
  };
36
41
 
37
- export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
42
+ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, ReadonlyWorldStateAccess {
38
43
  /**
39
44
  * Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
40
45
  * @param block - The L2 block to handle.
@@ -52,21 +57,21 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
52
57
  * @param toBlockNumber The block number of the new oldest historical block
53
58
  * @returns The new WorldStateStatus
54
59
  */
55
- removeHistoricalBlocks(toBlockNumber: bigint): Promise<WorldStateStatusFull>;
60
+ removeHistoricalBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
56
61
 
57
62
  /**
58
63
  * Removes all pending blocks down to but not including the given block number
59
64
  * @param toBlockNumber The block number of the new tip of the pending chain,
60
65
  * @returns The new WorldStateStatus
61
66
  */
62
- unwindBlocks(toBlockNumber: bigint): Promise<WorldStateStatusFull>;
67
+ unwindBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
63
68
 
64
69
  /**
65
- * Advances the finalised block number to be the number provided
66
- * @param toBlockNumber The block number that is now the tip of the finalised chain
70
+ * Advances the finalized block number to be the number provided
71
+ * @param toBlockNumber The block number that is now the tip of the finalized chain
67
72
  * @returns The new WorldStateStatus
68
73
  */
69
- setFinalised(toBlockNumber: bigint): Promise<WorldStateStatusSummary>;
74
+ setFinalized(toBlockNumber: BlockNumber): Promise<WorldStateStatusSummary>;
70
75
 
71
76
  /**
72
77
  * Gets the current status summary of the database.
@@ -76,4 +81,7 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
76
81
 
77
82
  /** Stops the database */
78
83
  close(): Promise<void>;
84
+
85
+ /** Deletes the db. */
86
+ clear(): Promise<void>;
79
87
  }