@aztec/pxe 0.0.1-commit.d117d021b → 0.0.1-commit.d1da697d6

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 (161) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.js +6 -0
  4. package/dest/contract_function_simulator/contract_function_simulator.d.ts +10 -5
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.js +29 -6
  7. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  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 +17 -9
  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 +2 -5
  16. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -3
  17. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -5
  19. package/dest/contract_function_simulator/oracle/interfaces.d.ts +20 -18
  20. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  22. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  23. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +38 -0
  24. package/dest/contract_function_simulator/oracle/oracle.d.ts +38 -17
  25. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/oracle/oracle.js +89 -37
  27. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  28. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -22
  29. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +20 -24
  31. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +45 -28
  32. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +164 -71
  34. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  35. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/pick_notes.js +9 -2
  37. package/dest/contract_logging.d.ts +9 -4
  38. package/dest/contract_logging.d.ts.map +1 -1
  39. package/dest/contract_logging.js +21 -6
  40. package/dest/contract_sync/contract_sync_service.d.ts +6 -5
  41. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  42. package/dest/contract_sync/contract_sync_service.js +44 -37
  43. package/dest/contract_sync/helpers.d.ts +2 -3
  44. package/dest/contract_sync/helpers.d.ts.map +1 -1
  45. package/dest/contract_sync/helpers.js +7 -2
  46. package/dest/debug/pxe_debug_utils.d.ts +3 -3
  47. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  48. package/dest/entrypoints/client/bundle/index.d.ts +1 -2
  49. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  50. package/dest/entrypoints/client/bundle/index.js +0 -1
  51. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  52. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  53. package/dest/entrypoints/client/bundle/utils.js +2 -2
  54. package/dest/entrypoints/client/lazy/index.d.ts +1 -2
  55. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  56. package/dest/entrypoints/client/lazy/index.js +0 -1
  57. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  58. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  59. package/dest/entrypoints/client/lazy/utils.js +2 -2
  60. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  61. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  62. package/dest/entrypoints/pxe_creation_options.js +3 -1
  63. package/dest/entrypoints/server/index.d.ts +1 -2
  64. package/dest/entrypoints/server/index.d.ts.map +1 -1
  65. package/dest/entrypoints/server/index.js +0 -1
  66. package/dest/entrypoints/server/utils.d.ts +2 -2
  67. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/server/utils.js +2 -2
  69. package/dest/events/event_service.d.ts +3 -2
  70. package/dest/events/event_service.d.ts.map +1 -1
  71. package/dest/events/event_service.js +16 -4
  72. package/dest/logs/log_service.d.ts +6 -7
  73. package/dest/logs/log_service.d.ts.map +1 -1
  74. package/dest/logs/log_service.js +32 -30
  75. package/dest/messages/message_context_service.d.ts +17 -0
  76. package/dest/messages/message_context_service.d.ts.map +1 -0
  77. package/dest/messages/message_context_service.js +36 -0
  78. package/dest/notes/note_service.d.ts +4 -5
  79. package/dest/notes/note_service.d.ts.map +1 -1
  80. package/dest/notes/note_service.js +14 -5
  81. package/dest/notes_filter.d.ts +2 -3
  82. package/dest/notes_filter.d.ts.map +1 -1
  83. package/dest/oracle_version.d.ts +2 -2
  84. package/dest/oracle_version.js +2 -2
  85. package/dest/pxe.d.ts +9 -7
  86. package/dest/pxe.d.ts.map +1 -1
  87. package/dest/pxe.js +39 -23
  88. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  89. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  90. package/dest/storage/capsule_store/capsule_service.js +50 -0
  91. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  92. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  93. package/dest/storage/capsule_store/capsule_store.js +33 -28
  94. package/dest/storage/capsule_store/index.d.ts +2 -1
  95. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  96. package/dest/storage/capsule_store/index.js +1 -0
  97. package/dest/storage/metadata.d.ts +1 -1
  98. package/dest/storage/metadata.js +1 -1
  99. package/dest/storage/note_store/note_store.d.ts +1 -1
  100. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  101. package/dest/storage/note_store/note_store.js +2 -2
  102. package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
  103. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  104. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  105. package/dest/tagging/index.d.ts +2 -2
  106. package/dest/tagging/index.d.ts.map +1 -1
  107. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
  108. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  109. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
  110. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  111. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  112. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  113. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
  114. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  115. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
  116. package/package.json +16 -16
  117. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  118. package/src/contract_function_simulator/contract_function_simulator.ts +42 -10
  119. package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
  120. package/src/contract_function_simulator/index.ts +1 -0
  121. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +0 -3
  122. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +0 -3
  123. package/src/contract_function_simulator/oracle/interfaces.ts +31 -16
  124. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
  125. package/src/contract_function_simulator/oracle/oracle.ts +116 -32
  126. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  127. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +24 -31
  128. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +284 -83
  129. package/src/contract_function_simulator/pick_notes.ts +9 -2
  130. package/src/contract_logging.ts +18 -5
  131. package/src/contract_sync/contract_sync_service.ts +77 -59
  132. package/src/contract_sync/helpers.ts +4 -4
  133. package/src/debug/pxe_debug_utils.ts +3 -3
  134. package/src/entrypoints/client/bundle/index.ts +0 -1
  135. package/src/entrypoints/client/bundle/utils.ts +2 -3
  136. package/src/entrypoints/client/lazy/index.ts +0 -1
  137. package/src/entrypoints/client/lazy/utils.ts +2 -3
  138. package/src/entrypoints/pxe_creation_options.ts +7 -0
  139. package/src/entrypoints/server/index.ts +0 -1
  140. package/src/entrypoints/server/utils.ts +2 -3
  141. package/src/events/event_service.ts +17 -4
  142. package/src/logs/log_service.ts +63 -48
  143. package/src/messages/message_context_service.ts +44 -0
  144. package/src/notes/note_service.ts +18 -8
  145. package/src/notes_filter.ts +1 -3
  146. package/src/oracle_version.ts +2 -2
  147. package/src/pxe.ts +62 -28
  148. package/src/storage/capsule_store/capsule_service.ts +90 -0
  149. package/src/storage/capsule_store/capsule_store.ts +34 -26
  150. package/src/storage/capsule_store/index.ts +1 -0
  151. package/src/storage/metadata.ts +1 -1
  152. package/src/storage/note_store/note_store.ts +2 -5
  153. package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
  154. package/src/tagging/index.ts +1 -1
  155. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
  156. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  157. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
  158. package/dest/access_scopes.d.ts +0 -9
  159. package/dest/access_scopes.d.ts.map +0 -1
  160. package/dest/access_scopes.js +0 -6
  161. package/src/access_scopes.ts +0 -9
@@ -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.d117d021b",
3
+ "version": "0.0.1-commit.d1da697d6",
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.d117d021b",
74
- "@aztec/bb.js": "0.0.1-commit.d117d021b",
75
- "@aztec/builder": "0.0.1-commit.d117d021b",
76
- "@aztec/constants": "0.0.1-commit.d117d021b",
77
- "@aztec/ethereum": "0.0.1-commit.d117d021b",
78
- "@aztec/foundation": "0.0.1-commit.d117d021b",
79
- "@aztec/key-store": "0.0.1-commit.d117d021b",
80
- "@aztec/kv-store": "0.0.1-commit.d117d021b",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.d117d021b",
82
- "@aztec/noir-types": "0.0.1-commit.d117d021b",
83
- "@aztec/protocol-contracts": "0.0.1-commit.d117d021b",
84
- "@aztec/simulator": "0.0.1-commit.d117d021b",
85
- "@aztec/stdlib": "0.0.1-commit.d117d021b",
73
+ "@aztec/bb-prover": "0.0.1-commit.d1da697d6",
74
+ "@aztec/bb.js": "0.0.1-commit.d1da697d6",
75
+ "@aztec/builder": "0.0.1-commit.d1da697d6",
76
+ "@aztec/constants": "0.0.1-commit.d1da697d6",
77
+ "@aztec/ethereum": "0.0.1-commit.d1da697d6",
78
+ "@aztec/foundation": "0.0.1-commit.d1da697d6",
79
+ "@aztec/key-store": "0.0.1-commit.d1da697d6",
80
+ "@aztec/kv-store": "0.0.1-commit.d1da697d6",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.d1da697d6",
82
+ "@aztec/noir-types": "0.0.1-commit.d1da697d6",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.d1da697d6",
84
+ "@aztec/simulator": "0.0.1-commit.d1da697d6",
85
+ "@aztec/stdlib": "0.0.1-commit.d1da697d6",
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.d117d021b",
95
- "@aztec/noir-test-contracts.js": "0.0.1-commit.d117d021b",
94
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.d1da697d6",
95
+ "@aztec/world-state": "0.0.1-commit.d1da697d6",
96
96
  "@jest/globals": "^30.0.0",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/lodash.omit": "^4.5.7",
@@ -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 {
@@ -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,
@@ -87,9 +89,10 @@ import {
87
89
  getFinalMinRevertibleSideEffectCounter,
88
90
  } from '@aztec/stdlib/tx';
89
91
 
90
- import type { AccessScopes } from '../access_scopes.js';
91
92
  import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
93
+ import type { MessageContextService } from '../messages/message_context_service.js';
92
94
  import type { AddressStore } from '../storage/address_store/address_store.js';
95
+ import { CapsuleService } from '../storage/capsule_store/capsule_service.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';
95
98
  import type { NoteStore } from '../storage/note_store/note_store.js';
@@ -119,7 +122,7 @@ export type ContractSimulatorRunOpts = {
119
122
  /** The address used as a tagging sender when emitting private logs. */
120
123
  senderForTags?: AztecAddress;
121
124
  /** The accounts whose notes we can access in this call. */
122
- scopes: AccessScopes;
125
+ scopes: AztecAddress[];
123
126
  /** The job ID for staged writes. */
124
127
  jobId: string;
125
128
  };
@@ -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
 
@@ -239,8 +245,9 @@ export class ContractFunctionSimulator {
239
245
  senderTaggingStore: this.senderTaggingStore,
240
246
  recipientTaggingStore: this.recipientTaggingStore,
241
247
  senderAddressBookStore: this.senderAddressBookStore,
242
- capsuleStore: this.capsuleStore,
248
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
243
249
  privateEventStore: this.privateEventStore,
250
+ messageContextService: this.messageContextService,
244
251
  contractSyncService: this.contractSyncService,
245
252
  jobId,
246
253
  totalPublicCalldataCount: 0,
@@ -277,7 +284,7 @@ export class ContractFunctionSimulator {
277
284
  );
278
285
  const publicFunctionsCalldata = await Promise.all(
279
286
  publicCallRequests.map(async r => {
280
- const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
287
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
281
288
  return new HashedValues(calldata, r.calldataHash);
282
289
  }),
283
290
  );
@@ -312,9 +319,9 @@ export class ContractFunctionSimulator {
312
319
  call: FunctionCall,
313
320
  authwits: AuthWitness[],
314
321
  anchorBlockHeader: BlockHeader,
315
- scopes: AccessScopes,
322
+ scopes: AztecAddress[],
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) {
@@ -333,8 +340,10 @@ export class ContractFunctionSimulator {
333
340
  aztecNode: this.aztecNode,
334
341
  recipientTaggingStore: this.recipientTaggingStore,
335
342
  senderAddressBookStore: this.senderAddressBookStore,
336
- capsuleStore: this.capsuleStore,
343
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
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';
@@ -16,7 +16,6 @@ export class EventValidationRequest {
16
16
  public serializedEvent: Fr[],
17
17
  public eventCommitment: Fr,
18
18
  public txHash: TxHash,
19
- public recipient: AztecAddress,
20
19
  ) {}
21
20
 
22
21
  static fromFields(fields: Fr[], maxEventSerializedLen: number): EventValidationRequest {
@@ -33,7 +32,6 @@ export class EventValidationRequest {
33
32
 
34
33
  const eventCommitment = reader.readField();
35
34
  const txHash = TxHash.fromField(reader.readField());
36
- const recipient = AztecAddress.fromField(reader.readField());
37
35
 
38
36
  if (reader.remainingFields() !== 0) {
39
37
  throw new Error(
@@ -48,7 +46,6 @@ export class EventValidationRequest {
48
46
  serializedEvent,
49
47
  eventCommitment,
50
48
  txHash,
51
- recipient,
52
49
  );
53
50
  }
54
51
  }
@@ -18,7 +18,6 @@ export class NoteValidationRequest {
18
18
  public noteHash: Fr,
19
19
  public nullifier: Fr,
20
20
  public txHash: TxHash,
21
- public recipient: AztecAddress,
22
21
  ) {}
23
22
 
24
23
  static fromFields(fields: Fr[], maxNotePackedLen: number): NoteValidationRequest {
@@ -37,7 +36,6 @@ export class NoteValidationRequest {
37
36
  const noteHash = reader.readField();
38
37
  const nullifier = reader.readField();
39
38
  const txHash = TxHash.fromField(reader.readField());
40
- const recipient = AztecAddress.fromField(reader.readField());
41
39
 
42
40
  if (reader.remainingFields() !== 0) {
43
41
  throw new Error(
@@ -55,7 +53,6 @@ export class NoteValidationRequest {
55
53
  noteHash,
56
54
  nullifier,
57
55
  txHash,
58
- recipient,
59
56
  );
60
57
  }
61
58
  }
@@ -86,7 +86,7 @@ export interface IUtilityExecutionOracle {
86
86
  nullifier: Fr,
87
87
  ): Promise<NullifierMembershipWitness | undefined>;
88
88
  getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
89
- tryGetPublicKeysAndPartialAddress(
89
+ getPublicKeysAndPartialAddress(
90
90
  account: AztecAddress,
91
91
  ): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined>;
92
92
  getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
@@ -107,37 +107,53 @@ export interface IUtilityExecutionOracle {
107
107
  offset: number,
108
108
  status: NoteStatus,
109
109
  ): Promise<NoteData[]>;
110
- checkNullifierExists(innerNullifier: Fr): Promise<boolean>;
110
+ doesNullifierExist(innerNullifier: Fr): Promise<boolean>;
111
111
  getL1ToL2MembershipWitness(
112
112
  contractAddress: AztecAddress,
113
113
  messageHash: Fr,
114
114
  secret: Fr,
115
115
  ): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
116
- storageRead(
116
+ getFromPublicStorage(
117
117
  anchorBlockHash: BlockHash,
118
118
  contractAddress: AztecAddress,
119
119
  startStorageSlot: Fr,
120
120
  numberOfElements: number,
121
121
  ): Promise<Fr[]>;
122
- fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
122
+ getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr, scope: AztecAddress): Promise<void>;
123
123
  validateAndStoreEnqueuedNotesAndEvents(
124
124
  contractAddress: AztecAddress,
125
125
  noteValidationRequestsArrayBaseSlot: Fr,
126
126
  eventValidationRequestsArrayBaseSlot: Fr,
127
127
  maxNotePackedLen: number,
128
128
  maxEventSerializedLen: number,
129
+ scope: AztecAddress,
129
130
  ): Promise<void>;
130
- bulkRetrieveLogs(
131
+ getLogsByTag(
131
132
  contractAddress: AztecAddress,
132
133
  logRetrievalRequestsArrayBaseSlot: Fr,
133
134
  logRetrievalResponsesArrayBaseSlot: Fr,
135
+ scope: AztecAddress,
134
136
  ): Promise<void>;
135
- storeCapsule(contractAddress: AztecAddress, key: Fr, capsule: Fr[]): Promise<void>;
136
- loadCapsule(contractAddress: AztecAddress, key: Fr): Promise<Fr[] | null>;
137
- deleteCapsule(contractAddress: AztecAddress, key: Fr): Promise<void>;
138
- copyCapsule(contractAddress: AztecAddress, srcKey: Fr, dstKey: Fr, numEntries: number): Promise<void>;
139
- aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
140
- getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
137
+ getMessageContextsByTxHash(
138
+ contractAddress: AztecAddress,
139
+ messageContextRequestsArrayBaseSlot: Fr,
140
+ messageContextResponsesArrayBaseSlot: Fr,
141
+ scope: AztecAddress,
142
+ ): Promise<void>;
143
+ setCapsule(contractAddress: AztecAddress, key: Fr, capsule: Fr[], scope: AztecAddress): void;
144
+ getCapsule(contractAddress: AztecAddress, key: Fr, scope: AztecAddress): Promise<Fr[] | null>;
145
+ deleteCapsule(contractAddress: AztecAddress, key: Fr, scope: AztecAddress): void;
146
+ copyCapsule(
147
+ contractAddress: AztecAddress,
148
+ srcKey: Fr,
149
+ dstKey: Fr,
150
+ numEntries: number,
151
+ scope: AztecAddress,
152
+ ): Promise<void>;
153
+ decryptAes128(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
154
+ getSharedSecret(address: AztecAddress, ephPk: Point, contractAddress: AztecAddress): Promise<Fr>;
155
+ setContractSyncCacheInvalid(contractAddress: AztecAddress, scopes: AztecAddress[]): void;
156
+ emitOffchainEffect(data: Fr[]): Promise<void>;
141
157
  }
142
158
 
143
159
  /**
@@ -147,8 +163,8 @@ export interface IUtilityExecutionOracle {
147
163
  export interface IPrivateExecutionOracle {
148
164
  isPrivate: true;
149
165
 
150
- storeInExecutionCache(values: Fr[], hash: Fr): void;
151
- loadFromExecutionCache(hash: Fr): Promise<Fr[]>;
166
+ setHashPreimage(values: Fr[], hash: Fr): void;
167
+ getHashPreimage(hash: Fr): Promise<Fr[]>;
152
168
  notifyCreatedNote(
153
169
  owner: AztecAddress,
154
170
  storageSlot: Fr,
@@ -169,11 +185,10 @@ export interface IPrivateExecutionOracle {
169
185
  sideEffectCounter: number,
170
186
  isStaticCall: boolean,
171
187
  ): Promise<{ endSideEffectCounter: Fr; returnsHash: Fr }>;
172
- validatePublicCalldata(calldataHash: Fr): Promise<void>;
188
+ assertValidPublicCalldata(calldataHash: Fr): Promise<void>;
173
189
  notifyRevertiblePhaseStart(minRevertibleSideEffectCounter: number): Promise<void>;
174
- inRevertiblePhase(sideEffectCounter: number): Promise<boolean>;
190
+ isExecutionInRevertiblePhase(sideEffectCounter: number): Promise<boolean>;
175
191
  getSenderForTags(): Promise<AztecAddress | undefined>;
176
192
  setSenderForTags(senderForTags: AztecAddress): Promise<void>;
177
193
  getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
178
- emitOffchainEffect(data: Fr[]): Promise<void>;
179
194
  }
@@ -0,0 +1,98 @@
1
+ import { toACVMField } from '@aztec/simulator/client';
2
+ import type { ACIRCallback, ACVMField } from '@aztec/simulator/client';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+
5
+ import type { Oracle } from './oracle.js';
6
+
7
+ /**
8
+ * Builds legacy oracle name callbacks for pinned protocol contracts whose artifacts are committed and cannot be
9
+ * changed.
10
+ * TODO(F-416): Remove these aliases on v5 when protocol contracts are redeployed.
11
+ */
12
+ export function buildLegacyOracleCallbacks(oracle: Oracle): ACIRCallback {
13
+ return {
14
+ // Simple prefix renames (privateXxx/utilityXxx → aztec_prv_/aztec_utl_)
15
+ utilityLog: (
16
+ level: ACVMField[],
17
+ message: ACVMField[],
18
+ _ignoredFieldsSize: ACVMField[],
19
+ fields: ACVMField[],
20
+ ): Promise<ACVMField[]> => oracle.aztec_utl_log(level, message, _ignoredFieldsSize, fields),
21
+ utilityAssertCompatibleOracleVersion: (version: ACVMField[]): Promise<ACVMField[]> =>
22
+ oracle.aztec_utl_assertCompatibleOracleVersion(version),
23
+ utilityLoadCapsule: (
24
+ contractAddress: ACVMField[],
25
+ slot: ACVMField[],
26
+ tSize: ACVMField[],
27
+ ): Promise<(ACVMField | ACVMField[])[]> =>
28
+ oracle.aztec_utl_getCapsule(contractAddress, slot, tSize, [toACVMField(AztecAddress.ZERO)]),
29
+ privateStoreInExecutionCache: (values: ACVMField[], hash: ACVMField[]): Promise<ACVMField[]> =>
30
+ oracle.aztec_prv_setHashPreimage(values, hash),
31
+ privateLoadFromExecutionCache: (returnsHash: ACVMField[]): Promise<ACVMField[][]> =>
32
+ oracle.aztec_prv_getHashPreimage(returnsHash),
33
+ privateCallPrivateFunction: (
34
+ contractAddress: ACVMField[],
35
+ functionSelector: ACVMField[],
36
+ argsHash: ACVMField[],
37
+ sideEffectCounter: ACVMField[],
38
+ isStaticCall: ACVMField[],
39
+ ): Promise<ACVMField[][]> =>
40
+ oracle.aztec_prv_callPrivateFunction(
41
+ contractAddress,
42
+ functionSelector,
43
+ argsHash,
44
+ sideEffectCounter,
45
+ isStaticCall,
46
+ ),
47
+ privateIsNullifierPending: (innerNullifier: ACVMField[], contractAddress: ACVMField[]): Promise<ACVMField[]> =>
48
+ oracle.aztec_prv_isNullifierPending(innerNullifier, contractAddress),
49
+ privateNotifyCreatedNullifier: (innerNullifier: ACVMField[]): Promise<ACVMField[]> =>
50
+ oracle.aztec_prv_notifyCreatedNullifier(innerNullifier),
51
+ privateNotifyCreatedContractClassLog: (
52
+ contractAddress: ACVMField[],
53
+ message: ACVMField[],
54
+ length: ACVMField[],
55
+ counter: ACVMField[],
56
+ ): Promise<ACVMField[]> =>
57
+ oracle.aztec_prv_notifyCreatedContractClassLog(contractAddress, message, length, counter),
58
+ utilityGetUtilityContext: (): Promise<(ACVMField | ACVMField[])[]> => oracle.aztec_utl_getUtilityContext(),
59
+ utilityStorageRead: (
60
+ blockHash: ACVMField[],
61
+ contractAddress: ACVMField[],
62
+ startStorageSlot: ACVMField[],
63
+ numberOfElements: ACVMField[],
64
+ ): Promise<ACVMField[][]> =>
65
+ oracle.aztec_utl_getFromPublicStorage(blockHash, contractAddress, startStorageSlot, numberOfElements),
66
+ utilityStoreCapsule: (
67
+ contractAddress: ACVMField[],
68
+ slot: ACVMField[],
69
+ capsule: ACVMField[],
70
+ ): Promise<ACVMField[]> =>
71
+ oracle.aztec_utl_setCapsule(contractAddress, slot, capsule, [toACVMField(AztecAddress.ZERO)]),
72
+ utilityCopyCapsule: (
73
+ contractAddress: ACVMField[],
74
+ srcSlot: ACVMField[],
75
+ dstSlot: ACVMField[],
76
+ numEntries: ACVMField[],
77
+ ): Promise<ACVMField[]> =>
78
+ oracle.aztec_utl_copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, [toACVMField(AztecAddress.ZERO)]),
79
+ utilityDeleteCapsule: (contractAddress: ACVMField[], slot: ACVMField[]): Promise<ACVMField[]> =>
80
+ oracle.aztec_utl_deleteCapsule(contractAddress, slot, [toACVMField(AztecAddress.ZERO)]),
81
+ utilityGetL1ToL2MembershipWitness: (
82
+ contractAddress: ACVMField[],
83
+ messageHash: ACVMField[],
84
+ secret: ACVMField[],
85
+ ): Promise<(ACVMField | ACVMField[])[]> =>
86
+ oracle.aztec_utl_getL1ToL2MembershipWitness(contractAddress, messageHash, secret),
87
+ // Renames (same signature, different oracle name)
88
+ privateNotifySetMinRevertibleSideEffectCounter: (counter: ACVMField[]): Promise<ACVMField[]> =>
89
+ oracle.aztec_prv_notifyRevertiblePhaseStart(counter),
90
+ // Signature changes: old 4-param oracles → new 1-param validatePublicCalldata
91
+ privateNotifyEnqueuedPublicFunctionCall: (
92
+ _contractAddress: ACVMField[],
93
+ calldataHash: ACVMField[],
94
+ _sideEffectCounter: ACVMField[],
95
+ _isStaticCall: ACVMField[],
96
+ ): Promise<ACVMField[]> => oracle.aztec_prv_assertValidPublicCalldata(calldataHash),
97
+ };
98
+ }