@aztec/pxe 0.0.1-commit.cb6bed7c2 → 0.0.1-commit.cbf2c2d5d

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 (87) hide show
  1. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  2. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  3. package/dest/contract_function_simulator/contract_function_simulator.js +25 -3
  4. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  5. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
  7. package/dest/contract_function_simulator/index.d.ts +2 -1
  8. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/index.js +1 -0
  10. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  13. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  14. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  16. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
  17. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
  18. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
  19. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
  20. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
  22. package/dest/contract_function_simulator/oracle/interfaces.d.ts +8 -7
  23. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  25. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  26. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
  27. package/dest/contract_function_simulator/oracle/oracle.d.ts +8 -7
  28. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/oracle/oracle.js +44 -18
  30. package/dest/contract_function_simulator/oracle/private_execution.js +4 -2
  31. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +8 -33
  32. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +7 -39
  34. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +19 -3
  35. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +60 -3
  37. package/dest/contract_sync/contract_sync_service.d.ts +5 -3
  38. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  39. package/dest/contract_sync/contract_sync_service.js +47 -30
  40. package/dest/messages/message_context_service.d.ts +17 -0
  41. package/dest/messages/message_context_service.d.ts.map +1 -0
  42. package/dest/messages/message_context_service.js +36 -0
  43. package/dest/oracle_version.d.ts +2 -2
  44. package/dest/oracle_version.js +2 -2
  45. package/dest/pxe.d.ts +6 -3
  46. package/dest/pxe.d.ts.map +1 -1
  47. package/dest/pxe.js +33 -19
  48. package/dest/storage/metadata.d.ts +1 -1
  49. package/dest/storage/metadata.js +1 -1
  50. package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
  51. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  52. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  53. package/dest/tagging/index.d.ts +2 -2
  54. package/dest/tagging/index.d.ts.map +1 -1
  55. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
  56. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  57. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
  58. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  59. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  60. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  61. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
  62. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  63. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
  64. package/package.json +16 -16
  65. package/src/contract_function_simulator/contract_function_simulator.ts +36 -4
  66. package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
  67. package/src/contract_function_simulator/index.ts +1 -0
  68. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
  69. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  70. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
  71. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
  72. package/src/contract_function_simulator/oracle/interfaces.ts +12 -15
  73. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
  74. package/src/contract_function_simulator/oracle/oracle.ts +53 -43
  75. package/src/contract_function_simulator/oracle/private_execution.ts +3 -3
  76. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +9 -57
  77. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +93 -3
  78. package/src/contract_sync/contract_sync_service.ts +67 -38
  79. package/src/messages/message_context_service.ts +45 -0
  80. package/src/oracle_version.ts +2 -2
  81. package/src/pxe.ts +51 -18
  82. package/src/storage/metadata.ts +1 -1
  83. package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
  84. package/src/tagging/index.ts +1 -1
  85. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
  86. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  87. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,mCAAmC,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,mCAAmC,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -14,4 +14,4 @@ import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagg
14
14
  * updates its status accordingly.
15
15
  */
16
16
  export declare function syncSenderTaggingIndexes(secret: ExtendedDirectionalAppTaggingSecret, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
17
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU5RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7O0dBVUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSxtQ0FBbUMsRUFDM0MsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FtRWYifQ==
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU5RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7O0dBVUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSxtQ0FBbUMsRUFDM0MsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FxRmYifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_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;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,mCAAmC,EAC3C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}
1
+ {"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_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;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,mCAAmC,EAC3C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAqFf"}
@@ -43,9 +43,18 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
43
43
  if (pendingTxHashes.length === 0) {
44
44
  break;
45
45
  }
46
- const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
46
+ const { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
47
47
  await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
48
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
+ }
49
58
  // We check if the finalized index has been updated.
50
59
  newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
51
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
  }
@@ -11,8 +11,9 @@ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_t
11
11
  * @param end - The ending index (exclusive) of the window to process.
12
12
  * @param aztecNode - The Aztec node instance to query for logs.
13
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.
14
15
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
15
16
  * preserving way.
16
17
  */
17
18
  export declare function loadAndStoreNewTaggingIndexes(extendedSecret: ExtendedDirectionalAppTaggingSecret, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCx3QkFBc0IsNkJBQTZCLENBQ2pELGNBQWMsRUFBRSxtQ0FBbUMsRUFDbkQsS0FBSyxFQUFFLE1BQU0sRUFDYixHQUFHLEVBQUUsTUFBTSxFQUNYLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFlBQVksRUFBRSxrQkFBa0IsRUFDaEMsZUFBZSxFQUFFLFNBQVMsRUFDMUIsS0FBSyxFQUFFLE1BQU0saUJBZWQifQ==
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,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;;;;;;;;;;;GAWG;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,iBAed"}
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"}
@@ -10,6 +10,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
10
10
  * @param end - The ending index (exclusive) of the window to process.
11
11
  * @param aztecNode - The Aztec node instance to query for logs.
12
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.
13
14
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
14
15
  * preserving way.
15
16
  */ export async function loadAndStoreNewTaggingIndexes(extendedSecret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
@@ -21,16 +22,18 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
21
22
  index: start + i
22
23
  })));
23
24
  const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
24
- const highestIndexMap = getTxHighestIndexMap(txsForTags, start, siloedTagsForWindow.length);
25
- // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
26
- 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()){
27
28
  const txHash = TxHash.fromString(txHashStr);
28
- await taggingStore.storePendingIndexes([
29
+ const ranges = [
29
30
  {
30
31
  extendedSecret,
31
- index: highestIndex
32
+ lowestIndex: Math.min(...indexes),
33
+ highestIndex: Math.max(...indexes)
32
34
  }
33
- ], txHash, jobId);
35
+ ];
36
+ await taggingStore.storePendingIndexes(ranges, txHash, jobId);
34
37
  }
35
38
  }
36
39
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
@@ -41,19 +44,29 @@ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
41
44
  const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
42
45
  return allLogs.map((logs)=>logs.map((log)=>log.txHash));
43
46
  }
44
- // Returns a map of txHash to the highest index for that txHash.
45
- function getTxHighestIndexMap(txHashesForTags, start, count) {
47
+ // Returns a map of txHash to all indexes for that txHash.
48
+ function getTxIndexesMap(txHashesForTags, start, count) {
46
49
  if (txHashesForTags.length !== count) {
47
50
  throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
48
51
  }
49
- const highestIndexMap = new Map();
52
+ const indexesMap = new Map();
53
+ // Iterate over indexes
50
54
  for(let i = 0; i < txHashesForTags.length; i++){
51
55
  const taggingIndex = start + i;
52
56
  const txHashesForTag = txHashesForTags[i];
57
+ // iterate over tx hashes that used that index (tag)
53
58
  for (const txHash of txHashesForTag){
54
59
  const key = txHash.toString();
55
- 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
+ }
56
69
  }
57
70
  }
58
- return highestIndexMap;
71
+ return indexesMap;
59
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.cb6bed7c2",
3
+ "version": "0.0.1-commit.cbf2c2d5d",
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.cb6bed7c2",
74
- "@aztec/bb.js": "0.0.1-commit.cb6bed7c2",
75
- "@aztec/builder": "0.0.1-commit.cb6bed7c2",
76
- "@aztec/constants": "0.0.1-commit.cb6bed7c2",
77
- "@aztec/ethereum": "0.0.1-commit.cb6bed7c2",
78
- "@aztec/foundation": "0.0.1-commit.cb6bed7c2",
79
- "@aztec/key-store": "0.0.1-commit.cb6bed7c2",
80
- "@aztec/kv-store": "0.0.1-commit.cb6bed7c2",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.cb6bed7c2",
82
- "@aztec/noir-types": "0.0.1-commit.cb6bed7c2",
83
- "@aztec/protocol-contracts": "0.0.1-commit.cb6bed7c2",
84
- "@aztec/simulator": "0.0.1-commit.cb6bed7c2",
85
- "@aztec/stdlib": "0.0.1-commit.cb6bed7c2",
73
+ "@aztec/bb-prover": "0.0.1-commit.cbf2c2d5d",
74
+ "@aztec/bb.js": "0.0.1-commit.cbf2c2d5d",
75
+ "@aztec/builder": "0.0.1-commit.cbf2c2d5d",
76
+ "@aztec/constants": "0.0.1-commit.cbf2c2d5d",
77
+ "@aztec/ethereum": "0.0.1-commit.cbf2c2d5d",
78
+ "@aztec/foundation": "0.0.1-commit.cbf2c2d5d",
79
+ "@aztec/key-store": "0.0.1-commit.cbf2c2d5d",
80
+ "@aztec/kv-store": "0.0.1-commit.cbf2c2d5d",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.cbf2c2d5d",
82
+ "@aztec/noir-types": "0.0.1-commit.cbf2c2d5d",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.cbf2c2d5d",
84
+ "@aztec/simulator": "0.0.1-commit.cbf2c2d5d",
85
+ "@aztec/stdlib": "0.0.1-commit.cbf2c2d5d",
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.cb6bed7c2",
95
- "@aztec/noir-test-contracts.js": "0.0.1-commit.cb6bed7c2",
94
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.cbf2c2d5d",
95
+ "@aztec/world-state": "0.0.1-commit.cbf2c2d5d",
96
96
  "@jest/globals": "^30.0.0",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/lodash.omit": "^4.5.7",
@@ -17,6 +17,7 @@ import {
17
17
  MAX_NULLIFIERS_PER_TX,
18
18
  MAX_NULLIFIER_READ_REQUESTS_PER_TX,
19
19
  MAX_PRIVATE_LOGS_PER_TX,
20
+ MAX_TX_LIFETIME,
20
21
  PRIVATE_TX_L2_GAS_OVERHEAD,
21
22
  PUBLIC_TX_L2_GAS_OVERHEAD,
22
23
  TX_DA_GAS_OVERHEAD,
@@ -79,6 +80,7 @@ import {
79
80
  BlockHeader,
80
81
  CallContext,
81
82
  HashedValues,
83
+ type OffchainEffect,
82
84
  PrivateExecutionResult,
83
85
  TxConstantData,
84
86
  TxExecutionRequest,
@@ -89,6 +91,7 @@ import {
89
91
 
90
92
  import type { AccessScopes } from '../access_scopes.js';
91
93
  import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
94
+ import type { MessageContextService } from '../messages/message_context_service.js';
92
95
  import type { AddressStore } from '../storage/address_store/address_store.js';
93
96
  import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
94
97
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
@@ -138,6 +141,7 @@ export type ContractFunctionSimulatorArgs = {
138
141
  privateEventStore: PrivateEventStore;
139
142
  simulator: CircuitSimulator;
140
143
  contractSyncService: ContractSyncService;
144
+ messageContextService: MessageContextService;
141
145
  };
142
146
 
143
147
  /**
@@ -157,6 +161,7 @@ export class ContractFunctionSimulator {
157
161
  private readonly privateEventStore: PrivateEventStore;
158
162
  private readonly simulator: CircuitSimulator;
159
163
  private readonly contractSyncService: ContractSyncService;
164
+ private readonly messageContextService: MessageContextService;
160
165
 
161
166
  constructor(args: ContractFunctionSimulatorArgs) {
162
167
  this.contractStore = args.contractStore;
@@ -171,6 +176,7 @@ export class ContractFunctionSimulator {
171
176
  this.privateEventStore = args.privateEventStore;
172
177
  this.simulator = args.simulator;
173
178
  this.contractSyncService = args.contractSyncService;
179
+ this.messageContextService = args.messageContextService;
174
180
  this.log = createLogger('simulator');
175
181
  }
176
182
 
@@ -241,6 +247,7 @@ export class ContractFunctionSimulator {
241
247
  senderAddressBookStore: this.senderAddressBookStore,
242
248
  capsuleStore: this.capsuleStore,
243
249
  privateEventStore: this.privateEventStore,
250
+ messageContextService: this.messageContextService,
244
251
  contractSyncService: this.contractSyncService,
245
252
  jobId,
246
253
  totalPublicCalldataCount: 0,
@@ -314,7 +321,7 @@ export class ContractFunctionSimulator {
314
321
  anchorBlockHeader: BlockHeader,
315
322
  scopes: AccessScopes,
316
323
  jobId: string,
317
- ): Promise<Fr[]> {
324
+ ): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
318
325
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
319
326
 
320
327
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
@@ -335,6 +342,8 @@ export class ContractFunctionSimulator {
335
342
  senderAddressBookStore: this.senderAddressBookStore,
336
343
  capsuleStore: this.capsuleStore,
337
344
  privateEventStore: this.privateEventStore,
345
+ messageContextService: this.messageContextService,
346
+ contractSyncService: this.contractSyncService,
338
347
  jobId,
339
348
  scopes,
340
349
  });
@@ -362,7 +371,10 @@ export class ContractFunctionSimulator {
362
371
  });
363
372
 
364
373
  this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
365
- return witnessMapToFields(acirExecutionResult.returnWitness);
374
+ return {
375
+ result: witnessMapToFields(acirExecutionResult.returnWitness),
376
+ offchainEffects: oracle.getOffchainEffects(),
377
+ };
366
378
  } catch (err) {
367
379
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
368
380
  }
@@ -432,14 +444,34 @@ export async function generateSimulatedProvingResult(
432
444
 
433
445
  let publicTeardownCallRequest;
434
446
 
447
+ // We set expiration timestamp to anchor_block_timestamp + MAX_TX_LIFETIME (24h) just like kernels do
448
+ let expirationTimestamp =
449
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.globalVariables.timestamp +
450
+ BigInt(MAX_TX_LIFETIME);
451
+
452
+ let feePayer = AztecAddress.zero();
453
+
435
454
  const executions = [privateExecutionResult.entrypoint];
436
455
 
437
456
  while (executions.length !== 0) {
438
457
  const execution = executions.shift()!;
439
458
  executions.unshift(...execution!.nestedExecutionResults);
440
459
 
460
+ // Just like kernels we overwrite the default value if the call sets it.
461
+ const callExpirationTimestamp = execution.publicInputs.expirationTimestamp;
462
+ if (callExpirationTimestamp !== 0n && callExpirationTimestamp < expirationTimestamp) {
463
+ expirationTimestamp = callExpirationTimestamp;
464
+ }
465
+
441
466
  const { contractAddress } = execution.publicInputs.callContext;
442
467
 
468
+ if (execution.publicInputs.isFeePayer) {
469
+ if (!feePayer.isZero()) {
470
+ throw new Error('Multiple fee payers found in private execution result');
471
+ }
472
+ feePayer = contractAddress;
473
+ }
474
+
443
475
  scopedNoteHashes.push(
444
476
  ...execution.publicInputs.noteHashes
445
477
  .getActiveItems()
@@ -660,8 +692,8 @@ export async function generateSimulatedProvingResult(
660
692
  daGas: TX_DA_GAS_OVERHEAD,
661
693
  }),
662
694
  ),
663
- /*feePayer=*/ AztecAddress.zero(),
664
- /*expirationTimestamp=*/ 0n,
695
+ /*feePayer=*/ feePayer,
696
+ /*expirationTimestamp=*/ expirationTimestamp,
665
697
  hasPublicCalls ? inputsForPublic : undefined,
666
698
  !hasPublicCalls ? inputsForRollup : undefined,
667
699
  );
@@ -1,32 +1,37 @@
1
- import { ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
1
+ import { ExtendedDirectionalAppTaggingSecret, type TaggingIndexRange } from '@aztec/stdlib/logs';
2
2
 
3
3
  /**
4
- * A map that stores the tagging index for a given extended directional app tagging secret.
4
+ * A map that stores the tagging index range for a given extended directional app tagging secret.
5
5
  * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
6
6
  * of sender -> recipient matters.
7
7
  */
8
8
  export class ExecutionTaggingIndexCache {
9
- private taggingIndexMap: Map<string, number> = new Map();
9
+ private taggingIndexMap: Map<string, { lowestIndex: number; highestIndex: number }> = new Map();
10
10
 
11
11
  public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
12
- return this.taggingIndexMap.get(secret.toString());
12
+ return this.taggingIndexMap.get(secret.toString())?.highestIndex;
13
13
  }
14
14
 
15
15
  public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
16
16
  const currentValue = this.taggingIndexMap.get(secret.toString());
17
- if (currentValue !== undefined && currentValue !== index - 1) {
18
- throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
17
+ if (currentValue !== undefined && currentValue.highestIndex !== index - 1) {
18
+ throw new Error(`Invalid tagging index update. Current value: ${currentValue.highestIndex}, new value: ${index}`);
19
+ }
20
+ if (currentValue !== undefined) {
21
+ currentValue.highestIndex = index;
22
+ } else {
23
+ this.taggingIndexMap.set(secret.toString(), { lowestIndex: index, highestIndex: index });
19
24
  }
20
- this.taggingIndexMap.set(secret.toString(), index);
21
25
  }
22
26
 
23
27
  /**
24
- * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
28
+ * Returns the tagging index ranges that were used in this execution (and that need to be stored in the db).
25
29
  */
26
- public getUsedPreTags(): PreTag[] {
27
- return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
30
+ public getUsedTaggingIndexRanges(): TaggingIndexRange[] {
31
+ return Array.from(this.taggingIndexMap.entries()).map(([secret, { lowestIndex, highestIndex }]) => ({
28
32
  extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
29
- index,
33
+ lowestIndex,
34
+ highestIndex,
30
35
  }));
31
36
  }
32
37
  }
@@ -4,6 +4,7 @@ export { HashedValuesCache } from './hashed_values_cache.js';
4
4
  export { pickNotes } from './pick_notes.js';
5
5
  export type { NoteData, IMiscOracle, IUtilityExecutionOracle, IPrivateExecutionOracle } from './oracle/interfaces.js';
6
6
  export { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
7
+ export { MessageContextService } from '../messages/message_context_service.js';
7
8
  export { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
8
9
  export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
9
10
  export { Oracle } from './oracle/oracle.js';
@@ -4,9 +4,6 @@ import { EventSelector } from '@aztec/stdlib/abi';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { TxHash } from '@aztec/stdlib/tx';
6
6
 
7
- // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
8
- const MAX_EVENT_SERIALIZED_LEN = 10;
9
-
10
7
  /**
11
8
  * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
12
9
  * expects for values of this type to be stored in a `CapsuleArray`.
@@ -22,7 +19,7 @@ export class EventValidationRequest {
22
19
  public recipient: AztecAddress,
23
20
  ) {}
24
21
 
25
- static fromFields(fields: Fr[] | FieldReader): EventValidationRequest {
22
+ static fromFields(fields: Fr[], maxEventSerializedLen: number): EventValidationRequest {
26
23
  const reader = FieldReader.asReader(fields);
27
24
 
28
25
  const contractAddress = AztecAddress.fromField(reader.readField());
@@ -30,7 +27,7 @@ export class EventValidationRequest {
30
27
 
31
28
  const randomness = reader.readField();
32
29
 
33
- const eventStorage = reader.readFieldArray(MAX_EVENT_SERIALIZED_LEN);
30
+ const eventStorage = reader.readFieldArray(maxEventSerializedLen);
34
31
  const eventLen = reader.readField().toNumber();
35
32
  const serializedEvent = eventStorage.slice(0, eventLen);
36
33
 
@@ -38,6 +35,12 @@ export class EventValidationRequest {
38
35
  const txHash = TxHash.fromField(reader.readField());
39
36
  const recipient = AztecAddress.fromField(reader.readField());
40
37
 
38
+ if (reader.remainingFields() !== 0) {
39
+ throw new Error(
40
+ `Error converting array of fields to EventValidationRequest: expected ${reader.cursor} fields but received ${fields.length} (maxEventSerializedLen=${maxEventSerializedLen}).`,
41
+ );
42
+ }
43
+
41
44
  return new EventValidationRequest(
42
45
  contractAddress,
43
46
  eventTypeId,
@@ -3,10 +3,7 @@ import { range } from '@aztec/foundation/array';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { TxHash } from '@aztec/stdlib/tx';
5
5
 
6
- import { MAX_NOTE_PACKED_LEN } from './note_validation_request.js';
7
-
8
- const MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION = MAX_NOTE_PACKED_LEN;
9
- const MAX_LOG_CONTENT_LEN = Math.max(MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION, PRIVATE_LOG_CIPHERTEXT_LEN);
6
+ const MAX_LOG_CONTENT_LEN = PRIVATE_LOG_CIPHERTEXT_LEN;
10
7
 
11
8
  /**
12
9
  * Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
@@ -0,0 +1,55 @@
1
+ import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
2
+ import { range } from '@aztec/foundation/array';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import type { TxHash } from '@aztec/stdlib/tx';
5
+
6
+ /**
7
+ * Intermediate struct used to return resolved message contexts from PXE. The
8
+ * `utilityResolveMessageContexts` oracle stores values of this type in a CapsuleArray.
9
+ */
10
+ export class MessageTxContext {
11
+ constructor(
12
+ public txHash: TxHash,
13
+ public uniqueNoteHashesInTx: Fr[],
14
+ public firstNullifierInTx: Fr,
15
+ ) {}
16
+
17
+ toFields(): Fr[] {
18
+ return [
19
+ this.txHash.hash,
20
+ ...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
21
+ this.firstNullifierInTx,
22
+ ];
23
+ }
24
+
25
+ static toEmptyFields(): Fr[] {
26
+ const serializationLen =
27
+ 1 /* txHash */ + MAX_NOTE_HASHES_PER_TX + 1 /* uniqueNoteHashesInTx BVec */ + 1; /* firstNullifierInTx */
28
+ return range(serializationLen).map(_ => Fr.zero());
29
+ }
30
+
31
+ static toSerializedOption(response: MessageTxContext | null): Fr[] {
32
+ if (response) {
33
+ return [new Fr(1), ...response.toFields()];
34
+ } else {
35
+ return [new Fr(0), ...MessageTxContext.toEmptyFields()];
36
+ }
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Helper function to serialize a bounded vector according to Noir's BoundedVec format
42
+ * @param values - The values to serialize
43
+ * @param maxLength - The maximum length of the bounded vector
44
+ * @returns The serialized bounded vector as Fr[]
45
+ */
46
+ function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
47
+ if (values.length > maxLength) {
48
+ throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
49
+ }
50
+
51
+ const lengthDiff = maxLength - values.length;
52
+ const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
53
+ const storage = values.concat(zeroPaddingArray);
54
+ return [...storage, new Fr(values.length)];
55
+ }
@@ -3,9 +3,6 @@ import { FieldReader } from '@aztec/foundation/serialize';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { TxHash } from '@aztec/stdlib/tx';
5
5
 
6
- // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
7
- export const MAX_NOTE_PACKED_LEN = 8;
8
-
9
6
  /**
10
7
  * Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
11
8
  * expects for values of this type to be stored in a `CapsuleArray`.
@@ -24,7 +21,7 @@ export class NoteValidationRequest {
24
21
  public recipient: AztecAddress,
25
22
  ) {}
26
23
 
27
- static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest {
24
+ static fromFields(fields: Fr[], maxNotePackedLen: number): NoteValidationRequest {
28
25
  const reader = FieldReader.asReader(fields);
29
26
 
30
27
  const contractAddress = AztecAddress.fromField(reader.readField());
@@ -33,7 +30,7 @@ export class NoteValidationRequest {
33
30
  const randomness = reader.readField();
34
31
  const noteNonce = reader.readField();
35
32
 
36
- const contentStorage = reader.readFieldArray(MAX_NOTE_PACKED_LEN);
33
+ const contentStorage = reader.readFieldArray(maxNotePackedLen);
37
34
  const contentLen = reader.readField().toNumber();
38
35
  const content = contentStorage.slice(0, contentLen);
39
36
 
@@ -44,7 +41,7 @@ export class NoteValidationRequest {
44
41
 
45
42
  if (reader.remainingFields() !== 0) {
46
43
  throw new Error(
47
- `Error converting array of fields to NoteValidationRequest. Hint: check that MAX_NOTE_PACKED_LEN is consistent with private_notes::MAX_NOTE_PACKED_LEN in Aztec-nr.`,
44
+ `Error converting array of fields to NoteValidationRequest: expected ${reader.cursor} fields but received ${fields.length} (maxNotePackedLen=${maxNotePackedLen}).`,
48
45
  );
49
46
  }
50
47