@aztec/txe 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316

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 (136) hide show
  1. package/dest/AuthRegistry-QVGDDH5X.js +3 -0
  2. package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
  3. package/dest/ContractClassRegistry-VWR3F42P.js +3 -0
  4. package/dest/ContractClassRegistry-VWR3F42P.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-FHIWE33X.js +3 -0
  6. package/dest/ContractInstanceRegistry-FHIWE33X.js.map +7 -0
  7. package/dest/FeeJuice-SAOWVGG7.js +3 -0
  8. package/dest/FeeJuice-SAOWVGG7.js.map +7 -0
  9. package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
  10. package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
  11. package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
  12. package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
  13. package/dest/SchnorrAccount-NME3E45O.js +3 -0
  14. package/dest/SchnorrAccount-NME3E45O.js.map +7 -0
  15. package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js +3 -0
  16. package/dest/SchnorrInitializerlessAccount-WTGXU6SW.js.map +7 -0
  17. package/dest/bin/check_txe_oracle_version.js +7 -15
  18. package/dest/bin/index.js +1 -1
  19. package/dest/bin/oracle_test_server.js +2 -2
  20. package/dest/chunk-32UHX7YY.js +3 -0
  21. package/dest/{chunk-CUSVOJA4.js → chunk-DXIAVNMJ.js} +2 -2
  22. package/dest/{chunk-CUSVOJA4.js.map → chunk-DXIAVNMJ.js.map} +3 -3
  23. package/dest/chunk-JHAAHRCL.js +260 -0
  24. package/dest/chunk-JHAAHRCL.js.map +7 -0
  25. package/dest/constants.d.ts +1 -1
  26. package/dest/constants.d.ts.map +1 -1
  27. package/dest/constants.js +1 -1
  28. package/dest/dispatcher_pool.d.ts +2 -2
  29. package/dest/dispatcher_pool.d.ts.map +1 -1
  30. package/dest/dispatcher_pool.js +5 -3
  31. package/dest/index.d.ts +2 -136
  32. package/dest/index.d.ts.map +1 -1
  33. package/dest/index.js +5 -3
  34. package/dest/metafile.json +9387 -7491
  35. package/dest/oracle/interfaces.d.ts +24 -11
  36. package/dest/oracle/interfaces.d.ts.map +1 -1
  37. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  38. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  39. package/dest/oracle/tagging_secret_strategy.js +12 -0
  40. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  41. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  42. package/dest/oracle/test-resolver/default_fixtures.js +200 -0
  43. package/dest/oracle/test-resolver/index.d.ts +1 -1
  44. package/dest/oracle/test-resolver/index.d.ts.map +1 -1
  45. package/dest/oracle/test-resolver/index.js +1 -2
  46. package/dest/oracle/test-resolver/resolver.d.ts +21 -7
  47. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
  48. package/dest/oracle/test-resolver/resolver.js +100 -33
  49. package/dest/oracle/txe_oracle_public_context.d.ts +9 -9
  50. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  51. package/dest/oracle/txe_oracle_public_context.js +15 -9
  52. package/dest/oracle/txe_oracle_registry.d.ts +51 -26
  53. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
  54. package/dest/oracle/txe_oracle_registry.js +258 -53
  55. package/dest/oracle/txe_oracle_top_level_context.d.ts +30 -9
  56. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  57. package/dest/oracle/txe_oracle_top_level_context.js +454 -288
  58. package/dest/oracle/txe_oracle_version.d.ts +4 -4
  59. package/dest/oracle/txe_oracle_version.js +4 -4
  60. package/dest/rpc_translator.d.ts +23 -4
  61. package/dest/rpc_translator.d.ts.map +1 -1
  62. package/dest/rpc_translator.js +167 -81
  63. package/dest/server.bundle.js +1 -1
  64. package/dest/state_machine/archiver.d.ts +1 -1
  65. package/dest/state_machine/archiver.d.ts.map +1 -1
  66. package/dest/state_machine/archiver.js +1 -2
  67. package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
  68. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  69. package/dest/state_machine/dummy_p2p_client.js +9 -0
  70. package/dest/state_machine/global_variable_builder.d.ts +3 -4
  71. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  72. package/dest/state_machine/global_variable_builder.js +0 -3
  73. package/dest/state_machine/index.d.ts +8 -6
  74. package/dest/state_machine/index.d.ts.map +1 -1
  75. package/dest/state_machine/index.js +41 -19
  76. package/dest/state_machine/synchronizer.d.ts +10 -2
  77. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  78. package/dest/state_machine/synchronizer.js +18 -5
  79. package/dest/txe_session.d.ts +29 -20
  80. package/dest/txe_session.d.ts.map +1 -1
  81. package/dest/txe_session.js +165 -41
  82. package/dest/utils/block_creation.d.ts +2 -2
  83. package/dest/utils/block_creation.d.ts.map +1 -1
  84. package/dest/utils/block_creation.js +2 -2
  85. package/dest/utils/encoding.d.ts +4 -3
  86. package/dest/utils/encoding.d.ts.map +1 -1
  87. package/dest/utils/tx_effect_creation.d.ts +1 -1
  88. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  89. package/dest/utils/tx_effect_creation.js +0 -1
  90. package/dest/utils/txe_public_contract_data_source.d.ts +1 -1
  91. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
  92. package/dest/utils/txe_public_contract_data_source.js +7 -4
  93. package/dest/worker.bundle.js +1 -1
  94. package/package.json +17 -17
  95. package/src/bin/check_txe_oracle_version.ts +9 -12
  96. package/src/bin/oracle_test_server.ts +2 -2
  97. package/src/constants.ts +1 -1
  98. package/src/dispatcher_pool.ts +4 -3
  99. package/src/index.ts +6 -4
  100. package/src/oracle/interfaces.ts +26 -9
  101. package/src/oracle/tagging_secret_strategy.ts +25 -0
  102. package/src/oracle/test-resolver/default_fixtures.ts +271 -0
  103. package/src/oracle/test-resolver/index.ts +1 -2
  104. package/src/oracle/test-resolver/resolver.ts +121 -41
  105. package/src/oracle/txe_oracle_public_context.ts +16 -14
  106. package/src/oracle/txe_oracle_registry.ts +197 -42
  107. package/src/oracle/txe_oracle_top_level_context.ts +201 -66
  108. package/src/oracle/txe_oracle_version.ts +4 -4
  109. package/src/rpc_translator.ts +224 -108
  110. package/src/state_machine/archiver.ts +0 -1
  111. package/src/state_machine/dummy_p2p_client.ts +13 -0
  112. package/src/state_machine/global_variable_builder.ts +2 -16
  113. package/src/state_machine/index.ts +50 -34
  114. package/src/state_machine/synchronizer.ts +26 -5
  115. package/src/txe_session.ts +284 -45
  116. package/src/utils/block_creation.ts +2 -1
  117. package/src/utils/tx_effect_creation.ts +0 -2
  118. package/src/utils/txe_public_contract_data_source.ts +6 -4
  119. package/dest/ContractClassRegistry-PII7Q556.js +0 -3
  120. package/dest/ContractClassRegistry-PII7Q556.js.map +0 -7
  121. package/dest/ContractInstanceRegistry-3MHLGFNZ.js +0 -3
  122. package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +0 -7
  123. package/dest/FeeJuice-TQV5AQK7.js +0 -3
  124. package/dest/FeeJuice-TQV5AQK7.js.map +0 -7
  125. package/dest/MultiCallEntrypoint-SBJUIJY7.js +0 -3
  126. package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +0 -7
  127. package/dest/SchnorrAccount-MQXPIZ44.js +0 -3
  128. package/dest/SchnorrAccount-MQXPIZ44.js.map +0 -7
  129. package/dest/chunk-BJVAAXNA.js +0 -3
  130. package/dest/chunk-OYLIPWI6.js +0 -260
  131. package/dest/chunk-OYLIPWI6.js.map +0 -7
  132. package/dest/oracle/test-resolver/fixtures.d.ts +0 -43
  133. package/dest/oracle/test-resolver/fixtures.d.ts.map +0 -1
  134. package/dest/oracle/test-resolver/fixtures.js +0 -39
  135. package/src/oracle/test-resolver/fixtures.ts +0 -84
  136. /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
@@ -6,32 +6,40 @@ 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,
32
- Oracle,
38
+ type Option,
33
39
  PrivateExecutionOracle,
40
+ TransientArrayService,
34
41
  UtilityExecutionOracle,
42
+ buildACIRCallback,
35
43
  executePrivateFunction,
36
44
  generateSimulatedProvingResult,
37
45
  } from '@aztec/pxe/simulator';
@@ -63,7 +71,10 @@ import {
63
71
  PrivateToPublicAccumulatedData,
64
72
  PublicCallRequest,
65
73
  } from '@aztec/stdlib/kernel';
66
- 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';
67
78
  import { ChonkProof } from '@aztec/stdlib/proofs';
68
79
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
69
80
  import { MerkleTreeId } from '@aztec/stdlib/trees';
@@ -89,6 +100,7 @@ import type { TXEAccountStore } from '../utils/txe_account_store.js';
89
100
  import type { TXEArtifactResolver } from '../utils/txe_artifact_resolver.js';
90
101
  import { TXEPublicContractDataSource } from '../utils/txe_public_contract_data_source.js';
91
102
  import type { ITxeExecutionOracle } from './interfaces.js';
103
+ import { type TXETaggingSecretStrategies, makeResolveTaggingSecretStrategyHook } from './tagging_secret_strategy.js';
92
104
 
93
105
  export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
94
106
  isMisc = true as const;
@@ -105,13 +117,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
105
117
  private accountStore: TXEAccountStore,
106
118
  private senderTaggingStore: SenderTaggingStore,
107
119
  private recipientTaggingStore: RecipientTaggingStore,
108
- private senderAddressBookStore: SenderAddressBookStore,
120
+ private taggingSecretSourcesStore: TaggingSecretSourcesStore,
109
121
  private capsuleStore: CapsuleStore,
122
+ private factStore: FactStore,
110
123
  private privateEventStore: PrivateEventStore,
111
124
  private nextBlockTimestamp: bigint,
112
125
  private version: Fr,
113
126
  private chainId: Fr,
114
127
  private authwits: Map<string, AuthWitness>,
128
+ private taggingSecretStrategies: TXETaggingSecretStrategies,
129
+ private authorizeAllUtilityCallTargets: boolean,
115
130
  private readonly artifactResolver: TXEArtifactResolver,
116
131
  private readonly rootPath: string,
117
132
  private readonly packageName: string,
@@ -173,7 +188,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
173
188
  return (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables.timestamp;
174
189
  }
175
190
 
176
- async getLastTxEffects() {
191
+ async getLastTxEffects(): Promise<{ txHash: TxHash; noteHashes: Fr[]; nullifiers: Fr[]; privateLogs: PrivateLog[] }> {
177
192
  const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
178
193
  const block = await this.stateMachine.archiver.getBlock({ number: latestBlockNumber });
179
194
 
@@ -208,7 +223,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
208
223
  contractAddress,
209
224
  null,
210
225
  async (call, execScopes) => {
211
- await this.executeUtilityCall(call, execScopes, jobId);
226
+ await this.executeUtilityCall(call, { scopes: execScopes, jobId });
212
227
  },
213
228
  blockHeader,
214
229
  jobId,
@@ -250,7 +265,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
250
265
  }
251
266
 
252
267
  private deploymentNullifier(address: AztecAddress): Promise<Fr> {
253
- return siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
268
+ return siloNullifier(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
254
269
  }
255
270
 
256
271
  async deploy(
@@ -285,14 +300,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
285
300
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
286
301
  }
287
302
 
288
- return [
289
- instance.salt,
290
- instance.deployer.toField(),
291
- instance.currentContractClassId,
292
- instance.initializationHash,
293
- instance.immutablesHash,
294
- ...instance.publicKeys.toFields(),
295
- ];
303
+ return CONTRACT_INSTANCE.serialization!.fn(instance).flat();
296
304
  }
297
305
 
298
306
  /**
@@ -320,7 +328,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
320
328
  await this.contractStore.addContractInstance(instance);
321
329
  await this.contractStore.addContractArtifact(artifact);
322
330
 
323
- const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
331
+ const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
324
332
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
325
333
  await this.addressStore.addCompleteAddress(completeAddress);
326
334
  this.logger.debug(`Created account ${completeAddress.address}`);
@@ -328,9 +336,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
328
336
  return completeAddress;
329
337
  }
330
338
 
331
- async createAccount(secret: Fr) {
332
- // This is a foot gun !
333
- const completeAddress = await this.keyStore.addAccount(secret, secret);
339
+ async createAccount(secret: Fr, partialAddress: Fr) {
340
+ const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
334
341
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
335
342
  await this.addressStore.addCompleteAddress(completeAddress);
336
343
  this.logger.debug(`Created account ${completeAddress.address}`);
@@ -351,7 +358,46 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
351
358
  this.authwits.set(authWitness.requestHash.toString(), authWitness);
352
359
  }
353
360
 
354
- 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
+ setAuthorizeAllUtilityCallTargets(authorizeAll: boolean): void {
377
+ this.authorizeAllUtilityCallTargets = authorizeAll;
378
+ }
379
+
380
+ async sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr> {
381
+ // Messages are appended to the tree, so the next free slot is simply the current tree size.
382
+ const { size } = await this.stateMachine.synchronizer
383
+ .getCommitted()
384
+ .getTreeInfo(MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
385
+ const leafIndex = new Fr(size);
386
+
387
+ const message = new L1ToL2Message(
388
+ new L1Actor(sender, this.chainId.toNumber()),
389
+ new L2Actor(recipient, this.version.toNumber()),
390
+ content,
391
+ secretHash,
392
+ leafIndex,
393
+ );
394
+
395
+ await this.mineBlock({ l1ToL2Messages: [message.hash()] });
396
+
397
+ return leafIndex;
398
+ }
399
+
400
+ async mineBlock(options: { nullifiers?: Fr[]; l1ToL2Messages?: Fr[] } = {}) {
355
401
  const blockNumber = await this.getNextBlockNumber();
356
402
 
357
403
  const txEffect = TxEffect.empty();
@@ -359,7 +405,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
359
405
  txEffect.txHash = new TxHash(new Fr(blockNumber));
360
406
 
361
407
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
362
- await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
408
+ await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees, options.l1ToL2Messages ?? []);
363
409
 
364
410
  const globals = makeGlobalVariables(undefined, {
365
411
  blockNumber,
@@ -373,7 +419,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
373
419
 
374
420
  this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
375
421
 
376
- await this.stateMachine.handleL2Block(block);
422
+ await this.stateMachine.handleL2Block(block, options.l1ToL2Messages ?? []);
377
423
  }
378
424
 
379
425
  async privateCallNewFlow(
@@ -388,11 +434,18 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
388
434
  authorizedUtilityCallTargets: AztecAddress[],
389
435
  gasSettings: GasSettings,
390
436
  ) {
437
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
438
+ const anchoredContractData = new AnchoredContractData(
439
+ this.contractStore,
440
+ this.stateMachine.contractClassService,
441
+ blockHeader,
442
+ );
443
+
391
444
  this.logger.verbose(
392
- `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
445
+ `Executing external function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
393
446
  );
394
447
 
395
- const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
448
+ const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
396
449
  if (!artifact) {
397
450
  const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
398
451
  ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
@@ -404,10 +457,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
404
457
 
405
458
  // Sync notes before executing private function to discover notes from previous transactions
406
459
  const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
407
- await this.executeUtilityCall(call, execScopes, jobId);
460
+ await this.executeUtilityCall(call, { scopes: execScopes, jobId });
408
461
  };
409
462
 
410
- const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
411
463
  await this.stateMachine.contractSyncService.ensureContractSynced(
412
464
  targetContractAddress,
413
465
  functionSelector,
@@ -435,9 +487,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
435
487
 
436
488
  const simulator = new WASMSimulator();
437
489
 
490
+ const transientArrayService = new TransientArrayService();
438
491
  const privateExecutionOracle = new PrivateExecutionOracle({
439
492
  argsHash,
440
493
  txContext,
494
+ txRequestSalt: Fr.ZERO,
441
495
  callContext,
442
496
  anchorBlockHeader: blockHeader,
443
497
  utilityExecutor,
@@ -446,15 +500,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
446
500
  executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
447
501
  noteCache,
448
502
  taggingIndexCache,
449
- contractStore: this.contractStore,
503
+ anchoredContractData,
450
504
  noteStore: this.noteStore,
451
505
  keyStore: this.keyStore,
452
506
  addressStore: this.addressStore,
453
507
  aztecNode: this.stateMachine.node,
454
508
  senderTaggingStore: this.senderTaggingStore,
455
509
  recipientTaggingStore: this.recipientTaggingStore,
456
- senderAddressBookStore: this.senderAddressBookStore,
510
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
457
511
  capsuleService: new CapsuleService(this.capsuleStore, scopes),
512
+ factService: new FactService(this.factStore, scopes),
458
513
  privateEventStore: this.privateEventStore,
459
514
  contractSyncService: this.stateMachine.contractSyncService,
460
515
  jobId,
@@ -465,14 +520,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
465
520
  // contract would perform, including setting senderForTags.
466
521
  senderForTags: from,
467
522
  simulator,
468
- messageContextService: this.stateMachine.messageContextService,
523
+ txResolver: this.stateMachine.txResolver,
469
524
  l2TipsStore: this.stateMachine.l2TipsProvider,
470
525
  hooks: composeHooks({
471
526
  authorizeUtilityCall: this.buildAuthorizeUtilityCallHook(
472
527
  isStaticCall ? 'private view' : 'private',
473
528
  authorizedUtilityCallTargets,
474
529
  ),
530
+ resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
475
531
  }),
532
+ transientArrayService,
476
533
  });
477
534
 
478
535
  // Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
@@ -500,7 +557,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
500
557
  }),
501
558
  );
502
559
 
503
- noteCache.finish();
504
560
  const nonceGenerator = noteCache.getNonceGenerator();
505
561
  result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
506
562
  } catch (err) {
@@ -512,7 +568,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
512
568
  // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
513
569
  const { publicInputs } = await generateSimulatedProvingResult(
514
570
  result,
515
- (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
571
+ (addr, sel) => anchoredContractData.getDebugFunctionName(addr, sel),
516
572
  this.stateMachine.node,
517
573
  minRevertibleSideEffectCounter,
518
574
  );
@@ -524,7 +580,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
524
580
  globals.version = this.version;
525
581
  globals.gasFees = GasFees.empty();
526
582
 
527
- const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
583
+ await using forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
528
584
 
529
585
  const bindings = this.logger.getBindings();
530
586
  const contractsDB = new PublicContractsDB(
@@ -539,11 +595,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
539
595
  collectStatistics: false,
540
596
  collectCallMetadata: true,
541
597
  });
598
+ // The AVM simulator reads this fork's contracts DB, scoped by fork id, for each simulation.
599
+ const forkId = forkedWorldTrees.getRevision().forkId;
542
600
  const processor = new PublicProcessor(
543
601
  globals,
544
602
  guardedMerkleTrees,
545
603
  contractsDB,
546
- new PublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
604
+ new PublicTxSimulator(
605
+ this.stateMachine.synchronizer.avmSimulator,
606
+ globals,
607
+ contractsDB,
608
+ forkId,
609
+ config,
610
+ bindings,
611
+ ),
547
612
  new TestDateProvider(),
548
613
  undefined,
549
614
  createLogger('simulator:public-processor', bindings),
@@ -571,7 +636,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
571
636
  } else if (!processedTx.revertCode.isOK()) {
572
637
  if (processedTx.revertReason) {
573
638
  try {
574
- await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
639
+ await enrichPublicSimulationError(
640
+ processedTx.revertReason,
641
+ this.contractStore,
642
+ this.stateMachine.contractClassService,
643
+ await this.stateMachine.anchorBlockStore.getBlockHeader(),
644
+ this.logger,
645
+ );
575
646
  // eslint-disable-next-line no-empty
576
647
  } catch {}
577
648
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -588,8 +659,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
588
659
 
589
660
  if (isStaticCall) {
590
661
  await checkpoint!.revert();
591
-
592
- await forkedWorldTrees.close();
593
662
  return { returnValues: executionResult.returnValues ?? [], offchainEffects };
594
663
  }
595
664
 
@@ -610,8 +679,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
610
679
 
611
680
  await this.stateMachine.handleL2Block(l2Block);
612
681
 
613
- await forkedWorldTrees.close();
614
-
615
682
  return { returnValues: executionResult.returnValues ?? [], offchainEffects };
616
683
  }
617
684
 
@@ -622,16 +689,21 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
622
689
  isStaticCall: boolean,
623
690
  gasSettings: GasSettings,
624
691
  ) {
692
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
693
+ const anchoredContractData = new AnchoredContractData(
694
+ this.contractStore,
695
+ this.stateMachine.contractClassService,
696
+ anchorBlockHeader,
697
+ );
698
+
625
699
  this.logger.verbose(
626
- `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
700
+ `Executing public function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
627
701
  );
628
702
 
629
703
  const blockNumber = await this.getNextBlockNumber();
630
704
 
631
705
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
632
706
 
633
- const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
634
-
635
707
  const calldataHash = await computeCalldataHash(calldata);
636
708
  const calldataHashedValues = new HashedValues(calldata, calldataHash);
637
709
 
@@ -642,7 +714,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
642
714
  globals.version = this.version;
643
715
  globals.gasFees = GasFees.empty();
644
716
 
645
- const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
717
+ await using forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
646
718
 
647
719
  const bindings2 = this.logger.getBindings();
648
720
  const contractsDB = new PublicContractsDB(
@@ -657,7 +729,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
657
729
  collectStatistics: false,
658
730
  collectCallMetadata: true,
659
731
  });
660
- const simulator = new PublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
732
+ // The AVM simulator reads this fork's contracts DB, scoped by fork id, for each simulation.
733
+ const forkId2 = forkedWorldTrees.getRevision().forkId;
734
+ const simulator = new PublicTxSimulator(
735
+ this.stateMachine.synchronizer.avmSimulator,
736
+ globals,
737
+ contractsDB,
738
+ forkId2,
739
+ config,
740
+ bindings2,
741
+ );
661
742
  const processor = new PublicProcessor(
662
743
  globals,
663
744
  guardedMerkleTrees,
@@ -724,7 +805,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
724
805
  } else if (!processedTx.revertCode.isOK()) {
725
806
  if (processedTx.revertReason) {
726
807
  try {
727
- await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
808
+ await enrichPublicSimulationError(
809
+ processedTx.revertReason,
810
+ this.contractStore,
811
+ this.stateMachine.contractClassService,
812
+ anchorBlockHeader,
813
+ this.logger,
814
+ );
728
815
  // eslint-disable-next-line no-empty
729
816
  } catch {}
730
817
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -737,9 +824,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
737
824
 
738
825
  if (isStaticCall) {
739
826
  await checkpoint!.revert();
740
-
741
- await forkedWorldTrees.close();
742
-
743
827
  return returnValues ?? [];
744
828
  }
745
829
 
@@ -760,30 +844,35 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
760
844
 
761
845
  await this.stateMachine.handleL2Block(l2Block);
762
846
 
763
- await forkedWorldTrees.close();
764
-
765
847
  return returnValues ?? [];
766
848
  }
767
849
 
768
850
  async executeUtilityFunction(
851
+ from: AztecAddress | undefined,
769
852
  targetContractAddress: AztecAddress,
770
853
  functionSelector: FunctionSelector,
771
854
  args: Fr[],
772
855
  jobId: string,
773
856
  authorizedUtilityCallTargets: AztecAddress[],
774
857
  ) {
775
- const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
858
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
859
+ const anchoredContractData = new AnchoredContractData(
860
+ this.contractStore,
861
+ this.stateMachine.contractClassService,
862
+ blockHeader,
863
+ );
864
+
865
+ const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
776
866
  if (!artifact) {
777
867
  throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
778
868
  }
779
869
 
780
870
  // Sync notes before executing utility function to discover notes from previous transactions
781
- const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
782
871
  await this.stateMachine.contractSyncService.ensureContractSynced(
783
872
  targetContractAddress,
784
873
  functionSelector,
785
874
  async (call, execScopes) => {
786
- await this.executeUtilityCall(call, execScopes, jobId);
875
+ await this.executeUtilityCall(call, { scopes: execScopes, jobId });
787
876
  },
788
877
  blockHeader,
789
878
  jobId,
@@ -801,16 +890,34 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
801
890
  returnTypes: [],
802
891
  });
803
892
 
804
- return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId, authorizedUtilityCallTargets);
893
+ return this.executeUtilityCall(call, {
894
+ from,
895
+ scopes: await this.keyStore.getAccounts(),
896
+ jobId,
897
+ authorizedUtilityCallTargets,
898
+ });
805
899
  }
806
900
 
807
901
  private async executeUtilityCall(
808
902
  call: FunctionCall,
809
- scopes: AztecAddress[],
810
- jobId: string,
811
- authorizedUtilityCallTargets: AztecAddress[] = [],
903
+ {
904
+ from = AztecAddress.NULL_MSG_SENDER,
905
+ scopes,
906
+ jobId,
907
+ authorizedUtilityCallTargets = [],
908
+ }: { from?: AztecAddress; scopes: AztecAddress[]; jobId: string; authorizedUtilityCallTargets?: AztecAddress[] },
812
909
  ): Promise<Fr[]> {
813
- const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
910
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
911
+ const anchoredContractData = new AnchoredContractData(
912
+ this.contractStore,
913
+ this.stateMachine.contractClassService,
914
+ anchorBlockHeader,
915
+ );
916
+
917
+ const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
918
+ if (!entryPointArtifact) {
919
+ throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
920
+ }
814
921
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
815
922
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
816
923
  }
@@ -821,26 +928,31 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
821
928
  });
822
929
 
823
930
  try {
824
- const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
825
931
  const simulator = new WASMSimulator();
826
932
  const utilityExecutor = async (syncCall: FunctionCall, execScopes: AztecAddress[]) => {
827
- await this.executeUtilityCall(syncCall, execScopes, jobId);
933
+ await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId });
828
934
  };
829
935
  const oracle = new UtilityExecutionOracle({
830
- contractAddress: call.to,
936
+ callContext: CallContext.from({
937
+ msgSender: from,
938
+ contractAddress: call.to,
939
+ functionSelector: call.selector,
940
+ isStaticCall: true,
941
+ }),
831
942
  authWitnesses: [],
832
943
  capsules: [],
833
944
  anchorBlockHeader,
834
- contractStore: this.contractStore,
945
+ anchoredContractData,
835
946
  noteStore: this.noteStore,
836
947
  keyStore: this.keyStore,
837
948
  addressStore: this.addressStore,
838
949
  aztecNode: this.stateMachine.node,
839
950
  recipientTaggingStore: this.recipientTaggingStore,
840
- senderAddressBookStore: this.senderAddressBookStore,
951
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
841
952
  capsuleService: new CapsuleService(this.capsuleStore, scopes),
953
+ factService: new FactService(this.factStore, scopes),
842
954
  privateEventStore: this.privateEventStore,
843
- messageContextService: this.stateMachine.messageContextService,
955
+ txResolver: this.stateMachine.txResolver,
844
956
  contractSyncService: this.stateMachine.contractSyncService,
845
957
  l2TipsStore: this.stateMachine.l2TipsProvider,
846
958
  jobId,
@@ -850,9 +962,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
850
962
  authorizeUtilityCall: this.buildAuthorizeUtilityCallHook('utility', authorizedUtilityCallTargets),
851
963
  }),
852
964
  utilityExecutor,
965
+ // Execution-tree root (top-level utility run or contract sync): own store; nested frames inherit it.
966
+ transientArrayService: new TransientArrayService(),
853
967
  });
854
968
  const acirExecutionResult = await simulator
855
- .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
969
+ .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle))
856
970
  .catch((err: Error) => {
857
971
  err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
858
972
  throw new ExecutionError(
@@ -873,9 +987,19 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
873
987
  }
874
988
  }
875
989
 
876
- close(): [bigint, Map<string, AuthWitness>] {
990
+ close(): {
991
+ nextBlockTimestamp: bigint;
992
+ authwits: Map<string, AuthWitness>;
993
+ taggingSecretStrategies: TXETaggingSecretStrategies;
994
+ authorizeAllUtilityCallTargets: boolean;
995
+ } {
877
996
  this.logger.debug('Exiting Top Level Context');
878
- return [this.nextBlockTimestamp, this.authwits];
997
+ return {
998
+ nextBlockTimestamp: this.nextBlockTimestamp,
999
+ authwits: this.authwits,
1000
+ taggingSecretStrategies: this.taggingSecretStrategies,
1001
+ authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets,
1002
+ };
879
1003
  }
880
1004
 
881
1005
  private async getLastBlockNumber(): Promise<BlockNumber> {
@@ -887,6 +1011,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
887
1011
  callerContext: 'private' | 'private view' | 'utility',
888
1012
  authorizedTargets: AztecAddress[],
889
1013
  ): ExecutionHooks['authorizeUtilityCall'] | undefined {
1014
+ if (this.authorizeAllUtilityCallTargets) {
1015
+ return authorizeAllUtilityCallsHook;
1016
+ }
890
1017
  if (authorizedTargets.length === 0) {
891
1018
  return undefined;
892
1019
  }
@@ -896,3 +1023,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
896
1023
  });
897
1024
  }
898
1025
  }
1026
+
1027
+ /**
1028
+ * An `authorizeUtilityCall` hook that authorizes every cross-contract utility call.
1029
+ *
1030
+ * Backs the `aztec_txe_setAuthorizeAllUtilityCallTargets` oracle.
1031
+ */
1032
+ export const authorizeAllUtilityCallsHook: NonNullable<ExecutionHooks['authorizeUtilityCall']> = () =>
1033
+ Promise.resolve({ authorized: true });
@@ -5,13 +5,13 @@
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 = 4;
9
+ export const TXE_ORACLE_VERSION_MINOR = 1;
10
10
 
11
11
  /**
12
- * This hash is computed from the TXE oracle interfaces (IAvmExecutionOracle and ITxeExecutionOracle) and is used to
12
+ * This hash is computed from the TXE-specific entries in `TXE_ORACLE_REGISTRY` and is used to
13
13
  * detect when those interfaces change. When it does, bump:
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 = '1a6c578d0a47cd8dd7dae07fd00abe781225a73920c596d873afcc061c0e4284';