@aztec/pxe 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1

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 (264) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +1 -1
  3. package/dest/bin/check_oracle_version.js +110 -10
  4. package/dest/config/index.d.ts +9 -17
  5. package/dest/config/index.d.ts.map +1 -1
  6. package/dest/config/index.js +10 -16
  7. package/dest/config/package_info.d.ts +1 -1
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -6
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +97 -42
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +40 -57
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_note_cache.d.ts +11 -9
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/execution_note_cache.js +28 -17
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  20. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/index.d.ts +4 -2
  23. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/index.js +2 -1
  25. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
  26. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +2 -2
  28. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
  32. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -3
  33. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
  35. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  36. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  37. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  38. package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
  39. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/index.js +1 -1
  41. package/dest/contract_function_simulator/oracle/interfaces.d.ts +104 -0
  42. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  43. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  44. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
  45. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  47. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
  48. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
  50. package/dest/contract_function_simulator/oracle/oracle.d.ts +17 -15
  51. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/oracle/oracle.js +101 -81
  53. package/dest/contract_function_simulator/oracle/private_execution.d.ts +6 -5
  54. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  55. package/dest/contract_function_simulator/oracle/private_execution.js +7 -16
  56. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +34 -22
  57. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +89 -25
  59. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +23 -33
  60. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +38 -42
  62. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  63. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  64. package/dest/contract_function_simulator/pick_notes.js +1 -1
  65. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  66. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  67. package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
  68. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
  69. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +34 -68
  70. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/pxe_oracle_interface.js +220 -208
  72. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  73. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  74. package/dest/entrypoints/client/bundle/index.js +2 -1
  75. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  76. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  77. package/dest/entrypoints/client/bundle/utils.js +21 -12
  78. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  79. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/lazy/index.js +2 -1
  81. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  82. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/lazy/utils.js +20 -11
  84. package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
  85. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  86. package/dest/entrypoints/server/index.d.ts +4 -2
  87. package/dest/entrypoints/server/index.d.ts.map +1 -1
  88. package/dest/entrypoints/server/index.js +2 -1
  89. package/dest/entrypoints/server/utils.d.ts +5 -24
  90. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  91. package/dest/entrypoints/server/utils.js +17 -45
  92. package/dest/error_enriching.d.ts +11 -0
  93. package/dest/error_enriching.d.ts.map +1 -0
  94. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
  95. package/dest/events/index.d.ts +2 -0
  96. package/dest/events/index.d.ts.map +1 -0
  97. package/dest/events/index.js +1 -0
  98. package/dest/events/private_event_filter_validator.d.ts +8 -0
  99. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  100. package/dest/events/private_event_filter_validator.js +39 -0
  101. package/dest/oracle_version.d.ts +3 -3
  102. package/dest/oracle_version.js +2 -2
  103. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
  104. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
  106. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
  108. package/dest/private_kernel/hints/index.d.ts +1 -1
  109. package/dest/private_kernel/index.d.ts +1 -1
  110. package/dest/private_kernel/private_kernel_execution_prover.d.ts +9 -2
  111. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  112. package/dest/private_kernel/private_kernel_execution_prover.js +38 -32
  113. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
  114. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  115. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +8 -7
  116. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
  117. package/dest/pxe.d.ts +240 -0
  118. package/dest/pxe.d.ts.map +1 -0
  119. package/dest/{pxe_service/pxe_service.js → pxe.js} +227 -241
  120. package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
  121. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  122. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  123. package/dest/storage/address_data_provider/index.d.ts +1 -1
  124. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +3 -5
  125. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  126. package/dest/storage/capsule_data_provider/capsule_data_provider.js +1 -5
  127. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  128. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +6 -17
  129. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  130. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -15
  131. package/dest/storage/contract_data_provider/index.d.ts +1 -1
  132. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +1 -1
  133. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  134. package/dest/storage/contract_data_provider/private_functions_tree.js +1 -1
  135. package/dest/storage/index.d.ts +1 -2
  136. package/dest/storage/index.d.ts.map +1 -1
  137. package/dest/storage/index.js +0 -1
  138. package/dest/storage/metadata.d.ts +1 -1
  139. package/dest/storage/note_data_provider/index.d.ts +2 -2
  140. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  141. package/dest/storage/note_data_provider/index.js +1 -1
  142. package/dest/storage/note_data_provider/note_data_provider.d.ts +75 -11
  143. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  144. package/dest/storage/note_data_provider/note_data_provider.js +143 -81
  145. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +31 -17
  146. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
  147. package/dest/storage/private_event_data_provider/private_event_data_provider.js +47 -28
  148. package/dest/storage/sync_data_provider/index.d.ts +1 -1
  149. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +4 -5
  150. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  151. package/dest/storage/sync_data_provider/sync_data_provider.js +0 -3
  152. package/dest/storage/tagging_data_provider/index.d.ts +1 -1
  153. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +29 -7
  154. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  155. package/dest/storage/tagging_data_provider/tagging_data_provider.js +46 -39
  156. package/dest/synchronizer/index.d.ts +1 -1
  157. package/dest/synchronizer/synchronizer.d.ts +3 -2
  158. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  159. package/dest/synchronizer/synchronizer.js +4 -4
  160. package/dest/tagging/constants.d.ts +2 -0
  161. package/dest/tagging/constants.d.ts.map +1 -0
  162. package/dest/tagging/constants.js +2 -0
  163. package/dest/tagging/index.d.ts +7 -0
  164. package/dest/tagging/index.d.ts.map +1 -0
  165. package/dest/tagging/index.js +5 -0
  166. package/dest/tagging/siloed_tag.d.ts +14 -0
  167. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  168. package/dest/tagging/siloed_tag.js +20 -0
  169. package/dest/tagging/tag.d.ts +12 -0
  170. package/dest/tagging/tag.d.ts.map +1 -0
  171. package/dest/tagging/tag.js +17 -0
  172. package/dest/tagging/utils.d.ts +18 -0
  173. package/dest/tagging/utils.d.ts.map +1 -0
  174. package/dest/tagging/utils.js +24 -0
  175. package/package.json +22 -24
  176. package/src/bin/check_oracle_version.ts +134 -10
  177. package/src/config/index.ts +18 -32
  178. package/src/config/package_info.ts +1 -1
  179. package/src/contract_function_simulator/contract_function_simulator.ts +151 -62
  180. package/src/contract_function_simulator/execution_data_provider.ts +47 -65
  181. package/src/contract_function_simulator/execution_note_cache.ts +33 -17
  182. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  183. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  184. package/src/contract_function_simulator/index.ts +3 -1
  185. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  186. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  187. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
  188. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
  189. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  190. package/src/contract_function_simulator/oracle/index.ts +1 -1
  191. package/src/contract_function_simulator/oracle/interfaces.ts +176 -0
  192. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  193. package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
  194. package/src/contract_function_simulator/oracle/oracle.ts +135 -80
  195. package/src/contract_function_simulator/oracle/private_execution.ts +10 -17
  196. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +123 -49
  197. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +68 -80
  198. package/src/contract_function_simulator/pick_notes.ts +1 -1
  199. package/src/contract_function_simulator/pxe_oracle_interface.ts +291 -271
  200. package/src/entrypoints/client/bundle/index.ts +3 -1
  201. package/src/entrypoints/client/bundle/utils.ts +21 -23
  202. package/src/entrypoints/client/lazy/index.ts +3 -1
  203. package/src/entrypoints/client/lazy/utils.ts +20 -23
  204. package/src/entrypoints/pxe_creation_options.ts +4 -1
  205. package/src/entrypoints/server/index.ts +3 -1
  206. package/src/entrypoints/server/utils.ts +20 -68
  207. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
  208. package/src/events/index.ts +1 -0
  209. package/src/events/private_event_filter_validator.ts +47 -0
  210. package/src/oracle_version.ts +2 -2
  211. package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
  212. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
  213. package/src/private_kernel/private_kernel_execution_prover.ts +51 -43
  214. package/src/private_kernel/private_kernel_oracle.ts +2 -1
  215. package/src/private_kernel/private_kernel_oracle_impl.ts +4 -3
  216. package/src/{pxe_service/pxe_service.ts → pxe.ts} +256 -308
  217. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  218. package/src/storage/capsule_data_provider/capsule_data_provider.ts +2 -12
  219. package/src/storage/contract_data_provider/contract_data_provider.ts +4 -27
  220. package/src/storage/contract_data_provider/private_functions_tree.ts +1 -1
  221. package/src/storage/index.ts +0 -1
  222. package/src/storage/note_data_provider/index.ts +1 -1
  223. package/src/storage/note_data_provider/note_data_provider.ts +171 -109
  224. package/src/storage/private_event_data_provider/private_event_data_provider.ts +69 -41
  225. package/src/storage/sync_data_provider/sync_data_provider.ts +3 -8
  226. package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
  227. package/src/synchronizer/synchronizer.ts +4 -4
  228. package/src/tagging/constants.ts +2 -0
  229. package/src/tagging/index.ts +6 -0
  230. package/src/tagging/siloed_tag.ts +22 -0
  231. package/src/tagging/tag.ts +16 -0
  232. package/src/tagging/utils.ts +31 -0
  233. package/dest/bin/index.d.ts +0 -3
  234. package/dest/bin/index.d.ts.map +0 -1
  235. package/dest/bin/index.js +0 -48
  236. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
  237. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
  238. package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
  239. package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
  240. package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
  241. package/dest/contract_function_simulator/tagging_utils.js +0 -23
  242. package/dest/pxe_service/error_enriching.d.ts +0 -11
  243. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  244. package/dest/pxe_service/index.d.ts +0 -3
  245. package/dest/pxe_service/index.d.ts.map +0 -1
  246. package/dest/pxe_service/index.js +0 -2
  247. package/dest/pxe_service/pxe_service.d.ts +0 -100
  248. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  249. package/dest/storage/data_provider.d.ts +0 -4
  250. package/dest/storage/data_provider.d.ts.map +0 -1
  251. package/dest/storage/data_provider.js +0 -1
  252. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  253. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  254. package/dest/storage/note_data_provider/note_dao.js +0 -102
  255. package/dest/test/pxe_test_suite.d.ts +0 -3
  256. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  257. package/dest/test/pxe_test_suite.js +0 -97
  258. package/src/bin/index.ts +0 -62
  259. package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
  260. package/src/contract_function_simulator/tagging_utils.ts +0 -32
  261. package/src/pxe_service/index.ts +0 -2
  262. package/src/storage/data_provider.ts +0 -3
  263. package/src/storage/note_data_provider/note_dao.ts +0 -154
  264. package/src/test/pxe_test_suite.ts +0 -113
@@ -1,27 +1,44 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { createLogger } from '@aztec/foundation/log';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
  import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
6
  import type { EventSelector } from '@aztec/stdlib/abi';
6
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { TxHash } from '@aztec/stdlib/tx';
8
+ import { L2BlockHash } from '@aztec/stdlib/block';
9
+ import { type InTx, TxHash } from '@aztec/stdlib/tx';
8
10
 
9
- import type { DataProvider } from '../data_provider.js';
11
+ import type { PackedPrivateEvent } from '../../pxe.js';
10
12
 
11
- interface PrivateEventEntry {
13
+ export type PrivateEventDataProviderFilter = {
14
+ contractAddress: AztecAddress;
15
+ fromBlock: number;
16
+ toBlock: number;
17
+ scopes: AztecAddress[];
18
+ txHash?: TxHash;
19
+ };
20
+
21
+ type PrivateEventEntry = {
12
22
  msgContent: Buffer;
13
- blockNumber: number;
14
23
  eventCommitmentIndex: number;
15
- }
24
+ l2BlockNumber: number;
25
+ l2BlockHash: Buffer;
26
+ txHash: Buffer;
27
+ };
28
+
29
+ type PrivateEventMetadata = InTx & {
30
+ contractAddress: AztecAddress;
31
+ scope: AztecAddress;
32
+ };
16
33
 
17
34
  /**
18
35
  * Stores decrypted private event logs.
19
36
  */
20
- export class PrivateEventDataProvider implements DataProvider {
37
+ export class PrivateEventDataProvider {
21
38
  #store: AztecAsyncKVStore;
22
39
  /** Array storing the actual private event log entries containing the log content and block number */
23
40
  #eventLogs: AztecAsyncArray<PrivateEventEntry>;
24
- /** Map from contract_address_recipient_eventSelector to array of indices into #eventLogs for efficient lookup */
41
+ /** Map from contract_address_scope_eventSelector to array of indices into #eventLogs for efficient lookup */
25
42
  #eventLogIndex: AztecAsyncMap<string, number[]>;
26
43
  /** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
27
44
  #seenLogs: AztecAsyncMap<number, boolean>;
@@ -35,27 +52,31 @@ export class PrivateEventDataProvider implements DataProvider {
35
52
  this.#seenLogs = this.#store.openMap('seen_logs');
36
53
  }
37
54
 
55
+ #keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
56
+ return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
57
+ }
58
+
38
59
  /**
39
60
  * Store a private event log.
40
- * @param contractAddress - The address of the contract that emitted the event.
41
- * @param recipient - The recipient of the event.
42
61
  * @param eventSelector - The event selector of the event.
43
62
  * @param msgContent - The content of the event.
44
- * @param txHash - The transaction hash of the event log.
45
63
  * @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
46
- * @param blockNumber - The block number in which the event was emitted.
64
+ * @param metadata
65
+ * contractAddress - The address of the contract that emitted the event.
66
+ * scope - The address to which the event is scoped.
67
+ * txHash - The transaction hash of the event log.
68
+ * blockNumber - The block number in which the event was emitted.
47
69
  */
48
70
  storePrivateEventLog(
49
- contractAddress: AztecAddress,
50
- recipient: AztecAddress,
51
71
  eventSelector: EventSelector,
52
72
  msgContent: Fr[],
53
- txHash: TxHash,
54
73
  eventCommitmentIndex: number,
55
- blockNumber: number,
74
+ metadata: PrivateEventMetadata,
56
75
  ): Promise<void> {
76
+ const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
77
+
57
78
  return this.#store.transactionAsync(async () => {
58
- const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
79
+ const key = this.#keyFor(contractAddress, scope, eventSelector);
59
80
 
60
81
  // Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
61
82
  const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
@@ -64,13 +85,15 @@ export class PrivateEventDataProvider implements DataProvider {
64
85
  return;
65
86
  }
66
87
 
67
- this.logger.verbose('storing private event log', { contractAddress, recipient, msgContent, blockNumber });
88
+ this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
68
89
 
69
90
  const index = await this.#eventLogs.lengthAsync();
70
91
  await this.#eventLogs.push({
71
92
  msgContent: serializeToBuffer(msgContent),
72
- blockNumber,
93
+ l2BlockNumber,
94
+ l2BlockHash: l2BlockHash.toBuffer(),
73
95
  eventCommitmentIndex,
96
+ txHash: txHash.toBuffer(),
74
97
  });
75
98
 
76
99
  const existingIndices = (await this.#eventLogIndex.getAsync(key)) || [];
@@ -83,29 +106,28 @@ export class PrivateEventDataProvider implements DataProvider {
83
106
 
84
107
  /**
85
108
  * Returns the private events given search parameters.
86
- * @param contractAddress - The address of the contract to get events from.
87
- * @param from - The block number to search from.
88
- * @param numBlocks - The amount of blocks to search.
89
- * @param recipients - The addresses that decrypted the logs.
90
109
  * @param eventSelector - The event selector to filter by.
91
- * @returns - The event log contents.
110
+ * @param filter - Filtering criteria:
111
+ * contractAddress: The address of the contract to get events from.
112
+ * fromBlock: The block number to search from (inclusive).
113
+ * toBlock: The block number to search upto (exclusive).
114
+ * scope: - The addresses that decrypted the logs.
115
+ * @returns - The event log contents, augmented with metadata about
116
+ * the transaction and block it the event was included in .
92
117
  */
93
118
  public async getPrivateEvents(
94
- contractAddress: AztecAddress,
95
- from: number,
96
- numBlocks: number,
97
- recipients: AztecAddress[],
98
119
  eventSelector: EventSelector,
99
- ): Promise<Fr[][]> {
100
- const events: Array<{ msgContent: Fr[]; blockNumber: number; eventCommitmentIndex: number }> = [];
120
+ filter: PrivateEventDataProviderFilter,
121
+ ): Promise<PackedPrivateEvent[]> {
122
+ const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
101
123
 
102
- for (const recipient of recipients) {
103
- const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
124
+ for (const scope of filter.scopes) {
125
+ const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
104
126
  const indices = (await this.#eventLogIndex.getAsync(key)) || [];
105
127
 
106
128
  for (const index of indices) {
107
129
  const entry = await this.#eventLogs.atAsync(index);
108
- if (!entry || entry.blockNumber < from || entry.blockNumber >= from + numBlocks) {
130
+ if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
109
131
  continue;
110
132
  }
111
133
 
@@ -113,22 +135,28 @@ export class PrivateEventDataProvider implements DataProvider {
113
135
  const reader = BufferReader.asReader(entry.msgContent);
114
136
  const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
115
137
  const msgContent = reader.readArray(numFields, Fr);
138
+ const txHash = TxHash.fromBuffer(entry.txHash);
139
+ const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
140
+
141
+ if (filter.txHash && !txHash.equals(filter.txHash)) {
142
+ continue;
143
+ }
116
144
 
117
145
  events.push({
118
- msgContent,
119
- blockNumber: entry.blockNumber,
120
146
  eventCommitmentIndex: entry.eventCommitmentIndex,
147
+ event: {
148
+ packedEvent: msgContent,
149
+ l2BlockNumber: BlockNumber(entry.l2BlockNumber),
150
+ txHash,
151
+ l2BlockHash,
152
+ eventSelector,
153
+ },
121
154
  });
122
155
  }
123
156
  }
124
157
 
125
158
  // Sort by eventCommitmentIndex only
126
159
  events.sort((a, b) => a.eventCommitmentIndex - b.eventCommitmentIndex);
127
-
128
- return events.map(e => e.msgContent);
129
- }
130
-
131
- getSize(): Promise<number> {
132
- return this.#eventLogs.lengthAsync();
160
+ return events.map(ev => ev.event);
133
161
  }
134
162
  }
@@ -1,9 +1,8 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
2
3
  import { BlockHeader } from '@aztec/stdlib/tx';
3
4
 
4
- import type { DataProvider } from '../data_provider.js';
5
-
6
- export class SyncDataProvider implements DataProvider {
5
+ export class SyncDataProvider {
7
6
  #store: AztecAsyncKVStore;
8
7
  #synchronizedHeader: AztecAsyncSingleton<Buffer>;
9
8
 
@@ -16,7 +15,7 @@ export class SyncDataProvider implements DataProvider {
16
15
  await this.#synchronizedHeader.set(header.toBuffer());
17
16
  }
18
17
 
19
- async getBlockNumber(): Promise<number> {
18
+ async getBlockNumber(): Promise<BlockNumber> {
20
19
  const headerBuffer = await this.#synchronizedHeader.getAsync();
21
20
  if (!headerBuffer) {
22
21
  throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
@@ -33,8 +32,4 @@ export class SyncDataProvider implements DataProvider {
33
32
 
34
33
  return BlockHeader.fromBuffer(headerBuffer);
35
34
  }
36
-
37
- async getSize(): Promise<number> {
38
- return (await this.#synchronizedHeader.getAsync())?.length ?? 0;
39
- }
40
35
  }
@@ -1,93 +1,90 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
1
  import { toArray } from '@aztec/foundation/iterable';
3
2
  import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
4
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { IndexedTaggingSecret } from '@aztec/stdlib/logs';
4
+ import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
6
5
 
7
6
  export class TaggingDataProvider {
8
7
  #store: AztecAsyncKVStore;
9
8
  #addressBook: AztecAsyncMap<string, true>;
10
9
 
11
- // Stores the last index used for each tagging secret, taking direction into account
12
- // This is necessary to avoid reusing the same index for the same secret, which happens if
13
- // sender and recipient are the same
14
- #taggingSecretIndexesForSenders: AztecAsyncMap<string, number>;
15
- #taggingSecretIndexesForRecipients: AztecAsyncMap<string, number>;
10
+ // Stores the last used index for each directional app tagging secret. Taking into account whether we are
11
+ // requesting the index as a sender or as a recipient because the sender and recipient can be in the same PXE.
12
+ #lastUsedIndexesAsSenders: AztecAsyncMap<string, number>;
13
+ #lastUsedIndexesAsRecipients: AztecAsyncMap<string, number>;
16
14
 
17
15
  constructor(store: AztecAsyncKVStore) {
18
16
  this.#store = store;
19
17
 
20
18
  this.#addressBook = this.#store.openMap('address_book');
21
19
 
22
- this.#taggingSecretIndexesForSenders = this.#store.openMap('tagging_secret_indexes_for_senders');
23
- this.#taggingSecretIndexesForRecipients = this.#store.openMap('tagging_secret_indexes_for_recipients');
20
+ this.#lastUsedIndexesAsSenders = this.#store.openMap('last_used_indexes_as_senders');
21
+ this.#lastUsedIndexesAsRecipients = this.#store.openMap('last_used_indexes_as_recipients');
24
22
  }
25
23
 
26
- setTaggingSecretsIndexesAsSender(indexedSecrets: IndexedTaggingSecret[], sender: AztecAddress) {
27
- return this.#setTaggingSecretsIndexes(indexedSecrets, this.#taggingSecretIndexesForSenders, sender);
28
- }
24
+ /**
25
+ * Sets the last used indexes when sending a log.
26
+ * @param preTags - The pre tags containing the directional app tagging secrets and the indexes that are to be
27
+ * updated in the db.
28
+ * @throws If any two pre tags contain the same directional app tagging secret
29
+ */
30
+ setLastUsedIndexesAsSender(preTags: PreTag[]) {
31
+ this.#assertUniqueSecrets(preTags, 'sender');
29
32
 
30
- setTaggingSecretsIndexesAsRecipient(indexedSecrets: IndexedTaggingSecret[], recipient: AztecAddress) {
31
- return this.#setTaggingSecretsIndexes(indexedSecrets, this.#taggingSecretIndexesForRecipients, recipient);
33
+ return Promise.all(
34
+ preTags.map(({ secret, index }) => this.#lastUsedIndexesAsSenders.set(secret.toString(), index)),
35
+ );
32
36
  }
33
37
 
34
38
  /**
35
- * Sets the indexes of the tagging secrets for the given app tagging secrets in the direction of the given address.
36
- * @dev We need to specify the direction because app tagging secrets are direction-less due to the way they are generated
37
- * but we need to guarantee that the index is stored under a uni-directional key because the tags are themselves
38
- * uni-directional.
39
- * @param indexedSecrets - The app tagging secrets and indexes to set.
40
- * @param storageMap - The storage map to set the indexes in.
41
- * @param inDirectionOf - The address that the secrets are in the direction of.
39
+ * Sets the last used indexes when looking for logs.
40
+ * @param preTags - The pre tags containing the directional app tagging secrets and the indexes that are to be
41
+ * updated in the db.
42
+ * @throws If any two pre tags contain the same directional app tagging secret
42
43
  */
43
- #setTaggingSecretsIndexes(
44
- indexedSecrets: IndexedTaggingSecret[],
45
- storageMap: AztecAsyncMap<string, number>,
46
- inDirectionOf: AztecAddress,
47
- ) {
44
+ setLastUsedIndexesAsRecipient(preTags: PreTag[]) {
45
+ this.#assertUniqueSecrets(preTags, 'recipient');
46
+
48
47
  return Promise.all(
49
- indexedSecrets.map(indexedSecret =>
50
- storageMap.set(`${indexedSecret.appTaggingSecret.toString()}_${inDirectionOf.toString()}`, indexedSecret.index),
51
- ),
48
+ preTags.map(({ secret, index }) => this.#lastUsedIndexesAsRecipients.set(secret.toString(), index)),
52
49
  );
53
50
  }
54
51
 
55
- getTaggingSecretsIndexesAsRecipient(appTaggingSecrets: Fr[], recipient: AztecAddress) {
56
- return this.#getTaggingSecretsIndexes(appTaggingSecrets, this.#taggingSecretIndexesForRecipients, recipient);
52
+ // It should never happen that we would receive any two pre tags on the input containing the same directional app
53
+ // tagging secret as everywhere we always just apply the largest index. Hence this check is a good way to catch
54
+ // bugs.
55
+ #assertUniqueSecrets(preTags: PreTag[], role: 'sender' | 'recipient'): void {
56
+ const secretStrings = preTags.map(({ secret }) => secret.toString());
57
+ const uniqueSecrets = new Set(secretStrings);
58
+ if (uniqueSecrets.size !== secretStrings.length) {
59
+ throw new Error(`Duplicate secrets found when setting last used indexes as ${role}`);
60
+ }
57
61
  }
58
62
 
59
- getTaggingSecretsIndexesAsSender(appTaggingSecrets: Fr[], sender: AztecAddress) {
60
- return this.#getTaggingSecretsIndexes(appTaggingSecrets, this.#taggingSecretIndexesForSenders, sender);
63
+ /**
64
+ * Returns the last used index when sending a log with a given secret.
65
+ * @param secret - The directional app tagging secret.
66
+ * @returns The last used index for the given directional app tagging secret, or undefined if not found.
67
+ */
68
+ async getLastUsedIndexesAsSender(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
69
+ return await this.#lastUsedIndexesAsSenders.getAsync(secret.toString());
61
70
  }
62
71
 
63
72
  /**
64
- * Returns the indexes of the tagging secrets for the given app tagging secrets in the direction of the given address.
65
- * @dev We need to specify the direction because app tagging secrets are direction-less due to the way they are generated
66
- * but we need to guarantee that the index is stored under a uni-directional key because the tags are themselves
67
- * uni-directional.
68
- * @param appTaggingSecrets - The app tagging secrets to get the indexes for.
69
- * @param storageMap - The storage map to get the indexes from.
70
- * @param inDirectionOf - The address that the secrets are in the direction of.
71
- * @returns The indexes of the tagging secrets.
73
+ * Returns the last used indexes when looking for logs as a recipient.
74
+ * @param secrets - The directional app tagging secrets to obtain the indexes for.
75
+ * @returns The last used indexes for the given directional app tagging secrets, or undefined if have never yet found
76
+ * a log for a given secret.
72
77
  */
73
- #getTaggingSecretsIndexes(
74
- appTaggingSecrets: Fr[],
75
- storageMap: AztecAsyncMap<string, number>,
76
- inDirectionOf: AztecAddress,
77
- ): Promise<number[]> {
78
- return Promise.all(
79
- appTaggingSecrets.map(
80
- async secret => (await storageMap.getAsync(`${secret.toString()}_${inDirectionOf.toString()}`)) ?? 0,
81
- ),
82
- );
78
+ getLastUsedIndexesAsRecipient(secrets: DirectionalAppTaggingSecret[]): Promise<(number | undefined)[]> {
79
+ return Promise.all(secrets.map(secret => this.#lastUsedIndexesAsRecipients.getAsync(secret.toString())));
83
80
  }
84
81
 
85
82
  resetNoteSyncData(): Promise<void> {
86
83
  return this.#store.transactionAsync(async () => {
87
- const recipients = await toArray(this.#taggingSecretIndexesForRecipients.keysAsync());
88
- await Promise.all(recipients.map(recipient => this.#taggingSecretIndexesForRecipients.delete(recipient)));
89
- const senders = await toArray(this.#taggingSecretIndexesForSenders.keysAsync());
90
- await Promise.all(senders.map(sender => this.#taggingSecretIndexesForSenders.delete(sender)));
84
+ const keysForSenders = await toArray(this.#lastUsedIndexesAsSenders.keysAsync());
85
+ await Promise.all(keysForSenders.map(secret => this.#lastUsedIndexesAsSenders.delete(secret)));
86
+ const keysForRecipients = await toArray(this.#lastUsedIndexesAsRecipients.keysAsync());
87
+ await Promise.all(keysForRecipients.map(secret => this.#lastUsedIndexesAsRecipients.delete(secret)));
91
88
  });
92
89
  }
93
90
 
@@ -1,3 +1,4 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
2
3
  import type { L2TipsKVStore } from '@aztec/kv-store/stores';
3
4
  import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
@@ -55,15 +56,14 @@ export class Synchronizer implements L2BlockStreamEventHandler {
55
56
  archive: lastBlock.archive.root.toString(),
56
57
  header: lastBlock.header.toInspect(),
57
58
  });
58
- await this.syncDataProvider.setHeader(lastBlock.header);
59
+ await this.syncDataProvider.setHeader(lastBlock.getBlockHeader());
59
60
  break;
60
61
  }
61
62
  case 'chain-pruned': {
62
63
  this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
63
64
  // We first unnullify and then remove so that unnullified notes that were created after the block number end up deleted.
64
65
  const lastSynchedBlockNumber = await this.syncDataProvider.getBlockNumber();
65
- await this.noteDataProvider.unnullifyNotesAfter(event.block.number, lastSynchedBlockNumber);
66
- await this.noteDataProvider.removeNotesAfter(event.block.number);
66
+ await this.noteDataProvider.rollbackNotesAndNullifiers(event.block.number, lastSynchedBlockNumber);
67
67
  // Remove all note tagging indexes to force a full resync. This is suboptimal, but unless we track the
68
68
  // block number in which each index is used it's all we can do.
69
69
  await this.taggingDataProvider.resetNoteSyncData();
@@ -110,7 +110,7 @@ export class Synchronizer implements L2BlockStreamEventHandler {
110
110
  }
111
111
  if (!currentHeader) {
112
112
  // REFACTOR: We should know the header of the genesis block without having to request it from the node.
113
- await this.syncDataProvider.setHeader((await this.node.getBlockHeader(0))!);
113
+ await this.syncDataProvider.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
114
114
  }
115
115
  await this.blockStream.sync();
116
116
  }
@@ -0,0 +1,2 @@
1
+ // Half the size of the window we slide over the tagging indexes.
2
+ export const WINDOW_HALF_SIZE = 10;
@@ -0,0 +1,6 @@
1
+ export * from './tag.js';
2
+ export * from './constants.js';
3
+ export * from './siloed_tag.js';
4
+ export * from './utils.js';
5
+ export { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
6
+ export { type PreTag } from '@aztec/stdlib/logs';
@@ -0,0 +1,22 @@
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+
5
+ import type { Tag } from './tag.js';
6
+
7
+ /**
8
+ * Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
9
+ * address that emitted the log.
10
+ */
11
+ export class SiloedTag {
12
+ private constructor(public readonly value: Fr) {}
13
+
14
+ static async compute(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
15
+ const siloedTag = await poseidon2Hash([app, tag.value]);
16
+ return new SiloedTag(siloedTag);
17
+ }
18
+
19
+ toString(): string {
20
+ return this.value.toString();
21
+ }
22
+ }
@@ -0,0 +1,16 @@
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { PreTag } from '@aztec/stdlib/logs';
4
+
5
+ /**
6
+ * Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
7
+ * with a contract address by kernels before being included in the final log.
8
+ */
9
+ export class Tag {
10
+ private constructor(public readonly value: Fr) {}
11
+
12
+ static async compute(preTag: PreTag): Promise<Tag> {
13
+ const tag = await poseidon2Hash([preTag.secret.value, preTag.index]);
14
+ return new Tag(tag);
15
+ }
16
+ }
@@ -0,0 +1,31 @@
1
+ import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
2
+
3
+ // TODO(benesjan): Make this return tags instead - this will moves some complexity from syncTaggedLogs
4
+ export function getPreTagsForTheWindow(
5
+ secretsAndWindows: { secret: DirectionalAppTaggingSecret; leftMostIndex: number; rightMostIndex: number }[],
6
+ ): PreTag[] {
7
+ const secrets = [];
8
+ for (const secretAndWindow of secretsAndWindows) {
9
+ for (let i = secretAndWindow.leftMostIndex; i <= secretAndWindow.rightMostIndex; i++) {
10
+ secrets.push({ secret: secretAndWindow.secret, index: i });
11
+ }
12
+ }
13
+ return secrets;
14
+ }
15
+
16
+ /**
17
+ * Creates a map from directional app tagging secret to initial index.
18
+ * @param preTags - The pre tags to get the initial indexes map from.
19
+ * @returns The map from directional app tagging secret to initial index.
20
+ */
21
+ export function getInitialIndexesMap(preTags: { secret: DirectionalAppTaggingSecret; index: number | undefined }[]): {
22
+ [k: string]: number;
23
+ } {
24
+ const initialIndexes: { [k: string]: number } = {};
25
+
26
+ for (const preTag of preTags) {
27
+ initialIndexes[preTag.secret.toString()] = preTag.index ?? 0;
28
+ }
29
+
30
+ return initialIndexes;
31
+ }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env -S node --no-warnings
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":""}
package/dest/bin/index.js DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env -S node --no-warnings
2
- import { createNamespacedSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
3
- import { createLogger } from '@aztec/foundation/log';
4
- import { PXESchema, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
5
- import http from 'http';
6
- import { getPXEServiceConfig } from '../config/index.js';
7
- import { createPXEService } from '../entrypoints/server/utils.js';
8
- const { PXE_PORT = 8080, AZTEC_NODE_URL = 'http://localhost:8079' } = process.env;
9
- const logger = createLogger('pxe:service');
10
- /**
11
- * Creates an http server that forwards calls to the PXE and starts it on the given port.
12
- * @param pxeService - PXE that answers queries to the created HTTP server.
13
- * @param port - Port to listen in.
14
- * @param maxBatchSize - Maximum allowed batch size for JSON RPC batch requests.
15
- * @returns A running http server.
16
- */ function startPXEHttpServer(pxeService, port, opts = {}) {
17
- const rpcServer = createNamespacedSafeJsonRpcServer({
18
- pxe: [
19
- pxeService,
20
- PXESchema
21
- ]
22
- }, opts);
23
- const app = rpcServer.getApp();
24
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
25
- const httpServer = http.createServer(app.callback());
26
- httpServer.listen(port);
27
- return httpServer;
28
- }
29
- /**
30
- * Create and start a new PXE HTTP Server
31
- */ async function main() {
32
- logger.info(`Setting up PXE...`);
33
- const pxeConfig = getPXEServiceConfig();
34
- const nodeRpcClient = createAztecNodeClient(AZTEC_NODE_URL, {});
35
- const pxeService = await createPXEService(nodeRpcClient, pxeConfig);
36
- const shutdown = ()=>{
37
- logger.info('Shutting down...');
38
- process.exit(0);
39
- };
40
- process.once('SIGINT', shutdown);
41
- process.once('SIGTERM', shutdown);
42
- startPXEHttpServer(pxeService, PXE_PORT);
43
- logger.info(`PXE listening on port ${PXE_PORT}`);
44
- }
45
- main().catch((err)=>{
46
- logger.error(err);
47
- process.exit(1);
48
- });
@@ -1,87 +0,0 @@
1
- import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
2
- import { Fr, Point } from '@aztec/foundation/fields';
3
- import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
6
- import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
7
- import type { ContractClassLog, IndexedTaggingSecret } from '@aztec/stdlib/logs';
8
- import type { Note, NoteStatus } from '@aztec/stdlib/note';
9
- import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
10
- import type { BlockHeader } from '@aztec/stdlib/tx';
11
- import type { UInt64 } from '@aztec/stdlib/types';
12
- import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
13
- /**
14
- * Information about a note needed during execution.
15
- */
16
- export interface NoteData {
17
- /** The actual note content (the fields of the Noir #[note] struct). */
18
- note: Note;
19
- /** The address of the contract that owns the note. */
20
- contractAddress: AztecAddress;
21
- /** The storage slot of the note. */
22
- storageSlot: Fr;
23
- /** The nonce injected into the note hash preimage by kernels. */
24
- noteNonce: Fr;
25
- /** A hash of the note as it gets stored in the note hash tree. */
26
- noteHash: Fr;
27
- /** The corresponding nullifier of the note. Undefined for pending notes. */
28
- siloedNullifier?: Fr;
29
- /** The note's leaf index in the note hash tree. Undefined for pending notes. */
30
- index?: bigint;
31
- }
32
- /**
33
- * Oracle with typed parameters and typed return values.
34
- * Methods that require read and/or write will have to be implemented based on the context (public, private, or view)
35
- * and are unavailable by default.
36
- */
37
- export declare abstract class TypedOracle {
38
- utilityAssertCompatibleOracleVersion(_version: number): void;
39
- utilityGetRandomField(): Fr;
40
- privateStoreInExecutionCache(_values: Fr[], _hash: Fr): void;
41
- privateLoadFromExecutionCache(_hash: Fr): Promise<Fr[]>;
42
- utilityGetBlockNumber(): Promise<number>;
43
- utilityGetTimestamp(): Promise<UInt64>;
44
- utilityGetContractAddress(): Promise<AztecAddress>;
45
- utilityGetChainId(): Promise<Fr>;
46
- utilityGetVersion(): Promise<Fr>;
47
- utilityGetKeyValidationRequest(_pkMHash: Fr): Promise<KeyValidationRequest>;
48
- utilityGetContractInstance(_address: AztecAddress): Promise<ContractInstance>;
49
- utilityGetMembershipWitness(_blockNumber: number, _treeId: MerkleTreeId, _leafValue: Fr): Promise<Fr[] | undefined>;
50
- utilityGetNullifierMembershipWitness(_blockNumber: number, _nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
51
- utilityGetPublicDataWitness(_blockNumber: number, _leafSlot: Fr): Promise<PublicDataWitness | undefined>;
52
- utilityGetLowNullifierMembershipWitness(_blockNumber: number, _nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
53
- utilityGetBlockHeader(_blockNumber: number): Promise<BlockHeader | undefined>;
54
- utilityGetCompleteAddress(_account: AztecAddress): Promise<CompleteAddress>;
55
- utilityGetAuthWitness(_messageHash: Fr): Promise<Fr[] | undefined>;
56
- utilityGetNotes(_storageSlot: Fr, _numSelects: number, _selectByIndexes: number[], _selectByOffsets: number[], _selectByLengths: number[], _selectValues: Fr[], _selectComparators: number[], _sortByIndexes: number[], _sortByOffsets: number[], _sortByLengths: number[], _sortOrder: number[], _limit: number, _offset: number, _status: NoteStatus): Promise<NoteData[]>;
57
- privateNotifyCreatedNote(_storageSlot: Fr, _noteTypeId: NoteSelector, _note: Fr[], _noteHash: Fr, _counter: number): void;
58
- privateNotifyNullifiedNote(_innerNullifier: Fr, _noteHash: Fr, _counter: number): Promise<void>;
59
- privateNotifyCreatedNullifier(_innerNullifier: Fr): Promise<void>;
60
- utilityCheckNullifierExists(_innerNullifier: Fr): Promise<boolean>;
61
- utilityGetL1ToL2MembershipWitness(_contractAddress: AztecAddress, _messageHash: Fr, _secret: Fr): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
62
- utilityStorageRead(_contractAddress: AztecAddress, _startStorageSlot: Fr, _blockNumber: number, _numberOfElements: number): Promise<Fr[]>;
63
- privateNotifyCreatedContractClassLog(_log: ContractClassLog, _counter: number): void;
64
- privateCallPrivateFunction(_targetContractAddress: AztecAddress, _functionSelector: FunctionSelector, _argsHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<{
65
- endSideEffectCounter: Fr;
66
- returnsHash: Fr;
67
- }>;
68
- privateNotifyEnqueuedPublicFunctionCall(_targetContractAddress: AztecAddress, _calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
69
- privateNotifySetPublicTeardownFunctionCall(_targetContractAddress: AztecAddress, _calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
70
- privateNotifySetMinRevertibleSideEffectCounter(_minRevertibleSideEffectCounter: number): Promise<void>;
71
- utilityDebugLog(_message: string, _fields: Fr[]): void;
72
- utilityGetIndexedTaggingSecretAsSender(_sender: AztecAddress, _recipient: AztecAddress): Promise<IndexedTaggingSecret>;
73
- privateIncrementAppTaggingSecretIndexAsSender(_sender: AztecAddress, _recipient: AztecAddress): Promise<void>;
74
- utilityFetchTaggedLogs(_pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
75
- utilityValidateEnqueuedNotesAndEvents(_contractAddress: AztecAddress, _noteValidationRequestsArrayBaseSlot: Fr, _eventValidationRequestsArrayBaseSlot: Fr): Promise<void>;
76
- utilityBulkRetrieveLogs(_contractAddress: AztecAddress, _logRetrievalRequestsArrayBaseSlot: Fr, _logRetrievalResponsesArrayBaseSlot: Fr): Promise<void>;
77
- utilityStoreCapsule(_contractAddress: AztecAddress, _key: Fr, _capsule: Fr[]): Promise<void>;
78
- utilityLoadCapsule(_contractAddress: AztecAddress, _key: Fr): Promise<Fr[] | null>;
79
- utilityDeleteCapsule(_contractAddress: AztecAddress, _key: Fr): Promise<void>;
80
- utilityCopyCapsule(_contractAddress: AztecAddress, _srcKey: Fr, _dstKey: Fr, _numEntries: number): Promise<void>;
81
- utilityAes128Decrypt(_ciphertext: Buffer, _iv: Buffer, _symKey: Buffer): Promise<Buffer>;
82
- utilityGetSharedSecret(_address: AztecAddress, _ephPk: Point): Promise<Point>;
83
- utilityEmitOffchainEffect(_data: Fr[]): Promise<void>;
84
- privateGetSenderForTags(): Promise<AztecAddress | undefined>;
85
- privateSetSenderForTags(_senderForTags: AztecAddress): Promise<void>;
86
- }
87
- //# sourceMappingURL=typed_oracle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typed_oracle.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/oracle/typed_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,uEAAuE;IACvE,IAAI,EAAE,IAAI,CAAC;IACX,sDAAsD;IACtD,eAAe,EAAE,YAAY,CAAC;IAC9B,oCAAoC;IACpC,WAAW,EAAE,EAAE,CAAC;IAChB,iEAAiE;IACjE,SAAS,EAAE,EAAE,CAAC;IACd,kEAAkE;IAClE,QAAQ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