@aztec/pxe 0.0.1-commit.f504929 → 0.0.1-commit.f5d02921e

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 (123) 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/config/index.d.ts +2 -2
  5. package/dest/config/index.d.ts.map +1 -1
  6. package/dest/config/index.js +1 -1
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.js +29 -6
  10. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  11. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
  13. package/dest/contract_function_simulator/index.d.ts +2 -1
  14. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/index.js +1 -0
  16. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
  17. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
  19. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  20. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
  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 +5 -10
  25. package/dest/contract_function_simulator/oracle/interfaces.d.ts +26 -21
  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 +38 -0
  30. package/dest/contract_function_simulator/oracle/oracle.d.ts +39 -19
  31. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/oracle/oracle.js +91 -44
  33. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  34. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +11 -36
  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 +12 -44
  37. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +50 -28
  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 +167 -64
  40. package/dest/contract_logging.d.ts +9 -4
  41. package/dest/contract_logging.d.ts.map +1 -1
  42. package/dest/contract_logging.js +21 -6
  43. package/dest/contract_sync/contract_sync_service.d.ts +7 -4
  44. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  45. package/dest/contract_sync/contract_sync_service.js +59 -32
  46. package/dest/contract_sync/helpers.d.ts +2 -2
  47. package/dest/contract_sync/helpers.d.ts.map +1 -1
  48. package/dest/contract_sync/helpers.js +7 -2
  49. package/dest/events/event_service.d.ts +3 -2
  50. package/dest/events/event_service.d.ts.map +1 -1
  51. package/dest/events/event_service.js +16 -4
  52. package/dest/logs/log_service.d.ts +6 -7
  53. package/dest/logs/log_service.d.ts.map +1 -1
  54. package/dest/logs/log_service.js +24 -28
  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/notes/note_service.d.ts +2 -2
  59. package/dest/notes/note_service.d.ts.map +1 -1
  60. package/dest/notes/note_service.js +14 -5
  61. package/dest/oracle_version.d.ts +2 -2
  62. package/dest/oracle_version.js +2 -2
  63. package/dest/pxe.d.ts +6 -3
  64. package/dest/pxe.d.ts.map +1 -1
  65. package/dest/pxe.js +37 -21
  66. package/dest/storage/capsule_store/capsule_service.d.ts +22 -0
  67. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  68. package/dest/storage/capsule_store/capsule_service.js +50 -0
  69. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  70. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  71. package/dest/storage/capsule_store/capsule_store.js +33 -28
  72. package/dest/storage/capsule_store/index.d.ts +2 -1
  73. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  74. package/dest/storage/capsule_store/index.js +1 -0
  75. package/dest/storage/metadata.d.ts +1 -1
  76. package/dest/storage/metadata.js +1 -1
  77. package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
  78. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  79. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  80. package/dest/tagging/index.d.ts +2 -2
  81. package/dest/tagging/index.d.ts.map +1 -1
  82. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
  83. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  84. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
  85. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  86. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  87. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  88. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
  89. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  90. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
  91. package/package.json +16 -16
  92. package/src/block_synchronizer/block_synchronizer.ts +6 -0
  93. package/src/config/index.ts +1 -1
  94. package/src/contract_function_simulator/contract_function_simulator.ts +40 -7
  95. package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
  96. package/src/contract_function_simulator/index.ts +1 -0
  97. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
  98. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  99. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
  100. package/src/contract_function_simulator/oracle/interfaces.ts +38 -29
  101. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
  102. package/src/contract_function_simulator/oracle/oracle.ts +120 -64
  103. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  104. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -62
  105. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +290 -77
  106. package/src/contract_logging.ts +18 -5
  107. package/src/contract_sync/contract_sync_service.ts +89 -49
  108. package/src/contract_sync/helpers.ts +3 -2
  109. package/src/events/event_service.ts +17 -4
  110. package/src/logs/log_service.ts +51 -46
  111. package/src/messages/message_context_service.ts +44 -0
  112. package/src/notes/note_service.ts +16 -5
  113. package/src/oracle_version.ts +2 -2
  114. package/src/pxe.ts +55 -19
  115. package/src/storage/capsule_store/capsule_service.ts +91 -0
  116. package/src/storage/capsule_store/capsule_store.ts +34 -26
  117. package/src/storage/capsule_store/index.ts +1 -0
  118. package/src/storage/metadata.ts +1 -1
  119. package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
  120. package/src/tagging/index.ts +1 -1
  121. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
  122. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  123. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -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.f504929",
3
+ "version": "0.0.1-commit.f5d02921e",
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.f504929",
74
- "@aztec/bb.js": "0.0.1-commit.f504929",
75
- "@aztec/builder": "0.0.1-commit.f504929",
76
- "@aztec/constants": "0.0.1-commit.f504929",
77
- "@aztec/ethereum": "0.0.1-commit.f504929",
78
- "@aztec/foundation": "0.0.1-commit.f504929",
79
- "@aztec/key-store": "0.0.1-commit.f504929",
80
- "@aztec/kv-store": "0.0.1-commit.f504929",
81
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.f504929",
82
- "@aztec/noir-types": "0.0.1-commit.f504929",
83
- "@aztec/protocol-contracts": "0.0.1-commit.f504929",
84
- "@aztec/simulator": "0.0.1-commit.f504929",
85
- "@aztec/stdlib": "0.0.1-commit.f504929",
73
+ "@aztec/bb-prover": "0.0.1-commit.f5d02921e",
74
+ "@aztec/bb.js": "0.0.1-commit.f5d02921e",
75
+ "@aztec/builder": "0.0.1-commit.f5d02921e",
76
+ "@aztec/constants": "0.0.1-commit.f5d02921e",
77
+ "@aztec/ethereum": "0.0.1-commit.f5d02921e",
78
+ "@aztec/foundation": "0.0.1-commit.f5d02921e",
79
+ "@aztec/key-store": "0.0.1-commit.f5d02921e",
80
+ "@aztec/kv-store": "0.0.1-commit.f5d02921e",
81
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.f5d02921e",
82
+ "@aztec/noir-types": "0.0.1-commit.f5d02921e",
83
+ "@aztec/protocol-contracts": "0.0.1-commit.f5d02921e",
84
+ "@aztec/simulator": "0.0.1-commit.f5d02921e",
85
+ "@aztec/stdlib": "0.0.1-commit.f5d02921e",
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.f504929",
95
- "@aztec/noir-test-contracts.js": "0.0.1-commit.f504929",
94
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.f5d02921e",
95
+ "@aztec/world-state": "0.0.1-commit.f5d02921e",
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 {
@@ -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
 
@@ -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,7 +91,9 @@ 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';
96
+ import { CapsuleService } from '../storage/capsule_store/capsule_service.js';
93
97
  import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
94
98
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
95
99
  import type { NoteStore } from '../storage/note_store/note_store.js';
@@ -138,6 +142,7 @@ export type ContractFunctionSimulatorArgs = {
138
142
  privateEventStore: PrivateEventStore;
139
143
  simulator: CircuitSimulator;
140
144
  contractSyncService: ContractSyncService;
145
+ messageContextService: MessageContextService;
141
146
  };
142
147
 
143
148
  /**
@@ -157,6 +162,7 @@ export class ContractFunctionSimulator {
157
162
  private readonly privateEventStore: PrivateEventStore;
158
163
  private readonly simulator: CircuitSimulator;
159
164
  private readonly contractSyncService: ContractSyncService;
165
+ private readonly messageContextService: MessageContextService;
160
166
 
161
167
  constructor(args: ContractFunctionSimulatorArgs) {
162
168
  this.contractStore = args.contractStore;
@@ -171,6 +177,7 @@ export class ContractFunctionSimulator {
171
177
  this.privateEventStore = args.privateEventStore;
172
178
  this.simulator = args.simulator;
173
179
  this.contractSyncService = args.contractSyncService;
180
+ this.messageContextService = args.messageContextService;
174
181
  this.log = createLogger('simulator');
175
182
  }
176
183
 
@@ -239,8 +246,9 @@ export class ContractFunctionSimulator {
239
246
  senderTaggingStore: this.senderTaggingStore,
240
247
  recipientTaggingStore: this.recipientTaggingStore,
241
248
  senderAddressBookStore: this.senderAddressBookStore,
242
- capsuleStore: this.capsuleStore,
249
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
243
250
  privateEventStore: this.privateEventStore,
251
+ messageContextService: this.messageContextService,
244
252
  contractSyncService: this.contractSyncService,
245
253
  jobId,
246
254
  totalPublicCalldataCount: 0,
@@ -277,7 +285,7 @@ export class ContractFunctionSimulator {
277
285
  );
278
286
  const publicFunctionsCalldata = await Promise.all(
279
287
  publicCallRequests.map(async r => {
280
- const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
288
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
281
289
  return new HashedValues(calldata, r.calldataHash);
282
290
  }),
283
291
  );
@@ -314,7 +322,7 @@ export class ContractFunctionSimulator {
314
322
  anchorBlockHeader: BlockHeader,
315
323
  scopes: AccessScopes,
316
324
  jobId: string,
317
- ): Promise<Fr[]> {
325
+ ): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
318
326
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
319
327
 
320
328
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
@@ -333,8 +341,10 @@ export class ContractFunctionSimulator {
333
341
  aztecNode: this.aztecNode,
334
342
  recipientTaggingStore: this.recipientTaggingStore,
335
343
  senderAddressBookStore: this.senderAddressBookStore,
336
- capsuleStore: this.capsuleStore,
344
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
337
345
  privateEventStore: this.privateEventStore,
346
+ messageContextService: this.messageContextService,
347
+ contractSyncService: this.contractSyncService,
338
348
  jobId,
339
349
  scopes,
340
350
  });
@@ -362,7 +372,10 @@ export class ContractFunctionSimulator {
362
372
  });
363
373
 
364
374
  this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
365
- return witnessMapToFields(acirExecutionResult.returnWitness);
375
+ return {
376
+ result: witnessMapToFields(acirExecutionResult.returnWitness),
377
+ offchainEffects: oracle.getOffchainEffects(),
378
+ };
366
379
  } catch (err) {
367
380
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
368
381
  }
@@ -432,14 +445,34 @@ export async function generateSimulatedProvingResult(
432
445
 
433
446
  let publicTeardownCallRequest;
434
447
 
448
+ // We set expiration timestamp to anchor_block_timestamp + MAX_TX_LIFETIME (24h) just like kernels do
449
+ let expirationTimestamp =
450
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.globalVariables.timestamp +
451
+ BigInt(MAX_TX_LIFETIME);
452
+
453
+ let feePayer = AztecAddress.zero();
454
+
435
455
  const executions = [privateExecutionResult.entrypoint];
436
456
 
437
457
  while (executions.length !== 0) {
438
458
  const execution = executions.shift()!;
439
459
  executions.unshift(...execution!.nestedExecutionResults);
440
460
 
461
+ // Just like kernels we overwrite the default value if the call sets it.
462
+ const callExpirationTimestamp = execution.publicInputs.expirationTimestamp;
463
+ if (callExpirationTimestamp !== 0n && callExpirationTimestamp < expirationTimestamp) {
464
+ expirationTimestamp = callExpirationTimestamp;
465
+ }
466
+
441
467
  const { contractAddress } = execution.publicInputs.callContext;
442
468
 
469
+ if (execution.publicInputs.isFeePayer) {
470
+ if (!feePayer.isZero()) {
471
+ throw new Error('Multiple fee payers found in private execution result');
472
+ }
473
+ feePayer = contractAddress;
474
+ }
475
+
443
476
  scopedNoteHashes.push(
444
477
  ...execution.publicInputs.noteHashes
445
478
  .getActiveItems()
@@ -660,8 +693,8 @@ export async function generateSimulatedProvingResult(
660
693
  daGas: TX_DA_GAS_OVERHEAD,
661
694
  }),
662
695
  ),
663
- /*feePayer=*/ AztecAddress.zero(),
664
- /*expirationTimestamp=*/ 0n,
696
+ /*feePayer=*/ feePayer,
697
+ /*expirationTimestamp=*/ expirationTimestamp,
665
698
  hasPublicCalls ? inputsForPublic : undefined,
666
699
  !hasPublicCalls ? inputsForRollup : undefined,
667
700
  );
@@ -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`.
@@ -19,10 +16,9 @@ export class EventValidationRequest {
19
16
  public serializedEvent: Fr[],
20
17
  public eventCommitment: Fr,
21
18
  public txHash: TxHash,
22
- public recipient: AztecAddress,
23
19
  ) {}
24
20
 
25
- static fromFields(fields: Fr[] | FieldReader): EventValidationRequest {
21
+ static fromFields(fields: Fr[], maxEventSerializedLen: number): EventValidationRequest {
26
22
  const reader = FieldReader.asReader(fields);
27
23
 
28
24
  const contractAddress = AztecAddress.fromField(reader.readField());
@@ -30,13 +26,18 @@ export class EventValidationRequest {
30
26
 
31
27
  const randomness = reader.readField();
32
28
 
33
- const eventStorage = reader.readFieldArray(MAX_EVENT_SERIALIZED_LEN);
29
+ const eventStorage = reader.readFieldArray(maxEventSerializedLen);
34
30
  const eventLen = reader.readField().toNumber();
35
31
  const serializedEvent = eventStorage.slice(0, eventLen);
36
32
 
37
33
  const eventCommitment = reader.readField();
38
34
  const txHash = TxHash.fromField(reader.readField());
39
- const recipient = AztecAddress.fromField(reader.readField());
35
+
36
+ if (reader.remainingFields() !== 0) {
37
+ throw new Error(
38
+ `Error converting array of fields to EventValidationRequest: expected ${reader.cursor} fields but received ${fields.length} (maxEventSerializedLen=${maxEventSerializedLen}).`,
39
+ );
40
+ }
40
41
 
41
42
  return new EventValidationRequest(
42
43
  contractAddress,
@@ -45,7 +46,6 @@ export class EventValidationRequest {
45
46
  serializedEvent,
46
47
  eventCommitment,
47
48
  txHash,
48
- recipient,
49
49
  );
50
50
  }
51
51
  }
@@ -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
@@ -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`.
@@ -21,10 +18,9 @@ export class NoteValidationRequest {
21
18
  public noteHash: Fr,
22
19
  public nullifier: Fr,
23
20
  public txHash: TxHash,
24
- public recipient: AztecAddress,
25
21
  ) {}
26
22
 
27
- static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest {
23
+ static fromFields(fields: Fr[], maxNotePackedLen: number): NoteValidationRequest {
28
24
  const reader = FieldReader.asReader(fields);
29
25
 
30
26
  const contractAddress = AztecAddress.fromField(reader.readField());
@@ -33,18 +29,17 @@ export class NoteValidationRequest {
33
29
  const randomness = reader.readField();
34
30
  const noteNonce = reader.readField();
35
31
 
36
- const contentStorage = reader.readFieldArray(MAX_NOTE_PACKED_LEN);
32
+ const contentStorage = reader.readFieldArray(maxNotePackedLen);
37
33
  const contentLen = reader.readField().toNumber();
38
34
  const content = contentStorage.slice(0, contentLen);
39
35
 
40
36
  const noteHash = reader.readField();
41
37
  const nullifier = reader.readField();
42
38
  const txHash = TxHash.fromField(reader.readField());
43
- const recipient = AztecAddress.fromField(reader.readField());
44
39
 
45
40
  if (reader.remainingFields() !== 0) {
46
41
  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.`,
42
+ `Error converting array of fields to NoteValidationRequest: expected ${reader.cursor} fields but received ${fields.length} (maxNotePackedLen=${maxNotePackedLen}).`,
48
43
  );
49
44
  }
50
45
 
@@ -58,7 +53,6 @@ export class NoteValidationRequest {
58
53
  noteHash,
59
54
  nullifier,
60
55
  txHash,
61
- recipient,
62
56
  );
63
57
  }
64
58
  }
@@ -6,8 +6,9 @@ import { MembershipWitness } from '@aztec/foundation/trees';
6
6
  import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
7
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
8
8
  import { BlockHash } from '@aztec/stdlib/block';
9
- import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
9
+ import type { ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
10
10
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
11
+ import type { PublicKeys } from '@aztec/stdlib/keys';
11
12
  import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
12
13
  import type { Note, NoteStatus } from '@aztec/stdlib/note';
13
14
  import { type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
@@ -85,7 +86,9 @@ export interface IUtilityExecutionOracle {
85
86
  nullifier: Fr,
86
87
  ): Promise<NullifierMembershipWitness | undefined>;
87
88
  getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
88
- tryGetPublicKeysAndPartialAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
89
+ getPublicKeysAndPartialAddress(
90
+ account: AztecAddress,
91
+ ): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined>;
89
92
  getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
90
93
  getNotes(
91
94
  owner: AztecAddress | undefined,
@@ -104,35 +107,53 @@ export interface IUtilityExecutionOracle {
104
107
  offset: number,
105
108
  status: NoteStatus,
106
109
  ): Promise<NoteData[]>;
107
- checkNullifierExists(innerNullifier: Fr): Promise<boolean>;
110
+ doesNullifierExist(innerNullifier: Fr): Promise<boolean>;
108
111
  getL1ToL2MembershipWitness(
109
112
  contractAddress: AztecAddress,
110
113
  messageHash: Fr,
111
114
  secret: Fr,
112
115
  ): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
113
- storageRead(
116
+ getFromPublicStorage(
114
117
  anchorBlockHash: BlockHash,
115
118
  contractAddress: AztecAddress,
116
119
  startStorageSlot: Fr,
117
120
  numberOfElements: number,
118
121
  ): Promise<Fr[]>;
119
- fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
122
+ getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr, scope: AztecAddress): Promise<void>;
120
123
  validateAndStoreEnqueuedNotesAndEvents(
121
124
  contractAddress: AztecAddress,
122
125
  noteValidationRequestsArrayBaseSlot: Fr,
123
126
  eventValidationRequestsArrayBaseSlot: Fr,
127
+ maxNotePackedLen: number,
128
+ maxEventSerializedLen: number,
129
+ scope: AztecAddress,
124
130
  ): Promise<void>;
125
- bulkRetrieveLogs(
131
+ getLogsByTag(
126
132
  contractAddress: AztecAddress,
127
133
  logRetrievalRequestsArrayBaseSlot: Fr,
128
134
  logRetrievalResponsesArrayBaseSlot: Fr,
135
+ scope: AztecAddress,
129
136
  ): Promise<void>;
130
- storeCapsule(contractAddress: AztecAddress, key: Fr, capsule: Fr[]): Promise<void>;
131
- loadCapsule(contractAddress: AztecAddress, key: Fr): Promise<Fr[] | null>;
132
- deleteCapsule(contractAddress: AztecAddress, key: Fr): Promise<void>;
133
- copyCapsule(contractAddress: AztecAddress, srcKey: Fr, dstKey: Fr, numEntries: number): Promise<void>;
134
- aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
135
- 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>;
136
157
  }
137
158
 
138
159
  /**
@@ -142,8 +163,8 @@ export interface IUtilityExecutionOracle {
142
163
  export interface IPrivateExecutionOracle {
143
164
  isPrivate: true;
144
165
 
145
- storeInExecutionCache(values: Fr[], hash: Fr): void;
146
- loadFromExecutionCache(hash: Fr): Promise<Fr[]>;
166
+ setHashPreimage(values: Fr[], hash: Fr): void;
167
+ getHashPreimage(hash: Fr): Promise<Fr[]>;
147
168
  notifyCreatedNote(
148
169
  owner: AztecAddress,
149
170
  storageSlot: Fr,
@@ -164,22 +185,10 @@ export interface IPrivateExecutionOracle {
164
185
  sideEffectCounter: number,
165
186
  isStaticCall: boolean,
166
187
  ): Promise<{ endSideEffectCounter: Fr; returnsHash: Fr }>;
167
- notifyEnqueuedPublicFunctionCall(
168
- targetContractAddress: AztecAddress,
169
- calldataHash: Fr,
170
- sideEffectCounter: number,
171
- isStaticCall: boolean,
172
- ): Promise<void>;
173
- notifySetPublicTeardownFunctionCall(
174
- targetContractAddress: AztecAddress,
175
- calldataHash: Fr,
176
- sideEffectCounter: number,
177
- isStaticCall: boolean,
178
- ): Promise<void>;
179
- notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
180
- isSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean>;
188
+ assertValidPublicCalldata(calldataHash: Fr): Promise<void>;
189
+ notifyRevertiblePhaseStart(minRevertibleSideEffectCounter: number): Promise<void>;
190
+ isExecutionInRevertiblePhase(sideEffectCounter: number): Promise<boolean>;
181
191
  getSenderForTags(): Promise<AztecAddress | undefined>;
182
192
  setSenderForTags(senderForTags: AztecAddress): Promise<void>;
183
193
  getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
184
- emitOffchainEffect(data: Fr[]): Promise<void>;
185
194
  }