@aztec/pxe 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2

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 (139) hide show
  1. package/dest/config/index.d.ts +2 -2
  2. package/dest/config/index.d.ts.map +1 -1
  3. package/dest/config/index.js +1 -1
  4. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.js +33 -11
  7. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  8. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  10. package/dest/contract_function_simulator/index.d.ts +2 -1
  11. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/index.js +1 -0
  13. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
  14. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  16. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  17. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  19. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
  20. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
  23. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
  25. package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
  26. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  28. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
  30. package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -44
  31. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/oracle/oracle.js +163 -94
  33. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  34. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -47
  35. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +40 -80
  37. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +57 -39
  38. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +138 -63
  40. package/dest/contract_logging.d.ts +22 -0
  41. package/dest/contract_logging.d.ts.map +1 -0
  42. package/dest/contract_logging.js +23 -0
  43. package/dest/contract_sync/contract_sync_service.d.ts +5 -3
  44. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  45. package/dest/contract_sync/contract_sync_service.js +47 -30
  46. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  47. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  48. package/dest/entrypoints/client/bundle/index.js +1 -0
  49. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  50. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  51. package/dest/entrypoints/client/lazy/index.js +1 -0
  52. package/dest/logs/log_service.d.ts +1 -1
  53. package/dest/logs/log_service.d.ts.map +1 -1
  54. package/dest/logs/log_service.js +4 -4
  55. package/dest/messages/message_context_service.d.ts +17 -0
  56. package/dest/messages/message_context_service.d.ts.map +1 -0
  57. package/dest/messages/message_context_service.js +36 -0
  58. package/dest/oracle_version.d.ts +2 -2
  59. package/dest/oracle_version.js +3 -3
  60. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  61. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  62. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +125 -64
  63. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  64. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  65. package/dest/private_kernel/hints/test_utils.js +203 -0
  66. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  67. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  68. package/dest/private_kernel/private_kernel_execution_prover.js +13 -5
  69. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  70. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  71. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  72. package/dest/pxe.d.ts +8 -4
  73. package/dest/pxe.d.ts.map +1 -1
  74. package/dest/pxe.js +55 -33
  75. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  76. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  77. package/dest/storage/contract_store/contract_store.js +140 -64
  78. package/dest/storage/metadata.d.ts +1 -1
  79. package/dest/storage/metadata.js +1 -1
  80. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  81. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  82. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  83. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  84. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  85. package/dest/tagging/index.d.ts +3 -3
  86. package/dest/tagging/index.d.ts.map +1 -1
  87. package/dest/tagging/index.js +1 -1
  88. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  89. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  90. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  91. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  92. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  93. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  94. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  95. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  96. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  97. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  98. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  99. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  100. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  101. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  102. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  103. package/package.json +16 -16
  104. package/src/config/index.ts +1 -1
  105. package/src/contract_function_simulator/contract_function_simulator.ts +51 -20
  106. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  107. package/src/contract_function_simulator/index.ts +1 -0
  108. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
  109. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  110. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
  111. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
  112. package/src/contract_function_simulator/oracle/interfaces.ts +54 -54
  113. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
  114. package/src/contract_function_simulator/oracle/oracle.ts +176 -138
  115. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  116. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +45 -99
  117. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +200 -80
  118. package/src/contract_logging.ts +39 -0
  119. package/src/contract_sync/contract_sync_service.ts +67 -38
  120. package/src/entrypoints/client/bundle/index.ts +1 -0
  121. package/src/entrypoints/client/lazy/index.ts +1 -0
  122. package/src/logs/log_service.ts +10 -5
  123. package/src/messages/message_context_service.ts +45 -0
  124. package/src/oracle_version.ts +3 -3
  125. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +157 -110
  126. package/src/private_kernel/hints/test_utils.ts +325 -0
  127. package/src/private_kernel/private_kernel_execution_prover.ts +13 -6
  128. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  129. package/src/pxe.ts +74 -34
  130. package/src/storage/contract_store/contract_store.ts +170 -71
  131. package/src/storage/metadata.ts +1 -1
  132. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  133. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  134. package/src/tagging/index.ts +2 -2
  135. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  136. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  137. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  138. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  139. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
@@ -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.cd76b27",
3
+ "version": "0.0.1-commit.ce4f8c4f2",
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.cd76b27",
74
- "@aztec/bb.js": "0.0.1-commit.cd76b27",
75
- "@aztec/builder": "0.0.1-commit.cd76b27",
76
- "@aztec/constants": "0.0.1-commit.cd76b27",
77
- "@aztec/ethereum": "0.0.1-commit.cd76b27",
78
- "@aztec/foundation": "0.0.1-commit.cd76b27",
79
- "@aztec/key-store": "0.0.1-commit.cd76b27",
80
- "@aztec/kv-store": "0.0.1-commit.cd76b27",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.cd76b27",
82
- "@aztec/noir-types": "0.0.1-commit.cd76b27",
83
- "@aztec/protocol-contracts": "0.0.1-commit.cd76b27",
84
- "@aztec/simulator": "0.0.1-commit.cd76b27",
85
- "@aztec/stdlib": "0.0.1-commit.cd76b27",
73
+ "@aztec/bb-prover": "0.0.1-commit.ce4f8c4f2",
74
+ "@aztec/bb.js": "0.0.1-commit.ce4f8c4f2",
75
+ "@aztec/builder": "0.0.1-commit.ce4f8c4f2",
76
+ "@aztec/constants": "0.0.1-commit.ce4f8c4f2",
77
+ "@aztec/ethereum": "0.0.1-commit.ce4f8c4f2",
78
+ "@aztec/foundation": "0.0.1-commit.ce4f8c4f2",
79
+ "@aztec/key-store": "0.0.1-commit.ce4f8c4f2",
80
+ "@aztec/kv-store": "0.0.1-commit.ce4f8c4f2",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.ce4f8c4f2",
82
+ "@aztec/noir-types": "0.0.1-commit.ce4f8c4f2",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.ce4f8c4f2",
84
+ "@aztec/simulator": "0.0.1-commit.ce4f8c4f2",
85
+ "@aztec/stdlib": "0.0.1-commit.ce4f8c4f2",
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.cd76b27",
95
- "@aztec/noir-test-contracts.js": "0.0.1-commit.cd76b27",
94
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.ce4f8c4f2",
95
+ "@aztec/world-state": "0.0.1-commit.ce4f8c4f2",
96
96
  "@jest/globals": "^30.0.0",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/lodash.omit": "^4.5.7",
@@ -5,8 +5,8 @@ import {
5
5
  numberConfigHelper,
6
6
  parseBooleanEnv,
7
7
  } from '@aztec/foundation/config';
8
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
9
8
  import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
9
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
10
10
 
11
11
  export { getPackageInfo } from './package_info.js';
12
12
 
@@ -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';
@@ -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,
@@ -88,6 +91,7 @@ import {
88
91
 
89
92
  import type { AccessScopes } from '../access_scopes.js';
90
93
  import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
94
+ import type { MessageContextService } from '../messages/message_context_service.js';
91
95
  import type { AddressStore } from '../storage/address_store/address_store.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';
@@ -137,6 +141,7 @@ export type ContractFunctionSimulatorArgs = {
137
141
  privateEventStore: PrivateEventStore;
138
142
  simulator: CircuitSimulator;
139
143
  contractSyncService: ContractSyncService;
144
+ messageContextService: MessageContextService;
140
145
  };
141
146
 
142
147
  /**
@@ -156,6 +161,7 @@ export class ContractFunctionSimulator {
156
161
  private readonly privateEventStore: PrivateEventStore;
157
162
  private readonly simulator: CircuitSimulator;
158
163
  private readonly contractSyncService: ContractSyncService;
164
+ private readonly messageContextService: MessageContextService;
159
165
 
160
166
  constructor(args: ContractFunctionSimulatorArgs) {
161
167
  this.contractStore = args.contractStore;
@@ -170,6 +176,7 @@ export class ContractFunctionSimulator {
170
176
  this.privateEventStore = args.privateEventStore;
171
177
  this.simulator = args.simulator;
172
178
  this.contractSyncService = args.contractSyncService;
179
+ this.messageContextService = args.messageContextService;
173
180
  this.log = createLogger('simulator');
174
181
  }
175
182
 
@@ -240,6 +247,7 @@ export class ContractFunctionSimulator {
240
247
  senderAddressBookStore: this.senderAddressBookStore,
241
248
  capsuleStore: this.capsuleStore,
242
249
  privateEventStore: this.privateEventStore,
250
+ messageContextService: this.messageContextService,
243
251
  contractSyncService: this.contractSyncService,
244
252
  jobId,
245
253
  totalPublicCalldataCount: 0,
@@ -276,7 +284,7 @@ export class ContractFunctionSimulator {
276
284
  );
277
285
  const publicFunctionsCalldata = await Promise.all(
278
286
  publicCallRequests.map(async r => {
279
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
287
+ const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
280
288
  return new HashedValues(calldata, r.calldataHash);
281
289
  }),
282
290
  );
@@ -313,7 +321,7 @@ export class ContractFunctionSimulator {
313
321
  anchorBlockHeader: BlockHeader,
314
322
  scopes: AccessScopes,
315
323
  jobId: string,
316
- ): Promise<Fr[]> {
324
+ ): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
317
325
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
318
326
 
319
327
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
@@ -334,6 +342,8 @@ export class ContractFunctionSimulator {
334
342
  senderAddressBookStore: this.senderAddressBookStore,
335
343
  capsuleStore: this.capsuleStore,
336
344
  privateEventStore: this.privateEventStore,
345
+ messageContextService: this.messageContextService,
346
+ contractSyncService: this.contractSyncService,
337
347
  jobId,
338
348
  scopes,
339
349
  });
@@ -361,7 +371,10 @@ export class ContractFunctionSimulator {
361
371
  });
362
372
 
363
373
  this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
364
- return witnessMapToFields(acirExecutionResult.returnWitness);
374
+ return {
375
+ result: witnessMapToFields(acirExecutionResult.returnWitness),
376
+ offchainEffects: oracle.getOffchainEffects(),
377
+ };
365
378
  } catch (err) {
366
379
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
367
380
  }
@@ -431,14 +444,34 @@ export async function generateSimulatedProvingResult(
431
444
 
432
445
  let publicTeardownCallRequest;
433
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
+
434
454
  const executions = [privateExecutionResult.entrypoint];
435
455
 
436
456
  while (executions.length !== 0) {
437
457
  const execution = executions.shift()!;
438
458
  executions.unshift(...execution!.nestedExecutionResults);
439
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
+
440
466
  const { contractAddress } = execution.publicInputs.callContext;
441
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
+
442
475
  scopedNoteHashes.push(
443
476
  ...execution.publicInputs.noteHashes
444
477
  .getActiveItems()
@@ -653,9 +686,14 @@ export async function generateSimulatedProvingResult(
653
686
 
654
687
  const publicInputs = new PrivateKernelTailCircuitPublicInputs(
655
688
  constantData,
656
- /*gasUsed=*/ gasUsed.add(Gas.from({ l2Gas: FIXED_L2_GAS, daGas: FIXED_DA_GAS })),
657
- /*feePayer=*/ AztecAddress.zero(),
658
- /*expirationTimestamp=*/ 0n,
689
+ /*gasUsed=*/ gasUsed.add(
690
+ Gas.from({
691
+ l2Gas: isPrivateOnlyTx ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
692
+ daGas: TX_DA_GAS_OVERHEAD,
693
+ }),
694
+ ),
695
+ /*feePayer=*/ feePayer,
696
+ /*expirationTimestamp=*/ expirationTimestamp,
659
697
  hasPublicCalls ? inputsForPublic : undefined,
660
698
  !hasPublicCalls ? inputsForRollup : undefined,
661
699
  );
@@ -683,6 +721,7 @@ function squashTransientSideEffects(
683
721
  scopedNullifiersCLA,
684
722
  /*futureNoteHashReads=*/ [],
685
723
  /*futureNullifierReads=*/ [],
724
+ /*futureLogs=*/ [],
686
725
  noteHashNullifierCounterMap,
687
726
  minRevertibleSideEffectCounter,
688
727
  );
@@ -725,16 +764,8 @@ async function verifyReadRequests(
725
764
  nullifierReadRequests.length,
726
765
  );
727
766
 
728
- const noteHashResetActions = getNoteHashReadRequestResetActions(
729
- noteHashReadRequestsCLA,
730
- scopedNoteHashesCLA,
731
- /*futureNoteHashes=*/ [],
732
- );
733
- const nullifierResetActions = getNullifierReadRequestResetActions(
734
- nullifierReadRequestsCLA,
735
- scopedNullifiersCLA,
736
- /*futureNullifiers=*/ [],
737
- );
767
+ const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA);
768
+ const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA);
738
769
 
739
770
  const settledNoteHashReads: { index: number; value: Fr }[] = [];
740
771
  for (let i = 0; i < noteHashResetActions.actions.length; i++) {
@@ -810,9 +841,9 @@ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccu
810
841
  meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
811
842
 
812
843
  const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, log => log.isEmpty());
813
- // Every contract class log emits its length and contract address as additional fields
844
+ // Every contract class log emits its contract address as an additional field
814
845
  meteredDAFields += data.contractClassLogsHashes.reduce(
815
- (acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 2 : acc),
846
+ (acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 1 : acc),
816
847
  0,
817
848
  );
818
849
  meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
@@ -1,32 +1,37 @@
1
- import { DirectionalAppTaggingSecret, 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 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
- public getLastUsedIndex(secret: DirectionalAppTaggingSecret): number | undefined {
12
- return this.taggingIndexMap.get(secret.toString());
11
+ public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
12
+ return this.taggingIndexMap.get(secret.toString())?.highestIndex;
13
13
  }
14
14
 
15
- public setLastUsedIndex(secret: DirectionalAppTaggingSecret, index: number) {
15
+ public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
16
16
  const currentValue = this.taggingIndexMap.get(secret.toString());
17
- 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]) => ({
28
- secret: DirectionalAppTaggingSecret.fromString(secret),
29
- index,
30
+ public getUsedTaggingIndexRanges(): TaggingIndexRange[] {
31
+ return Array.from(this.taggingIndexMap.entries()).map(([secret, { lowestIndex, highestIndex }]) => ({
32
+ extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
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 = 11;
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
+ }