@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec

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 (79) hide show
  1. package/dest/bin/index.d.ts +1 -1
  2. package/dest/index.d.ts +1 -1
  3. package/dest/index.d.ts.map +1 -1
  4. package/dest/index.js +3 -2
  5. package/dest/oracle/interfaces.d.ts +9 -6
  6. package/dest/oracle/interfaces.d.ts.map +1 -1
  7. package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
  8. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_public_context.js +4 -6
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts +20 -12
  11. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  12. package/dest/oracle/txe_oracle_top_level_context.js +95 -63
  13. package/dest/rpc_translator.d.ts +17 -8
  14. package/dest/rpc_translator.d.ts.map +1 -1
  15. package/dest/rpc_translator.js +69 -20
  16. package/dest/state_machine/archiver.d.ts +31 -14
  17. package/dest/state_machine/archiver.d.ts.map +1 -1
  18. package/dest/state_machine/archiver.js +105 -17
  19. package/dest/state_machine/dummy_p2p_client.d.ts +4 -2
  20. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  21. package/dest/state_machine/dummy_p2p_client.js +6 -1
  22. package/dest/state_machine/global_variable_builder.d.ts +5 -3
  23. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  24. package/dest/state_machine/global_variable_builder.js +12 -0
  25. package/dest/state_machine/index.d.ts +5 -5
  26. package/dest/state_machine/index.d.ts.map +1 -1
  27. package/dest/state_machine/index.js +14 -20
  28. package/dest/state_machine/mock_epoch_cache.d.ts +6 -5
  29. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  30. package/dest/state_machine/mock_epoch_cache.js +8 -7
  31. package/dest/state_machine/synchronizer.d.ts +5 -4
  32. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  33. package/dest/state_machine/synchronizer.js +5 -4
  34. package/dest/txe_session.d.ts +19 -13
  35. package/dest/txe_session.d.ts.map +1 -1
  36. package/dest/txe_session.js +55 -41
  37. package/dest/util/encoding.d.ts +623 -24
  38. package/dest/util/encoding.d.ts.map +1 -1
  39. package/dest/util/encoding.js +1 -1
  40. package/dest/util/expected_failure_error.d.ts +1 -1
  41. package/dest/util/expected_failure_error.d.ts.map +1 -1
  42. package/dest/util/txe_account_store.d.ts +10 -0
  43. package/dest/util/txe_account_store.d.ts.map +1 -0
  44. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  45. package/dest/util/txe_contract_store.d.ts +12 -0
  46. package/dest/util/txe_contract_store.d.ts.map +1 -0
  47. package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
  48. package/dest/util/txe_public_contract_data_source.d.ts +7 -6
  49. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  50. package/dest/util/txe_public_contract_data_source.js +11 -11
  51. package/dest/utils/block_creation.d.ts +19 -4
  52. package/dest/utils/block_creation.d.ts.map +1 -1
  53. package/dest/utils/block_creation.js +24 -3
  54. package/dest/utils/tx_effect_creation.d.ts +4 -3
  55. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  56. package/dest/utils/tx_effect_creation.js +6 -6
  57. package/package.json +18 -17
  58. package/src/index.ts +15 -12
  59. package/src/oracle/interfaces.ts +8 -5
  60. package/src/oracle/txe_oracle_public_context.ts +6 -11
  61. package/src/oracle/txe_oracle_top_level_context.ts +126 -88
  62. package/src/rpc_translator.ts +90 -20
  63. package/src/state_machine/archiver.ts +141 -29
  64. package/src/state_machine/dummy_p2p_client.ts +9 -2
  65. package/src/state_machine/global_variable_builder.ts +21 -3
  66. package/src/state_machine/index.ts +19 -18
  67. package/src/state_machine/mock_epoch_cache.ts +12 -11
  68. package/src/state_machine/synchronizer.ts +8 -7
  69. package/src/txe_session.ts +113 -72
  70. package/src/util/encoding.ts +1 -1
  71. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  72. package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
  73. package/src/util/txe_public_contract_data_source.ts +13 -12
  74. package/src/utils/block_creation.ts +35 -3
  75. package/src/utils/tx_effect_creation.ts +8 -7
  76. package/dest/util/txe_account_data_provider.d.ts +0 -10
  77. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  78. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  79. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
@@ -6,15 +6,21 @@ import {
6
6
  DEFAULT_TEARDOWN_L2_GAS_LIMIT,
7
7
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
8
8
  } from '@aztec/constants';
9
- import { Schnorr } from '@aztec/foundation/crypto';
10
- import { Fr } from '@aztec/foundation/fields';
9
+ import { BlockNumber } from '@aztec/foundation/branded-types';
10
+ import { Schnorr } from '@aztec/foundation/crypto/schnorr';
11
+ import { Fr } from '@aztec/foundation/curves/bn254';
11
12
  import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
12
13
  import { TestDateProvider } from '@aztec/foundation/timer';
13
14
  import type { KeyStore } from '@aztec/key-store';
14
15
  import {
15
- AddressDataProvider,
16
+ AddressStore,
17
+ CapsuleStore,
18
+ NoteStore,
16
19
  ORACLE_VERSION,
17
- PXEOracleInterface,
20
+ PrivateEventStore,
21
+ RecipientTaggingStore,
22
+ SenderAddressBookStore,
23
+ SenderTaggingStore,
18
24
  enrichPublicSimulationError,
19
25
  } from '@aztec/pxe/server';
20
26
  import {
@@ -38,18 +44,18 @@ import {
38
44
  witnessMapToFields,
39
45
  } from '@aztec/simulator/client';
40
46
  import {
47
+ CppPublicTxSimulator,
41
48
  GuardedMerkleTreeOperations,
42
49
  PublicContractsDB,
43
50
  PublicProcessor,
44
- PublicTxSimulator,
45
51
  } from '@aztec/simulator/server';
46
- import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
52
+ import { type ContractArtifact, EventSelector, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
47
53
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
54
+ import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
48
55
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
49
- import { Body, L2Block } from '@aztec/stdlib/block';
50
56
  import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
51
57
  import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
52
- import { computeCalldataHash, siloNullifier } from '@aztec/stdlib/hash';
58
+ import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
53
59
  import {
54
60
  PartialPrivateTailPublicInputsForPublic,
55
61
  PrivateKernelTailCircuitPublicInputs,
@@ -57,7 +63,7 @@ import {
57
63
  PublicCallRequest,
58
64
  } from '@aztec/stdlib/kernel';
59
65
  import { ChonkProof } from '@aztec/stdlib/proofs';
60
- import { makeAppendOnlyTreeSnapshot, makeGlobalVariables } from '@aztec/stdlib/testing';
66
+ import { makeGlobalVariables } from '@aztec/stdlib/testing';
61
67
  import { MerkleTreeId } from '@aztec/stdlib/trees';
62
68
  import {
63
69
  CallContext,
@@ -75,14 +81,11 @@ import type { UInt64 } from '@aztec/stdlib/types';
75
81
  import { ForkCheckpoint } from '@aztec/world-state';
76
82
 
77
83
  import type { TXEStateMachine } from '../state_machine/index.js';
78
- import type { TXEAccountDataProvider } from '../util/txe_account_data_provider.js';
79
- import type { TXEContractDataProvider } from '../util/txe_contract_data_provider.js';
84
+ import { DEFAULT_ADDRESS } from '../txe_session.js';
85
+ import type { TXEAccountStore } from '../util/txe_account_store.js';
86
+ import type { TXEContractStore } from '../util/txe_contract_store.js';
80
87
  import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
81
- import {
82
- getSingleTxBlockRequestHash,
83
- insertTxEffectIntoWorldTrees,
84
- makeTXEBlockHeader,
85
- } from '../utils/block_creation.js';
88
+ import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
86
89
  import type { ITxeExecutionOracle } from './interfaces.js';
87
90
 
88
91
  export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
@@ -93,11 +96,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
93
96
 
94
97
  constructor(
95
98
  private stateMachine: TXEStateMachine,
96
- private contractDataProvider: TXEContractDataProvider,
99
+ private contractStore: TXEContractStore,
100
+ private noteStore: NoteStore,
97
101
  private keyStore: KeyStore,
98
- private addressDataProvider: AddressDataProvider,
99
- private accountDataProvider: TXEAccountDataProvider,
100
- private pxeOracleInterface: PXEOracleInterface,
102
+ private addressStore: AddressStore,
103
+ private accountStore: TXEAccountStore,
104
+ private senderTaggingStore: SenderTaggingStore,
105
+ private recipientTaggingStore: RecipientTaggingStore,
106
+ private senderAddressBookStore: SenderAddressBookStore,
107
+ private capsuleStore: CapsuleStore,
108
+ private privateEventStore: PrivateEventStore,
101
109
  private nextBlockTimestamp: bigint,
102
110
  private version: Fr,
103
111
  private chainId: Fr,
@@ -131,8 +139,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
131
139
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
132
140
  }
133
141
 
134
- async txeGetNextBlockNumber(): Promise<number> {
135
- return (await this.getLastBlockNumber()) + 1;
142
+ txeGetDefaultAddress(): AztecAddress {
143
+ return DEFAULT_ADDRESS;
144
+ }
145
+
146
+ async txeGetNextBlockNumber(): Promise<BlockNumber> {
147
+ return BlockNumber((await this.getLastBlockNumber()) + 1);
136
148
  }
137
149
 
138
150
  txeGetNextBlockTimestamp(): Promise<bigint> {
@@ -144,7 +156,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
144
156
  }
145
157
 
146
158
  async txeGetLastTxEffects() {
147
- const block = await this.stateMachine.archiver.getBlock('latest');
159
+ const block = await this.stateMachine.archiver.getL2Block('latest');
148
160
 
149
161
  if (block!.body.txEffects.length != 1) {
150
162
  // Note that calls like env.mine() will result in blocks with no transactions, hitting this
@@ -156,6 +168,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
156
168
  return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
157
169
  }
158
170
 
171
+ async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
172
+ return (
173
+ await this.privateEventStore.getPrivateEvents(selector, {
174
+ contractAddress,
175
+ scopes: [scope],
176
+ fromBlock: 0,
177
+ toBlock: (await this.getLastBlockNumber()) + 1,
178
+ })
179
+ ).map(e => e.packedEvent);
180
+ }
181
+
159
182
  async txeAdvanceBlocksBy(blocks: number) {
160
183
  this.logger.debug(`time traveling ${blocks} blocks`);
161
184
 
@@ -183,8 +206,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
183
206
  if (!secret.equals(Fr.ZERO)) {
184
207
  await this.txeAddAccount(artifact, instance, secret);
185
208
  } else {
186
- await this.contractDataProvider.addContractInstance(instance);
187
- await this.contractDataProvider.addContractArtifact(instance.currentContractClassId, artifact);
209
+ await this.contractStore.addContractInstance(instance);
210
+ await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
188
211
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
189
212
  }
190
213
  }
@@ -193,29 +216,29 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
193
216
  const partialAddress = await computePartialAddress(instance);
194
217
 
195
218
  this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
196
- await this.contractDataProvider.addContractInstance(instance);
197
- await this.contractDataProvider.addContractArtifact(instance.currentContractClassId, artifact);
219
+ await this.contractStore.addContractInstance(instance);
220
+ await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
198
221
 
199
222
  const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
200
- await this.accountDataProvider.setAccount(completeAddress.address, completeAddress);
201
- await this.addressDataProvider.addCompleteAddress(completeAddress);
223
+ await this.accountStore.setAccount(completeAddress.address, completeAddress);
224
+ await this.addressStore.addCompleteAddress(completeAddress);
202
225
  this.logger.debug(`Created account ${completeAddress.address}`);
203
226
 
204
227
  return completeAddress;
205
228
  }
206
229
 
207
230
  async txeCreateAccount(secret: Fr) {
208
- // This is a footgun !
231
+ // This is a foot gun !
209
232
  const completeAddress = await this.keyStore.addAccount(secret, secret);
210
- await this.accountDataProvider.setAccount(completeAddress.address, completeAddress);
211
- await this.addressDataProvider.addCompleteAddress(completeAddress);
233
+ await this.accountStore.setAccount(completeAddress.address, completeAddress);
234
+ await this.addressStore.addCompleteAddress(completeAddress);
212
235
  this.logger.debug(`Created account ${completeAddress.address}`);
213
236
 
214
237
  return completeAddress;
215
238
  }
216
239
 
217
240
  async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
218
- const account = await this.accountDataProvider.getAccount(address);
241
+ const account = await this.accountStore.getAccount(address);
219
242
  const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
220
243
 
221
244
  const schnorr = new Schnorr();
@@ -236,19 +259,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
236
259
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
237
260
  await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
238
261
 
239
- const block = new L2Block(
240
- makeAppendOnlyTreeSnapshot(),
241
- await makeTXEBlockHeader(
242
- forkedWorldTrees,
243
- makeGlobalVariables(undefined, {
244
- blockNumber,
245
- timestamp: this.nextBlockTimestamp,
246
- version: this.version,
247
- chainId: this.chainId,
248
- }),
249
- ),
250
- new Body([txEffect]),
251
- );
262
+ const globals = makeGlobalVariables(undefined, {
263
+ blockNumber,
264
+ timestamp: this.nextBlockTimestamp,
265
+ version: this.version,
266
+ chainId: this.chainId,
267
+ });
268
+ const block = await makeTXEBlock(forkedWorldTrees, globals, [txEffect]);
252
269
 
253
270
  await forkedWorldTrees.close();
254
271
 
@@ -266,10 +283,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
266
283
  isStaticCall: boolean = false,
267
284
  ) {
268
285
  this.logger.verbose(
269
- `Executing external function ${await this.contractDataProvider.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
286
+ `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
270
287
  );
271
288
 
272
- const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
289
+ const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
273
290
  if (!artifact) {
274
291
  const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
275
292
  ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
@@ -289,10 +306,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
289
306
 
290
307
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
291
308
 
292
- const blockHeader = await this.pxeOracleInterface.getAnchorBlockHeader();
309
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
293
310
 
294
- const txRequestHash = getSingleTxBlockRequestHash(blockNumber);
295
- const noteCache = new ExecutionNoteCache(txRequestHash);
311
+ const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
312
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
296
313
  const taggingIndexCache = new ExecutionTaggingIndexCache();
297
314
 
298
315
  const simulator = new WASMSimulator();
@@ -310,7 +327,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
310
327
  HashedValuesCache.create([new HashedValues(args, argsHash)]),
311
328
  noteCache,
312
329
  taggingIndexCache,
313
- this.pxeOracleInterface,
330
+ this.contractStore,
331
+ this.noteStore,
332
+ this.keyStore,
333
+ this.addressStore,
334
+ this.stateMachine.node,
335
+ this.stateMachine.anchorBlockStore,
336
+ this.senderTaggingStore,
337
+ this.recipientTaggingStore,
338
+ this.senderAddressBookStore,
339
+ this.capsuleStore,
340
+ this.privateEventStore,
314
341
  0,
315
342
  1,
316
343
  undefined, // log
@@ -359,8 +386,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
359
386
  // According to the protocol rules, the nonce generator for the note hashes
360
387
  // can either be the first nullifier in the tx or the hash of the initial tx request
361
388
  // if there are none.
362
- const nonceGenerator = result.firstNullifier.equals(Fr.ZERO) ? txRequestHash : result.firstNullifier;
363
- const { publicInputs } = await generateSimulatedProvingResult(result, nonceGenerator, this.contractDataProvider);
389
+ const nonceGenerator = result.firstNullifier.equals(Fr.ZERO) ? protocolNullifier : result.firstNullifier;
390
+ const { publicInputs } = await generateSimulatedProvingResult(result, nonceGenerator, this.contractStore);
364
391
 
365
392
  const globals = makeGlobalVariables();
366
393
  globals.blockNumber = blockNumber;
@@ -371,16 +398,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
371
398
 
372
399
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
373
400
 
374
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractDataProvider));
401
+ const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
375
402
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
403
+ const config = PublicSimulatorConfig.from({
404
+ skipFeeEnforcement: true,
405
+ collectDebugLogs: true,
406
+ collectHints: false,
407
+ collectStatistics: false,
408
+ collectCallMetadata: true,
409
+ });
376
410
  const processor = new PublicProcessor(
377
411
  globals,
378
412
  guardedMerkleTrees,
379
413
  contractsDB,
380
- new PublicTxSimulator(guardedMerkleTrees, contractsDB, globals, {
381
- doMerkleOperations: true,
382
- skipFeeEnforcement: true,
383
- }),
414
+ new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config),
384
415
  new TestDateProvider(),
385
416
  );
386
417
 
@@ -406,7 +437,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
406
437
  } else if (!processedTx.revertCode.isOK()) {
407
438
  if (processedTx.revertReason) {
408
439
  try {
409
- await enrichPublicSimulationError(processedTx.revertReason, this.contractDataProvider, this.logger);
440
+ await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
410
441
  // eslint-disable-next-line no-empty
411
442
  } catch {}
412
443
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -435,13 +466,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
435
466
  const l1ToL2Messages = Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero);
436
467
  await forkedWorldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2Messages);
437
468
 
438
- const body = new Body([txEffect]);
439
-
440
- const l2Block = new L2Block(
441
- makeAppendOnlyTreeSnapshot(),
442
- await makeTXEBlockHeader(forkedWorldTrees, globals),
443
- body,
444
- );
469
+ const l2Block = await makeTXEBlock(forkedWorldTrees, globals, [txEffect]);
445
470
 
446
471
  await this.stateMachine.handleL2Block(l2Block);
447
472
 
@@ -457,7 +482,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
457
482
  isStaticCall: boolean,
458
483
  ) {
459
484
  this.logger.verbose(
460
- `Executing public function ${await this.contractDataProvider.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
485
+ `Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
461
486
  );
462
487
 
463
488
  const blockNumber = await this.txeGetNextBlockNumber();
@@ -470,7 +495,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
470
495
 
471
496
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
472
497
 
473
- const anchorBlockHeader = await this.pxeOracleInterface.getAnchorBlockHeader();
498
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
474
499
 
475
500
  const calldataHash = await computeCalldataHash(calldata);
476
501
  const calldataHashedValues = new HashedValues(calldata, calldataHash);
@@ -484,12 +509,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
484
509
 
485
510
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
486
511
 
487
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractDataProvider));
512
+ const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
488
513
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
489
- const simulator = new PublicTxSimulator(guardedMerkleTrees, contractsDB, globals, {
490
- doMerkleOperations: true,
514
+ const config = PublicSimulatorConfig.from({
491
515
  skipFeeEnforcement: true,
516
+ collectDebugLogs: true,
517
+ collectHints: false,
518
+ collectStatistics: false,
519
+ collectCallMetadata: true,
492
520
  });
521
+ const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
493
522
  const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, simulator, new TestDateProvider());
494
523
 
495
524
  // We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
@@ -497,9 +526,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
497
526
  // side-effect, which the AVM then expects to exist in order to use it as the nonce generator when siloing notes as
498
527
  // unique.
499
528
  const nonRevertibleAccumulatedData = PrivateToPublicAccumulatedData.empty();
500
- if (!isStaticCall) {
501
- nonRevertibleAccumulatedData.nullifiers[0] = getSingleTxBlockRequestHash(blockNumber);
502
- }
529
+ nonRevertibleAccumulatedData.nullifiers[0] = getSingleTxBlockRequestHash(blockNumber);
503
530
 
504
531
  // The enqueued public call itself we make be revertible so that the public execution is itself revertible, as tests
505
532
  // may require producing reverts.
@@ -550,7 +577,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
550
577
  } else if (!processedTx.revertCode.isOK()) {
551
578
  if (processedTx.revertReason) {
552
579
  try {
553
- await enrichPublicSimulationError(processedTx.revertReason, this.contractDataProvider, this.logger);
580
+ await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
554
581
  // eslint-disable-next-line no-empty
555
582
  } catch {}
556
583
  throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
@@ -582,13 +609,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
582
609
  const l1ToL2Messages = Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero);
583
610
  await forkedWorldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2Messages);
584
611
 
585
- const body = new Body([txEffect]);
586
-
587
- const l2Block = new L2Block(
588
- makeAppendOnlyTreeSnapshot(),
589
- await makeTXEBlockHeader(forkedWorldTrees, globals),
590
- body,
591
- );
612
+ const l2Block = await makeTXEBlock(forkedWorldTrees, globals, [txEffect]);
592
613
 
593
614
  await this.stateMachine.handleL2Block(l2Block);
594
615
 
@@ -602,7 +623,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
602
623
  functionSelector: FunctionSelector,
603
624
  args: Fr[],
604
625
  ) {
605
- const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
626
+ const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
606
627
  if (!artifact) {
607
628
  throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
608
629
  }
@@ -613,7 +634,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
613
634
  to: targetContractAddress,
614
635
  };
615
636
 
616
- const entryPointArtifact = await this.pxeOracleInterface.getFunctionArtifact(call.to, call.selector);
637
+ const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
617
638
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
618
639
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
619
640
  }
@@ -624,7 +645,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
624
645
  });
625
646
 
626
647
  try {
627
- const oracle = new UtilityExecutionOracle(call.to, [], [], this.pxeOracleInterface);
648
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
649
+ const oracle = new UtilityExecutionOracle(
650
+ call.to,
651
+ [],
652
+ [],
653
+ anchorBlockHeader,
654
+ this.contractStore,
655
+ this.noteStore,
656
+ this.keyStore,
657
+ this.addressStore,
658
+ this.stateMachine.node,
659
+ this.stateMachine.anchorBlockStore,
660
+ this.recipientTaggingStore,
661
+ this.senderAddressBookStore,
662
+ this.capsuleStore,
663
+ this.privateEventStore,
664
+ );
628
665
  const acirExecutionResult = await new WASMSimulator()
629
666
  .executeUserCircuit(toACVMWitness(0, args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
630
667
  .catch((err: Error) => {
@@ -652,7 +689,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
652
689
  return [this.nextBlockTimestamp, this.authwits];
653
690
  }
654
691
 
655
- private async getLastBlockNumber(): Promise<number> {
656
- return (await this.stateMachine.node.getBlockHeader('latest'))?.globalVariables.blockNumber ?? 0;
692
+ private async getLastBlockNumber(): Promise<BlockNumber> {
693
+ const header = await this.stateMachine.node.getBlockHeader('latest');
694
+ return header ? header.globalVariables.blockNumber : BlockNumber.ZERO;
657
695
  }
658
696
  }