@aztec/txe 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d

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 (170) hide show
  1. package/dest/AuthRegistry-56AMRLSQ.js +3 -0
  2. package/dest/AuthRegistry-56AMRLSQ.js.map +7 -0
  3. package/dest/ContractClassRegistry-CRN27URB.js +3 -0
  4. package/dest/ContractClassRegistry-CRN27URB.js.map +7 -0
  5. package/dest/ContractInstanceRegistry-GRGL26IC.js +3 -0
  6. package/dest/ContractInstanceRegistry-GRGL26IC.js.map +7 -0
  7. package/dest/FeeJuice-J23RVHLW.js +3 -0
  8. package/dest/FeeJuice-J23RVHLW.js.map +7 -0
  9. package/dest/HandshakeRegistry-5.0.1-PEFCLEGP.js +3 -0
  10. package/dest/HandshakeRegistry-5.0.1-PEFCLEGP.js.map +7 -0
  11. package/dest/HandshakeRegistry-GNFACTEE.js +3 -0
  12. package/dest/HandshakeRegistry-GNFACTEE.js.map +7 -0
  13. package/dest/MultiCallEntrypoint-MIDICLQB.js +3 -0
  14. package/dest/MultiCallEntrypoint-MIDICLQB.js.map +7 -0
  15. package/dest/SchnorrAccount-ZRENHSMV.js +3 -0
  16. package/dest/SchnorrAccount-ZRENHSMV.js.map +7 -0
  17. package/dest/SchnorrInitializerlessAccount-L56LOFSV.js +3 -0
  18. package/dest/SchnorrInitializerlessAccount-L56LOFSV.js.map +7 -0
  19. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  20. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  21. package/dest/bin/check_txe_oracle_version.js +53 -0
  22. package/dest/bin/index.js +3 -30
  23. package/dest/bin/index.js.map +7 -0
  24. package/dest/bin/oracle_test_server.d.ts +3 -0
  25. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  26. package/dest/bin/oracle_test_server.js +41 -0
  27. package/dest/chunk-BJVAAXNA.js +3 -0
  28. package/dest/chunk-BJVAAXNA.js.map +7 -0
  29. package/dest/chunk-LVLJKGGH.js +266 -0
  30. package/dest/chunk-LVLJKGGH.js.map +7 -0
  31. package/dest/chunk-OVMCQ5A6.js +304 -0
  32. package/dest/chunk-OVMCQ5A6.js.map +7 -0
  33. package/dest/constants.d.ts +5 -1
  34. package/dest/constants.d.ts.map +1 -1
  35. package/dest/constants.js +9 -1
  36. package/dest/dispatcher_pool.d.ts +67 -0
  37. package/dest/dispatcher_pool.d.ts.map +1 -0
  38. package/dest/dispatcher_pool.js +286 -0
  39. package/dest/index.d.ts +51 -7
  40. package/dest/index.d.ts.map +1 -1
  41. package/dest/index.js +72 -190
  42. package/dest/metafile.json +40494 -0
  43. package/dest/msgpackr_fr_extension.d.ts +2 -0
  44. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  45. package/dest/msgpackr_fr_extension.js +21 -0
  46. package/dest/oracle/interfaces.d.ts +47 -9
  47. package/dest/oracle/interfaces.d.ts.map +1 -1
  48. package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
  49. package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
  50. package/dest/oracle/tagging_secret_strategy.js +12 -0
  51. package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
  52. package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
  53. package/dest/oracle/test-resolver/default_fixtures.js +200 -0
  54. package/dest/oracle/test-resolver/index.d.ts +9 -0
  55. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  56. package/dest/oracle/test-resolver/index.js +32 -0
  57. package/dest/oracle/test-resolver/resolver.d.ts +48 -0
  58. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  59. package/dest/oracle/test-resolver/resolver.js +181 -0
  60. package/dest/oracle/txe_oracle_public_context.d.ts +26 -2
  61. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  62. package/dest/oracle/txe_oracle_public_context.js +49 -1
  63. package/dest/oracle/txe_oracle_registry.d.ts +172 -0
  64. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  65. package/dest/oracle/txe_oracle_registry.js +767 -0
  66. package/dest/oracle/txe_oracle_top_level_context.d.ts +58 -18
  67. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  68. package/dest/oracle/txe_oracle_top_level_context.js +286 -97
  69. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  70. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  71. package/dest/oracle/txe_oracle_version.js +14 -0
  72. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  73. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  74. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  75. package/dest/rpc_server.d.ts +14 -0
  76. package/dest/rpc_server.d.ts.map +1 -0
  77. package/dest/rpc_server.js +78 -0
  78. package/dest/rpc_translator.d.ts +115 -233
  79. package/dest/rpc_translator.d.ts.map +1 -1
  80. package/dest/rpc_translator.js +791 -647
  81. package/dest/server.bundle.js +3 -0
  82. package/dest/server.bundle.js.map +7 -0
  83. package/dest/state_machine/archiver.d.ts +4 -3
  84. package/dest/state_machine/archiver.d.ts.map +1 -1
  85. package/dest/state_machine/archiver.js +25 -16
  86. package/dest/state_machine/dummy_p2p_client.d.ts +16 -7
  87. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  88. package/dest/state_machine/dummy_p2p_client.js +26 -2
  89. package/dest/state_machine/global_variable_builder.d.ts +10 -6
  90. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  91. package/dest/state_machine/global_variable_builder.js +8 -5
  92. package/dest/state_machine/index.d.ts +11 -7
  93. package/dest/state_machine/index.d.ts.map +1 -1
  94. package/dest/state_machine/index.js +52 -14
  95. package/dest/state_machine/mock_epoch_cache.d.ts +1 -2
  96. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  97. package/dest/state_machine/mock_epoch_cache.js +0 -3
  98. package/dest/state_machine/synchronizer.d.ts +5 -2
  99. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  100. package/dest/state_machine/synchronizer.js +7 -3
  101. package/dest/txe_session.d.ts +90 -20
  102. package/dest/txe_session.d.ts.map +1 -1
  103. package/dest/txe_session.js +313 -67
  104. package/dest/utils/block_creation.d.ts +2 -2
  105. package/dest/utils/block_creation.d.ts.map +1 -1
  106. package/dest/utils/block_creation.js +2 -2
  107. package/dest/utils/encoding.d.ts +192 -0
  108. package/dest/utils/encoding.d.ts.map +1 -0
  109. package/dest/{util → utils}/encoding.js +7 -2
  110. package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
  111. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  112. package/dest/utils/tx_effect_creation.d.ts +1 -1
  113. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  114. package/dest/utils/tx_effect_creation.js +0 -1
  115. package/dest/{util → utils}/txe_account_store.d.ts +1 -1
  116. package/dest/utils/txe_account_store.d.ts.map +1 -0
  117. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  118. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  119. package/dest/utils/txe_artifact_resolver.js +161 -0
  120. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  121. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  122. package/dest/{util → utils}/txe_public_contract_data_source.js +7 -4
  123. package/dest/worker.bundle.js +3 -0
  124. package/dest/worker.bundle.js.map +7 -0
  125. package/dest/worker.d.ts +2 -0
  126. package/dest/worker.d.ts.map +1 -0
  127. package/dest/worker.js +92 -0
  128. package/package.json +38 -21
  129. package/src/bin/check_txe_oracle_version.ts +67 -0
  130. package/src/bin/index.ts +11 -2
  131. package/src/bin/oracle_test_server.ts +51 -0
  132. package/src/constants.ts +11 -1
  133. package/src/dispatcher_pool.ts +317 -0
  134. package/src/index.ts +99 -227
  135. package/src/msgpackr_fr_extension.ts +23 -0
  136. package/src/oracle/interfaces.ts +47 -8
  137. package/src/oracle/tagging_secret_strategy.ts +25 -0
  138. package/src/oracle/test-resolver/default_fixtures.ts +271 -0
  139. package/src/oracle/test-resolver/index.ts +44 -0
  140. package/src/oracle/test-resolver/resolver.ts +245 -0
  141. package/src/oracle/txe_oracle_public_context.ts +62 -0
  142. package/src/oracle/txe_oracle_registry.ts +556 -0
  143. package/src/oracle/txe_oracle_top_level_context.ts +357 -118
  144. package/src/oracle/txe_oracle_version.ts +17 -0
  145. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  146. package/src/rpc_server.ts +87 -0
  147. package/src/rpc_translator.ts +890 -938
  148. package/src/state_machine/archiver.ts +37 -17
  149. package/src/state_machine/dummy_p2p_client.ts +43 -10
  150. package/src/state_machine/global_variable_builder.ts +12 -17
  151. package/src/state_machine/index.ts +63 -32
  152. package/src/state_machine/mock_epoch_cache.ts +0 -4
  153. package/src/state_machine/synchronizer.ts +9 -3
  154. package/src/txe_session.ts +545 -80
  155. package/src/utils/block_creation.ts +2 -1
  156. package/src/{util → utils}/encoding.ts +8 -2
  157. package/src/utils/tx_effect_creation.ts +0 -2
  158. package/src/utils/txe_artifact_resolver.ts +217 -0
  159. package/src/{util → utils}/txe_public_contract_data_source.ts +6 -4
  160. package/src/worker.ts +98 -0
  161. package/dest/util/encoding.d.ts +0 -788
  162. package/dest/util/encoding.d.ts.map +0 -1
  163. package/dest/util/expected_failure_error.d.ts.map +0 -1
  164. package/dest/util/txe_account_store.d.ts.map +0 -1
  165. package/dest/util/txe_public_contract_data_source.d.ts +0 -20
  166. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  167. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  168. /package/dest/{util → utils}/txe_account_store.js +0 -0
  169. /package/src/{util → utils}/expected_failure_error.ts +0 -0
  170. /package/src/{util → utils}/txe_account_store.ts +0 -0
@@ -2,31 +2,44 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { KeyStore } from '@aztec/key-store';
5
- import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
6
- import { AddressStore, AnchorBlockStore, CapsuleService, CapsuleStore, ContractSyncService, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
7
- import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
5
+ import { openEphemeralStore } from '@aztec/kv-store/lmdb-v2';
6
+ import { AddressStore, AnchorBlockStore, AnchoredContractData, CapsuleService, CapsuleStore, FactService, FactStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderTaggingStore, TaggingSecretSourcesStore, composeHooks } from '@aztec/pxe/server';
7
+ import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, LEGACY_ORACLE_REGISTRY, TransientArrayService, UtilityExecutionOracle, buildACIRCallback } from '@aztec/pxe/simulator';
8
8
  import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
9
+ import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-registry/constants';
9
10
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
10
11
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
11
- import { GasSettings } from '@aztec/stdlib/gas';
12
12
  import { computeProtocolNullifier } from '@aztec/stdlib/hash';
13
13
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
14
- import { CallContext, TxContext } from '@aztec/stdlib/tx';
14
+ import { CallContext, OFFCHAIN_MESSAGE_IDENTIFIER, TxContext } from '@aztec/stdlib/tx';
15
15
  import { z } from 'zod';
16
- import { DEFAULT_ADDRESS } from './constants.js';
16
+ import { DEFAULT_ADDRESS, MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY, MAX_OFFCHAIN_EFFECT_LEN } from './constants.js';
17
+ import { makeResolveTaggingSecretStrategyHook } from './oracle/tagging_secret_strategy.js';
17
18
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
18
- import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
19
- import { RPCTranslator } from './rpc_translator.js';
19
+ import { callTxeLegacyHandler } from './oracle/txe_oracle_registry.js';
20
+ import { TXEOracleTopLevelContext, authorizeAllUtilityCallsHook } from './oracle/txe_oracle_top_level_context.js';
21
+ import { TXE_ORACLE_VERSION_MAJOR, TXE_ORACLE_VERSION_MINOR } from './oracle/txe_oracle_version.js';
22
+ import { TXEPrivateExecutionOracle } from './oracle/txe_private_execution_oracle.js';
23
+ import { RPCTranslator, UnavailableOracleError } from './rpc_translator.js';
20
24
  import { TXEArchiver } from './state_machine/archiver.js';
21
25
  import { TXEStateMachine } from './state_machine/index.js';
22
- import { TXEAccountStore } from './util/txe_account_store.js';
23
26
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
24
27
  import { makeTxEffect } from './utils/tx_effect_creation.js';
28
+ import { TXEAccountStore } from './utils/txe_account_store.js';
29
+ function emptyLastCallState() {
30
+ return {
31
+ offchainEffects: [],
32
+ queried: false,
33
+ txHash: Fr.ZERO,
34
+ anchorBlockTimestamp: 0n
35
+ };
36
+ }
25
37
  /**
26
38
  * A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
27
39
  * state, etc., independent of all other tests running in parallel.
28
40
  */ export class TXESession {
29
41
  logger;
42
+ sessionStore;
30
43
  stateMachine;
31
44
  oracleHandler;
32
45
  contractStore;
@@ -36,19 +49,28 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
36
49
  accountStore;
37
50
  senderTaggingStore;
38
51
  recipientTaggingStore;
39
- senderAddressBookStore;
52
+ taggingSecretSourcesStore;
40
53
  capsuleStore;
54
+ factStore;
41
55
  privateEventStore;
42
56
  jobCoordinator;
43
57
  currentJobId;
44
58
  chainId;
45
59
  version;
46
60
  nextBlockTimestamp;
47
- contractSyncService;
61
+ artifactResolver;
62
+ rootPath;
63
+ packageName;
48
64
  state;
49
65
  authwits;
50
- constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp, contractSyncService){
66
+ taggingSecretStrategies;
67
+ authorizeAllUtilityCallTargets;
68
+ lastCallInfo;
69
+ txeOracleVersion;
70
+ disposed;
71
+ constructor(logger, sessionStore, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, taggingSecretSourcesStore, capsuleStore, factStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp, artifactResolver, rootPath, packageName){
51
72
  this.logger = logger;
73
+ this.sessionStore = sessionStore;
52
74
  this.stateMachine = stateMachine;
53
75
  this.oracleHandler = oracleHandler;
54
76
  this.contractStore = contractStore;
@@ -58,52 +80,85 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
58
80
  this.accountStore = accountStore;
59
81
  this.senderTaggingStore = senderTaggingStore;
60
82
  this.recipientTaggingStore = recipientTaggingStore;
61
- this.senderAddressBookStore = senderAddressBookStore;
83
+ this.taggingSecretSourcesStore = taggingSecretSourcesStore;
62
84
  this.capsuleStore = capsuleStore;
85
+ this.factStore = factStore;
63
86
  this.privateEventStore = privateEventStore;
64
87
  this.jobCoordinator = jobCoordinator;
65
88
  this.currentJobId = currentJobId;
66
89
  this.chainId = chainId;
67
90
  this.version = version;
68
91
  this.nextBlockTimestamp = nextBlockTimestamp;
69
- this.contractSyncService = contractSyncService;
92
+ this.artifactResolver = artifactResolver;
93
+ this.rootPath = rootPath;
94
+ this.packageName = packageName;
70
95
  this.state = {
71
96
  name: 'TOP_LEVEL'
72
97
  };
73
98
  this.authwits = new Map();
99
+ this.taggingSecretStrategies = new Map();
100
+ this.authorizeAllUtilityCallTargets = false;
101
+ this.lastCallInfo = emptyLastCallState();
102
+ this.disposed = false;
74
103
  }
75
- static async init(contractStore) {
76
- const store = await openTmpStore('txe-session');
104
+ /**
105
+ * Closes the per-session `txe-session` LMDB and the `NativeWorldStateService` .
106
+ * Called via IPC when the dispatcher detects the end of a test. Idempotent.
107
+ */ async dispose() {
108
+ if (this.disposed) {
109
+ return;
110
+ }
111
+ this.disposed = true;
112
+ try {
113
+ await this.stateMachine.synchronizer.nativeWorldStateService.close();
114
+ } catch (err) {
115
+ this.logger.warn(`Error closing native world state during session dispose`, err);
116
+ }
117
+ try {
118
+ await this.sessionStore.close();
119
+ } catch (err) {
120
+ this.logger.warn(`Error closing session LMDB during dispose`, err);
121
+ }
122
+ }
123
+ static async init(contractStore, artifactResolver, rootPath, packageName) {
124
+ // Size LMDB's reader slots to the libuv pool (capped to 2 in bin/index.ts via
125
+ // HARDWARE_CONCURRENCY): each native LMDB read needs a libuv worker thread to run, so any
126
+ // slot beyond the pool size would sit idle while still consuming a semaphore + reader-table
127
+ // entry per session.
128
+ const store = await openEphemeralStore('txe-session', undefined, 2);
77
129
  const addressStore = new AddressStore(store);
78
130
  const privateEventStore = new PrivateEventStore(store);
79
131
  const noteStore = new NoteStore(store);
80
132
  const senderTaggingStore = new SenderTaggingStore(store);
81
133
  const recipientTaggingStore = new RecipientTaggingStore(store);
82
- const senderAddressBookStore = new SenderAddressBookStore(store);
134
+ const taggingSecretSourcesStore = new TaggingSecretSourcesStore(store);
83
135
  const capsuleStore = new CapsuleStore(store);
136
+ const factStore = new FactStore(store);
84
137
  const keyStore = new KeyStore(store);
85
138
  const accountStore = new TXEAccountStore(store);
86
- // Create job coordinator and register staged stores
139
+ const archiver = new TXEArchiver(store);
140
+ const anchorBlockStore = new AnchorBlockStore(store);
141
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
87
142
  const jobCoordinator = new JobCoordinator(store);
88
143
  jobCoordinator.registerStores([
89
144
  capsuleStore,
145
+ factStore,
90
146
  senderTaggingStore,
91
147
  recipientTaggingStore,
92
148
  privateEventStore,
93
- noteStore
149
+ noteStore,
150
+ stateMachine.contractSyncService
94
151
  ]);
95
- const archiver = new TXEArchiver(store);
96
- const anchorBlockStore = new AnchorBlockStore(store);
97
- const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
98
152
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
99
153
  const version = new Fr(await stateMachine.node.getVersion());
100
154
  const chainId = new Fr(await stateMachine.node.getChainId());
101
155
  const initialJobId = jobCoordinator.beginJob();
102
156
  const logger = createLogger('txe:session');
103
- const contractSyncService = new ContractSyncService(stateMachine.node, contractStore, noteStore, logger);
104
- const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map(), contractSyncService);
105
- await topLevelOracleHandler.advanceBlocksBy(1);
106
- return new TXESession(logger, stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp, contractSyncService);
157
+ const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, taggingSecretSourcesStore, capsuleStore, factStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map(), new Map(), false, artifactResolver, rootPath, packageName);
158
+ await topLevelOracleHandler.mineDeploymentNullifiers([
159
+ STANDARD_AUTH_REGISTRY_ADDRESS
160
+ ]);
161
+ return new TXESession(logger, store, stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, taggingSecretSourcesStore, capsuleStore, factStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp, artifactResolver, rootPath, packageName);
107
162
  }
108
163
  /**
109
164
  * Processes an oracle function invoked by the Noir test associated to this session.
@@ -112,13 +167,28 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
112
167
  * @returns The oracle return values.
113
168
  */ processFunction(functionName, inputs) {
114
169
  try {
170
+ // Oracles retired into the PXE legacy registry have no translator method; dispatch them through the same
171
+ // buildACIRCallback legacy path that contract execution uses, keeping TXE's two oracle paths in sync.
172
+ // Use an own-property check: `in` would match inherited `Object.prototype` keys (e.g. `constructor`), routing
173
+ // them into the legacy path instead of letting them fall through to the unknown-oracle error.
174
+ if (Object.hasOwn(LEGACY_ORACLE_REGISTRY, functionName)) {
175
+ return callTxeLegacyHandler(functionName, inputs, this.oracleHandler);
176
+ }
115
177
  const translator = new RPCTranslator(this, this.oracleHandler);
116
178
  // We perform a runtime validation to check that the function name corresponds to a real oracle handler.
117
179
  const validatedFunctionName = z.string().refine((fn)=>typeof translator[fn] === 'function' && !fn.startsWith('handlerAs') && fn !== 'constructor').parse(functionName);
118
180
  return translator[validatedFunctionName](...inputs);
119
181
  } catch (error) {
120
182
  if (error instanceof z.ZodError) {
121
- throw new Error(`${functionName} does not correspond to any oracle handler available on RPCTranslator`);
183
+ let versionHint;
184
+ if (!this.txeOracleVersion) {
185
+ versionHint = ' The test appears to use an older version of Aztec.nr that does not' + ' support test environment oracle versioning. Update Aztec.nr to a compatible version.' + ' See https://docs.aztec.network/errors/12';
186
+ } else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
187
+ versionHint = ` The test uses Aztec.nr test oracle version` + ` ${this.txeOracleVersion.major}.${this.txeOracleVersion.minor}, but this test environment` + ` only supports up to ${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}.` + ` Upgrade the Aztec CLI to a compatible version.` + ` See https://docs.aztec.network/errors/12`;
188
+ } else {
189
+ versionHint = ` The test's oracle version (${this.txeOracleVersion.major}.${this.txeOracleVersion.minor})` + ` is compatible with this test environment` + ` (${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}), so this oracle should be` + ` available. This is an unexpected error, please report it.` + ` See https://docs.aztec.network/errors/13`;
190
+ }
191
+ throw new Error(`Unknown oracle '${functionName}'.${versionHint}`);
122
192
  } else if (error instanceof Error) {
123
193
  throw new Error(`Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`);
124
194
  } else {
@@ -126,14 +196,132 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
126
196
  }
127
197
  }
128
198
  }
129
- getCurrentJob() {
130
- return this.currentJobId;
131
- }
132
199
  /** Commits the current job and begins a new one. Returns the new job ID. */ async cycleJob() {
133
200
  await this.jobCoordinator.commitJob(this.currentJobId);
134
201
  this.currentJobId = this.jobCoordinator.beginJob();
135
202
  return this.currentJobId;
136
203
  }
204
+ resetLastCall() {
205
+ const notQueriedMessageCount = this.lastCallInfo.queried ? 0 : this.lastCallInfo.offchainEffects.filter((payload)=>payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
206
+ if (notQueriedMessageCount > 0) {
207
+ this.logger.warn(`Dropping ${notQueriedMessageCount} unqueried offchain message(s) from the previous top-level call. ` + `To deliver them, call \`env.offchain_messages()\` and forward the result to the recipient contract's ` + `\`offchain_receive\` utility before issuing another top-level call. To intentionally discard, assign ` + `to \`let _ = env.offchain_messages()\` to silence this warning.`);
208
+ }
209
+ this.lastCallInfo = emptyLastCallState();
210
+ }
211
+ recordOffchainEffect(data) {
212
+ this.lastCallInfo.offchainEffects.push(data);
213
+ }
214
+ setLastCallContext(txHash, anchorBlockTimestamp) {
215
+ this.lastCallInfo.txHash = txHash;
216
+ this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
217
+ }
218
+ async withTopLevelCallTracking(work) {
219
+ this.resetLastCall();
220
+ // Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
221
+ // side effect, and that block's timestamp should not be attributed to this call's anchor.
222
+ const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest')).header.globalVariables.timestamp;
223
+ const { result, txHash } = await work();
224
+ this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
225
+ return result;
226
+ }
227
+ getLastCallOffchainEffects() {
228
+ this.lastCallInfo.queried = true;
229
+ const effects = this.lastCallInfo.offchainEffects;
230
+ if (effects.length > MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY) {
231
+ throw new Error(`${effects.length} offchain effects exceed max ${MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY}`);
232
+ }
233
+ if (effects.some((e)=>e.length > MAX_OFFCHAIN_EFFECT_LEN)) {
234
+ throw new Error(`Some offchain effect has length larger than max ${MAX_OFFCHAIN_EFFECT_LEN}`);
235
+ }
236
+ return {
237
+ effects
238
+ };
239
+ }
240
+ getLastCallContext() {
241
+ const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
242
+ return {
243
+ txHash,
244
+ anchorBlockTimestamp
245
+ };
246
+ }
247
+ async executePrivateCall(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, authorizedUtilityCallTargets, gasSettings) {
248
+ const handler = this.handlerAsTxe();
249
+ return await this.withTopLevelCallTracking(async ()=>{
250
+ const { returnValues, offchainEffects } = await handler.privateCallNewFlow(from?.value, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, this.currentJobId, authorizedUtilityCallTargets, gasSettings);
251
+ // Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than round-tripping
252
+ // them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty at this point. Drain the effects
253
+ // from the execution tree into the session buffer so the next `env.offchain_messages()` call in the test sees
254
+ // them.
255
+ for (const data of offchainEffects){
256
+ this.recordOffchainEffect(data);
257
+ }
258
+ await this.cycleJob();
259
+ if (isStaticCall) {
260
+ // Static calls revert their checkpoint and mine no block, so there is no tx hash to tag offchain effects
261
+ // with. Querying `getLastTxEffects()` here would return an unrelated predecessor tx.
262
+ return {
263
+ result: returnValues
264
+ };
265
+ }
266
+ const { txHash } = await handler.getLastTxEffects();
267
+ return {
268
+ result: returnValues,
269
+ txHash: txHash.hash
270
+ };
271
+ });
272
+ }
273
+ async executeUtilityFunction(from, targetContractAddress, functionSelector, args, authorizedUtilityCallTargets) {
274
+ const handler = this.handlerAsTxe();
275
+ return await this.withTopLevelCallTracking(async ()=>{
276
+ const returnValues = await handler.executeUtilityFunction(from?.value, targetContractAddress, functionSelector, args, this.currentJobId, authorizedUtilityCallTargets);
277
+ await this.cycleJob();
278
+ return {
279
+ result: returnValues
280
+ };
281
+ });
282
+ }
283
+ async executePublicCall(from, targetContractAddress, calldata, isStaticCall, gasSettings) {
284
+ const handler = this.handlerAsTxe();
285
+ return await this.withTopLevelCallTracking(async ()=>{
286
+ const returnValues = await handler.publicCallNewFlow(from?.value, targetContractAddress, calldata, isStaticCall, gasSettings);
287
+ await this.cycleJob();
288
+ if (isStaticCall) {
289
+ // See the equivalent branch in `executePrivateCall`.
290
+ return {
291
+ result: returnValues
292
+ };
293
+ }
294
+ const { txHash } = await handler.getLastTxEffects();
295
+ return {
296
+ result: returnValues,
297
+ txHash: txHash.hash
298
+ };
299
+ });
300
+ }
301
+ async getPrivateEvents(selector, contractAddress, scope) {
302
+ const handler = this.handlerAsTxe();
303
+ await handler.syncContractNonOracleMethod(contractAddress, scope, this.currentJobId);
304
+ // Cycle the job to commit the stores after the contract sync.
305
+ await this.cycleJob();
306
+ return handler.getPrivateEvents(selector, contractAddress, scope);
307
+ }
308
+ handlerAsTxe() {
309
+ if (!('isTxe' in this.oracleHandler)) {
310
+ throw new UnavailableOracleError('Txe');
311
+ }
312
+ return this.oracleHandler;
313
+ }
314
+ setTxeOracleVersion(major, minor) {
315
+ if (major !== TXE_ORACLE_VERSION_MAJOR) {
316
+ const hint = major > TXE_ORACLE_VERSION_MAJOR ? 'The test was compiled with a newer version of Aztec.nr than your test environment supports. Upgrade your test environment to a compatible version.' : 'The test was compiled with an older version of Aztec.nr than your test environment supports. Recompile the test with a compatible version of Aztec.nr.';
317
+ throw new Error(`Incompatible test environment version: ${hint} See https://docs.aztec.network/errors/12 (expected test oracle major version ${TXE_ORACLE_VERSION_MAJOR}, got ${major})`);
318
+ }
319
+ this.txeOracleVersion = {
320
+ major,
321
+ minor
322
+ };
323
+ this.logger.debug(`Test compiled with test oracle version ${major}.${minor}`);
324
+ }
137
325
  async enterTopLevelState() {
138
326
  switch(this.state.name){
139
327
  case 'PRIVATE':
@@ -162,20 +350,23 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
162
350
  }
163
351
  // Commit all staged stores from the job that was just completed, then begin a new job
164
352
  await this.cycleJob();
165
- this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.nextBlockTimestamp, this.version, this.chainId, this.authwits, this.contractSyncService);
353
+ this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.taggingSecretSourcesStore, this.capsuleStore, this.factStore, this.privateEventStore, this.nextBlockTimestamp, this.version, this.chainId, this.authwits, this.taggingSecretStrategies, this.authorizeAllUtilityCallTargets, this.artifactResolver, this.rootPath, this.packageName);
166
354
  this.state = {
167
355
  name: 'TOP_LEVEL'
168
356
  };
169
357
  this.logger.debug(`Entered state ${this.state.name}`);
170
358
  }
171
- async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
359
+ async enterPrivateState(contractAddressOpt, anchorBlockNumberOpt, gasSettings) {
360
+ const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
361
+ const anchorBlockNumber = anchorBlockNumberOpt?.value;
172
362
  this.exitTopLevelState();
363
+ this.resetLastCall();
173
364
  // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
174
365
  // build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
175
366
  // a single transaction with the effects of what was done in the test.
176
- const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
367
+ const anchorBlock = await this.stateMachine.node.getBlock(anchorBlockNumber ?? 'latest').then((b)=>b?.header);
177
368
  await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
178
- const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
369
+ const latestBlock = await this.stateMachine.node.getBlock('latest').then((b)=>b?.header);
179
370
  const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
180
371
  blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
181
372
  timestamp: this.nextBlockTimestamp,
@@ -187,9 +378,12 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
187
378
  const noteCache = new ExecutionNoteCache(protocolNullifier);
188
379
  const taggingIndexCache = new ExecutionTaggingIndexCache();
189
380
  const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
190
- this.oracleHandler = new PrivateExecutionOracle({
381
+ const transientArrayService = new TransientArrayService();
382
+ const anchoredContractData = new AnchoredContractData(this.contractStore, this.stateMachine.contractClassService, anchorBlock);
383
+ this.oracleHandler = new TXEPrivateExecutionOracle({
191
384
  argsHash: Fr.ZERO,
192
- txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
385
+ txContext: new TxContext(this.chainId, this.version, gasSettings),
386
+ txRequestSalt: Fr.ZERO,
193
387
  callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
194
388
  anchorBlockHeader: anchorBlock,
195
389
  utilityExecutor,
@@ -198,20 +392,28 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
198
392
  executionCache: new HashedValuesCache(),
199
393
  noteCache,
200
394
  taggingIndexCache,
201
- contractStore: this.contractStore,
395
+ anchoredContractData,
202
396
  noteStore: this.noteStore,
203
397
  keyStore: this.keyStore,
204
398
  addressStore: this.addressStore,
205
399
  aztecNode: this.stateMachine.node,
206
400
  senderTaggingStore: this.senderTaggingStore,
207
401
  recipientTaggingStore: this.recipientTaggingStore,
208
- senderAddressBookStore: this.senderAddressBookStore,
402
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
209
403
  capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
404
+ factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
210
405
  privateEventStore: this.privateEventStore,
211
406
  contractSyncService: this.stateMachine.contractSyncService,
407
+ l2TipsStore: this.stateMachine.l2TipsProvider,
212
408
  jobId: this.currentJobId,
213
409
  scopes: await this.keyStore.getAccounts(),
214
- messageContextService: this.stateMachine.messageContextService
410
+ txResolver: this.stateMachine.txResolver,
411
+ simulator: new WASMSimulator(),
412
+ hooks: composeHooks({
413
+ resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
414
+ authorizeUtilityCall: this.authorizeAllUtilityCallTargets ? authorizeAllUtilityCallsHook : undefined
415
+ }),
416
+ transientArrayService
215
417
  });
216
418
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
217
419
  // data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
@@ -225,27 +427,36 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
225
427
  taggingIndexCache
226
428
  };
227
429
  this.logger.debug(`Entered state ${this.state.name}`);
430
+ // Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
431
+ // via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
432
+ this.setLastCallContext(Fr.ZERO, anchorBlock.globalVariables.timestamp);
228
433
  return this.oracleHandler.getPrivateContextInputs();
229
434
  }
230
- async enterPublicState(contractAddress) {
435
+ async enterPublicState(contractAddressOpt) {
436
+ const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
231
437
  this.exitTopLevelState();
438
+ this.resetLastCall();
232
439
  // The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
233
440
  // the test. The block therefore gets the *next* block number and timestamp.
234
- const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.blockNumber;
441
+ const latestHeader = (await this.stateMachine.node.getBlockData('latest')).header;
235
442
  const globalVariables = makeGlobalVariables(undefined, {
236
- blockNumber: BlockNumber(latestBlockNumber + 1),
443
+ blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
237
444
  timestamp: this.nextBlockTimestamp,
238
445
  version: this.version,
239
446
  chainId: this.chainId
240
447
  });
241
- this.oracleHandler = new TXEOraclePublicContext(contractAddress ?? DEFAULT_ADDRESS, await this.stateMachine.synchronizer.nativeWorldStateService.fork(), getSingleTxBlockRequestHash(globalVariables.blockNumber), globalVariables);
448
+ this.oracleHandler = new TXEOraclePublicContext(contractAddress, await this.stateMachine.synchronizer.nativeWorldStateService.fork(), getSingleTxBlockRequestHash(globalVariables.blockNumber), globalVariables, this.contractStore);
242
449
  this.state = {
243
450
  name: 'PUBLIC'
244
451
  };
245
452
  this.logger.debug(`Entered state ${this.state.name}`);
453
+ // Public state is anchored at the latest block.
454
+ this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
246
455
  }
247
- async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
456
+ async enterUtilityState(contractAddressOpt) {
457
+ const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
248
458
  this.exitTopLevelState();
459
+ this.resetLastCall();
249
460
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
250
461
  // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
251
462
  // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
@@ -254,43 +465,62 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
254
465
  // TODO(#12553): make the synchronizer sync here instead and remove this
255
466
  await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
256
467
  this.oracleHandler = new UtilityExecutionOracle({
257
- contractAddress,
468
+ callContext: CallContext.from({
469
+ msgSender: AztecAddress.NULL_MSG_SENDER,
470
+ contractAddress,
471
+ // No specific function is being executed in this inlined utility context, hence the empty selector.
472
+ functionSelector: FunctionSelector.empty(),
473
+ isStaticCall: true
474
+ }),
258
475
  authWitnesses: [],
259
476
  capsules: [],
260
477
  anchorBlockHeader,
261
- contractStore: this.contractStore,
478
+ anchoredContractData: new AnchoredContractData(this.contractStore, this.stateMachine.contractClassService, anchorBlockHeader),
262
479
  noteStore: this.noteStore,
263
480
  keyStore: this.keyStore,
264
481
  addressStore: this.addressStore,
265
482
  aztecNode: this.stateMachine.node,
266
483
  recipientTaggingStore: this.recipientTaggingStore,
267
- senderAddressBookStore: this.senderAddressBookStore,
484
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
268
485
  capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
486
+ factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
269
487
  privateEventStore: this.privateEventStore,
270
- messageContextService: this.stateMachine.messageContextService,
271
- contractSyncService: this.contractSyncService,
488
+ txResolver: this.stateMachine.txResolver,
489
+ contractSyncService: this.stateMachine.contractSyncService,
490
+ l2TipsStore: this.stateMachine.l2TipsProvider,
272
491
  jobId: this.currentJobId,
273
- scopes: await this.keyStore.getAccounts()
492
+ scopes: await this.keyStore.getAccounts(),
493
+ simulator: new WASMSimulator(),
494
+ utilityExecutor: this.utilityExecutorForContractSync(anchorBlockHeader),
495
+ hooks: composeHooks({
496
+ authorizeUtilityCall: this.authorizeAllUtilityCallTargets ? authorizeAllUtilityCallsHook : undefined
497
+ }),
498
+ // Execution-tree root (top-level utility run): own store; nested frames inherit it.
499
+ transientArrayService: new TransientArrayService()
274
500
  });
275
501
  this.state = {
276
502
  name: 'UTILITY'
277
503
  };
278
504
  this.logger.debug(`Entered state ${this.state.name}`);
505
+ // Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
506
+ this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
279
507
  }
280
508
  exitTopLevelState() {
281
509
  if (this.state.name != 'TOP_LEVEL') {
282
510
  throw new Error(`Expected to be in state 'TOP_LEVEL', but got '${this.state.name}' instead`);
283
511
  }
284
512
  // Note that while all public and private contexts do is build a single block that we then process when exiting
285
- // those, the top level context performs a large number of actions not captured in the following 'close' call. Among
286
- // others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
287
- // `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
288
- // slight inconsistency in the working model of this class, but is not too bad.
289
- // TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
290
- // level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
291
- // the authwits if not persisted, so we'd not be able to pass more than one per execution.
292
- // Ideally authwits would be passed alongside a contract call instead of pre-seeded.
293
- [this.nextBlockTimestamp, this.authwits] = this.oracleHandler.close();
513
+ // them, the top level context does most of its work as it goes: it creates empty blocks (via `advanceBlocksBy`
514
+ // and `deploy`), creates blocks with transactions (via `privateCallNewFlow` and `publicCallNewFlow`), adds
515
+ // accounts to PXE (via `addAccount`), etc. This is a slight inconsistency in the working model of this class, but
516
+ // is not too bad. The `close` call below therefore only hands back the session-scoped values that a test
517
+ // sets directly at the top level, outside any contract execution (e.g. via `advanceTimestampBy`,
518
+ // `addAuthWitness`, `setTaggingSecretStrategies`). The oracle handler is discarded on every state transition,
519
+ // so the session must seed these values into the contexts it creates later.
520
+ // TODO: persisting authwits this way is quite unfortunate: they create a temporary utility context that would
521
+ // otherwise reset them, so we'd not be able to pass more than one per execution. Ideally authwits would be passed
522
+ // alongside a contract call instead of pre-seeded.
523
+ ({ nextBlockTimestamp: this.nextBlockTimestamp, authwits: this.authwits, taggingSecretStrategies: this.taggingSecretStrategies, authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets } = this.oracleHandler.close());
294
524
  }
295
525
  async exitPrivateState() {
296
526
  if (this.state.name != 'PRIVATE') {
@@ -329,31 +559,47 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
329
559
  }
330
560
  utilityExecutorForContractSync(anchorBlock) {
331
561
  return async (call, scopes)=>{
332
- const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
562
+ const anchoredContractData = new AnchoredContractData(this.contractStore, this.stateMachine.contractClassService, anchorBlock);
563
+ const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
564
+ if (!entryPointArtifact) {
565
+ throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
566
+ }
333
567
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
334
568
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
335
569
  }
336
570
  try {
571
+ const simulator = new WASMSimulator();
337
572
  const oracle = new UtilityExecutionOracle({
338
- contractAddress: call.to,
573
+ callContext: CallContext.from({
574
+ msgSender: AztecAddress.NULL_MSG_SENDER,
575
+ contractAddress: call.to,
576
+ functionSelector: call.selector,
577
+ isStaticCall: true
578
+ }),
339
579
  authWitnesses: [],
340
580
  capsules: [],
341
581
  anchorBlockHeader: anchorBlock,
342
- contractStore: this.contractStore,
582
+ anchoredContractData,
343
583
  noteStore: this.noteStore,
344
584
  keyStore: this.keyStore,
345
585
  addressStore: this.addressStore,
346
586
  aztecNode: this.stateMachine.node,
347
587
  recipientTaggingStore: this.recipientTaggingStore,
348
- senderAddressBookStore: this.senderAddressBookStore,
588
+ taggingSecretSourcesStore: this.taggingSecretSourcesStore,
349
589
  capsuleService: new CapsuleService(this.capsuleStore, scopes),
590
+ factService: new FactService(this.factStore, scopes),
350
591
  privateEventStore: this.privateEventStore,
351
- messageContextService: this.stateMachine.messageContextService,
352
- contractSyncService: this.contractSyncService,
592
+ txResolver: this.stateMachine.txResolver,
593
+ contractSyncService: this.stateMachine.contractSyncService,
594
+ l2TipsStore: this.stateMachine.l2TipsProvider,
353
595
  jobId: this.currentJobId,
354
- scopes
596
+ scopes,
597
+ simulator,
598
+ utilityExecutor: this.utilityExecutorForContractSync(anchorBlock),
599
+ // Top-level utility entrypoint: gets a fresh store. Nested frames inherit it via UtilityExecutionOracle.
600
+ transientArrayService: new TransientArrayService()
355
601
  });
356
- await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
602
+ await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle)).catch((err)=>{
357
603
  err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
358
604
  throw new ExecutionError(err.message, {
359
605
  contractAddress: call.to,
@@ -9,7 +9,7 @@ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
9
9
  * @returns The transaction request hash.
10
10
  */
11
11
  export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
12
- export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
12
+ export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations, l1ToL2Messages?: Fr[]): Promise<void>;
13
13
  export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
14
14
  /**
15
15
  * Creates an L2Block with proper archive chaining.
@@ -25,4 +25,4 @@ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations
25
25
  * @returns The created L2Block with proper archive chaining
26
26
  */
27
27
  export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUEyQyxNQUFNLGlDQUFpQyxDQUFDO0FBRXZHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQVEsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEQsT0FBTyxFQUF3QyxLQUFLLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDM0csT0FBTyxFQUFFLFdBQVcsRUFBRSxlQUFlLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUU7Ozs7R0FJRztBQUNILHdCQUFnQiwyQkFBMkIsQ0FBQyxXQUFXLEVBQUUsV0FBVyxHQUFHLEVBQUUsQ0FFeEU7QUFFRCx3QkFBc0IsNEJBQTRCLENBQ2hELFFBQVEsRUFBRSxRQUFRLEVBQ2xCLFVBQVUsRUFBRSx5QkFBeUIsR0FDcEMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWtCZjtBQUVELHdCQUFzQixrQkFBa0IsQ0FDdEMsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxlQUFlLEVBQUUsZUFBZSxHQUMvQixPQUFPLENBQUMsV0FBVyxDQUFDLENBWXRCO0FBRUQ7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLFlBQVksQ0FDaEMsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxlQUFlLEVBQUUsZUFBZSxFQUNoQyxTQUFTLEVBQUUsUUFBUSxFQUFFLEdBQ3BCLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FpQmxCIn0=
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUEyQyxNQUFNLGlDQUFpQyxDQUFDO0FBRXZHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQVEsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEQsT0FBTyxFQUF3QyxLQUFLLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDM0csT0FBTyxFQUFFLFdBQVcsRUFBRSxlQUFlLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUU7Ozs7R0FJRztBQUNILHdCQUFnQiwyQkFBMkIsQ0FBQyxXQUFXLEVBQUUsV0FBVyxHQUFHLEVBQUUsQ0FFeEU7QUFFRCx3QkFBc0IsNEJBQTRCLENBQ2hELFFBQVEsRUFBRSxRQUFRLEVBQ2xCLFVBQVUsRUFBRSx5QkFBeUIsRUFDckMsY0FBYyxHQUFFLEVBQUUsRUFBTyxHQUN4QixPQUFPLENBQUMsSUFBSSxDQUFDLENBa0JmO0FBRUQsd0JBQXNCLGtCQUFrQixDQUN0QyxVQUFVLEVBQUUseUJBQXlCLEVBQ3JDLGVBQWUsRUFBRSxlQUFlLEdBQy9CLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FZdEI7QUFFRDs7Ozs7Ozs7Ozs7O0dBWUc7QUFDSCx3QkFBc0IsWUFBWSxDQUNoQyxVQUFVLEVBQUUseUJBQXlCLEVBQ3JDLGVBQWUsRUFBRSxlQUFlLEVBQ2hDLFNBQVMsRUFBRSxRQUFRLEVBQUUsR0FDcEIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQWlCbEIifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAA2C,MAAM,iCAAiC,CAAC;AAEvG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAQ,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAiBlB"}
1
+ {"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAA2C,MAAM,iCAAiC,CAAC;AAEvG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAQ,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,EACrC,cAAc,GAAE,EAAE,EAAO,GACxB,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAiBlB"}