@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
@@ -1,18 +1,18 @@
1
- import { DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
1
+ import { ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
2
2
 
3
3
  /**
4
- * A map that stores the tagging index for a given directional app tagging secret.
4
+ * A map that stores the tagging index for a given extended directional app tagging secret.
5
5
  * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
6
6
  * of sender -> recipient matters.
7
7
  */
8
8
  export class ExecutionTaggingIndexCache {
9
9
  private taggingIndexMap: Map<string, number> = new Map();
10
10
 
11
- public getLastUsedIndex(secret: DirectionalAppTaggingSecret): number | undefined {
11
+ public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
12
12
  return this.taggingIndexMap.get(secret.toString());
13
13
  }
14
14
 
15
- public setLastUsedIndex(secret: DirectionalAppTaggingSecret, index: number) {
15
+ public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
16
16
  const currentValue = this.taggingIndexMap.get(secret.toString());
17
17
  if (currentValue !== undefined && currentValue !== index - 1) {
18
18
  throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
@@ -25,7 +25,7 @@ export class ExecutionTaggingIndexCache {
25
25
  */
26
26
  public getUsedPreTags(): PreTag[] {
27
27
  return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
28
- secret: DirectionalAppTaggingSecret.fromString(secret),
28
+ extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
29
29
  index,
30
30
  }));
31
31
  }
@@ -5,10 +5,10 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { TxHash } from '@aztec/stdlib/tx';
6
6
 
7
7
  // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
8
- const MAX_EVENT_SERIALIZED_LEN = 12;
8
+ const MAX_EVENT_SERIALIZED_LEN = 11;
9
9
 
10
10
  /**
11
- * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateEnqueuedNotesAndEvents` oracle
11
+ * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
12
12
  * expects for values of this type to be stored in a `CapsuleArray`.
13
13
  */
14
14
  export class EventValidationRequest {
@@ -4,10 +4,10 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { TxHash } from '@aztec/stdlib/tx';
5
5
 
6
6
  // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
7
- export const MAX_NOTE_PACKED_LEN = 10;
7
+ export const MAX_NOTE_PACKED_LEN = 9;
8
8
 
9
9
  /**
10
- * Intermediate struct used to perform batch note validation by PXE. The `utilityValidateEnqueuedNotesAndEvents` oracle
10
+ * Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
11
11
  * expects for values of this type to be stored in a `CapsuleArray`.
12
12
  */
13
13
  export class NoteValidationRequest {
@@ -1,15 +1,16 @@
1
- import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
1
+ import type { ARCHIVE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { Point } from '@aztec/foundation/curves/grumpkin';
5
+ import { MembershipWitness } from '@aztec/foundation/trees';
5
6
  import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
6
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import { L2BlockHash } from '@aztec/stdlib/block';
8
+ import { BlockHash } from '@aztec/stdlib/block';
8
9
  import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
9
10
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
10
11
  import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
11
12
  import type { Note, NoteStatus } from '@aztec/stdlib/note';
12
- import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
13
+ import { type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
13
14
  import type { BlockHeader } from '@aztec/stdlib/tx';
14
15
 
15
16
  import type { UtilityContext } from '../noir-structs/utility_context.js';
@@ -53,7 +54,7 @@ export interface IMiscOracle {
53
54
 
54
55
  utilityGetRandomField(): Fr;
55
56
  utilityAssertCompatibleOracleVersion(version: number): void;
56
- utilityDebugLog(level: number, message: string, fields: Fr[]): void;
57
+ utilityLog(level: number, message: string, fields: Fr[]): Promise<void>;
57
58
  }
58
59
 
59
60
  /**
@@ -66,18 +67,25 @@ export interface IUtilityExecutionOracle {
66
67
  utilityGetUtilityContext(): UtilityContext;
67
68
  utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
68
69
  utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
69
- utilityGetMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[] | undefined>;
70
+ utilityGetNoteHashMembershipWitness(
71
+ anchorBlockHash: BlockHash,
72
+ noteHash: Fr,
73
+ ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
74
+ utilityGetBlockHashMembershipWitness(
75
+ anchorBlockHash: BlockHash,
76
+ blockHash: BlockHash,
77
+ ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
70
78
  utilityGetNullifierMembershipWitness(
71
- blockHash: L2BlockHash,
79
+ anchorBlockHash: BlockHash,
72
80
  nullifier: Fr,
73
81
  ): Promise<NullifierMembershipWitness | undefined>;
74
- utilityGetPublicDataWitness(blockHash: L2BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
82
+ utilityGetPublicDataWitness(anchorBlockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
75
83
  utilityGetLowNullifierMembershipWitness(
76
- blockHash: L2BlockHash,
84
+ anchorBlockHash: BlockHash,
77
85
  nullifier: Fr,
78
86
  ): Promise<NullifierMembershipWitness | undefined>;
79
87
  utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
80
- utilityGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress>;
88
+ utilityTryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
81
89
  utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
82
90
  utilityGetNotes(
83
91
  owner: AztecAddress | undefined,
@@ -103,13 +111,13 @@ export interface IUtilityExecutionOracle {
103
111
  secret: Fr,
104
112
  ): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
105
113
  utilityStorageRead(
106
- blockHash: L2BlockHash,
114
+ anchorBlockHash: BlockHash,
107
115
  contractAddress: AztecAddress,
108
116
  startStorageSlot: Fr,
109
117
  numberOfElements: number,
110
118
  ): Promise<Fr[]>;
111
119
  utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
112
- utilityValidateEnqueuedNotesAndEvents(
120
+ utilityValidateAndStoreEnqueuedNotesAndEvents(
113
121
  contractAddress: AztecAddress,
114
122
  noteValidationRequestsArrayBaseSlot: Fr,
115
123
  eventValidationRequestsArrayBaseSlot: Fr,
@@ -147,6 +155,7 @@ export interface IPrivateExecutionOracle {
147
155
  ): void;
148
156
  privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
149
157
  privateNotifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
158
+ privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean>;
150
159
  privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
151
160
  privateCallPrivateFunction(
152
161
  targetContractAddress: AztecAddress,
@@ -12,9 +12,8 @@ import {
12
12
  } from '@aztec/simulator/client';
13
13
  import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { L2BlockHash } from '@aztec/stdlib/block';
15
+ import { BlockHash } from '@aztec/stdlib/block';
16
16
  import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
17
- import { MerkleTreeId } from '@aztec/stdlib/trees';
18
17
 
19
18
  import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
20
19
  import { packAsHintedNote } from './note_packing_utils.js';
@@ -138,33 +137,49 @@ export class Oracle {
138
137
  ].map(toACVMField);
139
138
  }
140
139
 
141
- async utilityGetMembershipWitness(
140
+ async utilityGetNoteHashMembershipWitness(
141
+ [anchorBlockHash]: ACVMField[],
142
+ [noteHash]: ACVMField[],
143
+ ): Promise<(ACVMField | ACVMField[])[]> {
144
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
145
+ const parsedNoteHash = Fr.fromString(noteHash);
146
+
147
+ const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(
148
+ parsedAnchorBlockHash,
149
+ parsedNoteHash,
150
+ );
151
+ if (!witness) {
152
+ throw new Error(
153
+ `Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
154
+ );
155
+ }
156
+ return witness.toNoirRepresentation();
157
+ }
158
+
159
+ async utilityGetBlockHashMembershipWitness(
160
+ [anchorBlockHash]: ACVMField[],
142
161
  [blockHash]: ACVMField[],
143
- [treeId]: ACVMField[],
144
- [leafValue]: ACVMField[],
145
162
  ): Promise<(ACVMField | ACVMField[])[]> {
146
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
147
- const parsedTreeId = Fr.fromString(treeId).toNumber();
148
- const parsedLeafValue = Fr.fromString(leafValue);
163
+ const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
164
+ const parsedBlockHash = BlockHash.fromString(blockHash);
149
165
 
150
- const witness = await this.handlerAsUtility().utilityGetMembershipWitness(
166
+ const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(
167
+ parsedAnchorBlockHash,
151
168
  parsedBlockHash,
152
- parsedTreeId,
153
- parsedLeafValue,
154
169
  );
155
170
  if (!witness) {
156
171
  throw new Error(
157
- `Leaf ${leafValue} not found in the tree ${MerkleTreeId[parsedTreeId]} at block hash ${parsedBlockHash.toString()}.`,
172
+ `Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
158
173
  );
159
174
  }
160
- return [toACVMField(witness[0]), witness.slice(1).map(toACVMField)];
175
+ return witness.toNoirRepresentation();
161
176
  }
162
177
 
163
178
  async utilityGetNullifierMembershipWitness(
164
179
  [blockHash]: ACVMField[],
165
180
  [nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
166
181
  ): Promise<(ACVMField | ACVMField[])[]> {
167
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
182
+ const parsedBlockHash = BlockHash.fromString(blockHash);
168
183
  const parsedNullifier = Fr.fromString(nullifier);
169
184
 
170
185
  const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
@@ -183,7 +198,7 @@ export class Oracle {
183
198
  [blockHash]: ACVMField[],
184
199
  [nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
185
200
  ): Promise<(ACVMField | ACVMField[])[]> {
186
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
201
+ const parsedBlockHash = BlockHash.fromString(blockHash);
187
202
  const parsedNullifier = Fr.fromString(nullifier);
188
203
 
189
204
  const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
@@ -202,7 +217,7 @@ export class Oracle {
202
217
  [blockHash]: ACVMField[],
203
218
  [leafSlot]: ACVMField[],
204
219
  ): Promise<(ACVMField | ACVMField[])[]> {
205
- const parsedBlockHash = L2BlockHash.fromString(blockHash);
220
+ const parsedBlockHash = BlockHash.fromString(blockHash);
206
221
  const parsedLeafSlot = Fr.fromString(leafSlot);
207
222
 
208
223
  const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
@@ -233,12 +248,19 @@ export class Oracle {
233
248
  return [witness.map(toACVMField)];
234
249
  }
235
250
 
236
- async utilityGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<ACVMField[][]> {
251
+ async utilityTryGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
237
252
  const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
238
- const { publicKeys, partialAddress } =
239
- await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
253
+ const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(parsedAddress);
240
254
 
241
- return [[...publicKeys.toFields(), partialAddress].map(toACVMField)];
255
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
256
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
257
+ if (result === undefined) {
258
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
259
+ return [toACVMField(0), Array(13).fill(toACVMField(0))];
260
+ } else {
261
+ // Data was found so we set `some` to 1 and return it along with `value`.
262
+ return [toACVMField(1), [...result.publicKeys.toFields(), result.partialAddress].map(toACVMField)];
263
+ }
242
264
  }
243
265
 
244
266
  async utilityGetNotes(
@@ -341,6 +363,14 @@ export class Oracle {
341
363
  return [];
342
364
  }
343
365
 
366
+ async privateIsNullifierPending([innerNullifier]: ACVMField[], [contractAddress]: ACVMField[]): Promise<ACVMField[]> {
367
+ const isPending = await this.handlerAsPrivate().privateIsNullifierPending(
368
+ Fr.fromString(innerNullifier),
369
+ AztecAddress.fromString(contractAddress),
370
+ );
371
+ return [toACVMField(isPending)];
372
+ }
373
+
344
374
  async utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
345
375
  const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
346
376
  return [toACVMField(exists)];
@@ -366,7 +396,7 @@ export class Oracle {
366
396
  [numberOfElements]: ACVMField[],
367
397
  ): Promise<ACVMField[][]> {
368
398
  const values = await this.handlerAsUtility().utilityStorageRead(
369
- L2BlockHash.fromString(blockHash),
399
+ BlockHash.fromString(blockHash),
370
400
  new AztecAddress(Fr.fromString(contractAddress)),
371
401
  Fr.fromString(startStorageSlot),
372
402
  +numberOfElements,
@@ -387,7 +417,7 @@ export class Oracle {
387
417
  return Promise.resolve([]);
388
418
  }
389
419
 
390
- utilityDebugLog(
420
+ async utilityLog(
391
421
  level: ACVMField[],
392
422
  message: ACVMField[],
393
423
  _ignoredFieldsSize: ACVMField[],
@@ -396,8 +426,8 @@ export class Oracle {
396
426
  const levelFr = Fr.fromString(level[0]);
397
427
  const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
398
428
  const fieldsFr = fields.map(Fr.fromString);
399
- this.handlerAsMisc().utilityDebugLog(levelFr.toNumber(), messageStr, fieldsFr);
400
- return Promise.resolve([]);
429
+ await this.handlerAsMisc().utilityLog(levelFr.toNumber(), messageStr, fieldsFr);
430
+ return [];
401
431
  }
402
432
 
403
433
  // This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
@@ -478,12 +508,12 @@ export class Oracle {
478
508
  return [];
479
509
  }
480
510
 
481
- async utilityValidateEnqueuedNotesAndEvents(
511
+ async utilityValidateAndStoreEnqueuedNotesAndEvents(
482
512
  [contractAddress]: ACVMField[],
483
513
  [noteValidationRequestsArrayBaseSlot]: ACVMField[],
484
514
  [eventValidationRequestsArrayBaseSlot]: ACVMField[],
485
515
  ): Promise<ACVMField[]> {
486
- await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(
516
+ await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
487
517
  AztecAddress.fromString(contractAddress),
488
518
  Fr.fromString(noteValidationRequestsArrayBaseSlot),
489
519
  Fr.fromString(eventValidationRequestsArrayBaseSlot),
@@ -2,7 +2,6 @@ import { PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, PRIVATE_CONTEXT_INPUTS_LENGTH } f
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
5
  import {
7
6
  type ACVMWitness,
8
7
  type CircuitSimulator,
@@ -18,15 +17,10 @@ import {
18
17
  countArgumentsSize,
19
18
  } from '@aztec/stdlib/abi';
20
19
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
21
- import { L2BlockHash } from '@aztec/stdlib/block';
22
- import type { ContractInstance } from '@aztec/stdlib/contract';
23
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
24
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
25
20
  import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
26
21
  import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
27
- import { BlockHeader, PrivateCallExecutionResult } from '@aztec/stdlib/tx';
22
+ import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
28
23
 
29
- import { ContractStore } from '../../storage/contract_store/index.js';
30
24
  import { Oracle } from './oracle.js';
31
25
  import type { PrivateExecutionOracle } from './private_execution_oracle.js';
32
26
 
@@ -145,56 +139,3 @@ export function extractPrivateCircuitPublicInputs(
145
139
  }
146
140
  return PrivateCircuitPublicInputs.fromFields(returnData);
147
141
  }
148
-
149
- /**
150
- * Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
151
- * from the instance is used.
152
- * @param contractAddress - The address of the contract to read the class id for.
153
- * @param instance - The instance of the contract.
154
- * @param aztecNode - The Aztec node to query for storage.
155
- * @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
156
- * @returns The current class id.
157
- */
158
- export async function readCurrentClassId(
159
- contractAddress: AztecAddress,
160
- instance: ContractInstance,
161
- aztecNode: AztecNode,
162
- header: BlockHeader,
163
- ) {
164
- const blockHashFr = await header.hash();
165
- const blockHash = L2BlockHash.fromField(blockHashFr);
166
- const timestamp = header.globalVariables.timestamp;
167
- const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
168
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
169
- aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
170
- );
171
- let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
172
- if (currentClassId.isZero()) {
173
- currentClassId = instance.originalContractClassId;
174
- }
175
- return currentClassId;
176
- }
177
-
178
- /**
179
- * Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
180
- * provider (i.e. PXE's own storage).
181
- * @param header - The header of the block at which to verify the current class id.
182
- */
183
- export async function verifyCurrentClassId(
184
- contractAddress: AztecAddress,
185
- aztecNode: AztecNode,
186
- contractStore: ContractStore,
187
- header: BlockHeader,
188
- ) {
189
- const instance = await contractStore.getContractInstance(contractAddress);
190
- if (!instance) {
191
- throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
192
- }
193
-
194
- const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
195
- if (!instance.currentContractClassId.equals(currentClassId)) {
196
- throw new Error(
197
- `Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
198
- );
199
- }
200
- }