@aztec/pxe 0.0.1-commit.ff7989d6c → 0.0.1-commit.fff30aa

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 (223) hide show
  1. package/dest/bin/check_oracle_version.js +4 -4
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +3 -1
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +10 -0
  5. package/dest/config/package_info.js +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts +13 -5
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.js +39 -12
  9. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  10. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  11. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  12. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  13. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  15. package/dest/contract_function_simulator/index.d.ts +2 -1
  16. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/index.js +1 -0
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  26. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
  29. package/dest/contract_function_simulator/oracle/interfaces.d.ts +61 -45
  30. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  32. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -44
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +281 -96
  37. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  38. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +24 -50
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +53 -75
  41. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +94 -60
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +276 -110
  44. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  45. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/pick_notes.js +20 -3
  47. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  48. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  50. package/dest/contract_logging.d.ts +9 -4
  51. package/dest/contract_logging.d.ts.map +1 -1
  52. package/dest/contract_logging.js +21 -6
  53. package/dest/contract_sync/contract_sync_service.d.ts +6 -5
  54. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  55. package/dest/contract_sync/contract_sync_service.js +62 -43
  56. package/dest/contract_sync/helpers.d.ts +2 -3
  57. package/dest/contract_sync/helpers.d.ts.map +1 -1
  58. package/dest/contract_sync/helpers.js +7 -2
  59. package/dest/debug/pxe_debug_utils.d.ts +3 -3
  60. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  61. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  62. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  63. package/dest/entrypoints/client/bundle/index.js +0 -1
  64. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  65. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  66. package/dest/entrypoints/client/bundle/utils.js +2 -2
  67. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  68. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  69. package/dest/entrypoints/client/lazy/index.js +0 -1
  70. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  71. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  72. package/dest/entrypoints/client/lazy/utils.js +2 -2
  73. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  74. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  75. package/dest/entrypoints/pxe_creation_options.js +3 -1
  76. package/dest/entrypoints/server/index.d.ts +2 -3
  77. package/dest/entrypoints/server/index.d.ts.map +1 -1
  78. package/dest/entrypoints/server/index.js +1 -2
  79. package/dest/entrypoints/server/utils.d.ts +2 -2
  80. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  81. package/dest/entrypoints/server/utils.js +2 -2
  82. package/dest/events/event_service.d.ts +3 -2
  83. package/dest/events/event_service.d.ts.map +1 -1
  84. package/dest/events/event_service.js +16 -4
  85. package/dest/events/private_event_filter_validator.d.ts +3 -2
  86. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  87. package/dest/events/private_event_filter_validator.js +15 -0
  88. package/dest/logs/log_service.d.ts +7 -8
  89. package/dest/logs/log_service.d.ts.map +1 -1
  90. package/dest/logs/log_service.js +29 -39
  91. package/dest/messages/message_context_service.d.ts +17 -0
  92. package/dest/messages/message_context_service.d.ts.map +1 -0
  93. package/dest/messages/message_context_service.js +36 -0
  94. package/dest/notes/note_service.d.ts +4 -5
  95. package/dest/notes/note_service.d.ts.map +1 -1
  96. package/dest/notes/note_service.js +14 -5
  97. package/dest/notes_filter.d.ts +2 -3
  98. package/dest/notes_filter.d.ts.map +1 -1
  99. package/dest/oracle_version.d.ts +4 -3
  100. package/dest/oracle_version.d.ts.map +1 -1
  101. package/dest/oracle_version.js +20 -10
  102. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  103. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  104. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +125 -64
  105. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  106. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  107. package/dest/private_kernel/hints/test_utils.js +203 -0
  108. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  109. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  110. package/dest/private_kernel/private_kernel_execution_prover.js +17 -12
  111. package/dest/private_kernel/private_kernel_oracle.d.ts +5 -5
  112. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  113. package/dest/private_kernel/private_kernel_oracle.js +12 -15
  114. package/dest/pxe.d.ts +10 -7
  115. package/dest/pxe.d.ts.map +1 -1
  116. package/dest/pxe.js +51 -28
  117. package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
  118. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  119. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  120. package/dest/storage/capsule_store/capsule_service.js +50 -0
  121. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  122. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  123. package/dest/storage/capsule_store/capsule_store.js +36 -28
  124. package/dest/storage/capsule_store/index.d.ts +2 -1
  125. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  126. package/dest/storage/capsule_store/index.js +1 -0
  127. package/dest/storage/contract_store/contract_store.d.ts +1 -1
  128. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  129. package/dest/storage/contract_store/contract_store.js +4 -2
  130. package/dest/storage/metadata.d.ts +1 -1
  131. package/dest/storage/metadata.js +1 -1
  132. package/dest/storage/note_store/note_store.d.ts +1 -1
  133. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  134. package/dest/storage/note_store/note_store.js +2 -2
  135. package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
  136. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  137. package/dest/storage/private_event_store/private_event_store.js +3 -0
  138. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  139. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  140. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  141. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  142. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  143. package/dest/tagging/index.d.ts +3 -3
  144. package/dest/tagging/index.d.ts.map +1 -1
  145. package/dest/tagging/index.js +1 -1
  146. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -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 +4 -18
  149. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  150. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  151. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  152. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  153. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  154. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  155. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  156. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  157. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  158. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  159. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  160. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  161. package/package.json +16 -16
  162. package/src/bin/check_oracle_version.ts +4 -4
  163. package/src/block_synchronizer/block_synchronizer.ts +12 -0
  164. package/src/config/package_info.ts +1 -1
  165. package/src/contract_function_simulator/contract_function_simulator.ts +60 -24
  166. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  167. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  168. package/src/contract_function_simulator/index.ts +1 -0
  169. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
  170. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  171. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  172. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
  173. package/src/contract_function_simulator/oracle/interfaces.ts +82 -54
  174. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  175. package/src/contract_function_simulator/oracle/oracle.ts +363 -139
  176. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  177. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +65 -95
  178. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +451 -147
  179. package/src/contract_function_simulator/pick_notes.ts +22 -3
  180. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  181. package/src/contract_logging.ts +18 -5
  182. package/src/contract_sync/contract_sync_service.ts +99 -75
  183. package/src/contract_sync/helpers.ts +4 -4
  184. package/src/debug/pxe_debug_utils.ts +3 -3
  185. package/src/entrypoints/client/bundle/index.ts +0 -1
  186. package/src/entrypoints/client/bundle/utils.ts +2 -3
  187. package/src/entrypoints/client/lazy/index.ts +0 -1
  188. package/src/entrypoints/client/lazy/utils.ts +2 -3
  189. package/src/entrypoints/pxe_creation_options.ts +7 -0
  190. package/src/entrypoints/server/index.ts +1 -2
  191. package/src/entrypoints/server/utils.ts +2 -3
  192. package/src/events/event_service.ts +17 -4
  193. package/src/events/private_event_filter_validator.ts +21 -1
  194. package/src/logs/log_service.ts +59 -75
  195. package/src/messages/message_context_service.ts +44 -0
  196. package/src/notes/note_service.ts +18 -8
  197. package/src/notes_filter.ts +1 -3
  198. package/src/oracle_version.ts +20 -10
  199. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +157 -110
  200. package/src/private_kernel/hints/test_utils.ts +325 -0
  201. package/src/private_kernel/private_kernel_execution_prover.ts +17 -15
  202. package/src/private_kernel/private_kernel_oracle.ts +14 -14
  203. package/src/pxe.ts +78 -33
  204. package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
  205. package/src/storage/capsule_store/capsule_service.ts +90 -0
  206. package/src/storage/capsule_store/capsule_store.ts +44 -26
  207. package/src/storage/capsule_store/index.ts +1 -0
  208. package/src/storage/contract_store/contract_store.ts +8 -6
  209. package/src/storage/metadata.ts +1 -1
  210. package/src/storage/note_store/note_store.ts +2 -5
  211. package/src/storage/private_event_store/private_event_store.ts +4 -0
  212. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  213. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  214. package/src/tagging/index.ts +2 -2
  215. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +8 -21
  216. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  217. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  218. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  219. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
  220. package/dest/access_scopes.d.ts +0 -9
  221. package/dest/access_scopes.d.ts.map +0 -1
  222. package/dest/access_scopes.js +0 -6
  223. package/src/access_scopes.ts +0 -9
@@ -4,17 +4,14 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
4
4
  /**
5
5
  * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
6
6
  *
7
- * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
7
+ * @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
8
8
  * sender -> recipient matters.
9
- * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
10
- * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
11
- * of the private log which corresponds to the tag).
12
9
  * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
13
10
  * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
14
11
  * is simply the highest pending index plus one (or finalized if pending is undefined).
15
12
  * @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
16
13
  * updates its status accordingly.
17
- */ export async function syncSenderTaggingIndexes(secret, app, aztecNode, taggingStore, anchorBlockHash, jobId) {
14
+ */ export async function syncSenderTaggingIndexes(secret, aztecNode, taggingStore, anchorBlockHash, jobId) {
18
15
  // # Explanation of how syncing works
19
16
  //
20
17
  // When choosing an index, we select: highest pending index + 1 (or highest finalized index + 1 if no pending).
@@ -40,15 +37,24 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
40
37
  while(true){
41
38
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
42
39
  // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
43
- await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
40
+ await loadAndStoreNewTaggingIndexes(secret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
44
41
  // Retrieve all indexes within the current window from storage and update their status accordingly.
45
42
  const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
46
43
  if (pendingTxHashes.length === 0) {
47
44
  break;
48
45
  }
49
- const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
46
+ const { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
50
47
  await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
51
48
  await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
49
+ if (txHashesWithExecutionReverted.length > 0) {
50
+ const indexedTxEffects = await Promise.all(txHashesWithExecutionReverted.map((txHash)=>aztecNode.getTxEffect(txHash)));
51
+ for (const indexedTxEffect of indexedTxEffects){
52
+ if (indexedTxEffect === undefined) {
53
+ throw new Error('TxEffect not found for execution-reverted tx. This is either a bug or a reorg has occurred.');
54
+ }
55
+ await taggingStore.finalizePendingIndexesOfAPartiallyRevertedTx(indexedTxEffect.data, jobId);
56
+ }
57
+ }
52
58
  // We check if the finalized index has been updated.
53
59
  newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
54
60
  if (previousFinalizedIndex !== newFinalizedIndex) {
@@ -1,11 +1,12 @@
1
1
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
2
2
  import { TxHash } from '@aztec/stdlib/tx';
3
3
  /**
4
- * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
5
- * dropped.
4
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
5
+ * dropped, or execution-reverted (but mined).
6
6
  */
7
7
  export declare function getStatusChangeOfPending(pending: TxHash[], aztecNode: AztecNode): Promise<{
8
8
  txHashesToFinalize: TxHash[];
9
9
  txHashesToDrop: TxHash[];
10
+ txHashesWithExecutionReverted: TxHash[];
10
11
  }>;
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUFFLGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQUMsY0FBYyxFQUFFLE1BQU0sRUFBRSxDQUFBO0NBQUUsQ0FBQyxDQXlCckUifQ==
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUNULGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQzdCLGNBQWMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUN6Qiw2QkFBNkIsRUFBRSxNQUFNLEVBQUUsQ0FBQztDQUN6QyxDQUFDLENBb0NEIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAyBrE"}
1
+ {"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IACT,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,6BAA6B,EAAE,MAAM,EAAE,CAAC;CACzC,CAAC,CAoCD"}
@@ -1,22 +1,31 @@
1
1
  import { TxStatus } from '@aztec/stdlib/tx';
2
2
  /**
3
- * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
4
- * dropped.
3
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
4
+ * dropped, or execution-reverted (but mined).
5
5
  */ export async function getStatusChangeOfPending(pending, aztecNode) {
6
6
  // Get receipts for all pending tx hashes.
7
7
  const receipts = await Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash)));
8
8
  const txHashesToFinalize = [];
9
9
  const txHashesToDrop = [];
10
+ const txHashesWithExecutionReverted = [];
10
11
  for(let i = 0; i < receipts.length; i++){
11
12
  const receipt = receipts[i];
12
13
  const txHash = pending[i];
13
- if (receipt.status === TxStatus.FINALIZED && receipt.hasExecutionSucceeded()) {
14
- // Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
15
- // finalized.
16
- txHashesToFinalize.push(txHash);
17
- } else if (receipt.isDropped() || receipt.hasExecutionReverted()) {
18
- // Tx was dropped or reverted --> we drop the corresponding pending indexes.
19
- // TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
14
+ if (receipt.status === TxStatus.FINALIZED) {
15
+ // Tx has been included in a block and the corresponding block is finalized
16
+ if (receipt.hasExecutionSucceeded()) {
17
+ // No part of execution reverted - we just finalize all the indexes.
18
+ txHashesToFinalize.push(txHash);
19
+ } else if (receipt.hasExecutionReverted()) {
20
+ // Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
21
+ // phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
22
+ txHashesWithExecutionReverted.push(txHash);
23
+ } else {
24
+ // Defensive check - this branch should never be triggered
25
+ throw new Error('Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.');
26
+ }
27
+ } else if (receipt.isDropped()) {
28
+ // Tx was dropped from the mempool --> we drop the corresponding pending indexes.
20
29
  txHashesToDrop.push(txHash);
21
30
  } else {
22
31
  // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
@@ -24,6 +33,7 @@ import { TxStatus } from '@aztec/stdlib/tx';
24
33
  }
25
34
  return {
26
35
  txHashesToFinalize,
27
- txHashesToDrop
36
+ txHashesToDrop,
37
+ txHashesWithExecutionReverted
28
38
  };
29
39
  }
@@ -1,21 +1,19 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
1
  import type { BlockHash } from '@aztec/stdlib/block';
3
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
5
4
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
6
5
  /**
7
6
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
8
7
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
9
8
  * place is when a tx is being sent from this PXE.
10
- * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
11
- * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
12
- * kernel circuit behavior.
9
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
13
10
  * @param start - The starting index (inclusive) of the window to process.
14
11
  * @param end - The ending index (exclusive) of the window to process.
15
12
  * @param aztecNode - The Aztec node instance to query for logs.
16
13
  * @param taggingStore - The data provider to store pending indexes.
14
+ * @param anchorBlockHash - Hash of a block to use as reference block when querying node.
17
15
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
18
16
  * preserving way.
19
17
  */
20
- export declare function loadAndStoreNewTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILHdCQUFzQiw2QkFBNkIsQ0FDakQsTUFBTSxFQUFFLDJCQUEyQixFQUNuQyxHQUFHLEVBQUUsWUFBWSxFQUNqQixLQUFLLEVBQUUsTUFBTSxFQUNiLEdBQUcsRUFBRSxNQUFNLEVBQ1gsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxpQkFrQmQifQ==
18
+ export declare function loadAndStoreNewTaggingIndexes(extendedSecret: ExtendedDirectionalAppTaggingSecret, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLDZCQUE2QixDQUNqRCxjQUFjLEVBQUUsbUNBQW1DLEVBQ25ELEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxTQUFTLEVBQUUsU0FBUyxFQUNwQixZQUFZLEVBQUUsa0JBQWtCLEVBQ2hDLGVBQWUsRUFBRSxTQUFTLEVBQzFCLEtBQUssRUFBRSxNQUFNLGlCQWdCZCJ9
@@ -1 +1 @@
1
- {"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;;GAaG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAkBd"}
1
+ {"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CACjD,cAAc,EAAE,mCAAmC,EACnD,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAgBd"}
@@ -1,37 +1,39 @@
1
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
1
+ import { SiloedTag } from '@aztec/stdlib/logs';
2
2
  import { TxHash } from '@aztec/stdlib/tx';
3
3
  import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
4
4
  /**
5
5
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
6
6
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
7
7
  * place is when a tx is being sent from this PXE.
8
- * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
9
- * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
10
- * kernel circuit behavior.
8
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
11
9
  * @param start - The starting index (inclusive) of the window to process.
12
10
  * @param end - The ending index (exclusive) of the window to process.
13
11
  * @param aztecNode - The Aztec node instance to query for logs.
14
12
  * @param taggingStore - The data provider to store pending indexes.
13
+ * @param anchorBlockHash - Hash of a block to use as reference block when querying node.
15
14
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
16
15
  * preserving way.
17
- */ export async function loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
16
+ */ export async function loadAndStoreNewTaggingIndexes(extendedSecret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
18
17
  // We compute the tags for the current window of indexes
19
- const preTagsForWindow = Array(end - start).fill(0).map((_, i)=>({
20
- secret,
18
+ const siloedTagsForWindow = await Promise.all(Array.from({
19
+ length: end - start
20
+ }, (_, i)=>SiloedTag.compute({
21
+ extendedSecret,
21
22
  index: start + i
22
- }));
23
- const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
23
+ })));
24
24
  const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
25
- const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
26
- // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
27
- for (const [txHashStr, highestIndex] of highestIndexMap.entries()){
25
+ const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
26
+ // Now we iterate over the map, construct the tagging index ranges and store them in the db.
27
+ for (const [txHashStr, indexes] of txIndexesMap.entries()){
28
28
  const txHash = TxHash.fromString(txHashStr);
29
- await taggingStore.storePendingIndexes([
29
+ const ranges = [
30
30
  {
31
- secret,
32
- index: highestIndex
31
+ extendedSecret,
32
+ lowestIndex: Math.min(...indexes),
33
+ highestIndex: Math.max(...indexes)
33
34
  }
34
- ], txHash, jobId);
35
+ ];
36
+ await taggingStore.storePendingIndexes(ranges, txHash, jobId);
35
37
  }
36
38
  }
37
39
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
@@ -42,19 +44,29 @@ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
42
44
  const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
43
45
  return allLogs.map((logs)=>logs.map((log)=>log.txHash));
44
46
  }
45
- // Returns a map of txHash to the highest index for that txHash.
46
- function getTxHighestIndexMap(txHashesForTags, preTagsForWindow) {
47
- if (txHashesForTags.length !== preTagsForWindow.length) {
48
- throw new Error(`Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`);
47
+ // Returns a map of txHash to all indexes for that txHash.
48
+ function getTxIndexesMap(txHashesForTags, start, count) {
49
+ if (txHashesForTags.length !== count) {
50
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
49
51
  }
50
- const highestIndexMap = new Map();
52
+ const indexesMap = new Map();
53
+ // Iterate over indexes
51
54
  for(let i = 0; i < txHashesForTags.length; i++){
52
- const taggingIndex = preTagsForWindow[i].index;
55
+ const taggingIndex = start + i;
53
56
  const txHashesForTag = txHashesForTags[i];
57
+ // iterate over tx hashes that used that index (tag)
54
58
  for (const txHash of txHashesForTag){
55
59
  const key = txHash.toString();
56
- highestIndexMap.set(key, Math.max(highestIndexMap.get(key) ?? 0, taggingIndex));
60
+ const existing = indexesMap.get(key);
61
+ // Add the index to the tx's indexes
62
+ if (existing) {
63
+ existing.push(taggingIndex);
64
+ } else {
65
+ indexesMap.set(key, [
66
+ taggingIndex
67
+ ]);
68
+ }
57
69
  }
58
70
  }
59
- return highestIndexMap;
71
+ return indexesMap;
60
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.ff7989d6c",
3
+ "version": "0.0.1-commit.fff30aa",
4
4
  "type": "module",
5
5
  "typedocOptions": {
6
6
  "entryPoints": [
@@ -70,19 +70,19 @@
70
70
  ]
71
71
  },
72
72
  "dependencies": {
73
- "@aztec/bb-prover": "0.0.1-commit.ff7989d6c",
74
- "@aztec/bb.js": "0.0.1-commit.ff7989d6c",
75
- "@aztec/builder": "0.0.1-commit.ff7989d6c",
76
- "@aztec/constants": "0.0.1-commit.ff7989d6c",
77
- "@aztec/ethereum": "0.0.1-commit.ff7989d6c",
78
- "@aztec/foundation": "0.0.1-commit.ff7989d6c",
79
- "@aztec/key-store": "0.0.1-commit.ff7989d6c",
80
- "@aztec/kv-store": "0.0.1-commit.ff7989d6c",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.ff7989d6c",
82
- "@aztec/noir-types": "0.0.1-commit.ff7989d6c",
83
- "@aztec/protocol-contracts": "0.0.1-commit.ff7989d6c",
84
- "@aztec/simulator": "0.0.1-commit.ff7989d6c",
85
- "@aztec/stdlib": "0.0.1-commit.ff7989d6c",
73
+ "@aztec/bb-prover": "0.0.1-commit.fff30aa",
74
+ "@aztec/bb.js": "0.0.1-commit.fff30aa",
75
+ "@aztec/builder": "0.0.1-commit.fff30aa",
76
+ "@aztec/constants": "0.0.1-commit.fff30aa",
77
+ "@aztec/ethereum": "0.0.1-commit.fff30aa",
78
+ "@aztec/foundation": "0.0.1-commit.fff30aa",
79
+ "@aztec/key-store": "0.0.1-commit.fff30aa",
80
+ "@aztec/kv-store": "0.0.1-commit.fff30aa",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.fff30aa",
82
+ "@aztec/noir-types": "0.0.1-commit.fff30aa",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.fff30aa",
84
+ "@aztec/simulator": "0.0.1-commit.fff30aa",
85
+ "@aztec/stdlib": "0.0.1-commit.fff30aa",
86
86
  "koa": "^2.16.1",
87
87
  "koa-router": "^13.1.1",
88
88
  "lodash.omit": "^4.5.0",
@@ -91,8 +91,8 @@
91
91
  "viem": "npm:@aztec/viem@2.38.2"
92
92
  },
93
93
  "devDependencies": {
94
- "@aztec/merkle-tree": "0.0.1-commit.ff7989d6c",
95
- "@aztec/noir-test-contracts.js": "0.0.1-commit.ff7989d6c",
94
+ "@aztec/merkle-tree": "0.0.1-commit.fff30aa",
95
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.fff30aa",
96
96
  "@jest/globals": "^30.0.0",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/lodash.omit": "^4.5.7",
@@ -13,8 +13,9 @@ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
13
13
  *
14
14
  * The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
15
15
  * a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
16
- * changed and the ORACLE_VERSION constant needs to be incremented and the ORACLE_INTERFACE_HASH constant needs to be
17
- * updated.
16
+ * changed and the oracle version needs to be bumped:
17
+ * - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
18
+ * - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
18
19
  *
19
20
  * TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
20
21
  * oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
@@ -26,9 +27,8 @@ function assertOracleInterfaceMatches(): void {
26
27
  // We use keccak256 here just because we already have it in the dependencies.
27
28
  const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
28
29
  if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
29
- // This check exists only to notify you when you need to update the ORACLE_VERSION constant.
30
30
  throw new Error(
31
- `The Oracle interface has changed, which implies a breaking change in the aztec.nr/PXE oracle interface. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} and bump ORACLE_VERSION in pxe/src/oracle_version.ts.`,
31
+ `The Oracle interface has changed. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} in pxe/src/oracle_version.ts and bump the oracle version (ORACLE_VERSION_MAJOR for breaking changes, ORACLE_VERSION_MINOR for oracle additions).`,
32
32
  );
33
33
  }
34
34
  }
@@ -77,6 +77,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
77
77
  const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
78
78
  if (blockHeader) {
79
79
  await this.updateAnchorBlockHeader(blockHeader);
80
+ } else {
81
+ this.log.warn(`Block header not found for proven block ${event.block.number}, skipping anchor update`);
80
82
  }
81
83
  }
82
84
  break;
@@ -86,6 +88,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
86
88
  const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
87
89
  if (blockHeader) {
88
90
  await this.updateAnchorBlockHeader(blockHeader);
91
+ } else {
92
+ this.log.warn(`Block header not found for finalized block ${event.block.number}, skipping anchor update`);
89
93
  }
90
94
  }
91
95
  break;
@@ -152,6 +156,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
152
156
  }
153
157
 
154
158
  this.log.debug(`Syncing PXE with the node`);
159
+ // Capture the promise locally so we always await the exact promise we created, even if this.isSyncing is modified
160
+ // between assignment and await (e.g. due to future refactors introducing a yield point).
155
161
  const isSyncing = this.doSync();
156
162
  this.isSyncing = isSyncing;
157
163
  try {
@@ -161,6 +167,12 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
161
167
  }
162
168
  }
163
169
 
170
+ /** Stops the block synchronizer, waiting for any in-progress sync to complete. */
171
+ public async stop() {
172
+ await this.isSyncing;
173
+ await this.blockStream.stop();
174
+ }
175
+
164
176
  private async doSync() {
165
177
  let currentHeader;
166
178
 
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '5.0.0', name: '@aztec/pxe' };
2
+ return { version: '4.2.0', name: '@aztec/pxe' };
3
3
  }
@@ -4,8 +4,6 @@ import {
4
4
  AVM_SENDL2TOL1MSG_BASE_L2_GAS,
5
5
  DA_GAS_PER_FIELD,
6
6
  FIXED_AVM_STARTUP_L2_GAS,
7
- FIXED_DA_GAS,
8
- FIXED_L2_GAS,
9
7
  L2_GAS_PER_CONTRACT_CLASS_LOG,
10
8
  L2_GAS_PER_L2_TO_L1_MSG,
11
9
  L2_GAS_PER_NOTE_HASH,
@@ -19,6 +17,10 @@ import {
19
17
  MAX_NULLIFIERS_PER_TX,
20
18
  MAX_NULLIFIER_READ_REQUESTS_PER_TX,
21
19
  MAX_PRIVATE_LOGS_PER_TX,
20
+ MAX_TX_LIFETIME,
21
+ PRIVATE_TX_L2_GAS_OVERHEAD,
22
+ PUBLIC_TX_L2_GAS_OVERHEAD,
23
+ TX_DA_GAS_OVERHEAD,
22
24
  } from '@aztec/constants';
23
25
  import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
24
26
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -40,7 +42,7 @@ import type { FunctionCall } from '@aztec/stdlib/abi';
40
42
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
41
43
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
42
44
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
43
- import type { BlockParameter } from '@aztec/stdlib/block';
45
+ import type { BlockParameter, L2TipsProvider } from '@aztec/stdlib/block';
44
46
  import { Gas } from '@aztec/stdlib/gas';
45
47
  import {
46
48
  computeNoteHashNonce,
@@ -78,6 +80,7 @@ import {
78
80
  BlockHeader,
79
81
  CallContext,
80
82
  HashedValues,
83
+ type OffchainEffect,
81
84
  PrivateExecutionResult,
82
85
  TxConstantData,
83
86
  TxExecutionRequest,
@@ -86,9 +89,10 @@ import {
86
89
  getFinalMinRevertibleSideEffectCounter,
87
90
  } from '@aztec/stdlib/tx';
88
91
 
89
- import type { AccessScopes } from '../access_scopes.js';
90
92
  import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
93
+ import type { MessageContextService } from '../messages/message_context_service.js';
91
94
  import type { AddressStore } from '../storage/address_store/address_store.js';
95
+ import { CapsuleService } from '../storage/capsule_store/capsule_service.js';
92
96
  import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
93
97
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
94
98
  import type { NoteStore } from '../storage/note_store/note_store.js';
@@ -118,7 +122,7 @@ export type ContractSimulatorRunOpts = {
118
122
  /** The address used as a tagging sender when emitting private logs. */
119
123
  senderForTags?: AztecAddress;
120
124
  /** The accounts whose notes we can access in this call. */
121
- scopes: AccessScopes;
125
+ scopes: AztecAddress[];
122
126
  /** The job ID for staged writes. */
123
127
  jobId: string;
124
128
  };
@@ -130,6 +134,7 @@ export type ContractFunctionSimulatorArgs = {
130
134
  keyStore: KeyStore;
131
135
  addressStore: AddressStore;
132
136
  aztecNode: AztecNode;
137
+ l2TipsStore: L2TipsProvider;
133
138
  senderTaggingStore: SenderTaggingStore;
134
139
  recipientTaggingStore: RecipientTaggingStore;
135
140
  senderAddressBookStore: SenderAddressBookStore;
@@ -137,6 +142,7 @@ export type ContractFunctionSimulatorArgs = {
137
142
  privateEventStore: PrivateEventStore;
138
143
  simulator: CircuitSimulator;
139
144
  contractSyncService: ContractSyncService;
145
+ messageContextService: MessageContextService;
140
146
  };
141
147
 
142
148
  /**
@@ -149,6 +155,7 @@ export class ContractFunctionSimulator {
149
155
  private readonly keyStore: KeyStore;
150
156
  private readonly addressStore: AddressStore;
151
157
  private readonly aztecNode: AztecNode;
158
+ private readonly l2TipsStore: L2TipsProvider;
152
159
  private readonly senderTaggingStore: SenderTaggingStore;
153
160
  private readonly recipientTaggingStore: RecipientTaggingStore;
154
161
  private readonly senderAddressBookStore: SenderAddressBookStore;
@@ -156,6 +163,7 @@ export class ContractFunctionSimulator {
156
163
  private readonly privateEventStore: PrivateEventStore;
157
164
  private readonly simulator: CircuitSimulator;
158
165
  private readonly contractSyncService: ContractSyncService;
166
+ private readonly messageContextService: MessageContextService;
159
167
 
160
168
  constructor(args: ContractFunctionSimulatorArgs) {
161
169
  this.contractStore = args.contractStore;
@@ -163,6 +171,7 @@ export class ContractFunctionSimulator {
163
171
  this.keyStore = args.keyStore;
164
172
  this.addressStore = args.addressStore;
165
173
  this.aztecNode = args.aztecNode;
174
+ this.l2TipsStore = args.l2TipsStore;
166
175
  this.senderTaggingStore = args.senderTaggingStore;
167
176
  this.recipientTaggingStore = args.recipientTaggingStore;
168
177
  this.senderAddressBookStore = args.senderAddressBookStore;
@@ -170,6 +179,7 @@ export class ContractFunctionSimulator {
170
179
  this.privateEventStore = args.privateEventStore;
171
180
  this.simulator = args.simulator;
172
181
  this.contractSyncService = args.contractSyncService;
182
+ this.messageContextService = args.messageContextService;
173
183
  this.log = createLogger('simulator');
174
184
  }
175
185
 
@@ -238,8 +248,9 @@ export class ContractFunctionSimulator {
238
248
  senderTaggingStore: this.senderTaggingStore,
239
249
  recipientTaggingStore: this.recipientTaggingStore,
240
250
  senderAddressBookStore: this.senderAddressBookStore,
241
- capsuleStore: this.capsuleStore,
251
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
242
252
  privateEventStore: this.privateEventStore,
253
+ messageContextService: this.messageContextService,
243
254
  contractSyncService: this.contractSyncService,
244
255
  jobId,
245
256
  totalPublicCalldataCount: 0,
@@ -247,6 +258,7 @@ export class ContractFunctionSimulator {
247
258
  scopes,
248
259
  senderForTags,
249
260
  simulator: this.simulator,
261
+ l2TipsStore: this.l2TipsStore,
250
262
  });
251
263
 
252
264
  const setupTime = simulatorSetupTimer.ms();
@@ -276,7 +288,7 @@ export class ContractFunctionSimulator {
276
288
  );
277
289
  const publicFunctionsCalldata = await Promise.all(
278
290
  publicCallRequests.map(async r => {
279
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
291
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
280
292
  return new HashedValues(calldata, r.calldataHash);
281
293
  }),
282
294
  );
@@ -311,9 +323,9 @@ export class ContractFunctionSimulator {
311
323
  call: FunctionCall,
312
324
  authwits: AuthWitness[],
313
325
  anchorBlockHeader: BlockHeader,
314
- scopes: AccessScopes,
326
+ scopes: AztecAddress[],
315
327
  jobId: string,
316
- ): Promise<Fr[]> {
328
+ ): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
317
329
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
318
330
 
319
331
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
@@ -332,8 +344,11 @@ export class ContractFunctionSimulator {
332
344
  aztecNode: this.aztecNode,
333
345
  recipientTaggingStore: this.recipientTaggingStore,
334
346
  senderAddressBookStore: this.senderAddressBookStore,
335
- capsuleStore: this.capsuleStore,
347
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
336
348
  privateEventStore: this.privateEventStore,
349
+ messageContextService: this.messageContextService,
350
+ contractSyncService: this.contractSyncService,
351
+ l2TipsStore: this.l2TipsStore,
337
352
  jobId,
338
353
  scopes,
339
354
  });
@@ -361,7 +376,10 @@ export class ContractFunctionSimulator {
361
376
  });
362
377
 
363
378
  this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
364
- return witnessMapToFields(acirExecutionResult.returnWitness);
379
+ return {
380
+ result: witnessMapToFields(acirExecutionResult.returnWitness),
381
+ offchainEffects: oracle.getOffchainEffects(),
382
+ };
365
383
  } catch (err) {
366
384
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
367
385
  }
@@ -431,14 +449,34 @@ export async function generateSimulatedProvingResult(
431
449
 
432
450
  let publicTeardownCallRequest;
433
451
 
452
+ // We set expiration timestamp to anchor_block_timestamp + MAX_TX_LIFETIME (24h) just like kernels do
453
+ let expirationTimestamp =
454
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.globalVariables.timestamp +
455
+ BigInt(MAX_TX_LIFETIME);
456
+
457
+ let feePayer = AztecAddress.zero();
458
+
434
459
  const executions = [privateExecutionResult.entrypoint];
435
460
 
436
461
  while (executions.length !== 0) {
437
462
  const execution = executions.shift()!;
438
463
  executions.unshift(...execution!.nestedExecutionResults);
439
464
 
465
+ // Just like kernels we overwrite the default value if the call sets it.
466
+ const callExpirationTimestamp = execution.publicInputs.expirationTimestamp;
467
+ if (callExpirationTimestamp !== 0n && callExpirationTimestamp < expirationTimestamp) {
468
+ expirationTimestamp = callExpirationTimestamp;
469
+ }
470
+
440
471
  const { contractAddress } = execution.publicInputs.callContext;
441
472
 
473
+ if (execution.publicInputs.isFeePayer) {
474
+ if (!feePayer.isZero()) {
475
+ throw new Error('Multiple fee payers found in private execution result');
476
+ }
477
+ feePayer = contractAddress;
478
+ }
479
+
442
480
  scopedNoteHashes.push(
443
481
  ...execution.publicInputs.noteHashes
444
482
  .getActiveItems()
@@ -653,9 +691,14 @@ export async function generateSimulatedProvingResult(
653
691
 
654
692
  const publicInputs = new PrivateKernelTailCircuitPublicInputs(
655
693
  constantData,
656
- /*gasUsed=*/ gasUsed.add(Gas.from({ l2Gas: FIXED_L2_GAS, daGas: FIXED_DA_GAS })),
657
- /*feePayer=*/ AztecAddress.zero(),
658
- /*expirationTimestamp=*/ 0n,
694
+ /*gasUsed=*/ gasUsed.add(
695
+ Gas.from({
696
+ l2Gas: isPrivateOnlyTx ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
697
+ daGas: TX_DA_GAS_OVERHEAD,
698
+ }),
699
+ ),
700
+ /*feePayer=*/ feePayer,
701
+ /*expirationTimestamp=*/ expirationTimestamp,
659
702
  hasPublicCalls ? inputsForPublic : undefined,
660
703
  !hasPublicCalls ? inputsForRollup : undefined,
661
704
  );
@@ -683,6 +726,7 @@ function squashTransientSideEffects(
683
726
  scopedNullifiersCLA,
684
727
  /*futureNoteHashReads=*/ [],
685
728
  /*futureNullifierReads=*/ [],
729
+ /*futureLogs=*/ [],
686
730
  noteHashNullifierCounterMap,
687
731
  minRevertibleSideEffectCounter,
688
732
  );
@@ -725,16 +769,8 @@ async function verifyReadRequests(
725
769
  nullifierReadRequests.length,
726
770
  );
727
771
 
728
- const noteHashResetActions = getNoteHashReadRequestResetActions(
729
- noteHashReadRequestsCLA,
730
- scopedNoteHashesCLA,
731
- /*futureNoteHashes=*/ [],
732
- );
733
- const nullifierResetActions = getNullifierReadRequestResetActions(
734
- nullifierReadRequestsCLA,
735
- scopedNullifiersCLA,
736
- /*futureNullifiers=*/ [],
737
- );
772
+ const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA);
773
+ const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA);
738
774
 
739
775
  const settledNoteHashReads: { index: number; value: Fr }[] = [];
740
776
  for (let i = 0; i < noteHashResetActions.actions.length; i++) {