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

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 (226) hide show
  1. package/dest/access_scopes.d.ts +9 -0
  2. package/dest/access_scopes.d.ts.map +1 -0
  3. package/dest/access_scopes.js +6 -0
  4. package/dest/bin/check_oracle_version.js +1 -1
  5. package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
  6. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  7. package/dest/block_synchronizer/block_synchronizer.js +62 -16
  8. package/dest/config/index.d.ts +3 -1
  9. package/dest/config/index.d.ts.map +1 -1
  10. package/dest/config/index.js +17 -0
  11. package/dest/config/package_info.js +1 -1
  12. package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
  13. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/contract_function_simulator.js +175 -74
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
  20. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
  21. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
  23. package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -12
  24. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/oracle.d.ts +7 -5
  26. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/oracle.js +51 -29
  28. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  29. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
  31. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -36
  32. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +86 -30
  34. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +62 -30
  35. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +107 -88
  37. package/dest/contract_logging.d.ts +22 -0
  38. package/dest/contract_logging.d.ts.map +1 -0
  39. package/dest/contract_logging.js +23 -0
  40. package/dest/contract_sync/contract_sync_service.d.ts +43 -0
  41. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  42. package/dest/contract_sync/contract_sync_service.js +97 -0
  43. package/dest/contract_sync/helpers.d.ts +29 -0
  44. package/dest/contract_sync/helpers.d.ts.map +1 -0
  45. package/dest/contract_sync/helpers.js +55 -0
  46. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  47. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  48. package/dest/debug/pxe_debug_utils.js +28 -17
  49. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  50. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  51. package/dest/entrypoints/client/bundle/index.js +3 -0
  52. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  53. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  54. package/dest/entrypoints/client/bundle/utils.js +21 -7
  55. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  56. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  57. package/dest/entrypoints/client/lazy/index.js +3 -0
  58. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  59. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  60. package/dest/entrypoints/client/lazy/utils.js +22 -8
  61. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  62. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  63. package/dest/entrypoints/server/index.d.ts +4 -1
  64. package/dest/entrypoints/server/index.d.ts.map +1 -1
  65. package/dest/entrypoints/server/index.js +3 -0
  66. package/dest/entrypoints/server/utils.d.ts +1 -1
  67. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/server/utils.js +28 -9
  69. package/dest/events/event_service.d.ts +5 -6
  70. package/dest/events/event_service.d.ts.map +1 -1
  71. package/dest/events/event_service.js +6 -7
  72. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  73. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  74. package/dest/job_coordinator/job_coordinator.js +3 -2
  75. package/dest/logs/log_service.d.ts +7 -5
  76. package/dest/logs/log_service.d.ts.map +1 -1
  77. package/dest/logs/log_service.js +28 -32
  78. package/dest/notes/note_service.d.ts +9 -8
  79. package/dest/notes/note_service.d.ts.map +1 -1
  80. package/dest/notes/note_service.js +17 -16
  81. package/dest/notes_filter.d.ts +25 -0
  82. package/dest/notes_filter.d.ts.map +1 -0
  83. package/dest/notes_filter.js +4 -0
  84. package/dest/oracle_version.d.ts +3 -3
  85. package/dest/oracle_version.d.ts.map +1 -1
  86. package/dest/oracle_version.js +4 -3
  87. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  88. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  89. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  90. package/dest/private_kernel/hints/index.d.ts +1 -1
  91. package/dest/private_kernel/hints/index.js +1 -1
  92. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  93. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  94. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  95. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  96. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  97. package/dest/private_kernel/hints/test_utils.js +203 -0
  98. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  99. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  100. package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
  101. package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
  102. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  103. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  104. package/dest/pxe.d.ts +69 -23
  105. package/dest/pxe.d.ts.map +1 -1
  106. package/dest/pxe.js +104 -67
  107. package/dest/storage/address_store/address_store.d.ts +1 -1
  108. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  109. package/dest/storage/address_store/address_store.js +12 -11
  110. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  111. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  112. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  113. package/dest/storage/capsule_store/capsule_store.js +6 -8
  114. package/dest/storage/contract_store/contract_store.d.ts +42 -16
  115. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  116. package/dest/storage/contract_store/contract_store.js +157 -84
  117. package/dest/storage/metadata.d.ts +1 -1
  118. package/dest/storage/metadata.js +1 -1
  119. package/dest/storage/note_store/note_store.d.ts +47 -49
  120. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  121. package/dest/storage/note_store/note_store.js +278 -252
  122. package/dest/storage/note_store/stored_note.d.ts +16 -0
  123. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  124. package/dest/storage/note_store/stored_note.js +43 -0
  125. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  126. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  127. package/dest/storage/private_event_store/private_event_store.js +198 -147
  128. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  129. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  130. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  131. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  132. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  133. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  134. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  135. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  136. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  137. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  138. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  139. package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
  140. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  141. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  142. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  143. package/dest/tagging/index.d.ts +3 -2
  144. package/dest/tagging/index.d.ts.map +1 -1
  145. package/dest/tagging/index.js +2 -1
  146. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
  147. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  148. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  149. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  150. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
  151. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  152. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
  153. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
  154. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  155. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  156. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  157. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  158. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  159. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  160. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  161. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +20 -18
  162. package/package.json +25 -16
  163. package/src/access_scopes.ts +9 -0
  164. package/src/bin/check_oracle_version.ts +1 -0
  165. package/src/block_synchronizer/block_synchronizer.ts +76 -33
  166. package/src/config/index.ts +14 -0
  167. package/src/config/package_info.ts +1 -1
  168. package/src/contract_function_simulator/contract_function_simulator.ts +324 -137
  169. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  170. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +2 -2
  171. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
  172. package/src/contract_function_simulator/oracle/interfaces.ts +20 -11
  173. package/src/contract_function_simulator/oracle/oracle.ts +56 -26
  174. package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
  175. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -110
  176. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +172 -95
  177. package/src/contract_logging.ts +39 -0
  178. package/src/contract_sync/contract_sync_service.ts +152 -0
  179. package/src/contract_sync/helpers.ts +98 -0
  180. package/src/debug/pxe_debug_utils.ts +63 -18
  181. package/src/entrypoints/client/bundle/index.ts +3 -0
  182. package/src/entrypoints/client/bundle/utils.ts +16 -15
  183. package/src/entrypoints/client/lazy/index.ts +3 -0
  184. package/src/entrypoints/client/lazy/utils.ts +17 -15
  185. package/src/entrypoints/pxe_creation_options.ts +2 -1
  186. package/src/entrypoints/server/index.ts +3 -0
  187. package/src/entrypoints/server/utils.ts +22 -26
  188. package/src/events/event_service.ts +5 -7
  189. package/src/job_coordinator/job_coordinator.ts +4 -3
  190. package/src/logs/log_service.ts +48 -39
  191. package/src/notes/note_service.ts +24 -22
  192. package/src/notes_filter.ts +26 -0
  193. package/src/oracle_version.ts +4 -3
  194. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  195. package/src/private_kernel/hints/index.ts +1 -1
  196. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  197. package/src/private_kernel/hints/test_utils.ts +325 -0
  198. package/src/private_kernel/private_kernel_execution_prover.ts +25 -15
  199. package/src/private_kernel/private_kernel_oracle.ts +9 -9
  200. package/src/pxe.ts +211 -112
  201. package/src/storage/address_store/address_store.ts +15 -15
  202. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  203. package/src/storage/capsule_store/capsule_store.ts +8 -8
  204. package/src/storage/contract_store/contract_store.ts +186 -96
  205. package/src/storage/metadata.ts +1 -1
  206. package/src/storage/note_store/note_store.ts +321 -318
  207. package/src/storage/note_store/stored_note.ts +48 -0
  208. package/src/storage/private_event_store/private_event_store.ts +250 -190
  209. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  210. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  211. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  212. package/src/storage/tagging_store/sender_tagging_store.ts +214 -130
  213. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  214. package/src/tagging/index.ts +2 -1
  215. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +17 -10
  216. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  217. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
  218. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +6 -9
  219. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
  220. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +23 -23
  221. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  222. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  223. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  224. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  225. package/dest/tree_membership/tree_membership_service.js +0 -75
  226. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -0,0 +1,92 @@
1
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
+ import { MAX_LOGS_PER_TAG, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/api-limit';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
+ import type { SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
6
+
7
+ /**
8
+ * Generic pagination helper that fetches all pages of results.
9
+ * @param numTags - The number of tags being queried (determines result array size).
10
+ * @param fetchPage - Function that fetches a single page of results given a page number.
11
+ * @returns An array of arrays, one per tag, containing all results across all pages.
12
+ */
13
+ async function getAllPages<T>(numTags: number, fetchPage: (page: number) => Promise<T[][]>): Promise<T[][]> {
14
+ const allResultsPerTag: T[][] = Array.from({ length: numTags }, () => []);
15
+ let page = 0;
16
+ let hasMore = true;
17
+
18
+ while (hasMore) {
19
+ const resultsPage = await fetchPage(page);
20
+ hasMore = false;
21
+
22
+ for (let i = 0; i < resultsPage.length; i++) {
23
+ allResultsPerTag[i].push(...resultsPage[i]);
24
+ if (resultsPage[i].length === MAX_LOGS_PER_TAG) {
25
+ hasMore = true;
26
+ }
27
+ }
28
+ page++;
29
+ }
30
+
31
+ return allResultsPerTag;
32
+ }
33
+
34
+ /**
35
+ * Splits tags into chunks of MAX_RPC_LEN, fetches logs for each chunk using getAllPages, then stitches the results
36
+ * back into a single array preserving the original tag order.
37
+ */
38
+ async function getAllPagesInBatches<Tag, T>(
39
+ tags: Tag[],
40
+ fetchAllPagesForBatch: (batch: Tag[]) => Promise<T[][]>,
41
+ ): Promise<T[][]> {
42
+ if (tags.length <= MAX_RPC_LEN) {
43
+ return fetchAllPagesForBatch(tags);
44
+ }
45
+
46
+ const batches: Tag[][] = [];
47
+ for (let i = 0; i < tags.length; i += MAX_RPC_LEN) {
48
+ batches.push(tags.slice(i, i + MAX_RPC_LEN));
49
+ }
50
+ const batchResults = await Promise.all(batches.map(fetchAllPagesForBatch));
51
+ return batchResults.flat();
52
+ }
53
+
54
+ /**
55
+ * Fetches all private logs for the given tags, automatically paginating through all pages.
56
+ * @param aztecNode - The Aztec node to query.
57
+ * @param tags - The siloed tags to search for.
58
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
59
+ * because of reorgs).
60
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
61
+ */
62
+ export function getAllPrivateLogsByTags(
63
+ aztecNode: AztecNode,
64
+ tags: SiloedTag[],
65
+ anchorBlockHash: BlockHash,
66
+ ): Promise<TxScopedL2Log[][]> {
67
+ return getAllPagesInBatches(tags, batch =>
68
+ getAllPages(batch.length, page => aztecNode.getPrivateLogsByTags(batch, page, anchorBlockHash)),
69
+ );
70
+ }
71
+
72
+ /**
73
+ * Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
74
+ * @param aztecNode - The Aztec node to query.
75
+ * @param contractAddress - The contract address to search logs for.
76
+ * @param tags - The tags to search for.
77
+ * @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
78
+ * because of reorgs).
79
+ * @returns An array of log arrays, one per tag, containing all logs across all pages.
80
+ */
81
+ export function getAllPublicLogsByTagsFromContract(
82
+ aztecNode: AztecNode,
83
+ contractAddress: AztecAddress,
84
+ tags: Tag[],
85
+ anchorBlockHash: BlockHash,
86
+ ): Promise<TxScopedL2Log[][]> {
87
+ return getAllPagesInBatches(tags, batch =>
88
+ getAllPages(batch.length, page =>
89
+ aztecNode.getPublicLogsByTagsFromContract(contractAddress, batch, page, anchorBlockHash),
90
+ ),
91
+ );
92
+ }
@@ -12,7 +12,8 @@
12
12
  export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_private_logs_for_sender_recipient_pair.js';
13
13
  export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
14
14
  export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
15
+ export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
15
16
 
16
17
  // Re-export tagging-related types from stdlib
17
- export { DirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
18
+ export { ExtendedDirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
18
19
  export { type PreTag } from '@aztec/stdlib/logs';
@@ -1,7 +1,7 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
- import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
5
 
6
6
  import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
7
7
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -9,18 +9,18 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
9
9
  import { loadLogsForRange } from './utils/load_logs_for_range.js';
10
10
 
11
11
  /**
12
- * Loads private logs for `app` and sender-recipient pair defined by `secret` and updates the highest aged and
12
+ * Loads private logs for the app-sender-recipient triplet defined by `secret` and updates the highest aged and
13
13
  * finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
14
14
  *
15
15
  * @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
16
16
  * in the tagging data provider is indexed by the secret and hence completely disjoint.
17
17
  */
18
18
  export async function loadPrivateLogsForSenderRecipientPair(
19
- secret: DirectionalAppTaggingSecret,
20
- app: AztecAddress,
19
+ secret: ExtendedDirectionalAppTaggingSecret,
21
20
  aztecNode: AztecNode,
22
21
  taggingStore: RecipientTaggingStore,
23
22
  anchorBlockNumber: BlockNumber,
23
+ anchorBlockHash: BlockHash,
24
24
  jobId: string,
25
25
  ): Promise<TxScopedL2Log[]> {
26
26
  // # Explanation of how the algorithm works
@@ -28,7 +28,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
28
28
  // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
29
29
  //
30
30
  // highestAgedIndex is the highest index that was used in a tx that is included in a block at least
31
- // `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds ago.
31
+ // `MAX_TX_LIFETIME` seconds ago.
32
32
  // highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
33
33
  //
34
34
  // "(" denotes an open end of the range - the index is not included in the range.
@@ -40,19 +40,19 @@ export async function loadPrivateLogsForSenderRecipientPair(
40
40
  // ever appear.
41
41
  //
42
42
  // This relies on the "maximum inclusion timestamp" rule enforced by the kernel and rollup circuits:
43
- // - a transaction's maximum inclusion timestamp is at most `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds after
43
+ // - a transaction's maximum inclusion timestamp is at most `MAX_TX_LIFETIME` seconds after
44
44
  // the timestamp of its anchor block; and
45
45
  // - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
46
46
  //
47
47
  // Suppose some device used index `I` in a transaction anchored to block `B_N` at time `N`, and that block is now at
48
- // least `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds in the past. Then there is no possibility of any *other* device
48
+ // least `MAX_TX_LIFETIME` seconds in the past. Then there is no possibility of any *other* device
49
49
  // trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
50
50
  // a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
51
51
  // chosen a larger index.
52
52
  // If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
53
53
  // because it would already have been expired.
54
54
  //
55
- // Therefore, once we see that index `I` has been used in a block that is at least `MAX_INCLUDE_BY_TIMESTAMP_DURATION`
55
+ // Therefore, once we see that index `I` has been used in a block that is at least `MAX_TX_LIFETIME`
56
56
  // seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
57
57
  //
58
58
  // ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
@@ -92,7 +92,14 @@ export async function loadPrivateLogsForSenderRecipientPair(
92
92
 
93
93
  while (true) {
94
94
  // Get private logs with their block timestamps and corresponding tagging indexes
95
- const privateLogsWithIndexes = await loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber);
95
+ const privateLogsWithIndexes = await loadLogsForRange(
96
+ secret,
97
+ aztecNode,
98
+ start,
99
+ end,
100
+ anchorBlockNumber,
101
+ anchorBlockHash,
102
+ );
96
103
 
97
104
  if (privateLogsWithIndexes.length === 0) {
98
105
  break;
@@ -1,4 +1,4 @@
1
- import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
1
+ import { MAX_TX_LIFETIME } from '@aztec/constants';
2
2
  import type { TxScopedL2Log } from '@aztec/stdlib/logs';
3
3
 
4
4
  /**
@@ -16,7 +16,7 @@ export function findHighestIndexes(
16
16
  const ageInSeconds = currentTimestamp - log.blockTimestamp;
17
17
 
18
18
  if (
19
- ageInSeconds >= BigInt(MAX_INCLUDE_BY_TIMESTAMP_DURATION) &&
19
+ ageInSeconds >= BigInt(MAX_TX_LIFETIME) &&
20
20
  (highestAgedIndex === undefined || taggingIndex > highestAgedIndex)
21
21
  ) {
22
22
  highestAgedIndex = taggingIndex;
@@ -1,37 +1,38 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
- import type { DirectionalAppTaggingSecret, PreTag, TxScopedL2Log } from '@aztec/stdlib/logs';
5
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
+ import { SiloedTag } from '@aztec/stdlib/logs';
6
+
7
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
6
8
 
7
9
  /**
8
- * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
9
- * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
10
- * exclusive.
10
+ * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
11
+ * `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
12
+ * `end` is exclusive.
11
13
  */
12
14
  export async function loadLogsForRange(
13
- secret: DirectionalAppTaggingSecret,
14
- app: AztecAddress,
15
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
15
16
  aztecNode: AztecNode,
16
17
  start: number,
17
18
  end: number,
18
19
  anchorBlockNumber: BlockNumber,
20
+ anchorBlockHash: BlockHash,
19
21
  ): Promise<Array<{ log: TxScopedL2Log; taggingIndex: number }>> {
20
- // Derive tags for the window
21
- const preTags: PreTag[] = Array(end - start)
22
- .fill(0)
23
- .map((_, i) => ({ secret, index: start + i }));
24
- const siloedTags = await Promise.all(preTags.map(preTag => Tag.compute(preTag))).then(tags =>
25
- Promise.all(tags.map(tag => SiloedTag.compute(tag, app))),
22
+ // Derive siloed tags for the window
23
+ const siloedTags = await Promise.all(
24
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
26
25
  );
27
26
 
28
- const logs = await aztecNode.getPrivateLogsByTags(siloedTags);
27
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
28
+ // pagination here.
29
+ const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
29
30
 
30
31
  // Pair logs with their corresponding tagging indexes
31
32
  const logsWithIndexes: Array<{ log: TxScopedL2Log; taggingIndex: number }> = [];
32
33
  for (let i = 0; i < logs.length; i++) {
33
34
  const logsForTag = logs[i];
34
- const taggingIndex = preTags[i].index;
35
+ const taggingIndex = start + i;
35
36
  for (const log of logsForTag) {
36
37
  if (log.blockNumber <= anchorBlockNumber) {
37
38
  logsWithIndexes.push({ log, taggingIndex });
@@ -1,6 +1,6 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
1
+ import type { BlockHash } from '@aztec/stdlib/block';
2
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
4
 
5
5
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
6
6
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -10,11 +10,8 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
10
10
  /**
11
11
  * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
12
12
  *
13
- * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
13
+ * @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
14
14
  * sender -> recipient matters.
15
- * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
16
- * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
17
- * of the private log which corresponds to the tag).
18
15
  * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
19
16
  * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
20
17
  * is simply the highest pending index plus one (or finalized if pending is undefined).
@@ -22,10 +19,10 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
22
19
  * updates its status accordingly.
23
20
  */
24
21
  export async function syncSenderTaggingIndexes(
25
- secret: DirectionalAppTaggingSecret,
26
- app: AztecAddress,
22
+ secret: ExtendedDirectionalAppTaggingSecret,
27
23
  aztecNode: AztecNode,
28
24
  taggingStore: SenderTaggingStore,
25
+ anchorBlockHash: BlockHash,
29
26
  jobId: string,
30
27
  ): Promise<void> {
31
28
  // # Explanation of how syncing works
@@ -57,7 +54,7 @@ export async function syncSenderTaggingIndexes(
57
54
  while (true) {
58
55
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
59
56
  // 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);
57
+ await loadAndStoreNewTaggingIndexes(secret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
61
58
 
62
59
  // Retrieve all indexes within the current window from storage and update their status accordingly.
63
60
  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,18 +1,17 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
1
+ import type { BlockHash } from '@aztec/stdlib/block';
2
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
- import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
4
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
+ import { SiloedTag } from '@aztec/stdlib/logs';
5
5
  import { TxHash } from '@aztec/stdlib/tx';
6
6
 
7
7
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
8
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
8
9
 
9
10
  /**
10
11
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
11
12
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
12
13
  * place is when a tx is being sent from this PXE.
13
- * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
14
- * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
15
- * kernel circuit behavior.
14
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
16
15
  * @param start - The starting index (inclusive) of the window to process.
17
16
  * @param end - The ending index (exclusive) of the window to process.
18
17
  * @param aztecNode - The Aztec node instance to query for logs.
@@ -21,50 +20,51 @@ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_t
21
20
  * preserving way.
22
21
  */
23
22
  export async function loadAndStoreNewTaggingIndexes(
24
- secret: DirectionalAppTaggingSecret,
25
- app: AztecAddress,
23
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
26
24
  start: number,
27
25
  end: number,
28
26
  aztecNode: AztecNode,
29
27
  taggingStore: SenderTaggingStore,
28
+ anchorBlockHash: BlockHash,
30
29
  jobId: string,
31
30
  ) {
32
31
  // We compute the tags for the current window of indexes
33
- const preTagsForWindow: PreTag[] = Array(end - start)
34
- .fill(0)
35
- .map((_, i) => ({ secret, index: start + i }));
36
32
  const siloedTagsForWindow = await Promise.all(
37
- preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
33
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
38
34
  );
39
35
 
40
- const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode);
41
- const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
36
+ const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
37
+ const highestIndexMap = getTxHighestIndexMap(txsForTags, start, siloedTagsForWindow.length);
42
38
 
43
39
  // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
44
40
  for (const [txHashStr, highestIndex] of highestIndexMap.entries()) {
45
41
  const txHash = TxHash.fromString(txHashStr);
46
- await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash, jobId);
42
+ await taggingStore.storePendingIndexes([{ extendedSecret, index: highestIndex }], txHash, jobId);
47
43
  }
48
44
  }
49
45
 
50
46
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
51
47
  // an array for each tag.
52
- async function getTxsContainingTags(tags: SiloedTag[], aztecNode: AztecNode): Promise<TxHash[][]> {
53
- const allLogs = await aztecNode.getPrivateLogsByTags(tags);
48
+ async function getTxsContainingTags(
49
+ tags: SiloedTag[],
50
+ aztecNode: AztecNode,
51
+ anchorBlockHash: BlockHash,
52
+ ): Promise<TxHash[][]> {
53
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
54
+ // pagination here.
55
+ const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
54
56
  return allLogs.map(logs => logs.map(log => log.txHash));
55
57
  }
56
58
 
57
59
  // Returns a map of txHash to the highest index for that txHash.
58
- function getTxHighestIndexMap(txHashesForTags: TxHash[][], preTagsForWindow: PreTag[]): Map<string, number> {
59
- if (txHashesForTags.length !== preTagsForWindow.length) {
60
- throw new Error(
61
- `Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`,
62
- );
60
+ function getTxHighestIndexMap(txHashesForTags: TxHash[][], start: number, count: number): Map<string, number> {
61
+ if (txHashesForTags.length !== count) {
62
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
63
63
  }
64
64
 
65
65
  const highestIndexMap = new Map<string, number>();
66
66
  for (let i = 0; i < txHashesForTags.length; i++) {
67
- const taggingIndex = preTagsForWindow[i].index;
67
+ const taggingIndex = start + i;
68
68
  const txHashesForTag = txHashesForTags[i];
69
69
  for (const txHash of txHashesForTag) {
70
70
  const key = txHash.toString();
@@ -1,4 +0,0 @@
1
- import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
2
- import type { UInt64 } from '@aztec/stdlib/types';
3
- export declare function computeTxIncludeByTimestamp(previousKernel: PrivateKernelCircuitPublicInputs, maxDuration?: number): UInt64;
4
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcHV0ZV90eF9pbmNsdWRlX2J5X3RpbWVzdGFtcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL2hpbnRzL2NvbXB1dGVfdHhfaW5jbHVkZV9ieV90aW1lc3RhbXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsZ0NBQWdDLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQXFCbEQsd0JBQWdCLDJCQUEyQixDQUN6QyxjQUFjLEVBQUUsZ0NBQWdDLEVBQ2hELFdBQVcsU0FBb0MsR0FDOUMsTUFBTSxDQStCUiJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"compute_tx_include_by_timestamp.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/compute_tx_include_by_timestamp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAqBlD,wBAAgB,2BAA2B,CACzC,cAAc,EAAE,gCAAgC,EAChD,WAAW,SAAoC,GAC9C,MAAM,CA+BR"}
@@ -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: Fr, secret: Fr): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]>;
49
- }
50
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJlZV9tZW1iZXJzaGlwX3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90cmVlX21lbWJlcnNoaXAvdHJlZV9tZW1iZXJzaGlwX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDbEQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakUsT0FBTyxFQUFFLFlBQVksRUFBRSwwQkFBMEIsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBTWxHLHFCQUFhLHFCQUFxQjs7SUFDcEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQXRDLFlBQTZCLFNBQVMsRUFBRSxTQUFTLEVBQUk7SUFFckQ7OztPQUdHO0lBQ1UsaUJBQWlCLENBQUMsU0FBUyxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQUd6RTtJQUVEOzs7Ozs7T0FNRztJQUNVLG9CQUFvQixDQUFDLFNBQVMsRUFBRSxXQUFXLEVBQUUsTUFBTSxFQUFFLFlBQVksRUFBRSxTQUFTLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQVE1RztJQUVEOzs7Ozs7OztPQVFHO0lBQ0ksZ0NBQWdDLENBQ3JDLFNBQVMsRUFBRSxXQUFXLEVBQ3RCLFNBQVMsRUFBRSxFQUFFLEdBQ1osT0FBTyxDQUFDLDBCQUEwQixHQUFHLFNBQVMsQ0FBQyxDQUVqRDtJQUVEOzs7O09BSUc7SUFDSSxvQkFBb0IsQ0FBQyxTQUFTLEVBQUUsV0FBVyxFQUFFLFFBQVEsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLGlCQUFpQixHQUFHLFNBQVMsQ0FBQyxDQUV4RztJQUVEOzs7Ozs7T0FNRztJQUNJLDBCQUEwQixDQUMvQixlQUFlLEVBQUUsWUFBWSxFQUM3QixXQUFXLEVBQUUsRUFBRSxFQUNmLE1BQU0sRUFBRSxFQUFFLEdBQ1QsT0FBTyxDQUFDLENBQUMsTUFBTSxFQUFFLFdBQVcsQ0FBQyxPQUFPLHdCQUF3QixDQUFDLENBQUMsQ0FBQyxDQUVqRTtDQWdCRiJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"tree_membership_service.d.ts","sourceRoot":"","sources":["../../src/tree_membership/tree_membership_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,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
- }