@aztec/txe 5.0.0-rc.1 → 5.0.0

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 (133) hide show
  1. package/dest/AuthRegistry-FSRZIMX6.js +3 -0
  2. package/dest/AuthRegistry-FSRZIMX6.js.map +7 -0
  3. package/dest/ContractClassRegistry-N6NA3SFA.js +3 -0
  4. package/dest/ContractClassRegistry-N6NA3SFA.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-NADDSLGL.js +3 -0
  6. package/dest/ContractInstanceRegistry-NADDSLGL.js.map +7 -0
  7. package/dest/FeeJuice-QBH5JWJV.js +3 -0
  8. package/dest/FeeJuice-QBH5JWJV.js.map +7 -0
  9. package/dest/HandshakeRegistry-KKUEU7XW.js +3 -0
  10. package/dest/HandshakeRegistry-KKUEU7XW.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-TGICA67H.js +3 -0
  12. package/dest/MultiCallEntrypoint-TGICA67H.js.map +7 -0
  13. package/dest/SchnorrAccount-J5T6OKR3.js +3 -0
  14. package/dest/SchnorrAccount-J5T6OKR3.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js.map +7 -0
  17. package/dest/bin/index.js +1 -1
  18. package/dest/bin/oracle_test_server.js +2 -2
  19. package/dest/{chunk-UPW55EJX.js → chunk-PDOEF22H.js} +2 -2
  20. package/dest/{chunk-UPW55EJX.js.map → chunk-PDOEF22H.js.map} +3 -3
  21. package/dest/chunk-YP4ODNMQ.js +268 -0
  22. package/dest/chunk-YP4ODNMQ.js.map +7 -0
  23. package/dest/constants.d.ts +1 -1
  24. package/dest/constants.d.ts.map +1 -1
  25. package/dest/constants.js +1 -1
  26. package/dest/index.d.ts +1 -1
  27. package/dest/index.d.ts.map +1 -1
  28. package/dest/index.js +5 -3
  29. package/dest/metafile.json +9768 -8714
  30. package/dest/oracle/interfaces.d.ts +19 -10
  31. package/dest/oracle/interfaces.d.ts.map +1 -1
  32. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  33. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  34. package/dest/oracle/tagging_secret_strategy.js +12 -0
  35. package/dest/oracle/test-resolver/default_fixtures.d.ts +9 -0
  36. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  37. package/dest/oracle/test-resolver/default_fixtures.js +207 -0
  38. package/dest/oracle/test-resolver/index.d.ts +1 -1
  39. package/dest/oracle/test-resolver/index.d.ts.map +1 -1
  40. package/dest/oracle/test-resolver/index.js +1 -2
  41. package/dest/oracle/test-resolver/resolver.d.ts +22 -8
  42. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
  43. package/dest/oracle/test-resolver/resolver.js +100 -33
  44. package/dest/oracle/txe_oracle_public_context.d.ts +9 -9
  45. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  46. package/dest/oracle/txe_oracle_public_context.js +15 -9
  47. package/dest/oracle/txe_oracle_registry.d.ts +159 -3
  48. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
  49. package/dest/oracle/txe_oracle_registry.js +221 -34
  50. package/dest/oracle/txe_oracle_top_level_context.d.ts +22 -8
  51. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  52. package/dest/oracle/txe_oracle_top_level_context.js +107 -49
  53. package/dest/oracle/txe_oracle_version.d.ts +3 -3
  54. package/dest/oracle/txe_oracle_version.js +3 -3
  55. package/dest/rpc_translator.d.ts +14 -4
  56. package/dest/rpc_translator.d.ts.map +1 -1
  57. package/dest/rpc_translator.js +91 -11
  58. package/dest/server.bundle.js +1 -1
  59. package/dest/state_machine/archiver.d.ts +1 -1
  60. package/dest/state_machine/archiver.d.ts.map +1 -1
  61. package/dest/state_machine/archiver.js +1 -2
  62. package/dest/state_machine/dummy_p2p_client.d.ts +4 -2
  63. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  64. package/dest/state_machine/dummy_p2p_client.js +6 -0
  65. package/dest/state_machine/global_variable_builder.d.ts +3 -4
  66. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  67. package/dest/state_machine/global_variable_builder.js +0 -3
  68. package/dest/state_machine/index.d.ts +8 -6
  69. package/dest/state_machine/index.d.ts.map +1 -1
  70. package/dest/state_machine/index.js +40 -12
  71. package/dest/state_machine/synchronizer.d.ts +5 -2
  72. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  73. package/dest/state_machine/synchronizer.js +6 -2
  74. package/dest/txe_session.d.ts +8 -6
  75. package/dest/txe_session.d.ts.map +1 -1
  76. package/dest/txe_session.js +72 -32
  77. package/dest/utils/block_creation.d.ts +2 -2
  78. package/dest/utils/block_creation.d.ts.map +1 -1
  79. package/dest/utils/block_creation.js +2 -2
  80. package/dest/utils/encoding.d.ts +4 -3
  81. package/dest/utils/encoding.d.ts.map +1 -1
  82. package/dest/utils/tx_effect_creation.d.ts +1 -1
  83. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  84. package/dest/utils/tx_effect_creation.js +0 -1
  85. package/dest/utils/txe_public_contract_data_source.d.ts +1 -1
  86. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
  87. package/dest/utils/txe_public_contract_data_source.js +7 -4
  88. package/dest/worker.bundle.js +1 -1
  89. package/package.json +17 -17
  90. package/src/bin/oracle_test_server.ts +2 -2
  91. package/src/constants.ts +1 -1
  92. package/src/index.ts +5 -3
  93. package/src/oracle/interfaces.ts +21 -8
  94. package/src/oracle/tagging_secret_strategy.ts +25 -0
  95. package/src/oracle/test-resolver/default_fixtures.ts +282 -0
  96. package/src/oracle/test-resolver/index.ts +1 -2
  97. package/src/oracle/test-resolver/resolver.ts +122 -42
  98. package/src/oracle/txe_oracle_public_context.ts +16 -14
  99. package/src/oracle/txe_oracle_registry.ts +156 -18
  100. package/src/oracle/txe_oracle_top_level_context.ts +147 -50
  101. package/src/oracle/txe_oracle_version.ts +3 -3
  102. package/src/rpc_translator.ts +119 -11
  103. package/src/state_machine/archiver.ts +0 -1
  104. package/src/state_machine/dummy_p2p_client.ts +9 -0
  105. package/src/state_machine/global_variable_builder.ts +2 -16
  106. package/src/state_machine/index.ts +49 -30
  107. package/src/state_machine/synchronizer.ts +8 -2
  108. package/src/txe_session.ts +104 -27
  109. package/src/utils/block_creation.ts +2 -1
  110. package/src/utils/tx_effect_creation.ts +0 -2
  111. package/src/utils/txe_public_contract_data_source.ts +6 -4
  112. package/dest/AuthRegistry-CPGFQR26.js +0 -3
  113. package/dest/AuthRegistry-CPGFQR26.js.map +0 -7
  114. package/dest/ContractClassRegistry-EHVIHGEK.js +0 -3
  115. package/dest/ContractClassRegistry-EHVIHGEK.js.map +0 -7
  116. package/dest/ContractInstanceRegistry-DWZDXHRG.js +0 -3
  117. package/dest/ContractInstanceRegistry-DWZDXHRG.js.map +0 -7
  118. package/dest/FeeJuice-MI32ZO7B.js +0 -3
  119. package/dest/FeeJuice-MI32ZO7B.js.map +0 -7
  120. package/dest/HandshakeRegistry-3KSP3ITH.js +0 -3
  121. package/dest/HandshakeRegistry-3KSP3ITH.js.map +0 -7
  122. package/dest/MultiCallEntrypoint-IU7HYFYE.js +0 -3
  123. package/dest/MultiCallEntrypoint-IU7HYFYE.js.map +0 -7
  124. package/dest/SchnorrAccount-6TUE7JX4.js +0 -3
  125. package/dest/SchnorrAccount-6TUE7JX4.js.map +0 -7
  126. package/dest/SchnorrInitializerlessAccount-S3DU2DJK.js +0 -3
  127. package/dest/SchnorrInitializerlessAccount-S3DU2DJK.js.map +0 -7
  128. package/dest/chunk-5U25VAFR.js +0 -265
  129. package/dest/chunk-5U25VAFR.js.map +0 -7
  130. package/dest/oracle/test-resolver/fixtures.d.ts +0 -43
  131. package/dest/oracle/test-resolver/fixtures.d.ts.map +0 -1
  132. package/dest/oracle/test-resolver/fixtures.js +0 -39
  133. package/src/oracle/test-resolver/fixtures.ts +0 -84
@@ -6,29 +6,36 @@ import {
6
6
  import { BlockNumber } from '@aztec/foundation/branded-types';
7
7
  import { Schnorr } from '@aztec/foundation/crypto/schnorr';
8
8
  import { Fr } from '@aztec/foundation/curves/bn254';
9
+ import type { EthAddress } from '@aztec/foundation/eth-address';
9
10
  import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
10
11
  import { TestDateProvider } from '@aztec/foundation/timer';
11
12
  import type { KeyStore } from '@aztec/key-store';
12
13
  import {
13
14
  AddressStore,
15
+ AnchoredContractData,
14
16
  CapsuleService,
15
17
  CapsuleStore,
16
18
  type ContractStore,
17
19
  type ExecutionHooks,
20
+ FactService,
21
+ FactStore,
18
22
  NoteStore,
19
23
  ORACLE_VERSION_MAJOR,
20
24
  PrivateEventStore,
21
25
  RecipientTaggingStore,
22
- SenderAddressBookStore,
23
26
  SenderTaggingStore,
27
+ TaggingSecretSourcesStore,
28
+ type TaggingSecretStrategy,
24
29
  composeHooks,
25
30
  enrichPublicSimulationError,
26
31
  } from '@aztec/pxe/server';
27
32
  import {
33
+ CONTRACT_INSTANCE,
28
34
  ExecutionNoteCache,
29
35
  ExecutionTaggingIndexCache,
30
36
  HashedValuesCache,
31
37
  type IMiscOracle,
38
+ type Option,
32
39
  PrivateExecutionOracle,
33
40
  TransientArrayService,
34
41
  UtilityExecutionOracle,
@@ -64,7 +71,10 @@ import {
64
71
  PrivateToPublicAccumulatedData,
65
72
  PublicCallRequest,
66
73
  } from '@aztec/stdlib/kernel';
67
- import { hashPublicKey } from '@aztec/stdlib/keys';
74
+ import { deriveKeys, hashPublicKey } from '@aztec/stdlib/keys';
75
+ import type { PrivateLog } from '@aztec/stdlib/logs';
76
+ import { AppTaggingSecretKind } from '@aztec/stdlib/logs';
77
+ import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/stdlib/messaging';
68
78
  import { ChonkProof } from '@aztec/stdlib/proofs';
69
79
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
70
80
  import { MerkleTreeId } from '@aztec/stdlib/trees';
@@ -90,6 +100,7 @@ import type { TXEAccountStore } from '../utils/txe_account_store.js';
90
100
  import type { TXEArtifactResolver } from '../utils/txe_artifact_resolver.js';
91
101
  import { TXEPublicContractDataSource } from '../utils/txe_public_contract_data_source.js';
92
102
  import type { ITxeExecutionOracle } from './interfaces.js';
103
+ import { type TXETaggingSecretStrategies, makeResolveTaggingSecretStrategyHook } from './tagging_secret_strategy.js';
93
104
 
94
105
  export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
95
106
  isMisc = true as const;
@@ -106,13 +117,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
106
117
  private accountStore: TXEAccountStore,
107
118
  private senderTaggingStore: SenderTaggingStore,
108
119
  private recipientTaggingStore: RecipientTaggingStore,
109
- private senderAddressBookStore: SenderAddressBookStore,
120
+ private taggingSecretSourcesStore: TaggingSecretSourcesStore,
110
121
  private capsuleStore: CapsuleStore,
122
+ private factStore: FactStore,
111
123
  private privateEventStore: PrivateEventStore,
112
124
  private nextBlockTimestamp: bigint,
113
125
  private version: Fr,
114
126
  private chainId: Fr,
115
127
  private authwits: Map<string, AuthWitness>,
128
+ private taggingSecretStrategies: TXETaggingSecretStrategies,
116
129
  private readonly artifactResolver: TXEArtifactResolver,
117
130
  private readonly rootPath: string,
118
131
  private readonly packageName: string,
@@ -174,7 +187,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
174
187
  return (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables.timestamp;
175
188
  }
176
189
 
177
- async getLastTxEffects(): ReturnType<ITxeExecutionOracle['getLastTxEffects']> {
190
+ async getLastTxEffects(): Promise<{ txHash: TxHash; noteHashes: Fr[]; nullifiers: Fr[]; privateLogs: PrivateLog[] }> {
178
191
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
179
192
  const block = await this.stateMachine.archiver.getBlock({ number: latestBlockNumber });
180
193
 
@@ -209,7 +222,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
209
222
  contractAddress,
210
223
  null,
211
224
  async (call, execScopes) => {
212
- await this.executeUtilityCall(call, execScopes, jobId);
225
+ await this.executeUtilityCall(call, { scopes: execScopes, jobId });
213
226
  },
214
227
  blockHeader,
215
228
  jobId,
@@ -251,7 +264,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
251
264
  }
252
265
 
253
266
  private deploymentNullifier(address: AztecAddress): Promise<Fr> {
254
- return siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
267
+ return siloNullifier(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
255
268
  }
256
269
 
257
270
  async deploy(
@@ -286,14 +299,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
286
299
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
287
300
  }
288
301
 
289
- return [
290
- instance.salt,
291
- instance.deployer.toField(),
292
- instance.currentContractClassId,
293
- instance.initializationHash,
294
- instance.immutablesHash,
295
- ...instance.publicKeys.toFields(),
296
- ];
302
+ return CONTRACT_INSTANCE.serialization!.fn(instance).flat();
297
303
  }
298
304
 
299
305
  /**
@@ -321,7 +327,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
321
327
  await this.contractStore.addContractInstance(instance);
322
328
  await this.contractStore.addContractArtifact(artifact);
323
329
 
324
- const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
330
+ const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
325
331
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
326
332
  await this.addressStore.addCompleteAddress(completeAddress);
327
333
  this.logger.debug(`Created account ${completeAddress.address}`);
@@ -331,7 +337,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
331
337
 
332
338
  async createAccount(secret: Fr) {
333
339
  // This is a foot gun !
334
- const completeAddress = await this.keyStore.addAccount(secret, secret);
340
+ const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), secret);
335
341
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
336
342
  await this.addressStore.addCompleteAddress(completeAddress);
337
343
  this.logger.debug(`Created account ${completeAddress.address}`);
@@ -352,7 +358,42 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
352
358
  this.authwits.set(authWitness.requestHash.toString(), authWitness);
353
359
  }
354
360
 
355
- async mineBlock(options: { nullifiers?: Fr[] } = {}) {
361
+ setTaggingSecretStrategies(
362
+ unconstrainedStrategy: Option<TaggingSecretStrategy>,
363
+ constrainedStrategy: Option<TaggingSecretStrategy>,
364
+ ): void {
365
+ const apply = (mode: AppTaggingSecretKind, strategy: Option<TaggingSecretStrategy>) => {
366
+ if (strategy.isSome()) {
367
+ this.taggingSecretStrategies.set(mode, strategy.value);
368
+ } else {
369
+ this.taggingSecretStrategies.delete(mode);
370
+ }
371
+ };
372
+ apply(AppTaggingSecretKind.UNCONSTRAINED, unconstrainedStrategy);
373
+ apply(AppTaggingSecretKind.CONSTRAINED, constrainedStrategy);
374
+ }
375
+
376
+ async sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr> {
377
+ // Messages are appended to the tree, so the next free slot is simply the current tree size.
378
+ const { size } = await this.stateMachine.synchronizer
379
+ .getCommitted()
380
+ .getTreeInfo(MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
381
+ const leafIndex = new Fr(size);
382
+
383
+ const message = new L1ToL2Message(
384
+ new L1Actor(sender, this.chainId.toNumber()),
385
+ new L2Actor(recipient, this.version.toNumber()),
386
+ content,
387
+ secretHash,
388
+ leafIndex,
389
+ );
390
+
391
+ await this.mineBlock({ l1ToL2Messages: [message.hash()] });
392
+
393
+ return leafIndex;
394
+ }
395
+
396
+ async mineBlock(options: { nullifiers?: Fr[]; l1ToL2Messages?: Fr[] } = {}) {
356
397
  const blockNumber = await this.getNextBlockNumber();
357
398
 
358
399
  const txEffect = TxEffect.empty();
@@ -360,7 +401,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
360
401
  txEffect.txHash = new TxHash(new Fr(blockNumber));
361
402
 
362
403
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
363
- await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
404
+ await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees, options.l1ToL2Messages ?? []);
364
405
 
365
406
  const globals = makeGlobalVariables(undefined, {
366
407
  blockNumber,
@@ -374,7 +415,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
374
415
 
375
416
  this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
376
417
 
377
- await this.stateMachine.handleL2Block(block);
418
+ await this.stateMachine.handleL2Block(block, options.l1ToL2Messages ?? []);
378
419
  }
379
420
 
380
421
  async privateCallNewFlow(
@@ -389,11 +430,18 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
389
430
  authorizedUtilityCallTargets: AztecAddress[],
390
431
  gasSettings: GasSettings,
391
432
  ) {
433
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
434
+ const anchoredContractData = new AnchoredContractData(
435
+ this.contractStore,
436
+ this.stateMachine.contractClassService,
437
+ blockHeader,
438
+ );
439
+
392
440
  this.logger.verbose(
393
- `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
441
+ `Executing external function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
394
442
  );
395
443
 
396
- const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
444
+ const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
397
445
  if (!artifact) {
398
446
  const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
399
447
  ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
@@ -405,10 +453,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
405
453
 
406
454
  // Sync notes before executing private function to discover notes from previous transactions
407
455
  const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
408
- await this.executeUtilityCall(call, execScopes, jobId);
456
+ await this.executeUtilityCall(call, { scopes: execScopes, jobId });
409
457
  };
410
458
 
411
- const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
412
459
  await this.stateMachine.contractSyncService.ensureContractSynced(
413
460
  targetContractAddress,
414
461
  functionSelector,
@@ -440,6 +487,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
440
487
  const privateExecutionOracle = new PrivateExecutionOracle({
441
488
  argsHash,
442
489
  txContext,
490
+ // The TXE does not run the init kernel's salt binding, so no tx-request salt is in scope.
491
+ txRequestSalt: Fr.ZERO,
443
492
  callContext,
444
493
  anchorBlockHeader: blockHeader,
445
494
  utilityExecutor,
@@ -448,15 +497,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
448
497
  executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
449
498
  noteCache,
450
499
  taggingIndexCache,
451
- contractStore: this.contractStore,
500
+ anchoredContractData,
452
501
  noteStore: this.noteStore,
453
502
  keyStore: this.keyStore,
454
503
  addressStore: this.addressStore,
455
504
  aztecNode: this.stateMachine.node,
456
505
  senderTaggingStore: this.senderTaggingStore,
457
506
  recipientTaggingStore: this.recipientTaggingStore,
458
- senderAddressBookStore: this.senderAddressBookStore,
507
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
459
508
  capsuleService: new CapsuleService(this.capsuleStore, scopes),
509
+ factService: new FactService(this.factStore, scopes),
460
510
  privateEventStore: this.privateEventStore,
461
511
  contractSyncService: this.stateMachine.contractSyncService,
462
512
  jobId,
@@ -467,13 +517,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
467
517
  // contract would perform, including setting senderForTags.
468
518
  senderForTags: from,
469
519
  simulator,
470
- messageContextService: this.stateMachine.messageContextService,
520
+ txResolver: this.stateMachine.txResolver,
471
521
  l2TipsStore: this.stateMachine.l2TipsProvider,
472
522
  hooks: composeHooks({
473
523
  authorizeUtilityCall: this.buildAuthorizeUtilityCallHook(
474
524
  isStaticCall ? 'private view' : 'private',
475
525
  authorizedUtilityCallTargets,
476
526
  ),
527
+ resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
477
528
  }),
478
529
  transientArrayService,
479
530
  });
@@ -503,7 +554,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
503
554
  }),
504
555
  );
505
556
 
506
- noteCache.finish();
507
557
  const nonceGenerator = noteCache.getNonceGenerator();
508
558
  result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
509
559
  } catch (err) {
@@ -515,7 +565,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
515
565
  // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
516
566
  const { publicInputs } = await generateSimulatedProvingResult(
517
567
  result,
518
- (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
568
+ (addr, sel) => anchoredContractData.getDebugFunctionName(addr, sel),
519
569
  this.stateMachine.node,
520
570
  minRevertibleSideEffectCounter,
521
571
  );
@@ -574,7 +624,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
574
624
  } else if (!processedTx.revertCode.isOK()) {
575
625
  if (processedTx.revertReason) {
576
626
  try {
577
- await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
627
+ await enrichPublicSimulationError(
628
+ processedTx.revertReason,
629
+ this.contractStore,
630
+ this.stateMachine.contractClassService,
631
+ await this.stateMachine.anchorBlockStore.getBlockHeader(),
632
+ this.logger,
633
+ );
578
634
  // eslint-disable-next-line no-empty
579
635
  } catch {}
580
636
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -625,16 +681,21 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
625
681
  isStaticCall: boolean,
626
682
  gasSettings: GasSettings,
627
683
  ) {
684
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
685
+ const anchoredContractData = new AnchoredContractData(
686
+ this.contractStore,
687
+ this.stateMachine.contractClassService,
688
+ anchorBlockHeader,
689
+ );
690
+
628
691
  this.logger.verbose(
629
- `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
692
+ `Executing public function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
630
693
  );
631
694
 
632
695
  const blockNumber = await this.getNextBlockNumber();
633
696
 
634
697
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
635
698
 
636
- const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
637
-
638
699
  const calldataHash = await computeCalldataHash(calldata);
639
700
  const calldataHashedValues = new HashedValues(calldata, calldataHash);
640
701
 
@@ -727,7 +788,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
727
788
  } else if (!processedTx.revertCode.isOK()) {
728
789
  if (processedTx.revertReason) {
729
790
  try {
730
- await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
791
+ await enrichPublicSimulationError(
792
+ processedTx.revertReason,
793
+ this.contractStore,
794
+ this.stateMachine.contractClassService,
795
+ anchorBlockHeader,
796
+ this.logger,
797
+ );
731
798
  // eslint-disable-next-line no-empty
732
799
  } catch {}
733
800
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -769,24 +836,31 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
769
836
  }
770
837
 
771
838
  async executeUtilityFunction(
839
+ from: AztecAddress | undefined,
772
840
  targetContractAddress: AztecAddress,
773
841
  functionSelector: FunctionSelector,
774
842
  args: Fr[],
775
843
  jobId: string,
776
844
  authorizedUtilityCallTargets: AztecAddress[],
777
845
  ) {
778
- const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
846
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
847
+ const anchoredContractData = new AnchoredContractData(
848
+ this.contractStore,
849
+ this.stateMachine.contractClassService,
850
+ blockHeader,
851
+ );
852
+
853
+ const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
779
854
  if (!artifact) {
780
855
  throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
781
856
  }
782
857
 
783
858
  // Sync notes before executing utility function to discover notes from previous transactions
784
- const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
785
859
  await this.stateMachine.contractSyncService.ensureContractSynced(
786
860
  targetContractAddress,
787
861
  functionSelector,
788
862
  async (call, execScopes) => {
789
- await this.executeUtilityCall(call, execScopes, jobId);
863
+ await this.executeUtilityCall(call, { scopes: execScopes, jobId });
790
864
  },
791
865
  blockHeader,
792
866
  jobId,
@@ -804,16 +878,34 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
804
878
  returnTypes: [],
805
879
  });
806
880
 
807
- return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId, authorizedUtilityCallTargets);
881
+ return this.executeUtilityCall(call, {
882
+ from,
883
+ scopes: await this.keyStore.getAccounts(),
884
+ jobId,
885
+ authorizedUtilityCallTargets,
886
+ });
808
887
  }
809
888
 
810
889
  private async executeUtilityCall(
811
890
  call: FunctionCall,
812
- scopes: AztecAddress[],
813
- jobId: string,
814
- authorizedUtilityCallTargets: AztecAddress[] = [],
891
+ {
892
+ from = AztecAddress.NULL_MSG_SENDER,
893
+ scopes,
894
+ jobId,
895
+ authorizedUtilityCallTargets = [],
896
+ }: { from?: AztecAddress; scopes: AztecAddress[]; jobId: string; authorizedUtilityCallTargets?: AztecAddress[] },
815
897
  ): Promise<Fr[]> {
816
- const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
898
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
899
+ const anchoredContractData = new AnchoredContractData(
900
+ this.contractStore,
901
+ this.stateMachine.contractClassService,
902
+ anchorBlockHeader,
903
+ );
904
+
905
+ const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
906
+ if (!entryPointArtifact) {
907
+ throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
908
+ }
817
909
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
818
910
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
819
911
  }
@@ -824,35 +916,40 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
824
916
  });
825
917
 
826
918
  try {
827
- const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
828
919
  const simulator = new WASMSimulator();
829
920
  const utilityExecutor = async (syncCall: FunctionCall, execScopes: AztecAddress[]) => {
830
- await this.executeUtilityCall(syncCall, execScopes, jobId);
921
+ await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId, authorizedUtilityCallTargets });
831
922
  };
832
923
  const oracle = new UtilityExecutionOracle({
833
- contractAddress: call.to,
924
+ callContext: CallContext.from({
925
+ msgSender: from,
926
+ contractAddress: call.to,
927
+ functionSelector: call.selector,
928
+ isStaticCall: true,
929
+ }),
834
930
  authWitnesses: [],
835
931
  capsules: [],
836
932
  anchorBlockHeader,
837
- contractStore: this.contractStore,
933
+ anchoredContractData,
838
934
  noteStore: this.noteStore,
839
935
  keyStore: this.keyStore,
840
936
  addressStore: this.addressStore,
841
937
  aztecNode: this.stateMachine.node,
842
938
  recipientTaggingStore: this.recipientTaggingStore,
843
- senderAddressBookStore: this.senderAddressBookStore,
939
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
844
940
  capsuleService: new CapsuleService(this.capsuleStore, scopes),
941
+ factService: new FactService(this.factStore, scopes),
845
942
  privateEventStore: this.privateEventStore,
846
- messageContextService: this.stateMachine.messageContextService,
943
+ txResolver: this.stateMachine.txResolver,
847
944
  contractSyncService: this.stateMachine.contractSyncService,
848
945
  l2TipsStore: this.stateMachine.l2TipsProvider,
849
946
  jobId,
850
947
  scopes,
851
948
  simulator,
949
+ utilityExecutor,
852
950
  hooks: composeHooks({
853
951
  authorizeUtilityCall: this.buildAuthorizeUtilityCallHook('utility', authorizedUtilityCallTargets),
854
952
  }),
855
- utilityExecutor,
856
953
  // Execution-tree root (top-level utility run or contract sync): own store; nested frames inherit it.
857
954
  transientArrayService: new TransientArrayService(),
858
955
  });
@@ -878,9 +975,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
878
975
  }
879
976
  }
880
977
 
881
- close(): [bigint, Map<string, AuthWitness>] {
978
+ close(): [bigint, Map<string, AuthWitness>, TXETaggingSecretStrategies] {
882
979
  this.logger.debug('Exiting Top Level Context');
883
- return [this.nextBlockTimestamp, this.authwits];
980
+ return [this.nextBlockTimestamp, this.authwits, this.taggingSecretStrategies];
884
981
  }
885
982
 
886
983
  private async getLastBlockNumber(): Promise<BlockNumber> {
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * The Noir counterparts are in `noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr`.
7
7
  */
8
- export const TXE_ORACLE_VERSION_MAJOR = 1;
9
- export const TXE_ORACLE_VERSION_MINOR = 2;
8
+ export const TXE_ORACLE_VERSION_MAJOR = 3;
9
+ export const TXE_ORACLE_VERSION_MINOR = 0;
10
10
 
11
11
  /**
12
12
  * This hash is computed from the TXE oracle interfaces (IAvmExecutionOracle and ITxeExecutionOracle) and is used to
@@ -14,4 +14,4 @@ export const TXE_ORACLE_VERSION_MINOR = 2;
14
14
  * - TXE_ORACLE_VERSION_MAJOR (and reset MINOR to 0) for breaking changes, or
15
15
  * - TXE_ORACLE_VERSION_MINOR for additive changes (new oracle method added).
16
16
  */
17
- export const TXE_ORACLE_INTERFACE_HASH = '9e5f6ad5fd170d1de5ddd417f19cce47b17382567e08360dc6a783154828e218';
17
+ export const TXE_ORACLE_INTERFACE_HASH = 'bea75bd85baebd7aa1438efb1defab496d27540bc805a8d854bb74b8d45fd859';