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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dest/bin/check_oracle_version.js +1 -1
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +7 -5
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +56 -16
  5. package/dest/config/index.d.ts +3 -1
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +17 -0
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +2 -4
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +8 -13
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  12. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  13. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  14. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  15. package/dest/contract_function_simulator/oracle/interfaces.d.ts +13 -10
  16. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -3
  18. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/oracle/oracle.js +28 -18
  20. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  21. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
  23. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -3
  24. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +19 -8
  26. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +29 -17
  27. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +47 -45
  29. package/dest/contract_sync/index.d.ts +23 -0
  30. package/dest/contract_sync/index.d.ts.map +1 -0
  31. package/dest/contract_sync/index.js +54 -0
  32. package/dest/debug/pxe_debug_utils.d.ts +16 -6
  33. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  34. package/dest/debug/pxe_debug_utils.js +20 -10
  35. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  36. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  37. package/dest/entrypoints/client/bundle/utils.js +12 -6
  38. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  39. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  40. package/dest/entrypoints/client/lazy/utils.js +13 -7
  41. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  42. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  43. package/dest/entrypoints/server/index.d.ts +2 -1
  44. package/dest/entrypoints/server/index.d.ts.map +1 -1
  45. package/dest/entrypoints/server/index.js +1 -0
  46. package/dest/entrypoints/server/utils.d.ts +1 -1
  47. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  48. package/dest/entrypoints/server/utils.js +19 -8
  49. package/dest/events/event_service.d.ts +5 -6
  50. package/dest/events/event_service.d.ts.map +1 -1
  51. package/dest/events/event_service.js +6 -7
  52. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  53. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  54. package/dest/job_coordinator/job_coordinator.js +3 -2
  55. package/dest/logs/log_service.d.ts +5 -4
  56. package/dest/logs/log_service.d.ts.map +1 -1
  57. package/dest/logs/log_service.js +18 -15
  58. package/dest/notes/note_service.d.ts +6 -6
  59. package/dest/notes/note_service.d.ts.map +1 -1
  60. package/dest/notes/note_service.js +14 -14
  61. package/dest/oracle_version.d.ts +3 -3
  62. package/dest/oracle_version.d.ts.map +1 -1
  63. package/dest/oracle_version.js +4 -3
  64. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  65. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  66. package/dest/private_kernel/private_kernel_execution_prover.js +2 -2
  67. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -3
  68. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  69. package/dest/pxe.d.ts +1 -1
  70. package/dest/pxe.d.ts.map +1 -1
  71. package/dest/pxe.js +19 -15
  72. package/dest/storage/address_store/address_store.d.ts +1 -1
  73. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  74. package/dest/storage/address_store/address_store.js +12 -11
  75. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  76. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  77. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  78. package/dest/storage/capsule_store/capsule_store.js +6 -8
  79. package/dest/storage/contract_store/contract_store.d.ts +1 -2
  80. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  81. package/dest/storage/contract_store/contract_store.js +22 -25
  82. package/dest/storage/metadata.d.ts +1 -1
  83. package/dest/storage/metadata.js +1 -1
  84. package/dest/storage/note_store/note_store.d.ts +48 -50
  85. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  86. package/dest/storage/note_store/note_store.js +276 -252
  87. package/dest/storage/note_store/stored_note.d.ts +16 -0
  88. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  89. package/dest/storage/note_store/stored_note.js +43 -0
  90. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  91. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  92. package/dest/storage/private_event_store/private_event_store.js +198 -147
  93. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  94. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  95. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  96. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +1 -1
  97. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  98. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  99. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  100. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  101. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  102. package/dest/storage/tagging_store/sender_tagging_store.d.ts +1 -1
  103. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  104. package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
  105. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  106. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  107. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  108. package/dest/tagging/index.d.ts +2 -1
  109. package/dest/tagging/index.d.ts.map +1 -1
  110. package/dest/tagging/index.js +1 -0
  111. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
  112. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  113. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +2 -2
  114. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
  115. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  116. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
  117. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
  118. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  119. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +2 -2
  120. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  121. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  122. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  123. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +3 -2
  124. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  125. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +7 -4
  126. package/package.json +16 -16
  127. package/src/bin/check_oracle_version.ts +1 -0
  128. package/src/block_synchronizer/block_synchronizer.ts +70 -33
  129. package/src/config/index.ts +14 -0
  130. package/src/contract_function_simulator/contract_function_simulator.ts +7 -15
  131. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  132. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  133. package/src/contract_function_simulator/oracle/interfaces.ts +18 -9
  134. package/src/contract_function_simulator/oracle/oracle.ts +42 -19
  135. package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
  136. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -10
  137. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +67 -53
  138. package/src/contract_sync/index.ts +98 -0
  139. package/src/debug/pxe_debug_utils.ts +26 -11
  140. package/src/entrypoints/client/bundle/utils.ts +7 -14
  141. package/src/entrypoints/client/lazy/utils.ts +8 -14
  142. package/src/entrypoints/pxe_creation_options.ts +2 -1
  143. package/src/entrypoints/server/index.ts +1 -0
  144. package/src/entrypoints/server/utils.ts +15 -19
  145. package/src/events/event_service.ts +5 -7
  146. package/src/job_coordinator/job_coordinator.ts +4 -3
  147. package/src/logs/log_service.ts +29 -13
  148. package/src/notes/note_service.ts +21 -20
  149. package/src/oracle_version.ts +4 -3
  150. package/src/private_kernel/private_kernel_execution_prover.ts +6 -3
  151. package/src/private_kernel/private_kernel_oracle.ts +2 -2
  152. package/src/pxe.ts +48 -17
  153. package/src/storage/address_store/address_store.ts +15 -15
  154. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  155. package/src/storage/capsule_store/capsule_store.ts +8 -8
  156. package/src/storage/contract_store/contract_store.ts +22 -31
  157. package/src/storage/metadata.ts +1 -1
  158. package/src/storage/note_store/note_store.ts +314 -318
  159. package/src/storage/note_store/stored_note.ts +48 -0
  160. package/src/storage/private_event_store/private_event_store.ts +250 -190
  161. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  162. package/src/storage/tagging_store/recipient_tagging_store.ts +31 -21
  163. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  164. package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
  165. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  166. package/src/tagging/index.ts +1 -0
  167. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +11 -1
  168. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
  169. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +3 -1
  170. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
  171. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +12 -3
  172. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  173. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  174. package/dest/tree_membership/tree_membership_service.js +0 -75
  175. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -1,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';
@@ -66,14 +67,21 @@ 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>;
@@ -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);
@@ -341,6 +356,14 @@ export class Oracle {
341
356
  return [];
342
357
  }
343
358
 
359
+ async privateIsNullifierPending([innerNullifier]: ACVMField[], [contractAddress]: ACVMField[]): Promise<ACVMField[]> {
360
+ const isPending = await this.handlerAsPrivate().privateIsNullifierPending(
361
+ Fr.fromString(innerNullifier),
362
+ AztecAddress.fromString(contractAddress),
363
+ );
364
+ return [toACVMField(isPending)];
365
+ }
366
+
344
367
  async utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
345
368
  const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
346
369
  return [toACVMField(exists)];
@@ -366,7 +389,7 @@ export class Oracle {
366
389
  [numberOfElements]: ACVMField[],
367
390
  ): Promise<ACVMField[][]> {
368
391
  const values = await this.handlerAsUtility().utilityStorageRead(
369
- L2BlockHash.fromString(blockHash),
392
+ BlockHash.fromString(blockHash),
370
393
  new AztecAddress(Fr.fromString(contractAddress)),
371
394
  Fr.fromString(startStorageSlot),
372
395
  +numberOfElements,
@@ -478,12 +501,12 @@ export class Oracle {
478
501
  return [];
479
502
  }
480
503
 
481
- async utilityValidateEnqueuedNotesAndEvents(
504
+ async utilityValidateAndStoreEnqueuedNotesAndEvents(
482
505
  [contractAddress]: ACVMField[],
483
506
  [noteValidationRequestsArrayBaseSlot]: ACVMField[],
484
507
  [eventValidationRequestsArrayBaseSlot]: ACVMField[],
485
508
  ): Promise<ACVMField[]> {
486
- await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(
509
+ await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
487
510
  AztecAddress.fromString(contractAddress),
488
511
  Fr.fromString(noteValidationRequestsArrayBaseSlot),
489
512
  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
- }
@@ -30,9 +30,9 @@ import {
30
30
  type TxContext,
31
31
  } from '@aztec/stdlib/tx';
32
32
 
33
+ import { ensureContractSynced } from '../../contract_sync/index.js';
33
34
  import { NoteService } from '../../notes/note_service.js';
34
35
  import type { AddressStore } from '../../storage/address_store/address_store.js';
35
- import type { AnchorBlockStore } from '../../storage/anchor_block_store/anchor_block_store.js';
36
36
  import type { CapsuleStore } from '../../storage/capsule_store/capsule_store.js';
37
37
  import type { ContractStore } from '../../storage/contract_store/contract_store.js';
38
38
  import type { NoteStore } from '../../storage/note_store/note_store.js';
@@ -46,7 +46,7 @@ import { ExecutionTaggingIndexCache } from '../execution_tagging_index_cache.js'
46
46
  import type { HashedValuesCache } from '../hashed_values_cache.js';
47
47
  import { pickNotes } from '../pick_notes.js';
48
48
  import type { IPrivateExecutionOracle, NoteData } from './interfaces.js';
49
- import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
49
+ import { executePrivateFunction } from './private_execution.js';
50
50
  import { UtilityExecutionOracle } from './utility_execution_oracle.js';
51
51
 
52
52
  /**
@@ -88,7 +88,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
88
88
  keyStore: KeyStore,
89
89
  addressStore: AddressStore,
90
90
  aztecNode: AztecNode,
91
- anchorBlockStore: AnchorBlockStore,
92
91
  private readonly senderTaggingStore: SenderTaggingStore,
93
92
  recipientTaggingStore: RecipientTaggingStore,
94
93
  senderAddressBookStore: SenderAddressBookStore,
@@ -112,7 +111,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
112
111
  keyStore,
113
112
  addressStore,
114
113
  aztecNode,
115
- anchorBlockStore,
116
114
  recipientTaggingStore,
117
115
  senderAddressBookStore,
118
116
  capsuleStore,
@@ -265,7 +263,14 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
265
263
  // This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
266
264
  // are up to date. We do this here because this store is not synced as part of the global sync because
267
265
  // that'd be wasteful as most tagging secrets are not used in each tx.
268
- await syncSenderTaggingIndexes(secret, this.contractAddress, this.aztecNode, this.senderTaggingStore, this.jobId);
266
+ await syncSenderTaggingIndexes(
267
+ secret,
268
+ this.contractAddress,
269
+ this.aztecNode,
270
+ this.senderTaggingStore,
271
+ await this.anchorBlockHeader.hash(),
272
+ this.jobId,
273
+ );
269
274
 
270
275
  const lastUsedIndex = await this.senderTaggingStore.getLastUsedIndex(secret, this.jobId);
271
276
  // If lastUsedIndex is undefined, we've never used this secret, so start from 0
@@ -356,7 +361,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
356
361
 
357
362
  const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
358
363
 
359
- const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
364
+ const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
360
365
  const dbNotes = await noteService.getNotes(
361
366
  this.callContext.contractAddress,
362
367
  owner,
@@ -463,6 +468,19 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
463
468
  return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
464
469
  }
465
470
 
471
+ /**
472
+ * Check if a nullifier has been emitted in the same transaction, i.e. if privateNotifyCreatedNullifier has been
473
+ * called for this inner nullifier from the contract with the specified address.
474
+ * @param innerNullifier - The inner nullifier to check.
475
+ * @param contractAddress - Address of the contract that emitted the nullifier.
476
+ * @returns A boolean indicating whether the nullifier is pending or not.
477
+ */
478
+ public async privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean> {
479
+ const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
480
+ const isNullifierPending = this.noteCache.getNullifiers(contractAddress).has(siloedNullifier.toBigInt());
481
+ return Promise.resolve(isNullifierPending);
482
+ }
483
+
466
484
  /**
467
485
  * Emit a contract class log.
468
486
  * This fn exists because we only carry a poseidon hash through the kernels, and need to
@@ -519,9 +537,14 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
519
537
 
520
538
  isStaticCall = isStaticCall || this.callContext.isStaticCall;
521
539
 
522
- await verifyCurrentClassId(targetContractAddress, this.aztecNode, this.contractStore, this.anchorBlockHeader);
523
-
524
- await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, this.utilityExecutor);
540
+ await ensureContractSynced(
541
+ targetContractAddress,
542
+ functionSelector,
543
+ this.utilityExecutor,
544
+ this.aztecNode,
545
+ this.contractStore,
546
+ this.anchorBlockHeader,
547
+ );
525
548
 
526
549
  const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
527
550
  targetContractAddress,
@@ -548,7 +571,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
548
571
  this.keyStore,
549
572
  this.addressStore,
550
573
  this.aztecNode,
551
- this.anchorBlockStore,
552
574
  this.senderTaggingStore,
553
575
  this.recipientTaggingStore,
554
576
  this.senderAddressBookStore,