@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.e310a4c8

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 (175) hide show
  1. package/dest/bin/check_oracle_version.js +1 -1
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +7 -5
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +56 -16
  5. package/dest/config/index.d.ts +3 -1
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +17 -0
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +2 -4
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +8 -13
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  12. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  13. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  14. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  15. package/dest/contract_function_simulator/oracle/interfaces.d.ts +13 -10
  16. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -3
  18. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/oracle/oracle.js +28 -18
  20. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  21. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
  23. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -3
  24. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +19 -8
  26. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +29 -17
  27. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +47 -45
  29. package/dest/contract_sync/index.d.ts +23 -0
  30. package/dest/contract_sync/index.d.ts.map +1 -0
  31. package/dest/contract_sync/index.js +54 -0
  32. package/dest/debug/pxe_debug_utils.d.ts +16 -6
  33. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  34. package/dest/debug/pxe_debug_utils.js +20 -10
  35. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  36. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  37. package/dest/entrypoints/client/bundle/utils.js +12 -6
  38. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  39. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  40. package/dest/entrypoints/client/lazy/utils.js +13 -7
  41. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  42. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  43. package/dest/entrypoints/server/index.d.ts +2 -1
  44. package/dest/entrypoints/server/index.d.ts.map +1 -1
  45. package/dest/entrypoints/server/index.js +1 -0
  46. package/dest/entrypoints/server/utils.d.ts +1 -1
  47. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  48. package/dest/entrypoints/server/utils.js +19 -8
  49. package/dest/events/event_service.d.ts +5 -6
  50. package/dest/events/event_service.d.ts.map +1 -1
  51. package/dest/events/event_service.js +6 -7
  52. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  53. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  54. package/dest/job_coordinator/job_coordinator.js +3 -2
  55. package/dest/logs/log_service.d.ts +5 -4
  56. package/dest/logs/log_service.d.ts.map +1 -1
  57. package/dest/logs/log_service.js +18 -15
  58. package/dest/notes/note_service.d.ts +6 -6
  59. package/dest/notes/note_service.d.ts.map +1 -1
  60. package/dest/notes/note_service.js +14 -14
  61. package/dest/oracle_version.d.ts +3 -3
  62. package/dest/oracle_version.d.ts.map +1 -1
  63. package/dest/oracle_version.js +4 -3
  64. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  65. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  66. package/dest/private_kernel/private_kernel_execution_prover.js +2 -2
  67. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -3
  68. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  69. package/dest/pxe.d.ts +1 -1
  70. package/dest/pxe.d.ts.map +1 -1
  71. package/dest/pxe.js +19 -15
  72. package/dest/storage/address_store/address_store.d.ts +1 -1
  73. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  74. package/dest/storage/address_store/address_store.js +12 -11
  75. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  76. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  77. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  78. package/dest/storage/capsule_store/capsule_store.js +6 -8
  79. package/dest/storage/contract_store/contract_store.d.ts +1 -2
  80. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  81. package/dest/storage/contract_store/contract_store.js +22 -25
  82. package/dest/storage/metadata.d.ts +1 -1
  83. package/dest/storage/metadata.js +1 -1
  84. package/dest/storage/note_store/note_store.d.ts +48 -50
  85. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  86. package/dest/storage/note_store/note_store.js +276 -252
  87. package/dest/storage/note_store/stored_note.d.ts +16 -0
  88. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  89. package/dest/storage/note_store/stored_note.js +43 -0
  90. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  91. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  92. package/dest/storage/private_event_store/private_event_store.js +198 -147
  93. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  94. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  95. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  96. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +1 -1
  97. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  98. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  99. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  100. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  101. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  102. package/dest/storage/tagging_store/sender_tagging_store.d.ts +1 -1
  103. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  104. package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
  105. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  106. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  107. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  108. package/dest/tagging/index.d.ts +2 -1
  109. package/dest/tagging/index.d.ts.map +1 -1
  110. package/dest/tagging/index.js +1 -0
  111. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
  112. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  113. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +2 -2
  114. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
  115. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  116. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
  117. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
  118. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  119. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +2 -2
  120. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  121. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  122. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  123. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +3 -2
  124. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  125. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +7 -4
  126. package/package.json +16 -16
  127. package/src/bin/check_oracle_version.ts +1 -0
  128. package/src/block_synchronizer/block_synchronizer.ts +70 -33
  129. package/src/config/index.ts +14 -0
  130. package/src/contract_function_simulator/contract_function_simulator.ts +7 -15
  131. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  132. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  133. package/src/contract_function_simulator/oracle/interfaces.ts +18 -9
  134. package/src/contract_function_simulator/oracle/oracle.ts +42 -19
  135. package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
  136. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -10
  137. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +67 -53
  138. package/src/contract_sync/index.ts +98 -0
  139. package/src/debug/pxe_debug_utils.ts +26 -11
  140. package/src/entrypoints/client/bundle/utils.ts +7 -14
  141. package/src/entrypoints/client/lazy/utils.ts +8 -14
  142. package/src/entrypoints/pxe_creation_options.ts +2 -1
  143. package/src/entrypoints/server/index.ts +1 -0
  144. package/src/entrypoints/server/utils.ts +15 -19
  145. package/src/events/event_service.ts +5 -7
  146. package/src/job_coordinator/job_coordinator.ts +4 -3
  147. package/src/logs/log_service.ts +29 -13
  148. package/src/notes/note_service.ts +21 -20
  149. package/src/oracle_version.ts +4 -3
  150. package/src/private_kernel/private_kernel_execution_prover.ts +6 -3
  151. package/src/private_kernel/private_kernel_oracle.ts +2 -2
  152. package/src/pxe.ts +48 -17
  153. package/src/storage/address_store/address_store.ts +15 -15
  154. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  155. package/src/storage/capsule_store/capsule_store.ts +8 -8
  156. package/src/storage/contract_store/contract_store.ts +22 -31
  157. package/src/storage/metadata.ts +1 -1
  158. package/src/storage/note_store/note_store.ts +314 -318
  159. package/src/storage/note_store/stored_note.ts +48 -0
  160. package/src/storage/private_event_store/private_event_store.ts +250 -190
  161. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  162. package/src/storage/tagging_store/recipient_tagging_store.ts +31 -21
  163. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  164. package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
  165. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  166. package/src/tagging/index.ts +1 -0
  167. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +11 -1
  168. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
  169. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +3 -1
  170. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
  171. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +12 -3
  172. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  173. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  174. package/dest/tree_membership/tree_membership_service.js +0 -75
  175. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -1,5 +1,6 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHash } from '@aztec/stdlib/block';
3
4
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
5
  import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
6
 
@@ -21,6 +22,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
21
22
  aztecNode: AztecNode,
22
23
  taggingStore: RecipientTaggingStore,
23
24
  anchorBlockNumber: BlockNumber,
25
+ anchorBlockHash: BlockHash,
24
26
  jobId: string,
25
27
  ): Promise<TxScopedL2Log[]> {
26
28
  // # Explanation of how the algorithm works
@@ -92,7 +94,15 @@ export async function loadPrivateLogsForSenderRecipientPair(
92
94
 
93
95
  while (true) {
94
96
  // Get private logs with their block timestamps and corresponding tagging indexes
95
- const privateLogsWithIndexes = await loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber);
97
+ const privateLogsWithIndexes = await loadLogsForRange(
98
+ secret,
99
+ app,
100
+ aztecNode,
101
+ start,
102
+ end,
103
+ anchorBlockNumber,
104
+ anchorBlockHash,
105
+ );
96
106
 
97
107
  if (privateLogsWithIndexes.length === 0) {
98
108
  break;
@@ -1,9 +1,12 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHash } from '@aztec/stdlib/block';
3
4
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
5
  import type { DirectionalAppTaggingSecret, PreTag, TxScopedL2Log } from '@aztec/stdlib/logs';
5
6
  import { SiloedTag, Tag } from '@aztec/stdlib/logs';
6
7
 
8
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
9
+
7
10
  /**
8
11
  * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
9
12
  * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
@@ -16,6 +19,7 @@ export async function loadLogsForRange(
16
19
  start: number,
17
20
  end: number,
18
21
  anchorBlockNumber: BlockNumber,
22
+ anchorBlockHash: BlockHash,
19
23
  ): Promise<Array<{ log: TxScopedL2Log; taggingIndex: number }>> {
20
24
  // Derive tags for the window
21
25
  const preTags: PreTag[] = Array(end - start)
@@ -25,7 +29,9 @@ export async function loadLogsForRange(
25
29
  Promise.all(tags.map(tag => SiloedTag.compute(tag, app))),
26
30
  );
27
31
 
28
- const logs = await aztecNode.getPrivateLogsByTags(siloedTags);
32
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
33
+ // pagination here.
34
+ const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
29
35
 
30
36
  // Pair logs with their corresponding tagging indexes
31
37
  const logsWithIndexes: Array<{ log: TxScopedL2Log; taggingIndex: number }> = [];
@@ -1,4 +1,5 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
2
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
4
  import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
5
 
@@ -26,6 +27,7 @@ export async function syncSenderTaggingIndexes(
26
27
  app: AztecAddress,
27
28
  aztecNode: AztecNode,
28
29
  taggingStore: SenderTaggingStore,
30
+ anchorBlockHash: BlockHash,
29
31
  jobId: string,
30
32
  ): Promise<void> {
31
33
  // # Explanation of how syncing works
@@ -57,7 +59,7 @@ export async function syncSenderTaggingIndexes(
57
59
  while (true) {
58
60
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
59
61
  // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
60
- await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, jobId);
62
+ await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
61
63
 
62
64
  // Retrieve all indexes within the current window from storage and update their status accordingly.
63
65
  const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
@@ -9,11 +9,8 @@ export async function getStatusChangeOfPending(
9
9
  pending: TxHash[],
10
10
  aztecNode: AztecNode,
11
11
  ): Promise<{ txHashesToFinalize: TxHash[]; txHashesToDrop: TxHash[] }> {
12
- // Get receipts for all pending tx hashes and the finalized block number.
13
- const [receipts, tips] = await Promise.all([
14
- Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash))),
15
- aztecNode.getL2Tips(),
16
- ]);
12
+ // Get receipts for all pending tx hashes.
13
+ const receipts = await Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash)));
17
14
 
18
15
  const txHashesToFinalize: TxHash[] = [];
19
16
  const txHashesToDrop: TxHash[] = [];
@@ -22,25 +19,16 @@ export async function getStatusChangeOfPending(
22
19
  const receipt = receipts[i];
23
20
  const txHash = pending[i];
24
21
 
25
- if (
26
- receipt.status === TxStatus.SUCCESS &&
27
- receipt.blockNumber &&
28
- receipt.blockNumber <= tips.finalized.block.number
29
- ) {
22
+ if (receipt.status === TxStatus.FINALIZED && receipt.hasExecutionSucceeded()) {
30
23
  // Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
31
24
  // finalized.
32
25
  txHashesToFinalize.push(txHash);
33
- } else if (
34
- receipt.status === TxStatus.DROPPED ||
35
- receipt.status === TxStatus.APP_LOGIC_REVERTED ||
36
- receipt.status === TxStatus.TEARDOWN_REVERTED ||
37
- receipt.status === TxStatus.BOTH_REVERTED
38
- ) {
26
+ } else if (receipt.isDropped() || receipt.hasExecutionReverted()) {
39
27
  // Tx was dropped or reverted --> we drop the corresponding pending indexes.
40
28
  // TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
41
29
  txHashesToDrop.push(txHash);
42
30
  } else {
43
- // Tx is still pending or the corresponding block is not yet finalized --> we don't do anything.
31
+ // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
44
32
  }
45
33
  }
46
34
 
@@ -1,10 +1,12 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
2
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
4
  import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
4
5
  import { SiloedTag, Tag } from '@aztec/stdlib/logs';
5
6
  import { TxHash } from '@aztec/stdlib/tx';
6
7
 
7
8
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
9
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
8
10
 
9
11
  /**
10
12
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
@@ -27,6 +29,7 @@ export async function loadAndStoreNewTaggingIndexes(
27
29
  end: number,
28
30
  aztecNode: AztecNode,
29
31
  taggingStore: SenderTaggingStore,
32
+ anchorBlockHash: BlockHash,
30
33
  jobId: string,
31
34
  ) {
32
35
  // We compute the tags for the current window of indexes
@@ -37,7 +40,7 @@ export async function loadAndStoreNewTaggingIndexes(
37
40
  preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
38
41
  );
39
42
 
40
- const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode);
43
+ const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
41
44
  const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
42
45
 
43
46
  // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
@@ -49,8 +52,14 @@ export async function loadAndStoreNewTaggingIndexes(
49
52
 
50
53
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
51
54
  // an array for each tag.
52
- async function getTxsContainingTags(tags: SiloedTag[], aztecNode: AztecNode): Promise<TxHash[][]> {
53
- const allLogs = await aztecNode.getPrivateLogsByTags(tags);
55
+ async function getTxsContainingTags(
56
+ tags: SiloedTag[],
57
+ aztecNode: AztecNode,
58
+ anchorBlockHash: BlockHash,
59
+ ): Promise<TxHash[][]> {
60
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
61
+ // pagination here.
62
+ const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
54
63
  return allLogs.map(logs => logs.map(log => log.txHash));
55
64
  }
56
65
 
@@ -1,50 +0,0 @@
1
- import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
3
- import type { SiblingPath } from '@aztec/foundation/trees';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { L2BlockHash } from '@aztec/stdlib/block';
6
- import type { AztecNode } from '@aztec/stdlib/interfaces/server';
7
- import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
8
- export declare class TreeMembershipService {
9
- #private;
10
- private readonly aztecNode;
11
- constructor(aztecNode: AztecNode);
12
- /**
13
- * Gets the index of a nullifier in the nullifier tree.
14
- * @returns - The index of the nullifier. Undefined if it does not exist in the tree.
15
- */
16
- getNullifierIndex(nullifier: Fr): Promise<bigint | undefined>;
17
- /**
18
- * Fetches the index and sibling path of a leaf at a given block from a given tree.
19
- * @param blockHash - The block hash at which to get the membership witness.
20
- * @param treeId - Id of the tree to get the sibling path from.
21
- * @param leafValue - The leaf value
22
- * @returns The index and sibling path concatenated [index, sibling_path]
23
- */
24
- getMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]>;
25
- /**
26
- * Returns a low nullifier membership witness for a given nullifier at a given block.
27
- * @param blockHash - The block hash at which to get the index.
28
- * @param nullifier - Nullifier we try to find the low nullifier witness for.
29
- * @returns The low nullifier membership witness (if found).
30
- * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
31
- * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
32
- * we are trying to prove non-inclusion for.
33
- */
34
- getLowNullifierMembershipWitness(blockHash: L2BlockHash, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
35
- /**
36
- * Returns a witness for a given slot of the public data tree at a given block.
37
- * @param blockHash - The block hash at which to get the witness.
38
- * @param leafSlot - The slot of the public data in the public data tree.
39
- */
40
- getPublicDataWitness(blockHash: L2BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
41
- /**
42
- * Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
43
- * @param contractAddress - Address of a contract by which the message was emitted.
44
- * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
45
- * The message nullifier is computed locally, so the secret is not sent to the node.
46
- * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
47
- */
48
- getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: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E,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMlG,qBAAa,qBAAqB;;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAtC,YAA6B,SAAS,EAAE,SAAS,EAAI;IAErD;;;OAGG;IACU,iBAAiB,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAGzE;IAED;;;;;;OAMG;IACU,oBAAoB,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAQ5G;IAED;;;;;;;;OAQG;IACI,gCAAgC,CACrC,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,EAAE,GACZ,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAEjD;IAED;;;;OAIG;IACI,oBAAoB,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAExG;IAED;;;;;;OAMG;IACI,0BAA0B,CAC/B,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,EAAE,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAEjE;CAgBF"}
@@ -1,75 +0,0 @@
1
- import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
2
- import { MerkleTreeId } from '@aztec/stdlib/trees';
3
- // TODO: REmove this class as it no longer seems valuable. The only somewhat real functionality in this class is in
4
- // the `getMembershipWitness` method that is used by `utilityGetMembershipWitness` oracle by then in Aztec.nr we
5
- // have helper functions around that oracle for archive and note hash tree and the generic method itself is not used
6
- // anywhere else - make sense to just have simple specific handlers for the archive and note hash trees and drop this.
7
- export class TreeMembershipService {
8
- aztecNode;
9
- constructor(aztecNode){
10
- this.aztecNode = aztecNode;
11
- }
12
- /**
13
- * Gets the index of a nullifier in the nullifier tree.
14
- * @returns - The index of the nullifier. Undefined if it does not exist in the tree.
15
- */ async getNullifierIndex(nullifier) {
16
- const [leafIndex] = await this.aztecNode.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [
17
- nullifier
18
- ]);
19
- return leafIndex?.data;
20
- }
21
- /**
22
- * Fetches the index and sibling path of a leaf at a given block from a given tree.
23
- * @param blockHash - The block hash at which to get the membership witness.
24
- * @param treeId - Id of the tree to get the sibling path from.
25
- * @param leafValue - The leaf value
26
- * @returns The index and sibling path concatenated [index, sibling_path]
27
- */ async getMembershipWitness(blockHash, treeId, leafValue) {
28
- const witness = await this.#tryGetMembershipWitness(blockHash, treeId, leafValue);
29
- if (!witness) {
30
- throw new Error(`Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block hash ${blockHash.toString()}`);
31
- }
32
- return witness;
33
- }
34
- /**
35
- * Returns a low nullifier membership witness for a given nullifier at a given block.
36
- * @param blockHash - The block hash at which to get the index.
37
- * @param nullifier - Nullifier we try to find the low nullifier witness for.
38
- * @returns The low nullifier membership witness (if found).
39
- * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
40
- * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
41
- * we are trying to prove non-inclusion for.
42
- */ getLowNullifierMembershipWitness(blockHash, nullifier) {
43
- return this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier);
44
- }
45
- /**
46
- * Returns a witness for a given slot of the public data tree at a given block.
47
- * @param blockHash - The block hash at which to get the witness.
48
- * @param leafSlot - The slot of the public data in the public data tree.
49
- */ getPublicDataWitness(blockHash, leafSlot) {
50
- return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
51
- }
52
- /**
53
- * Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
54
- * @param contractAddress - Address of a contract by which the message was emitted.
55
- * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
56
- * The message nullifier is computed locally, so the secret is not sent to the node.
57
- * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
58
- */ getL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
59
- return getNonNullifiedL1ToL2MessageWitness(this.aztecNode, contractAddress, messageHash, secret);
60
- }
61
- async #tryGetMembershipWitness(blockHash, treeId, value) {
62
- switch(treeId){
63
- case MerkleTreeId.NULLIFIER_TREE:
64
- return (await this.aztecNode.getNullifierMembershipWitness(blockHash, value))?.withoutPreimage().toFields();
65
- case MerkleTreeId.NOTE_HASH_TREE:
66
- return (await this.aztecNode.getNoteHashMembershipWitness(blockHash, value))?.toFields();
67
- case MerkleTreeId.PUBLIC_DATA_TREE:
68
- return (await this.aztecNode.getPublicDataWitness(blockHash, value))?.withoutPreimage().toFields();
69
- case MerkleTreeId.ARCHIVE:
70
- return (await this.aztecNode.getArchiveMembershipWitness(blockHash, value))?.toFields();
71
- default:
72
- throw new Error('Not implemented');
73
- }
74
- }
75
- }
@@ -1,97 +0,0 @@
1
- import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
3
- import type { SiblingPath } from '@aztec/foundation/trees';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { L2BlockHash } from '@aztec/stdlib/block';
6
- import type { AztecNode } from '@aztec/stdlib/interfaces/server';
7
- import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
8
- import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
9
-
10
- // TODO: REmove this class as it no longer seems valuable. The only somewhat real functionality in this class is in
11
- // the `getMembershipWitness` method that is used by `utilityGetMembershipWitness` oracle by then in Aztec.nr we
12
- // have helper functions around that oracle for archive and note hash tree and the generic method itself is not used
13
- // anywhere else - make sense to just have simple specific handlers for the archive and note hash trees and drop this.
14
- export class TreeMembershipService {
15
- constructor(private readonly aztecNode: AztecNode) {}
16
-
17
- /**
18
- * Gets the index of a nullifier in the nullifier tree.
19
- * @returns - The index of the nullifier. Undefined if it does not exist in the tree.
20
- */
21
- public async getNullifierIndex(nullifier: Fr): Promise<bigint | undefined> {
22
- const [leafIndex] = await this.aztecNode.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [nullifier]);
23
- return leafIndex?.data;
24
- }
25
-
26
- /**
27
- * Fetches the index and sibling path of a leaf at a given block from a given tree.
28
- * @param blockHash - The block hash at which to get the membership witness.
29
- * @param treeId - Id of the tree to get the sibling path from.
30
- * @param leafValue - The leaf value
31
- * @returns The index and sibling path concatenated [index, sibling_path]
32
- */
33
- public async getMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
34
- const witness = await this.#tryGetMembershipWitness(blockHash, treeId, leafValue);
35
- if (!witness) {
36
- throw new Error(
37
- `Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block hash ${blockHash.toString()}`,
38
- );
39
- }
40
- return witness;
41
- }
42
-
43
- /**
44
- * Returns a low nullifier membership witness for a given nullifier at a given block.
45
- * @param blockHash - The block hash at which to get the index.
46
- * @param nullifier - Nullifier we try to find the low nullifier witness for.
47
- * @returns The low nullifier membership witness (if found).
48
- * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
49
- * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
50
- * we are trying to prove non-inclusion for.
51
- */
52
- public getLowNullifierMembershipWitness(
53
- blockHash: L2BlockHash,
54
- nullifier: Fr,
55
- ): Promise<NullifierMembershipWitness | undefined> {
56
- return this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier);
57
- }
58
-
59
- /**
60
- * Returns a witness for a given slot of the public data tree at a given block.
61
- * @param blockHash - The block hash at which to get the witness.
62
- * @param leafSlot - The slot of the public data in the public data tree.
63
- */
64
- public getPublicDataWitness(blockHash: L2BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
65
- return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
66
- }
67
-
68
- /**
69
- * Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
70
- * @param contractAddress - Address of a contract by which the message was emitted.
71
- * @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
72
- * The message nullifier is computed locally, so the secret is not sent to the node.
73
- * @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
74
- */
75
- public getL1ToL2MembershipWitness(
76
- contractAddress: AztecAddress,
77
- messageHash: Fr,
78
- secret: Fr,
79
- ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
80
- return getNonNullifiedL1ToL2MessageWitness(this.aztecNode, contractAddress, messageHash, secret);
81
- }
82
-
83
- async #tryGetMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, value: Fr): Promise<Fr[] | undefined> {
84
- switch (treeId) {
85
- case MerkleTreeId.NULLIFIER_TREE:
86
- return (await this.aztecNode.getNullifierMembershipWitness(blockHash, value))?.withoutPreimage().toFields();
87
- case MerkleTreeId.NOTE_HASH_TREE:
88
- return (await this.aztecNode.getNoteHashMembershipWitness(blockHash, value))?.toFields();
89
- case MerkleTreeId.PUBLIC_DATA_TREE:
90
- return (await this.aztecNode.getPublicDataWitness(blockHash, value))?.withoutPreimage().toFields();
91
- case MerkleTreeId.ARCHIVE:
92
- return (await this.aztecNode.getArchiveMembershipWitness(blockHash, value))?.toFields();
93
- default:
94
- throw new Error('Not implemented');
95
- }
96
- }
97
- }