@aztec/pxe 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212

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 +12 -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 +11 -11
  84. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  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 +9 -41
  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 +15 -23
  202. package/src/entrypoints/client/lazy/index.ts +3 -1
  203. package/src/entrypoints/client/lazy/utils.ts +14 -22
  204. package/src/entrypoints/pxe_creation_options.ts +2 -0
  205. package/src/entrypoints/server/index.ts +3 -1
  206. package/src/entrypoints/server/utils.ts +12 -56
  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,5 +1,5 @@
1
1
  import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
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
5
  import { type CircuitSimulator, toACVMWitness } from '@aztec/simulator/client';
@@ -12,9 +12,9 @@ import {
12
12
  } from '@aztec/stdlib/abi';
13
13
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
15
+ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
16
16
  import { PrivateContextInputs } from '@aztec/stdlib/kernel';
17
- import type { ContractClassLog } from '@aztec/stdlib/logs';
17
+ import type { ContractClassLog, DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
18
18
  import { Note, type NoteStatus } from '@aztec/stdlib/note';
19
19
  import {
20
20
  type BlockHeader,
@@ -26,18 +26,22 @@ import {
26
26
  type TxContext,
27
27
  } from '@aztec/stdlib/tx';
28
28
 
29
+ import { Tag } from '../../tagging/tag.js';
29
30
  import type { ExecutionDataProvider } from '../execution_data_provider.js';
30
31
  import type { ExecutionNoteCache } from '../execution_note_cache.js';
32
+ import { ExecutionTaggingIndexCache } from '../execution_tagging_index_cache.js';
31
33
  import type { HashedValuesCache } from '../hashed_values_cache.js';
32
34
  import { pickNotes } from '../pick_notes.js';
35
+ import type { IPrivateExecutionOracle, NoteData } from './interfaces.js';
33
36
  import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
34
- import type { NoteData } from './typed_oracle.js';
35
37
  import { UtilityExecutionOracle } from './utility_execution_oracle.js';
36
38
 
37
39
  /**
38
40
  * The execution oracle for the private part of a transaction.
39
41
  */
40
- export class PrivateExecutionOracle extends UtilityExecutionOracle {
42
+ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IPrivateExecutionOracle {
43
+ isPrivate = true as const;
44
+
41
45
  /**
42
46
  * New notes created during this execution.
43
47
  * It's possible that a note in this list has been nullified (in the same or other executions) and doesn't exist in
@@ -61,29 +65,32 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
61
65
  private contractClassLogs: CountedContractClassLog[] = [];
62
66
  private offchainEffects: { data: Fr[] }[] = [];
63
67
  private nestedExecutionResults: PrivateCallExecutionResult[] = [];
64
- private senderForTags?: AztecAddress;
65
68
 
66
69
  constructor(
67
70
  private readonly argsHash: Fr,
68
71
  private readonly txContext: TxContext,
69
72
  private readonly callContext: CallContext,
70
73
  /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
71
- protected readonly historicalHeader: BlockHeader,
74
+ protected readonly anchorBlockHeader: BlockHeader,
72
75
  /** List of transient auth witnesses to be used during this simulation */
73
76
  authWitnesses: AuthWitness[],
74
77
  capsules: Capsule[],
75
78
  private readonly executionCache: HashedValuesCache,
76
79
  private readonly noteCache: ExecutionNoteCache,
80
+ private readonly taggingIndexCache: ExecutionTaggingIndexCache,
77
81
  executionDataProvider: ExecutionDataProvider,
78
- private simulator: CircuitSimulator,
79
- private totalPublicCalldataCount: number,
82
+ private totalPublicCalldataCount: number = 0,
80
83
  protected sideEffectCounter: number = 0,
81
84
  log = createLogger('simulator:client_execution_context'),
82
85
  scopes?: AztecAddress[],
83
- senderForTags?: AztecAddress,
86
+ private senderForTags?: AztecAddress,
87
+ private simulator?: CircuitSimulator,
84
88
  ) {
85
89
  super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes);
86
- this.senderForTags = senderForTags;
90
+ }
91
+
92
+ public getPrivateContextInputs(): PrivateContextInputs {
93
+ return new PrivateContextInputs(this.callContext, this.anchorBlockHeader, this.txContext, this.sideEffectCounter);
87
94
  }
88
95
 
89
96
  // We still need this function until we can get user-defined ordering of structs for fn arguments
@@ -102,13 +109,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
102
109
  throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args?.length}`);
103
110
  }
104
111
 
105
- const privateContextInputs = new PrivateContextInputs(
106
- this.callContext,
107
- this.historicalHeader,
108
- this.txContext,
109
- this.sideEffectCounter,
110
- );
111
- const privateContextInputsAsFields = privateContextInputs.toFields();
112
+ const privateContextInputsAsFields = this.getPrivateContextInputs().toFields();
112
113
  if (privateContextInputsAsFields.length !== PRIVATE_CONTEXT_INPUTS_LENGTH) {
113
114
  throw new Error('Invalid private context inputs size');
114
115
  }
@@ -150,6 +151,13 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
150
151
  return this.offchainEffects;
151
152
  }
152
153
 
154
+ /**
155
+ * Returns the pre tags that were used in this execution (and that need to be stored in the db).
156
+ */
157
+ public getUsedPreTags(): PreTag[] {
158
+ return this.taggingIndexCache.getUsedPreTags();
159
+ }
160
+
153
161
  /**
154
162
  * Return the nested execution results during this execution.
155
163
  */
@@ -167,7 +175,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
167
175
  * The value persists through nested calls, meaning all calls down the stack will use the same
168
176
  * 'senderForTags' value (unless it is replaced).
169
177
  */
170
- public override privateGetSenderForTags(): Promise<AztecAddress | undefined> {
178
+ public privateGetSenderForTags(): Promise<AztecAddress | undefined> {
171
179
  return Promise.resolve(this.senderForTags);
172
180
  }
173
181
 
@@ -182,17 +190,57 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
182
190
  * through nested calls, meaning all calls down the stack will use the same 'senderForTags'
183
191
  * value (unless it is replaced by another call to this setter).
184
192
  */
185
- public override privateSetSenderForTags(senderForTags: AztecAddress): Promise<void> {
193
+ public privateSetSenderForTags(senderForTags: AztecAddress): Promise<void> {
186
194
  this.senderForTags = senderForTags;
187
195
  return Promise.resolve();
188
196
  }
189
197
 
198
+ /**
199
+ * Returns the next app tag for a given sender and recipient pair.
200
+ * @param sender - The address sending the log
201
+ * @param recipient - The address receiving the log
202
+ * @returns An app tag to be used in a log.
203
+ */
204
+ public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
205
+ const secret = await this.executionDataProvider.calculateDirectionalAppTaggingSecret(
206
+ this.contractAddress,
207
+ sender,
208
+ recipient,
209
+ );
210
+
211
+ const index = await this.#getIndexToUseForSecret(secret);
212
+ this.log.debug(
213
+ `Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
214
+ );
215
+ this.taggingIndexCache.setLastUsedIndex(secret, index);
216
+
217
+ return Tag.compute({ secret, index });
218
+ }
219
+
220
+ async #getIndexToUseForSecret(secret: DirectionalAppTaggingSecret): Promise<number> {
221
+ // If we have the tagging index in the cache, we use it. If not we obtain it from the execution data provider.
222
+ const lastUsedIndexInTx = this.taggingIndexCache.getLastUsedIndex(secret);
223
+
224
+ if (lastUsedIndexInTx !== undefined) {
225
+ return lastUsedIndexInTx + 1;
226
+ } else {
227
+ // This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
228
+ // are up to date. We do this here because this store is not synced as part of the global sync because
229
+ // that'd be wasteful as most tagging secrets are not used in each tx.
230
+ await this.executionDataProvider.syncTaggedLogsAsSender(secret, this.contractAddress);
231
+ const lastUsedIndex = await this.executionDataProvider.getLastUsedIndexAsSender(secret);
232
+ // If lastUsedIndex is undefined, we've never used this secret, so start from 0
233
+ // Otherwise, the next index to use is one past the last used index
234
+ return lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
235
+ }
236
+ }
237
+
190
238
  /**
191
239
  * Store values in the execution cache.
192
240
  * @param values - Values to store.
193
241
  * @returns The hash of the values.
194
242
  */
195
- public override privateStoreInExecutionCache(values: Fr[], hash: Fr) {
243
+ public privateStoreInExecutionCache(values: Fr[], hash: Fr) {
196
244
  return this.executionCache.store(values, hash);
197
245
  }
198
246
 
@@ -201,7 +249,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
201
249
  * @param hash - Hash of the values.
202
250
  * @returns The values.
203
251
  */
204
- public override privateLoadFromExecutionCache(hash: Fr): Promise<Fr[]> {
252
+ public privateLoadFromExecutionCache(hash: Fr): Promise<Fr[]> {
205
253
  const preimage = this.executionCache.getPreimage(hash);
206
254
  if (!preimage) {
207
255
  throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
@@ -209,6 +257,23 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
209
257
  return Promise.resolve(preimage);
210
258
  }
211
259
 
260
+ override async utilityCheckNullifierExists(innerNullifier: Fr): Promise<boolean> {
261
+ // This oracle must be overridden because while utility execution can only meaningfully check if a nullifier exists
262
+ // in the synched block, during private execution there's also the possibility of it being pending, i.e. created
263
+ // in the current transaction.
264
+
265
+ this.log.debug(`Checking existence of inner nullifier ${innerNullifier}`, {
266
+ contractAddress: this.contractAddress,
267
+ });
268
+
269
+ const nullifier = (await siloNullifier(this.contractAddress, innerNullifier)).toBigInt();
270
+
271
+ return (
272
+ this.noteCache.getNullifiers(this.contractAddress).has(nullifier) ||
273
+ (await super.utilityCheckNullifierExists(innerNullifier))
274
+ );
275
+ }
276
+
212
277
  /**
213
278
  * Gets some notes for a storage slot.
214
279
  *
@@ -217,6 +282,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
217
282
  * Real notes coming from DB will have a leafIndex which
218
283
  * represents their index in the note hash tree.
219
284
  *
285
+ * @param owner - The owner of the notes. If undefined, returns notes for all owners.
220
286
  * @param storageSlot - The storage slot.
221
287
  * @param numSelects - The number of valid selects in selectBy and selectValues.
222
288
  * @param selectBy - An array of indices of the fields to selects.
@@ -230,6 +296,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
230
296
  * @returns Array of note data.
231
297
  */
232
298
  public override async utilityGetNotes(
299
+ owner: AztecAddress | undefined,
233
300
  storageSlot: Fr,
234
301
  numSelects: number,
235
302
  selectByIndexes: number[],
@@ -246,11 +313,12 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
246
313
  status: NoteStatus,
247
314
  ): Promise<NoteData[]> {
248
315
  // Nullified pending notes are already removed from the list.
249
- const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, storageSlot);
316
+ const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, owner, storageSlot);
250
317
 
251
318
  const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
252
319
  const dbNotes = await this.executionDataProvider.getNotes(
253
320
  this.callContext.contractAddress,
321
+ owner,
254
322
  storageSlot,
255
323
  status,
256
324
  this.scopes,
@@ -300,15 +368,18 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
300
368
  /**
301
369
  * Keep track of the new note created during execution.
302
370
  * It can be used in subsequent calls (or transactions when chaining txs is possible).
303
- * @param contractAddress - The contract address.
371
+ * @param owner - The owner of the note.
304
372
  * @param storageSlot - The storage slot.
373
+ * @param randomness - The randomness injected into the note.
305
374
  * @param noteTypeId - The type ID of the note.
306
375
  * @param noteItems - The items to be included in a Note.
307
376
  * @param noteHash - A hash of the new note.
308
377
  * @returns
309
378
  */
310
- public override privateNotifyCreatedNote(
379
+ public privateNotifyCreatedNote(
380
+ owner: AztecAddress,
311
381
  storageSlot: Fr,
382
+ randomness: Fr,
312
383
  noteTypeId: NoteSelector,
313
384
  noteItems: Fr[],
314
385
  noteHash: Fr,
@@ -317,6 +388,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
317
388
  this.log.debug(`Notified of new note with inner hash ${noteHash}`, {
318
389
  contractAddress: this.callContext.contractAddress,
319
390
  storageSlot,
391
+ randomness,
320
392
  noteTypeId,
321
393
  counter,
322
394
  });
@@ -325,7 +397,9 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
325
397
  this.noteCache.addNewNote(
326
398
  {
327
399
  contractAddress: this.callContext.contractAddress,
400
+ owner,
328
401
  storageSlot,
402
+ randomness,
329
403
  noteNonce: Fr.ZERO, // Nonce cannot be known during private execution.
330
404
  note,
331
405
  siloedNullifier: undefined, // Siloed nullifier cannot be known for newly created note.
@@ -333,7 +407,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
333
407
  },
334
408
  counter,
335
409
  );
336
- this.newNotes.push(new NoteAndSlot(note, storageSlot, noteTypeId));
410
+ this.newNotes.push(NoteAndSlot.from({ note, storageSlot, randomness, noteTypeId }));
337
411
  }
338
412
 
339
413
  /**
@@ -342,7 +416,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
342
416
  * @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
343
417
  * @param noteHash - A hash of the new note.
344
418
  */
345
- public override async privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
419
+ public async privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number) {
346
420
  const nullifiedNoteHashCounter = await this.noteCache.nullifyNote(
347
421
  this.callContext.contractAddress,
348
422
  innerNullifier,
@@ -359,7 +433,8 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
359
433
  * @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
360
434
  * @param noteHash - A hash of the new note.
361
435
  */
362
- public override privateNotifyCreatedNullifier(innerNullifier: Fr) {
436
+ public privateNotifyCreatedNullifier(innerNullifier: Fr) {
437
+ this.log.debug(`Notified of new inner nullifier ${innerNullifier}`, { contractAddress: this.contractAddress });
363
438
  return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
364
439
  }
365
440
 
@@ -370,7 +445,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
370
445
  * @param log - The contract class log to be emitted.
371
446
  * @param counter - The contract class log's counter.
372
447
  */
373
- public override privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
448
+ public privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number) {
374
449
  this.contractClassLogs.push(new CountedContractClassLog(log, counter));
375
450
  const text = log.toBuffer().toString('hex');
376
451
  this.log.verbose(
@@ -399,13 +474,19 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
399
474
  * @param isStaticCall - Whether the call is a static call.
400
475
  * @returns The execution result.
401
476
  */
402
- override async privateCallPrivateFunction(
477
+ async privateCallPrivateFunction(
403
478
  targetContractAddress: AztecAddress,
404
479
  functionSelector: FunctionSelector,
405
480
  argsHash: Fr,
406
481
  sideEffectCounter: number,
407
482
  isStaticCall: boolean,
408
483
  ) {
484
+ if (!this.simulator) {
485
+ // In practice it is only when creating inline private contexts in a Noir test using TXE that we create an
486
+ // instance of this class without a simulator.
487
+ throw new Error('No simulator provided, cannot perform a nested private call');
488
+ }
489
+
409
490
  const simulatorSetupTimer = new Timer();
410
491
  this.log.debug(
411
492
  `Calling private function ${targetContractAddress}:${functionSelector} from ${this.callContext.contractAddress}`,
@@ -413,7 +494,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
413
494
 
414
495
  isStaticCall = isStaticCall || this.callContext.isStaticCall;
415
496
 
416
- await verifyCurrentClassId(targetContractAddress, this.executionDataProvider, this.historicalHeader);
497
+ await verifyCurrentClassId(targetContractAddress, this.executionDataProvider, this.anchorBlockHeader);
417
498
 
418
499
  const targetArtifact = await this.executionDataProvider.getFunctionArtifact(
419
500
  targetContractAddress,
@@ -428,18 +509,19 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
428
509
  argsHash,
429
510
  derivedTxContext,
430
511
  derivedCallContext,
431
- this.historicalHeader,
512
+ this.anchorBlockHeader,
432
513
  this.authWitnesses,
433
514
  this.capsules,
434
515
  this.executionCache,
435
516
  this.noteCache,
517
+ this.taggingIndexCache,
436
518
  this.executionDataProvider,
437
- this.simulator,
438
519
  this.totalPublicCalldataCount,
439
520
  sideEffectCounter,
440
521
  this.log,
441
522
  this.scopes,
442
523
  this.senderForTags,
524
+ this.simulator,
443
525
  );
444
526
 
445
527
  const setupTime = simulatorSetupTimer.ms();
@@ -490,7 +572,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
490
572
  * @param sideEffectCounter - The side effect counter at the start of the call.
491
573
  * @param isStaticCall - Whether the call is a static call.
492
574
  */
493
- public override privateNotifyEnqueuedPublicFunctionCall(
575
+ public privateNotifyEnqueuedPublicFunctionCall(
494
576
  _targetContractAddress: AztecAddress,
495
577
  calldataHash: Fr,
496
578
  _sideEffectCounter: number,
@@ -507,7 +589,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
507
589
  * @param sideEffectCounter - The side effect counter at the start of the call.
508
590
  * @param isStaticCall - Whether the call is a static call.
509
591
  */
510
- public override privateNotifySetPublicTeardownFunctionCall(
592
+ public privateNotifySetPublicTeardownFunctionCall(
511
593
  _targetContractAddress: AztecAddress,
512
594
  calldataHash: Fr,
513
595
  _sideEffectCounter: number,
@@ -517,12 +599,14 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
517
599
  return Promise.resolve();
518
600
  }
519
601
 
520
- public override privateNotifySetMinRevertibleSideEffectCounter(
521
- minRevertibleSideEffectCounter: number,
522
- ): Promise<void> {
602
+ public privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void> {
523
603
  return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
524
604
  }
525
605
 
606
+ public privateIsSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean> {
607
+ return Promise.resolve(this.noteCache.isSideEffectCounterRevertible(sideEffectCounter));
608
+ }
609
+
526
610
  /**
527
611
  * Derives the call context for a nested execution.
528
612
  * @param targetContractAddress - The address of the contract being called.
@@ -547,17 +631,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle {
547
631
  return this.executionDataProvider.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
548
632
  }
549
633
 
550
- public override async privateIncrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress) {
551
- await this.executionDataProvider.incrementAppTaggingSecretIndexAsSender(this.contractAddress, sender, recipient);
552
- }
553
-
554
- public override async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
555
- await this.executionDataProvider.syncTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
556
-
557
- await this.executionDataProvider.removeNullifiedNotes(this.contractAddress);
558
- }
559
-
560
- public override utilityEmitOffchainEffect(data: Fr[]): Promise<void> {
634
+ public utilityEmitOffchainEffect(data: Fr[]): Promise<void> {
561
635
  this.offchainEffects.push({ data });
562
636
  return Promise.resolve();
563
637
  }