@aztec/txe 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240

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 (138) hide show
  1. package/dest/ContractClassRegistry-KKNT527R.js +3 -0
  2. package/dest/ContractClassRegistry-KKNT527R.js.map +7 -0
  3. package/dest/ContractInstanceRegistry-GSKBNL3Q.js +3 -0
  4. package/dest/ContractInstanceRegistry-GSKBNL3Q.js.map +7 -0
  5. package/dest/FeeJuice-GUJ5O6GB.js +3 -0
  6. package/dest/FeeJuice-GUJ5O6GB.js.map +7 -0
  7. package/dest/MultiCallEntrypoint-ZQPCKVKL.js +3 -0
  8. package/dest/MultiCallEntrypoint-ZQPCKVKL.js.map +7 -0
  9. package/dest/SchnorrAccount-QIXE5DXA.js +3 -0
  10. package/dest/SchnorrAccount-QIXE5DXA.js.map +7 -0
  11. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  12. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  13. package/dest/bin/check_txe_oracle_version.js +32 -0
  14. package/dest/bin/index.js +3 -30
  15. package/dest/bin/index.js.map +7 -0
  16. package/dest/chunk-BJVAAXNA.js +3 -0
  17. package/dest/chunk-BJVAAXNA.js.map +7 -0
  18. package/dest/chunk-DF6RMOC6.js +304 -0
  19. package/dest/chunk-DF6RMOC6.js.map +7 -0
  20. package/dest/chunk-PPJTNNUG.js +265 -0
  21. package/dest/chunk-PPJTNNUG.js.map +7 -0
  22. package/dest/constants.d.ts +3 -2
  23. package/dest/constants.d.ts.map +1 -1
  24. package/dest/constants.js +5 -1
  25. package/dest/dispatcher_pool.d.ts +67 -0
  26. package/dest/dispatcher_pool.d.ts.map +1 -0
  27. package/dest/dispatcher_pool.js +284 -0
  28. package/dest/index.d.ts +188 -7
  29. package/dest/index.d.ts.map +1 -1
  30. package/dest/index.js +148 -75
  31. package/dest/metafile.json +38147 -0
  32. package/dest/msgpackr_fr_extension.d.ts +2 -0
  33. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  34. package/dest/msgpackr_fr_extension.js +21 -0
  35. package/dest/oracle/interfaces.d.ts +40 -28
  36. package/dest/oracle/interfaces.d.ts.map +1 -1
  37. package/dest/oracle/txe_oracle_public_context.d.ts +18 -13
  38. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  39. package/dest/oracle/txe_oracle_public_context.js +31 -16
  40. package/dest/oracle/txe_oracle_top_level_context.d.ts +39 -23
  41. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  42. package/dest/oracle/txe_oracle_top_level_context.js +225 -89
  43. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  44. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  45. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  46. package/dest/rpc_server.d.ts +14 -0
  47. package/dest/rpc_server.d.ts.map +1 -0
  48. package/dest/rpc_server.js +78 -0
  49. package/dest/rpc_translator.d.ts +144 -82
  50. package/dest/rpc_translator.d.ts.map +1 -1
  51. package/dest/rpc_translator.js +599 -238
  52. package/dest/server.bundle.js +3 -0
  53. package/dest/server.bundle.js.map +7 -0
  54. package/dest/state_machine/archiver.d.ts +20 -69
  55. package/dest/state_machine/archiver.d.ts.map +1 -1
  56. package/dest/state_machine/archiver.js +47 -187
  57. package/dest/state_machine/dummy_p2p_client.d.ts +26 -16
  58. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  59. package/dest/state_machine/dummy_p2p_client.js +44 -20
  60. package/dest/state_machine/global_variable_builder.d.ts +9 -4
  61. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  62. package/dest/state_machine/global_variable_builder.js +9 -3
  63. package/dest/state_machine/index.d.ts +10 -6
  64. package/dest/state_machine/index.d.ts.map +1 -1
  65. package/dest/state_machine/index.js +55 -14
  66. package/dest/state_machine/mock_epoch_cache.d.ts +25 -8
  67. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  68. package/dest/state_machine/mock_epoch_cache.js +46 -9
  69. package/dest/state_machine/synchronizer.d.ts +6 -6
  70. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  71. package/dest/state_machine/synchronizer.js +4 -4
  72. package/dest/txe_oracle_version.d.ts +17 -0
  73. package/dest/txe_oracle_version.d.ts.map +1 -0
  74. package/dest/txe_oracle_version.js +14 -0
  75. package/dest/txe_session.d.ts +73 -10
  76. package/dest/txe_session.d.ts.map +1 -1
  77. package/dest/txe_session.js +242 -39
  78. package/dest/utils/block_creation.d.ts +4 -4
  79. package/dest/utils/block_creation.d.ts.map +1 -1
  80. package/dest/utils/block_creation.js +18 -4
  81. package/dest/utils/encoding.d.ts +191 -0
  82. package/dest/utils/encoding.d.ts.map +1 -0
  83. package/dest/{util → utils}/encoding.js +7 -2
  84. package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
  85. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  86. package/dest/utils/tx_effect_creation.d.ts +2 -3
  87. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  88. package/dest/utils/tx_effect_creation.js +3 -6
  89. package/dest/{util → utils}/txe_account_store.d.ts +1 -1
  90. package/dest/utils/txe_account_store.d.ts.map +1 -0
  91. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  92. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  93. package/dest/{util → utils}/txe_public_contract_data_source.js +6 -25
  94. package/dest/worker.bundle.js +3 -0
  95. package/dest/worker.bundle.js.map +7 -0
  96. package/dest/worker.d.ts +2 -0
  97. package/dest/worker.d.ts.map +1 -0
  98. package/dest/worker.js +92 -0
  99. package/package.json +38 -22
  100. package/src/bin/check_txe_oracle_version.ts +37 -0
  101. package/src/bin/index.ts +11 -2
  102. package/src/constants.ts +6 -1
  103. package/src/dispatcher_pool.ts +316 -0
  104. package/src/index.ts +166 -80
  105. package/src/msgpackr_fr_extension.ts +23 -0
  106. package/src/oracle/interfaces.ts +48 -34
  107. package/src/oracle/txe_oracle_public_context.ts +46 -18
  108. package/src/oracle/txe_oracle_top_level_context.ts +282 -151
  109. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  110. package/src/rpc_server.ts +87 -0
  111. package/src/rpc_translator.ts +687 -326
  112. package/src/state_machine/archiver.ts +53 -235
  113. package/src/state_machine/dummy_p2p_client.ts +70 -32
  114. package/src/state_machine/global_variable_builder.ts +18 -3
  115. package/src/state_machine/index.ts +72 -15
  116. package/src/state_machine/mock_epoch_cache.ts +57 -14
  117. package/src/state_machine/synchronizer.ts +6 -6
  118. package/src/txe_oracle_version.ts +17 -0
  119. package/src/txe_session.ts +352 -104
  120. package/src/utils/block_creation.ts +19 -16
  121. package/src/{util → utils}/encoding.ts +8 -2
  122. package/src/utils/tx_effect_creation.ts +3 -11
  123. package/src/{util → utils}/txe_public_contract_data_source.ts +10 -38
  124. package/src/worker.ts +98 -0
  125. package/dest/util/encoding.d.ts +0 -720
  126. package/dest/util/encoding.d.ts.map +0 -1
  127. package/dest/util/expected_failure_error.d.ts.map +0 -1
  128. package/dest/util/txe_account_store.d.ts.map +0 -1
  129. package/dest/util/txe_contract_store.d.ts +0 -12
  130. package/dest/util/txe_contract_store.d.ts.map +0 -1
  131. package/dest/util/txe_contract_store.js +0 -22
  132. package/dest/util/txe_public_contract_data_source.d.ts +0 -21
  133. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  134. package/src/util/txe_contract_store.ts +0 -36
  135. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  136. /package/dest/{util → utils}/txe_account_store.js +0 -0
  137. /package/src/{util → utils}/expected_failure_error.ts +0 -0
  138. /package/src/{util → utils}/txe_account_store.ts +0 -0
@@ -1,10 +1,10 @@
1
- import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT, DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
1
+ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PRIVATE_LOGS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Schnorr } from '@aztec/foundation/crypto/schnorr';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
6
6
  import { TestDateProvider } from '@aztec/foundation/timer';
7
- import { ORACLE_VERSION, enrichPublicSimulationError } from '@aztec/pxe/server';
7
+ import { CapsuleService, ORACLE_VERSION_MAJOR, composeHooks, enrichPublicSimulationError } from '@aztec/pxe/server';
8
8
  import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle, executePrivateFunction, generateSimulatedProvingResult } from '@aztec/pxe/simulator';
9
9
  import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
10
10
  import { CppPublicTxSimulator, GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor } from '@aztec/simulator/server';
@@ -13,17 +13,18 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
13
13
  import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
15
  import { computePartialAddress } from '@aztec/stdlib/contract';
16
- import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
16
+ import { Gas, GasFees } from '@aztec/stdlib/gas';
17
17
  import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
18
18
  import { PartialPrivateTailPublicInputsForPublic, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PublicCallRequest } from '@aztec/stdlib/kernel';
19
+ import { hashPublicKey } from '@aztec/stdlib/keys';
19
20
  import { ChonkProof } from '@aztec/stdlib/proofs';
20
21
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
21
22
  import { MerkleTreeId } from '@aztec/stdlib/trees';
22
23
  import { CallContext, HashedValues, PrivateExecutionResult, Tx, TxConstantData, TxContext, TxEffect, TxHash, collectNested } from '@aztec/stdlib/tx';
23
- import { ForkCheckpoint } from '@aztec/world-state';
24
- import { DEFAULT_ADDRESS, TXE_JOB_ID } from '../constants.js';
25
- import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
24
+ import { ForkCheckpoint } from '@aztec/world-state/native';
25
+ import { DEFAULT_ADDRESS } from '../constants.js';
26
26
  import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
27
+ import { TXEPublicContractDataSource } from '../utils/txe_public_contract_data_source.js';
27
28
  export class TXEOracleTopLevelContext {
28
29
  stateMachine;
29
30
  contractStore;
@@ -64,52 +65,83 @@ export class TXEOracleTopLevelContext {
64
65
  this.logger = createLogger('txe:top_level_context');
65
66
  this.logger.debug('Entering Top Level Context');
66
67
  }
67
- utilityAssertCompatibleOracleVersion(version) {
68
- if (version !== ORACLE_VERSION) {
69
- throw new Error(`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`);
68
+ contractOracleVersion;
69
+ assertCompatibleOracleVersion(major, minor) {
70
+ if (major !== ORACLE_VERSION_MAJOR) {
71
+ const hint = major > ORACLE_VERSION_MAJOR ? 'The contract was compiled with a newer version of Aztec.nr than this aztec cli version supports. Upgrade your aztec cli version to a compatible version.' : 'The contract was compiled with an older version of Aztec.nr than this aztec cli version supports. Recompile the contract with a compatible version of Aztec.nr.';
72
+ throw new Error(`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`);
70
73
  }
74
+ this.contractOracleVersion = {
75
+ major,
76
+ minor
77
+ };
78
+ }
79
+ // Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
80
+ nonOracleFunctionGetContractOracleVersion() {
81
+ return this.contractOracleVersion;
71
82
  }
72
83
  // This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
73
84
  // setup.
74
- utilityGetRandomField() {
85
+ getRandomField() {
75
86
  return Fr.random();
76
87
  }
77
88
  // We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
78
- utilityDebugLog(level, message, fields) {
89
+ log(level, message, fields) {
79
90
  if (!LogLevels[level]) {
80
- throw new Error(`Invalid debug log level: ${level}`);
91
+ throw new Error(`Invalid log level: ${level}`);
81
92
  }
82
93
  const levelName = LogLevels[level];
83
94
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, {
84
95
  module: `${this.logger.module}:debug_log`
85
96
  });
97
+ return Promise.resolve();
86
98
  }
87
- txeGetDefaultAddress() {
99
+ getDefaultAddress() {
88
100
  return DEFAULT_ADDRESS;
89
101
  }
90
- async txeGetNextBlockNumber() {
102
+ async getNextBlockNumber() {
91
103
  return BlockNumber(await this.getLastBlockNumber() + 1);
92
104
  }
93
- txeGetNextBlockTimestamp() {
105
+ getNextBlockTimestamp() {
94
106
  return Promise.resolve(this.nextBlockTimestamp);
95
107
  }
96
- async txeGetLastBlockTimestamp() {
97
- return (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.timestamp;
108
+ async getLastBlockTimestamp() {
109
+ return (await this.stateMachine.node.getBlockData('latest')).header.globalVariables.timestamp;
98
110
  }
99
- async txeGetLastTxEffects() {
100
- const block = await this.stateMachine.archiver.getL2Block('latest');
111
+ async getLastTxEffects() {
112
+ const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
113
+ const block = await this.stateMachine.archiver.getBlock({
114
+ number: latestBlockNumber
115
+ });
101
116
  if (block.body.txEffects.length != 1) {
102
117
  // Note that calls like env.mine() will result in blocks with no transactions, hitting this
103
118
  throw new Error(`Expected a single transaction in the last block, found ${block.body.txEffects.length}`);
104
119
  }
105
120
  const txEffects = block.body.txEffects[0];
121
+ const privateLogs = txEffects.privateLogs;
122
+ if (privateLogs.length > MAX_PRIVATE_LOGS_PER_TX) {
123
+ throw new Error(`${privateLogs.length} private logs exceed max ${MAX_PRIVATE_LOGS_PER_TX}`);
124
+ }
106
125
  return {
107
126
  txHash: txEffects.txHash,
108
127
  noteHashes: txEffects.noteHashes,
109
- nullifiers: txEffects.nullifiers
128
+ nullifiers: txEffects.nullifiers,
129
+ privateLogs
110
130
  };
111
131
  }
112
- async txeGetPrivateEvents(selector, contractAddress, scope) {
132
+ async syncContractNonOracleMethod(contractAddress, scope, jobId) {
133
+ if (contractAddress.equals(DEFAULT_ADDRESS)) {
134
+ this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
135
+ return;
136
+ }
137
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
138
+ await this.stateMachine.contractSyncService.ensureContractSynced(contractAddress, null, async (call, execScopes)=>{
139
+ await this.executeUtilityCall(call, execScopes, jobId);
140
+ }, blockHeader, jobId, [
141
+ scope
142
+ ]);
143
+ }
144
+ async getPrivateEvents(selector, contractAddress, scope) {
113
145
  return (await this.privateEventStore.getPrivateEvents(selector, {
114
146
  contractAddress,
115
147
  scopes: [
@@ -119,43 +151,53 @@ export class TXEOracleTopLevelContext {
119
151
  toBlock: await this.getLastBlockNumber() + 1
120
152
  })).map((e)=>e.packedEvent);
121
153
  }
122
- async txeAdvanceBlocksBy(blocks) {
154
+ async advanceBlocksBy(blocks) {
123
155
  this.logger.debug(`time traveling ${blocks} blocks`);
124
156
  for(let i = 0; i < blocks; i++){
125
157
  await this.mineBlock();
126
158
  }
127
159
  }
128
- txeAdvanceTimestampBy(duration) {
160
+ advanceTimestampBy(duration) {
129
161
  this.logger.debug(`time traveling ${duration} seconds`);
130
162
  this.nextBlockTimestamp += duration;
131
163
  }
132
- async txeDeploy(artifact, instance, secret) {
164
+ deploymentNullifier(address) {
165
+ return siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
166
+ }
167
+ async deploy(artifact, instance, secret) {
133
168
  // Emit deployment nullifier
134
169
  await this.mineBlock({
135
170
  nullifiers: [
136
- await siloNullifier(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), instance.address.toField())
171
+ await this.deploymentNullifier(instance.address)
137
172
  ]
138
173
  });
139
174
  if (!secret.equals(Fr.ZERO)) {
140
- await this.txeAddAccount(artifact, instance, secret);
175
+ await this.addAccount(artifact, instance, secret);
141
176
  } else {
142
177
  await this.contractStore.addContractInstance(instance);
143
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
178
+ await this.contractStore.addContractArtifact(artifact);
144
179
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
145
180
  }
146
181
  }
147
- async txeAddAccount(artifact, instance, secret) {
182
+ /**
183
+ * Mines a single block containing only the deployment nullifiers for the contracts at the given addresses.
184
+ */ async mineDeploymentNullifiers(addresses) {
185
+ await this.mineBlock({
186
+ nullifiers: await Promise.all(addresses.map((address)=>this.deploymentNullifier(address)))
187
+ });
188
+ }
189
+ async addAccount(artifact, instance, secret) {
148
190
  const partialAddress = await computePartialAddress(instance);
149
191
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
150
192
  await this.contractStore.addContractInstance(instance);
151
- await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
193
+ await this.contractStore.addContractArtifact(artifact);
152
194
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
153
195
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
154
196
  await this.addressStore.addCompleteAddress(completeAddress);
155
197
  this.logger.debug(`Created account ${completeAddress.address}`);
156
198
  return completeAddress;
157
199
  }
158
- async txeCreateAccount(secret) {
200
+ async createAccount(secret) {
159
201
  // This is a foot gun !
160
202
  const completeAddress = await this.keyStore.addAccount(secret, secret);
161
203
  await this.accountStore.setAccount(completeAddress.address, completeAddress);
@@ -163,18 +205,17 @@ export class TXEOracleTopLevelContext {
163
205
  this.logger.debug(`Created account ${completeAddress.address}`);
164
206
  return completeAddress;
165
207
  }
166
- async txeAddAuthWitness(address, messageHash) {
208
+ async addAuthWitness(address, messageHash) {
167
209
  const account = await this.accountStore.getAccount(address);
168
- const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
210
+ const ivpkMHash = await hashPublicKey(account.publicKeys.ivpkM);
211
+ const privateKey = await this.keyStore.getMasterSecretKey(ivpkMHash);
169
212
  const schnorr = new Schnorr();
170
- const signature = await schnorr.constructSignature(messageHash.toBuffer(), privateKey);
171
- const authWitness = new AuthWitness(messageHash, [
172
- ...signature.toBuffer()
173
- ]);
213
+ const signature = await schnorr.constructSignature(messageHash, privateKey);
214
+ const authWitness = new AuthWitness(messageHash, signature.toLimbFields());
174
215
  this.authwits.set(authWitness.requestHash.toString(), authWitness);
175
216
  }
176
217
  async mineBlock(options = {}) {
177
- const blockNumber = await this.txeGetNextBlockNumber();
218
+ const blockNumber = await this.getNextBlockNumber();
178
219
  const txEffect = TxEffect.empty();
179
220
  txEffect.nullifiers = [
180
221
  getSingleTxBlockRequestHash(blockNumber),
@@ -196,35 +237,74 @@ export class TXEOracleTopLevelContext {
196
237
  this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
197
238
  await this.stateMachine.handleL2Block(block);
198
239
  }
199
- async txePrivateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false) {
240
+ async privateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false, additionalScopes = [], jobId, authorizedUtilityCallTargets, gasSettings) {
200
241
  this.logger.verbose(`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`);
201
242
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
202
243
  if (!artifact) {
203
244
  const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)')) ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.' : 'Function Artifact does not exist';
204
245
  throw new Error(message);
205
246
  }
247
+ const scopes = from === undefined ? additionalScopes : [
248
+ from,
249
+ ...additionalScopes
250
+ ];
206
251
  // Sync notes before executing private function to discover notes from previous transactions
207
- const utilityExecutor = async (call)=>{
208
- await this.executeUtilityCall(call);
252
+ const utilityExecutor = async (call, execScopes)=>{
253
+ await this.executeUtilityCall(call, execScopes, jobId);
209
254
  };
210
- await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, utilityExecutor);
211
- const blockNumber = await this.txeGetNextBlockNumber();
212
- const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
213
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
214
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
215
- const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
216
- const txContext = new TxContext(this.chainId, this.version, gasSettings);
217
255
  const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
256
+ await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader, jobId, scopes);
257
+ const blockNumber = await this.getNextBlockNumber();
258
+ const msgSender = from ?? AztecAddress.NULL_MSG_SENDER;
259
+ const callContext = new CallContext(msgSender, targetContractAddress, functionSelector, isStaticCall);
260
+ const txContext = new TxContext(this.chainId, this.version, gasSettings);
218
261
  const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
219
262
  const noteCache = new ExecutionNoteCache(protocolNullifier);
263
+ // In production, the account contract sets the min revertible counter before calling the app function.
264
+ // Since TXE bypasses the account contract, we simulate this by setting minRevertibleSideEffectCounter to 1,
265
+ // marking all side effects as revertible.
266
+ const minRevertibleSideEffectCounter = 1;
267
+ await noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
220
268
  const taggingIndexCache = new ExecutionTaggingIndexCache();
221
269
  const simulator = new WASMSimulator();
222
- const privateExecutionOracle = new PrivateExecutionOracle(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ blockHeader, utilityExecutor, /** List of transient auth witnesses to be used during this simulation */ Array.from(this.authwits.values()), /** List of transient auth witnesses to be used during this simulation */ [], HashedValuesCache.create([
223
- new HashedValues(args, argsHash)
224
- ]), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, TXE_JOB_ID, 0, 1, undefined, undefined, /**
225
- * In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
226
- * contract would perform, including setting senderForTags.
227
- */ from, simulator);
270
+ const privateExecutionOracle = new PrivateExecutionOracle({
271
+ argsHash,
272
+ txContext,
273
+ callContext,
274
+ anchorBlockHeader: blockHeader,
275
+ utilityExecutor,
276
+ authWitnesses: Array.from(this.authwits.values()),
277
+ capsules: [],
278
+ executionCache: HashedValuesCache.create([
279
+ new HashedValues(args, argsHash)
280
+ ]),
281
+ noteCache,
282
+ taggingIndexCache,
283
+ contractStore: this.contractStore,
284
+ noteStore: this.noteStore,
285
+ keyStore: this.keyStore,
286
+ addressStore: this.addressStore,
287
+ aztecNode: this.stateMachine.node,
288
+ senderTaggingStore: this.senderTaggingStore,
289
+ recipientTaggingStore: this.recipientTaggingStore,
290
+ senderAddressBookStore: this.senderAddressBookStore,
291
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
292
+ privateEventStore: this.privateEventStore,
293
+ contractSyncService: this.stateMachine.contractSyncService,
294
+ jobId,
295
+ totalPublicCalldataCount: 0,
296
+ sideEffectCounter: minRevertibleSideEffectCounter,
297
+ scopes,
298
+ // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
299
+ // contract would perform, including setting senderForTags.
300
+ senderForTags: from,
301
+ simulator,
302
+ messageContextService: this.stateMachine.messageContextService,
303
+ l2TipsStore: this.stateMachine.l2TipsProvider,
304
+ hooks: composeHooks({
305
+ authorizeUtilityCall: this.buildAuthorizeUtilityCallHook(isStaticCall ? 'private view' : 'private', authorizedUtilityCallTargets)
306
+ })
307
+ });
228
308
  // 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.
229
309
  let result;
230
310
  let executionResult;
@@ -236,21 +316,19 @@ export class TXEOracleTopLevelContext {
236
316
  r.publicInputs.publicTeardownCallRequest
237
317
  ]));
238
318
  const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
239
- const calldata = await privateExecutionOracle.privateLoadFromExecutionCache(r.calldataHash);
319
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
240
320
  return new HashedValues(calldata, r.calldataHash);
241
321
  }));
242
- // TXE's top level context does not track side effect counters, and as such, minRevertibleSideEffectCounter is always 0.
243
- // This has the unfortunate consequence of always producing revertible nullifiers, which means we
244
- // must set the firstNullifierHint to Fr.ZERO so the txRequestHash is always used as nonce generator
245
- result = new PrivateExecutionResult(executionResult, Fr.ZERO, publicFunctionsCalldata);
322
+ noteCache.finish();
323
+ const nonceGenerator = noteCache.getNonceGenerator();
324
+ result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
246
325
  } catch (err) {
247
326
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
248
327
  }
249
- // According to the protocol rules, the nonce generator for the note hashes
250
- // can either be the first nullifier in the tx or the hash of the initial tx request
251
- // if there are none.
252
- const nonceGenerator = result.firstNullifier.equals(Fr.ZERO) ? protocolNullifier : result.firstNullifier;
253
- const { publicInputs } = await generateSimulatedProvingResult(result, nonceGenerator, this.contractStore);
328
+ // According to the protocol rules, there must be at least one nullifier in the tx. The first nullifier is used as
329
+ // the nonce generator for the note hashes.
330
+ // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
331
+ const { publicInputs } = await generateSimulatedProvingResult(result, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.stateMachine.node, minRevertibleSideEffectCounter);
254
332
  const globals = makeGlobalVariables();
255
333
  globals.blockNumber = blockNumber;
256
334
  globals.timestamp = this.nextBlockTimestamp;
@@ -258,7 +336,8 @@ export class TXEOracleTopLevelContext {
258
336
  globals.version = this.version;
259
337
  globals.gasFees = GasFees.empty();
260
338
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
261
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
339
+ const bindings = this.logger.getBindings();
340
+ const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore), bindings);
262
341
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
263
342
  const config = PublicSimulatorConfig.from({
264
343
  skipFeeEnforcement: true,
@@ -267,7 +346,7 @@ export class TXEOracleTopLevelContext {
267
346
  collectStatistics: false,
268
347
  collectCallMetadata: true
269
348
  });
270
- const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config), new TestDateProvider());
349
+ const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings), new TestDateProvider(), undefined, createLogger('simulator:public-processor', bindings));
271
350
  const tx = await Tx.create({
272
351
  data: publicInputs,
273
352
  chonkProof: ChonkProof.empty(),
@@ -296,10 +375,20 @@ export class TXEOracleTopLevelContext {
296
375
  throw new Error('Contract execution has reverted');
297
376
  }
298
377
  }
378
+ // Walk the nested private-call tree and collect every offchain effect the transaction emitted.
379
+ // PXE stores these on each `PrivateCallExecutionResult` and they never reach TXE via the
380
+ // `aztec_utl_emitOffchainEffect` foreign-call path (that path only fires at the top-level), so
381
+ // we pull them out here and the RPC wrapper will hand them to `TXESession` for buffering.
382
+ const offchainEffects = collectNested([
383
+ executionResult
384
+ ], (r)=>r.offchainEffects.map((e)=>e.data));
299
385
  if (isStaticCall) {
300
386
  await checkpoint.revert();
301
387
  await forkedWorldTrees.close();
302
- return executionResult.returnValues ?? [];
388
+ return {
389
+ returnValues: executionResult.returnValues ?? [],
390
+ offchainEffects
391
+ };
303
392
  }
304
393
  const txEffect = TxEffect.empty();
305
394
  txEffect.noteHashes = processedTx.txEffect.noteHashes;
@@ -315,14 +404,14 @@ export class TXEOracleTopLevelContext {
315
404
  ]);
316
405
  await this.stateMachine.handleL2Block(l2Block);
317
406
  await forkedWorldTrees.close();
318
- return executionResult.returnValues ?? [];
407
+ return {
408
+ returnValues: executionResult.returnValues ?? [],
409
+ offchainEffects
410
+ };
319
411
  }
320
- async txePublicCallNewFlow(from, targetContractAddress, calldata, isStaticCall) {
412
+ async publicCallNewFlow(from, targetContractAddress, calldata, isStaticCall, gasSettings) {
321
413
  this.logger.verbose(`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`);
322
- const blockNumber = await this.txeGetNextBlockNumber();
323
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
324
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
325
- const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
414
+ const blockNumber = await this.getNextBlockNumber();
326
415
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
327
416
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
328
417
  const calldataHash = await computeCalldataHash(calldata);
@@ -334,7 +423,8 @@ export class TXEOracleTopLevelContext {
334
423
  globals.version = this.version;
335
424
  globals.gasFees = GasFees.empty();
336
425
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
337
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
426
+ const bindings2 = this.logger.getBindings();
427
+ const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore), bindings2);
338
428
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
339
429
  const config = PublicSimulatorConfig.from({
340
430
  skipFeeEnforcement: true,
@@ -343,8 +433,8 @@ export class TXEOracleTopLevelContext {
343
433
  collectStatistics: false,
344
434
  collectCallMetadata: true
345
435
  });
346
- const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
347
- const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, simulator, new TestDateProvider());
436
+ const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
437
+ const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, simulator, new TestDateProvider(), undefined, createLogger('simulator:public-processor', bindings2));
348
438
  // We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
349
439
  // kernel init would in this case inject a nullifier with the transaction request hash as a non-revertible
350
440
  // side-effect, which the AVM then expects to exist in order to use it as the nonce generator when siloing notes as
@@ -354,10 +444,10 @@ export class TXEOracleTopLevelContext {
354
444
  // The enqueued public call itself we make be revertible so that the public execution is itself revertible, as tests
355
445
  // may require producing reverts.
356
446
  const revertibleAccumulatedData = PrivateToPublicAccumulatedData.empty();
357
- revertibleAccumulatedData.publicCallRequests[0] = new PublicCallRequest(from, targetContractAddress, isStaticCall, calldataHash);
447
+ revertibleAccumulatedData.publicCallRequests[0] = new PublicCallRequest(from ?? AztecAddress.NULL_MSG_SENDER, targetContractAddress, isStaticCall, calldataHash);
358
448
  const inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleAccumulatedData, revertibleAccumulatedData, PublicCallRequest.empty());
359
449
  const constantData = new TxConstantData(anchorBlockHeader, txContext, Fr.zero(), Fr.zero());
360
- const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*includeByTimestamp=*/ 0n, inputsForPublic, undefined);
450
+ const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*expirationTimestamp=*/ 0n, inputsForPublic, undefined);
361
451
  const tx = await Tx.create({
362
452
  data: txData,
363
453
  chonkProof: ChonkProof.empty(),
@@ -410,19 +500,29 @@ export class TXEOracleTopLevelContext {
410
500
  await forkedWorldTrees.close();
411
501
  return returnValues ?? [];
412
502
  }
413
- async txeSimulateUtilityFunction(targetContractAddress, functionSelector, args) {
503
+ async executeUtilityFunction(targetContractAddress, functionSelector, args, jobId, authorizedUtilityCallTargets) {
414
504
  const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
415
505
  if (!artifact) {
416
506
  throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
417
507
  }
418
508
  // Sync notes before executing utility function to discover notes from previous transactions
419
- await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, async (call)=>{
420
- await this.executeUtilityCall(call);
509
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
510
+ await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, async (call, execScopes)=>{
511
+ await this.executeUtilityCall(call, execScopes, jobId);
512
+ }, blockHeader, jobId, await this.keyStore.getAccounts());
513
+ const call = FunctionCall.from({
514
+ name: artifact.name,
515
+ to: targetContractAddress,
516
+ selector: functionSelector,
517
+ type: FunctionType.UTILITY,
518
+ hideMsgSender: false,
519
+ isStatic: false,
520
+ args,
521
+ returnTypes: []
421
522
  });
422
- const call = new FunctionCall(artifact.name, targetContractAddress, functionSelector, FunctionType.UTILITY, false, false, args, []);
423
- return this.executeUtilityCall(call);
523
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId, authorizedUtilityCallTargets);
424
524
  }
425
- async executeUtilityCall(call) {
525
+ async executeUtilityCall(call, scopes, jobId, authorizedUtilityCallTargets = []) {
426
526
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
427
527
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
428
528
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -433,8 +533,36 @@ export class TXEOracleTopLevelContext {
433
533
  });
434
534
  try {
435
535
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
436
- const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, TXE_JOB_ID);
437
- const acirExecutionResult = await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
536
+ const simulator = new WASMSimulator();
537
+ const utilityExecutor = async (syncCall, execScopes)=>{
538
+ await this.executeUtilityCall(syncCall, execScopes, jobId);
539
+ };
540
+ const oracle = new UtilityExecutionOracle({
541
+ contractAddress: call.to,
542
+ authWitnesses: [],
543
+ capsules: [],
544
+ anchorBlockHeader,
545
+ contractStore: this.contractStore,
546
+ noteStore: this.noteStore,
547
+ keyStore: this.keyStore,
548
+ addressStore: this.addressStore,
549
+ aztecNode: this.stateMachine.node,
550
+ recipientTaggingStore: this.recipientTaggingStore,
551
+ senderAddressBookStore: this.senderAddressBookStore,
552
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
553
+ privateEventStore: this.privateEventStore,
554
+ messageContextService: this.stateMachine.messageContextService,
555
+ contractSyncService: this.stateMachine.contractSyncService,
556
+ l2TipsStore: this.stateMachine.l2TipsProvider,
557
+ jobId,
558
+ scopes,
559
+ simulator,
560
+ hooks: composeHooks({
561
+ authorizeUtilityCall: this.buildAuthorizeUtilityCallHook('utility', authorizedUtilityCallTargets)
562
+ }),
563
+ utilityExecutor
564
+ });
565
+ const acirExecutionResult = await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
438
566
  err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
439
567
  throw new ExecutionError(err.message, {
440
568
  contractAddress: call.to,
@@ -443,10 +571,10 @@ export class TXEOracleTopLevelContext {
443
571
  cause: err
444
572
  });
445
573
  });
446
- this.logger.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
574
+ this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
447
575
  return witnessMapToFields(acirExecutionResult.returnWitness);
448
576
  } catch (err) {
449
- throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility simulation'));
577
+ throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
450
578
  }
451
579
  }
452
580
  close() {
@@ -457,7 +585,15 @@ export class TXEOracleTopLevelContext {
457
585
  ];
458
586
  }
459
587
  async getLastBlockNumber() {
460
- const header = await this.stateMachine.node.getBlockHeader('latest');
461
- return header ? header.globalVariables.blockNumber : BlockNumber.ZERO;
588
+ const block = await this.stateMachine.node.getBlock('latest');
589
+ return block ? block.header.globalVariables.blockNumber : BlockNumber.ZERO;
590
+ }
591
+ buildAuthorizeUtilityCallHook(callerContext, authorizedTargets) {
592
+ if (authorizedTargets.length === 0) {
593
+ return undefined;
594
+ }
595
+ return (req)=>Promise.resolve({
596
+ authorized: req.callerContext === callerContext && authorizedTargets.some((t)=>t.equals(req.target))
597
+ });
462
598
  }
463
599
  }
@@ -0,0 +1,17 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { PrivateExecutionOracle } from '@aztec/pxe/simulator';
3
+ import type { FunctionSelector } from '@aztec/stdlib/abi';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ /**
6
+ * TXE-specific subclass of PrivateExecutionOracle that forbids operations not supported in
7
+ * TestEnvironment::private_context. TXE uses dedicated oracle flows (e.g. private_call) instead.
8
+ */
9
+ export declare class TXEPrivateExecutionOracle extends PrivateExecutionOracle {
10
+ callPrivateFunction(_targetContractAddress: AztecAddress, _functionSelector: FunctionSelector, _argsHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<{
11
+ endSideEffectCounter: Fr;
12
+ returnsHash: Fr;
13
+ }>;
14
+ assertValidPublicCalldata(_calldataHash: Fr): Promise<void>;
15
+ notifyRevertiblePhaseStart(_minRevertibleSideEffectCounter: number): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3ByaXZhdGVfZXhlY3V0aW9uX29yYWNsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29yYWNsZS90eGVfcHJpdmF0ZV9leGVjdXRpb25fb3JhY2xlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sRUFBRSxzQkFBc0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEU7OztHQUdHO0FBQ0gscUJBQWEseUJBQTBCLFNBQVEsc0JBQXNCO0lBQzFELG1CQUFtQixDQUMxQixzQkFBc0IsRUFBRSxZQUFZLEVBQ3BDLGlCQUFpQixFQUFFLGdCQUFnQixFQUNuQyxTQUFTLEVBQUUsRUFBRSxFQUNiLGtCQUFrQixFQUFFLE1BQU0sRUFDMUIsYUFBYSxFQUFFLE9BQU8sR0FDckIsT0FBTyxDQUFDO1FBQUUsb0JBQW9CLEVBQUUsRUFBRSxDQUFDO1FBQUMsV0FBVyxFQUFFLEVBQUUsQ0FBQTtLQUFFLENBQUMsQ0FJeEQ7SUFFUSx5QkFBeUIsQ0FBQyxhQUFhLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFbkU7SUFFUSwwQkFBMEIsQ0FBQywrQkFBK0IsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUUxRjtDQUNGIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txe_private_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_private_execution_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,sBAAsB;IAC1D,mBAAmB,CAC1B,sBAAsB,EAAE,YAAY,EACpC,iBAAiB,EAAE,gBAAgB,EACnC,SAAS,EAAE,EAAE,EACb,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC;QAAE,oBAAoB,EAAE,EAAE,CAAC;QAAC,WAAW,EAAE,EAAE,CAAA;KAAE,CAAC,CAIxD;IAEQ,yBAAyB,CAAC,aAAa,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;IAEQ,0BAA0B,CAAC,+BAA+B,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1F;CACF"}
@@ -0,0 +1,15 @@
1
+ import { PrivateExecutionOracle } from '@aztec/pxe/simulator';
2
+ /**
3
+ * TXE-specific subclass of PrivateExecutionOracle that forbids operations not supported in
4
+ * TestEnvironment::private_context. TXE uses dedicated oracle flows (e.g. private_call) instead.
5
+ */ export class TXEPrivateExecutionOracle extends PrivateExecutionOracle {
6
+ callPrivateFunction(_targetContractAddress, _functionSelector, _argsHash, _sideEffectCounter, _isStaticCall) {
7
+ throw new Error('Contract calls are forbidden inside a `TestEnvironment::private_context`, use `private_call` instead');
8
+ }
9
+ assertValidPublicCalldata(_calldataHash) {
10
+ throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
11
+ }
12
+ notifyRevertiblePhaseStart(_minRevertibleSideEffectCounter) {
13
+ throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
14
+ }
15
+ }
@@ -0,0 +1,14 @@
1
+ import type { Logger } from '@aztec/foundation/log';
2
+ /**
3
+ * Creates the TXE RPC server. With `TXE_WORKERS=1` oracle calls run on the main thread (no
4
+ * worker_threads, no IPC overhead). With any other value oracle calls are
5
+ * routed to a pool of worker threads sized to that value, sticky by `session_id`.
6
+ *
7
+ * Each incoming TCP socket is tagged with the `session_id` of the first oracle call it carries —
8
+ * nargo uses one HTTP client per test, so the socket-to-session mapping is 1:1. When the socket
9
+ * closes (end of test), the dispatcher disposes the session and frees its world state + LMDB.
10
+ *
11
+ * Lives in its own module so the worker bundle does not pull in the HTTP server stack.
12
+ */
13
+ export declare function createTXERpcServer(logger: Logger): Promise<import("@aztec/foundation/json-rpc/server").SafeJsonRpcServer>;
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnBjX3NlcnZlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3JwY19zZXJ2ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFlcEQ7Ozs7Ozs7Ozs7R0FVRztBQUNILHdCQUFzQixrQkFBa0IsQ0FBQyxNQUFNLEVBQUUsTUFBTSwwRUE0Q3REIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc_server.d.ts","sourceRoot":"","sources":["../src/rpc_server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAepD;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,0EA4CtD"}