@aztec/txe 0.0.1-commit.0b941701 → 0.0.1-commit.134ed76

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 (40) hide show
  1. package/dest/oracle/interfaces.d.ts +2 -2
  2. package/dest/oracle/interfaces.d.ts.map +1 -1
  3. package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
  4. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  5. package/dest/oracle/txe_oracle_public_context.js +3 -4
  6. package/dest/oracle/txe_oracle_top_level_context.d.ts +2 -2
  7. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_top_level_context.js +84 -22
  9. package/dest/rpc_translator.d.ts +7 -7
  10. package/dest/rpc_translator.d.ts.map +1 -1
  11. package/dest/rpc_translator.js +40 -29
  12. package/dest/state_machine/archiver.d.ts +1 -1
  13. package/dest/state_machine/archiver.d.ts.map +1 -1
  14. package/dest/state_machine/archiver.js +2 -0
  15. package/dest/state_machine/dummy_p2p_client.d.ts +9 -8
  16. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  17. package/dest/state_machine/dummy_p2p_client.js +15 -12
  18. package/dest/state_machine/index.d.ts +5 -5
  19. package/dest/state_machine/index.d.ts.map +1 -1
  20. package/dest/state_machine/index.js +14 -9
  21. package/dest/state_machine/mock_epoch_cache.d.ts +3 -1
  22. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  23. package/dest/state_machine/mock_epoch_cache.js +4 -0
  24. package/dest/txe_session.d.ts +1 -1
  25. package/dest/txe_session.d.ts.map +1 -1
  26. package/dest/txe_session.js +64 -8
  27. package/dest/utils/block_creation.d.ts +1 -1
  28. package/dest/utils/block_creation.d.ts.map +1 -1
  29. package/dest/utils/block_creation.js +3 -1
  30. package/package.json +15 -15
  31. package/src/oracle/interfaces.ts +1 -1
  32. package/src/oracle/txe_oracle_public_context.ts +3 -5
  33. package/src/oracle/txe_oracle_top_level_context.ts +100 -71
  34. package/src/rpc_translator.ts +42 -24
  35. package/src/state_machine/archiver.ts +2 -0
  36. package/src/state_machine/dummy_p2p_client.ts +21 -15
  37. package/src/state_machine/index.ts +24 -9
  38. package/src/state_machine/mock_epoch_cache.ts +5 -0
  39. package/src/txe_session.ts +63 -64
  40. package/src/utils/block_creation.ts +3 -1
@@ -6,6 +6,7 @@ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
6
6
  import type { ProtocolContract } from '@aztec/protocol-contracts';
7
7
  import {
8
8
  AddressStore,
9
+ AnchorBlockStore,
9
10
  CapsuleStore,
10
11
  JobCoordinator,
11
12
  NoteService,
@@ -49,6 +50,7 @@ import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfac
49
50
  import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
50
51
  import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
51
52
  import { RPCTranslator } from './rpc_translator.js';
53
+ import { TXEArchiver } from './state_machine/archiver.js';
52
54
  import { TXEStateMachine } from './state_machine/index.js';
53
55
  import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
54
56
  import { TXEAccountStore } from './util/txe_account_store.js';
@@ -176,7 +178,9 @@ export class TXESession implements TXESessionStateHandler {
176
178
  await contractStore.addContractInstance(instance);
177
179
  }
178
180
 
179
- const stateMachine = await TXEStateMachine.create(store);
181
+ const archiver = new TXEArchiver(store);
182
+ const anchorBlockStore = new AnchorBlockStore(store);
183
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
180
184
 
181
185
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
182
186
  const version = new Fr(await stateMachine.node.getVersion());
@@ -312,17 +316,14 @@ export class TXESession implements TXESessionStateHandler {
312
316
  ): Promise<PrivateContextInputs> {
313
317
  this.exitTopLevelState();
314
318
 
315
- await new NoteService(
316
- this.noteStore,
317
- this.stateMachine.node,
318
- this.stateMachine.anchorBlockStore,
319
- this.currentJobId,
320
- ).syncNoteNullifiers(contractAddress);
321
-
322
319
  // Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
323
320
  // build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
324
321
  // a single transaction with the effects of what was done in the test.
325
322
  const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
323
+
324
+ await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
325
+ contractAddress,
326
+ );
326
327
  const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
327
328
 
328
329
  const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
@@ -338,30 +339,30 @@ export class TXESession implements TXESessionStateHandler {
338
339
  const taggingIndexCache = new ExecutionTaggingIndexCache();
339
340
 
340
341
  const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
341
- this.oracleHandler = new PrivateExecutionOracle(
342
- Fr.ZERO,
343
- new TxContext(this.chainId, this.version, GasSettings.empty()),
344
- new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
345
- anchorBlock!,
342
+ this.oracleHandler = new PrivateExecutionOracle({
343
+ argsHash: Fr.ZERO,
344
+ txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
345
+ callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
346
+ anchorBlockHeader: anchorBlock!,
346
347
  utilityExecutor,
347
- [],
348
- [],
349
- new HashedValuesCache(),
348
+ authWitnesses: [],
349
+ capsules: [],
350
+ executionCache: new HashedValuesCache(),
350
351
  noteCache,
351
352
  taggingIndexCache,
352
- this.contractStore,
353
- this.noteStore,
354
- this.keyStore,
355
- this.addressStore,
356
- this.stateMachine.node,
357
- this.stateMachine.anchorBlockStore,
358
- this.senderTaggingStore,
359
- this.recipientTaggingStore,
360
- this.senderAddressBookStore,
361
- this.capsuleStore,
362
- this.privateEventStore,
363
- this.currentJobId,
364
- );
353
+ contractStore: this.contractStore,
354
+ noteStore: this.noteStore,
355
+ keyStore: this.keyStore,
356
+ addressStore: this.addressStore,
357
+ aztecNode: this.stateMachine.node,
358
+ senderTaggingStore: this.senderTaggingStore,
359
+ recipientTaggingStore: this.recipientTaggingStore,
360
+ senderAddressBookStore: this.senderAddressBookStore,
361
+ capsuleStore: this.capsuleStore,
362
+ privateEventStore: this.privateEventStore,
363
+ contractSyncService: this.stateMachine.contractSyncService,
364
+ jobId: this.currentJobId,
365
+ });
365
366
 
366
367
  // We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
367
368
  // data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
@@ -401,6 +402,8 @@ export class TXESession implements TXESessionStateHandler {
401
402
  async enterUtilityState(contractAddress: AztecAddress = DEFAULT_ADDRESS) {
402
403
  this.exitTopLevelState();
403
404
 
405
+ const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
406
+
404
407
  // There is no automatic message discovery and contract-driven syncing process in inlined private or utility
405
408
  // contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
406
409
  // we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
@@ -409,29 +412,26 @@ export class TXESession implements TXESessionStateHandler {
409
412
  await new NoteService(
410
413
  this.noteStore,
411
414
  this.stateMachine.node,
412
- this.stateMachine.anchorBlockStore,
415
+ anchorBlockHeader,
413
416
  this.currentJobId,
414
417
  ).syncNoteNullifiers(contractAddress);
415
418
 
416
- const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
417
-
418
- this.oracleHandler = new UtilityExecutionOracle(
419
+ this.oracleHandler = new UtilityExecutionOracle({
419
420
  contractAddress,
420
- [],
421
- [],
421
+ authWitnesses: [],
422
+ capsules: [],
422
423
  anchorBlockHeader,
423
- this.contractStore,
424
- this.noteStore,
425
- this.keyStore,
426
- this.addressStore,
427
- this.stateMachine.node,
428
- this.stateMachine.anchorBlockStore,
429
- this.recipientTaggingStore,
430
- this.senderAddressBookStore,
431
- this.capsuleStore,
432
- this.privateEventStore,
433
- this.currentJobId,
434
- );
424
+ contractStore: this.contractStore,
425
+ noteStore: this.noteStore,
426
+ keyStore: this.keyStore,
427
+ addressStore: this.addressStore,
428
+ aztecNode: this.stateMachine.node,
429
+ recipientTaggingStore: this.recipientTaggingStore,
430
+ senderAddressBookStore: this.senderAddressBookStore,
431
+ capsuleStore: this.capsuleStore,
432
+ privateEventStore: this.privateEventStore,
433
+ jobId: this.currentJobId,
434
+ });
435
435
 
436
436
  this.state = { name: 'UTILITY' };
437
437
  this.logger.debug(`Entered state ${this.state.name}`);
@@ -506,23 +506,22 @@ export class TXESession implements TXESessionStateHandler {
506
506
  }
507
507
 
508
508
  try {
509
- const oracle = new UtilityExecutionOracle(
510
- call.to,
511
- [],
512
- [],
513
- anchorBlock!,
514
- this.contractStore,
515
- this.noteStore,
516
- this.keyStore,
517
- this.addressStore,
518
- this.stateMachine.node,
519
- this.stateMachine.anchorBlockStore,
520
- this.recipientTaggingStore,
521
- this.senderAddressBookStore,
522
- this.capsuleStore,
523
- this.privateEventStore,
524
- this.currentJobId,
525
- );
509
+ const oracle = new UtilityExecutionOracle({
510
+ contractAddress: call.to,
511
+ authWitnesses: [],
512
+ capsules: [],
513
+ anchorBlockHeader: anchorBlock!,
514
+ contractStore: this.contractStore,
515
+ noteStore: this.noteStore,
516
+ keyStore: this.keyStore,
517
+ addressStore: this.addressStore,
518
+ aztecNode: this.stateMachine.node,
519
+ recipientTaggingStore: this.recipientTaggingStore,
520
+ senderAddressBookStore: this.senderAddressBookStore,
521
+ capsuleStore: this.capsuleStore,
522
+ privateEventStore: this.privateEventStore,
523
+ jobId: this.currentJobId,
524
+ });
526
525
  await new WASMSimulator()
527
526
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
528
527
  .catch((err: Error) => {
@@ -87,7 +87,9 @@ export async function makeTXEBlock(
87
87
  const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
88
88
  const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
89
89
 
90
- // L2Block requires checkpointNumber and indexWithinCheckpoint
90
+ // L2Block requires checkpointNumber and indexWithinCheckpoint.
91
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
92
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
91
93
  const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
92
94
  const indexWithinCheckpoint = IndexWithinCheckpoint(0);
93
95