@aztec/pxe 4.1.2 → 4.2.0-aztecnr-rc.2

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 (109) hide show
  1. package/dest/config/package_info.js +1 -1
  2. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  3. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  4. package/dest/contract_function_simulator/contract_function_simulator.js +26 -4
  5. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  6. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  7. package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
  8. package/dest/contract_function_simulator/index.d.ts +2 -1
  9. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/index.js +1 -0
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
  12. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
  14. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  15. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  17. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
  18. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +5 -10
  20. package/dest/contract_function_simulator/oracle/interfaces.d.ts +45 -44
  21. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  23. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  24. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +41 -0
  25. package/dest/contract_function_simulator/oracle/oracle.d.ts +64 -44
  26. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/oracle.js +187 -97
  28. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  29. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -47
  30. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +32 -72
  32. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +54 -38
  33. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +173 -80
  35. package/dest/contract_logging.d.ts +9 -4
  36. package/dest/contract_logging.d.ts.map +1 -1
  37. package/dest/contract_logging.js +21 -6
  38. package/dest/contract_sync/contract_sync_service.d.ts +7 -4
  39. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  40. package/dest/contract_sync/contract_sync_service.js +59 -32
  41. package/dest/contract_sync/helpers.d.ts +2 -2
  42. package/dest/contract_sync/helpers.d.ts.map +1 -1
  43. package/dest/contract_sync/helpers.js +7 -2
  44. package/dest/events/event_service.d.ts +3 -2
  45. package/dest/events/event_service.d.ts.map +1 -1
  46. package/dest/events/event_service.js +16 -4
  47. package/dest/logs/log_service.d.ts +3 -4
  48. package/dest/logs/log_service.d.ts.map +1 -1
  49. package/dest/logs/log_service.js +16 -25
  50. package/dest/messages/message_context_service.d.ts +17 -0
  51. package/dest/messages/message_context_service.d.ts.map +1 -0
  52. package/dest/messages/message_context_service.js +36 -0
  53. package/dest/notes/note_service.d.ts +2 -2
  54. package/dest/notes/note_service.d.ts.map +1 -1
  55. package/dest/notes/note_service.js +14 -5
  56. package/dest/oracle_version.d.ts +2 -2
  57. package/dest/oracle_version.js +3 -3
  58. package/dest/pxe.d.ts +6 -3
  59. package/dest/pxe.d.ts.map +1 -1
  60. package/dest/pxe.js +39 -22
  61. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  62. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  63. package/dest/storage/capsule_store/capsule_store.js +33 -28
  64. package/dest/storage/metadata.d.ts +1 -1
  65. package/dest/storage/metadata.js +1 -1
  66. package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
  67. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  68. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  69. package/dest/tagging/index.d.ts +2 -2
  70. package/dest/tagging/index.d.ts.map +1 -1
  71. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
  72. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  73. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
  74. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  75. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  76. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  77. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
  78. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  79. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
  80. package/package.json +16 -16
  81. package/src/config/package_info.ts +1 -1
  82. package/src/contract_function_simulator/contract_function_simulator.ts +37 -5
  83. package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
  84. package/src/contract_function_simulator/index.ts +1 -0
  85. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
  86. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  87. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
  88. package/src/contract_function_simulator/oracle/interfaces.ts +59 -53
  89. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +107 -0
  90. package/src/contract_function_simulator/oracle/oracle.ts +223 -139
  91. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  92. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +34 -91
  93. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +279 -93
  94. package/src/contract_logging.ts +18 -5
  95. package/src/contract_sync/contract_sync_service.ts +89 -49
  96. package/src/contract_sync/helpers.ts +3 -2
  97. package/src/events/event_service.ts +17 -4
  98. package/src/logs/log_service.ts +40 -44
  99. package/src/messages/message_context_service.ts +44 -0
  100. package/src/notes/note_service.ts +16 -5
  101. package/src/oracle_version.ts +3 -3
  102. package/src/pxe.ts +57 -20
  103. package/src/storage/capsule_store/capsule_store.ts +34 -26
  104. package/src/storage/metadata.ts +1 -1
  105. package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
  106. package/src/tagging/index.ts +1 -1
  107. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
  108. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  109. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "4.1.2",
3
+ "version": "4.2.0-aztecnr-rc.2",
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": "4.1.2",
74
- "@aztec/bb.js": "4.1.2",
75
- "@aztec/builder": "4.1.2",
76
- "@aztec/constants": "4.1.2",
77
- "@aztec/ethereum": "4.1.2",
78
- "@aztec/foundation": "4.1.2",
79
- "@aztec/key-store": "4.1.2",
80
- "@aztec/kv-store": "4.1.2",
81
- "@aztec/noir-protocol-circuits-types": "4.1.2",
82
- "@aztec/noir-types": "4.1.2",
83
- "@aztec/protocol-contracts": "4.1.2",
84
- "@aztec/simulator": "4.1.2",
85
- "@aztec/stdlib": "4.1.2",
73
+ "@aztec/bb-prover": "4.2.0-aztecnr-rc.2",
74
+ "@aztec/bb.js": "4.2.0-aztecnr-rc.2",
75
+ "@aztec/builder": "4.2.0-aztecnr-rc.2",
76
+ "@aztec/constants": "4.2.0-aztecnr-rc.2",
77
+ "@aztec/ethereum": "4.2.0-aztecnr-rc.2",
78
+ "@aztec/foundation": "4.2.0-aztecnr-rc.2",
79
+ "@aztec/key-store": "4.2.0-aztecnr-rc.2",
80
+ "@aztec/kv-store": "4.2.0-aztecnr-rc.2",
81
+ "@aztec/noir-protocol-circuits-types": "4.2.0-aztecnr-rc.2",
82
+ "@aztec/noir-types": "4.2.0-aztecnr-rc.2",
83
+ "@aztec/protocol-contracts": "4.2.0-aztecnr-rc.2",
84
+ "@aztec/simulator": "4.2.0-aztecnr-rc.2",
85
+ "@aztec/stdlib": "4.2.0-aztecnr-rc.2",
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": "4.1.2",
95
- "@aztec/noir-test-contracts.js": "4.1.2",
94
+ "@aztec/merkle-tree": "4.2.0-aztecnr-rc.2",
95
+ "@aztec/noir-test-contracts.js": "4.2.0-aztecnr-rc.2",
96
96
  "@jest/globals": "^30.0.0",
97
97
  "@types/jest": "^30.0.0",
98
98
  "@types/lodash.omit": "^4.5.7",
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '4.1.0', name: '@aztec/pxe' };
2
+ return { version: '4.2.0', name: '@aztec/pxe' };
3
3
  }
@@ -17,6 +17,7 @@ import {
17
17
  MAX_NULLIFIERS_PER_TX,
18
18
  MAX_NULLIFIER_READ_REQUESTS_PER_TX,
19
19
  MAX_PRIVATE_LOGS_PER_TX,
20
+ MAX_TX_LIFETIME,
20
21
  PRIVATE_TX_L2_GAS_OVERHEAD,
21
22
  PUBLIC_TX_L2_GAS_OVERHEAD,
22
23
  TX_DA_GAS_OVERHEAD,
@@ -79,6 +80,7 @@ import {
79
80
  BlockHeader,
80
81
  CallContext,
81
82
  HashedValues,
83
+ type OffchainEffect,
82
84
  PrivateExecutionResult,
83
85
  TxConstantData,
84
86
  TxExecutionRequest,
@@ -89,6 +91,7 @@ import {
89
91
 
90
92
  import type { AccessScopes } from '../access_scopes.js';
91
93
  import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
94
+ import type { MessageContextService } from '../messages/message_context_service.js';
92
95
  import type { AddressStore } from '../storage/address_store/address_store.js';
93
96
  import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
94
97
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
@@ -138,6 +141,7 @@ export type ContractFunctionSimulatorArgs = {
138
141
  privateEventStore: PrivateEventStore;
139
142
  simulator: CircuitSimulator;
140
143
  contractSyncService: ContractSyncService;
144
+ messageContextService: MessageContextService;
141
145
  };
142
146
 
143
147
  /**
@@ -157,6 +161,7 @@ export class ContractFunctionSimulator {
157
161
  private readonly privateEventStore: PrivateEventStore;
158
162
  private readonly simulator: CircuitSimulator;
159
163
  private readonly contractSyncService: ContractSyncService;
164
+ private readonly messageContextService: MessageContextService;
160
165
 
161
166
  constructor(args: ContractFunctionSimulatorArgs) {
162
167
  this.contractStore = args.contractStore;
@@ -171,6 +176,7 @@ export class ContractFunctionSimulator {
171
176
  this.privateEventStore = args.privateEventStore;
172
177
  this.simulator = args.simulator;
173
178
  this.contractSyncService = args.contractSyncService;
179
+ this.messageContextService = args.messageContextService;
174
180
  this.log = createLogger('simulator');
175
181
  }
176
182
 
@@ -241,6 +247,7 @@ export class ContractFunctionSimulator {
241
247
  senderAddressBookStore: this.senderAddressBookStore,
242
248
  capsuleStore: this.capsuleStore,
243
249
  privateEventStore: this.privateEventStore,
250
+ messageContextService: this.messageContextService,
244
251
  contractSyncService: this.contractSyncService,
245
252
  jobId,
246
253
  totalPublicCalldataCount: 0,
@@ -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.privateLoadFromExecutionCache(r.calldataHash);
287
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
281
288
  return new HashedValues(calldata, r.calldataHash);
282
289
  }),
283
290
  );
@@ -314,7 +321,7 @@ export class ContractFunctionSimulator {
314
321
  anchorBlockHeader: BlockHeader,
315
322
  scopes: AccessScopes,
316
323
  jobId: string,
317
- ): Promise<Fr[]> {
324
+ ): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
318
325
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
319
326
 
320
327
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
@@ -335,6 +342,8 @@ export class ContractFunctionSimulator {
335
342
  senderAddressBookStore: this.senderAddressBookStore,
336
343
  capsuleStore: this.capsuleStore,
337
344
  privateEventStore: this.privateEventStore,
345
+ messageContextService: this.messageContextService,
346
+ contractSyncService: this.contractSyncService,
338
347
  jobId,
339
348
  scopes,
340
349
  });
@@ -362,7 +371,10 @@ export class ContractFunctionSimulator {
362
371
  });
363
372
 
364
373
  this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
365
- return witnessMapToFields(acirExecutionResult.returnWitness);
374
+ return {
375
+ result: witnessMapToFields(acirExecutionResult.returnWitness),
376
+ offchainEffects: oracle.getOffchainEffects(),
377
+ };
366
378
  } catch (err) {
367
379
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
368
380
  }
@@ -432,14 +444,34 @@ export async function generateSimulatedProvingResult(
432
444
 
433
445
  let publicTeardownCallRequest;
434
446
 
447
+ // We set expiration timestamp to anchor_block_timestamp + MAX_TX_LIFETIME (24h) just like kernels do
448
+ let expirationTimestamp =
449
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.globalVariables.timestamp +
450
+ BigInt(MAX_TX_LIFETIME);
451
+
452
+ let feePayer = AztecAddress.zero();
453
+
435
454
  const executions = [privateExecutionResult.entrypoint];
436
455
 
437
456
  while (executions.length !== 0) {
438
457
  const execution = executions.shift()!;
439
458
  executions.unshift(...execution!.nestedExecutionResults);
440
459
 
460
+ // Just like kernels we overwrite the default value if the call sets it.
461
+ const callExpirationTimestamp = execution.publicInputs.expirationTimestamp;
462
+ if (callExpirationTimestamp !== 0n && callExpirationTimestamp < expirationTimestamp) {
463
+ expirationTimestamp = callExpirationTimestamp;
464
+ }
465
+
441
466
  const { contractAddress } = execution.publicInputs.callContext;
442
467
 
468
+ if (execution.publicInputs.isFeePayer) {
469
+ if (!feePayer.isZero()) {
470
+ throw new Error('Multiple fee payers found in private execution result');
471
+ }
472
+ feePayer = contractAddress;
473
+ }
474
+
443
475
  scopedNoteHashes.push(
444
476
  ...execution.publicInputs.noteHashes
445
477
  .getActiveItems()
@@ -660,8 +692,8 @@ export async function generateSimulatedProvingResult(
660
692
  daGas: TX_DA_GAS_OVERHEAD,
661
693
  }),
662
694
  ),
663
- /*feePayer=*/ AztecAddress.zero(),
664
- /*expirationTimestamp=*/ 0n,
695
+ /*feePayer=*/ feePayer,
696
+ /*expirationTimestamp=*/ expirationTimestamp,
665
697
  hasPublicCalls ? inputsForPublic : undefined,
666
698
  !hasPublicCalls ? inputsForRollup : undefined,
667
699
  );
@@ -1,32 +1,37 @@
1
- import { ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
1
+ import { ExtendedDirectionalAppTaggingSecret, type TaggingIndexRange } from '@aztec/stdlib/logs';
2
2
 
3
3
  /**
4
- * A map that stores the tagging index for a given extended directional app tagging secret.
4
+ * A map that stores the tagging index range for a given extended directional app tagging secret.
5
5
  * Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
6
6
  * of sender -> recipient matters.
7
7
  */
8
8
  export class ExecutionTaggingIndexCache {
9
- private taggingIndexMap: Map<string, number> = new Map();
9
+ private taggingIndexMap: Map<string, { lowestIndex: number; highestIndex: number }> = new Map();
10
10
 
11
11
  public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
12
- return this.taggingIndexMap.get(secret.toString());
12
+ return this.taggingIndexMap.get(secret.toString())?.highestIndex;
13
13
  }
14
14
 
15
15
  public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
16
16
  const currentValue = this.taggingIndexMap.get(secret.toString());
17
- if (currentValue !== undefined && currentValue !== index - 1) {
18
- throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
17
+ if (currentValue !== undefined && currentValue.highestIndex !== index - 1) {
18
+ throw new Error(`Invalid tagging index update. Current value: ${currentValue.highestIndex}, new value: ${index}`);
19
+ }
20
+ if (currentValue !== undefined) {
21
+ currentValue.highestIndex = index;
22
+ } else {
23
+ this.taggingIndexMap.set(secret.toString(), { lowestIndex: index, highestIndex: index });
19
24
  }
20
- this.taggingIndexMap.set(secret.toString(), index);
21
25
  }
22
26
 
23
27
  /**
24
- * Returns the pre-tags that were used in this execution (and that need to be stored in the db).
28
+ * Returns the tagging index ranges that were used in this execution (and that need to be stored in the db).
25
29
  */
26
- public getUsedPreTags(): PreTag[] {
27
- return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
30
+ public getUsedTaggingIndexRanges(): TaggingIndexRange[] {
31
+ return Array.from(this.taggingIndexMap.entries()).map(([secret, { lowestIndex, highestIndex }]) => ({
28
32
  extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
29
- index,
33
+ lowestIndex,
34
+ highestIndex,
30
35
  }));
31
36
  }
32
37
  }
@@ -4,6 +4,7 @@ export { HashedValuesCache } from './hashed_values_cache.js';
4
4
  export { pickNotes } from './pick_notes.js';
5
5
  export type { NoteData, IMiscOracle, IUtilityExecutionOracle, IPrivateExecutionOracle } from './oracle/interfaces.js';
6
6
  export { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
7
+ export { MessageContextService } from '../messages/message_context_service.js';
7
8
  export { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
8
9
  export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
9
10
  export { Oracle } from './oracle/oracle.js';
@@ -4,9 +4,6 @@ import { EventSelector } from '@aztec/stdlib/abi';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import { TxHash } from '@aztec/stdlib/tx';
6
6
 
7
- // TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
8
- const MAX_EVENT_SERIALIZED_LEN = 10;
9
-
10
7
  /**
11
8
  * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
12
9
  * expects for values of this type to be stored in a `CapsuleArray`.
@@ -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
  }
@@ -53,9 +53,9 @@ export interface NoteData {
53
53
  export interface IMiscOracle {
54
54
  isMisc: true;
55
55
 
56
- utilityGetRandomField(): Fr;
57
- utilityAssertCompatibleOracleVersion(version: number): void;
58
- utilityLog(level: number, message: string, fields: Fr[]): Promise<void>;
56
+ getRandomField(): Fr;
57
+ assertCompatibleOracleVersion(version: number): void;
58
+ log(level: number, message: string, fields: Fr[]): Promise<void>;
59
59
  }
60
60
 
61
61
  /**
@@ -65,32 +65,32 @@ export interface IMiscOracle {
65
65
  export interface IUtilityExecutionOracle {
66
66
  isUtility: true;
67
67
 
68
- utilityGetUtilityContext(): UtilityContext;
69
- utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
70
- utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
71
- utilityGetNoteHashMembershipWitness(
68
+ getUtilityContext(): UtilityContext;
69
+ getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
70
+ getContractInstance(address: AztecAddress): Promise<ContractInstance>;
71
+ getNoteHashMembershipWitness(
72
72
  anchorBlockHash: BlockHash,
73
73
  noteHash: Fr,
74
74
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
75
- utilityGetBlockHashMembershipWitness(
75
+ getBlockHashMembershipWitness(
76
76
  anchorBlockHash: BlockHash,
77
77
  blockHash: BlockHash,
78
78
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
79
- utilityGetNullifierMembershipWitness(
79
+ getNullifierMembershipWitness(
80
80
  anchorBlockHash: BlockHash,
81
81
  nullifier: Fr,
82
82
  ): Promise<NullifierMembershipWitness | undefined>;
83
- utilityGetPublicDataWitness(anchorBlockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
84
- utilityGetLowNullifierMembershipWitness(
83
+ getPublicDataWitness(anchorBlockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
84
+ getLowNullifierMembershipWitness(
85
85
  anchorBlockHash: BlockHash,
86
86
  nullifier: Fr,
87
87
  ): Promise<NullifierMembershipWitness | undefined>;
88
- utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
89
- utilityTryGetPublicKeysAndPartialAddress(
88
+ getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
89
+ getPublicKeysAndPartialAddress(
90
90
  account: AztecAddress,
91
91
  ): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined>;
92
- utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
93
- utilityGetNotes(
92
+ getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
93
+ getNotes(
94
94
  owner: AztecAddress | undefined,
95
95
  storageSlot: Fr,
96
96
  numSelects: number,
@@ -107,35 +107,53 @@ export interface IUtilityExecutionOracle {
107
107
  offset: number,
108
108
  status: NoteStatus,
109
109
  ): Promise<NoteData[]>;
110
- utilityCheckNullifierExists(innerNullifier: Fr): Promise<boolean>;
111
- utilityGetL1ToL2MembershipWitness(
110
+ doesNullifierExist(innerNullifier: Fr): Promise<boolean>;
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
- utilityStorageRead(
116
+ getFromPublicStorage(
117
117
  anchorBlockHash: BlockHash,
118
118
  contractAddress: AztecAddress,
119
119
  startStorageSlot: Fr,
120
120
  numberOfElements: number,
121
121
  ): Promise<Fr[]>;
122
- utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
123
- utilityValidateAndStoreEnqueuedNotesAndEvents(
122
+ getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr, scope: AztecAddress): Promise<void>;
123
+ validateAndStoreEnqueuedNotesAndEvents(
124
124
  contractAddress: AztecAddress,
125
125
  noteValidationRequestsArrayBaseSlot: Fr,
126
126
  eventValidationRequestsArrayBaseSlot: Fr,
127
+ maxNotePackedLen: number,
128
+ maxEventSerializedLen: number,
129
+ scope: AztecAddress,
127
130
  ): Promise<void>;
128
- utilityBulkRetrieveLogs(
131
+ getLogsByTag(
129
132
  contractAddress: AztecAddress,
130
133
  logRetrievalRequestsArrayBaseSlot: Fr,
131
134
  logRetrievalResponsesArrayBaseSlot: Fr,
135
+ scope: AztecAddress,
132
136
  ): Promise<void>;
133
- utilityStoreCapsule(contractAddress: AztecAddress, key: Fr, capsule: Fr[]): Promise<void>;
134
- utilityLoadCapsule(contractAddress: AztecAddress, key: Fr): Promise<Fr[] | null>;
135
- utilityDeleteCapsule(contractAddress: AztecAddress, key: Fr): Promise<void>;
136
- utilityCopyCapsule(contractAddress: AztecAddress, srcKey: Fr, dstKey: Fr, numEntries: number): Promise<void>;
137
- utilityAes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
138
- utilityGetSharedSecret(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>;
139
157
  }
140
158
 
141
159
  /**
@@ -145,9 +163,9 @@ export interface IUtilityExecutionOracle {
145
163
  export interface IPrivateExecutionOracle {
146
164
  isPrivate: true;
147
165
 
148
- privateStoreInExecutionCache(values: Fr[], hash: Fr): void;
149
- privateLoadFromExecutionCache(hash: Fr): Promise<Fr[]>;
150
- privateNotifyCreatedNote(
166
+ setHashPreimage(values: Fr[], hash: Fr): void;
167
+ getHashPreimage(hash: Fr): Promise<Fr[]>;
168
+ notifyCreatedNote(
151
169
  owner: AztecAddress,
152
170
  storageSlot: Fr,
153
171
  randomness: Fr,
@@ -156,33 +174,21 @@ export interface IPrivateExecutionOracle {
156
174
  noteHash: Fr,
157
175
  counter: number,
158
176
  ): void;
159
- privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
160
- privateNotifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
161
- privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean>;
162
- privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
163
- privateCallPrivateFunction(
177
+ notifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
178
+ notifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
179
+ isNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean>;
180
+ notifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
181
+ callPrivateFunction(
164
182
  targetContractAddress: AztecAddress,
165
183
  functionSelector: FunctionSelector,
166
184
  argsHash: Fr,
167
185
  sideEffectCounter: number,
168
186
  isStaticCall: boolean,
169
187
  ): Promise<{ endSideEffectCounter: Fr; returnsHash: Fr }>;
170
- privateNotifyEnqueuedPublicFunctionCall(
171
- targetContractAddress: AztecAddress,
172
- calldataHash: Fr,
173
- sideEffectCounter: number,
174
- isStaticCall: boolean,
175
- ): Promise<void>;
176
- privateNotifySetPublicTeardownFunctionCall(
177
- targetContractAddress: AztecAddress,
178
- calldataHash: Fr,
179
- sideEffectCounter: number,
180
- isStaticCall: boolean,
181
- ): Promise<void>;
182
- privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
183
- privateIsSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean>;
184
- privateGetSenderForTags(): Promise<AztecAddress | undefined>;
185
- privateSetSenderForTags(senderForTags: AztecAddress): Promise<void>;
186
- privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
187
- utilityEmitOffchainEffect(data: Fr[]): Promise<void>;
188
+ assertValidPublicCalldata(calldataHash: Fr): Promise<void>;
189
+ notifyRevertiblePhaseStart(minRevertibleSideEffectCounter: number): Promise<void>;
190
+ isExecutionInRevertiblePhase(sideEffectCounter: number): Promise<boolean>;
191
+ getSenderForTags(): Promise<AztecAddress | undefined>;
192
+ setSenderForTags(senderForTags: AztecAddress): Promise<void>;
193
+ getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
188
194
  }
@@ -0,0 +1,107 @@
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
+ utilityEmitOffchainEffect: (data: ACVMField[]): Promise<ACVMField[]> => oracle.aztec_utl_emitOffchainEffect(data),
88
+ // Renames (same signature, different oracle name)
89
+ privateNotifySetMinRevertibleSideEffectCounter: (counter: ACVMField[]): Promise<ACVMField[]> =>
90
+ oracle.aztec_prv_notifyRevertiblePhaseStart(counter),
91
+ privateIsSideEffectCounterRevertible: (sideEffectCounter: ACVMField[]): Promise<ACVMField[]> =>
92
+ oracle.aztec_prv_isExecutionInRevertiblePhase(sideEffectCounter),
93
+ // Signature changes: old 4-param oracles → new 1-param validatePublicCalldata
94
+ privateNotifyEnqueuedPublicFunctionCall: (
95
+ _contractAddress: ACVMField[],
96
+ calldataHash: ACVMField[],
97
+ _sideEffectCounter: ACVMField[],
98
+ _isStaticCall: ACVMField[],
99
+ ): Promise<ACVMField[]> => oracle.aztec_prv_assertValidPublicCalldata(calldataHash),
100
+ privateNotifySetPublicTeardownFunctionCall: (
101
+ _contractAddress: ACVMField[],
102
+ calldataHash: ACVMField[],
103
+ _sideEffectCounter: ACVMField[],
104
+ _isStaticCall: ACVMField[],
105
+ ): Promise<ACVMField[]> => oracle.aztec_prv_assertValidPublicCalldata(calldataHash),
106
+ };
107
+ }