@aztec/txe 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed

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 (43) hide show
  1. package/dest/oracle/interfaces.d.ts +3 -3
  2. package/dest/oracle/interfaces.d.ts.map +1 -1
  3. package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
  4. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  5. package/dest/oracle/txe_oracle_public_context.js +6 -6
  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 +86 -24
  9. package/dest/rpc_translator.d.ts +14 -8
  10. package/dest/rpc_translator.d.ts.map +1 -1
  11. package/dest/rpc_translator.js +58 -34
  12. package/dest/state_machine/archiver.d.ts +2 -2
  13. package/dest/state_machine/archiver.d.ts.map +1 -1
  14. package/dest/state_machine/archiver.js +7 -6
  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 +7 -7
  19. package/dest/state_machine/index.d.ts.map +1 -1
  20. package/dest/state_machine/index.js +30 -16
  21. package/dest/state_machine/mock_epoch_cache.d.ts +6 -2
  22. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  23. package/dest/state_machine/mock_epoch_cache.js +6 -1
  24. package/dest/state_machine/synchronizer.d.ts +3 -3
  25. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  26. package/dest/txe_session.d.ts +1 -1
  27. package/dest/txe_session.d.ts.map +1 -1
  28. package/dest/txe_session.js +69 -11
  29. package/dest/utils/block_creation.d.ts +5 -5
  30. package/dest/utils/block_creation.d.ts.map +1 -1
  31. package/dest/utils/block_creation.js +7 -5
  32. package/package.json +15 -15
  33. package/src/oracle/interfaces.ts +2 -2
  34. package/src/oracle/txe_oracle_public_context.ts +8 -10
  35. package/src/oracle/txe_oracle_top_level_context.ts +104 -72
  36. package/src/rpc_translator.ts +60 -28
  37. package/src/state_machine/archiver.ts +6 -8
  38. package/src/state_machine/dummy_p2p_client.ts +21 -15
  39. package/src/state_machine/index.ts +48 -19
  40. package/src/state_machine/mock_epoch_cache.ts +7 -1
  41. package/src/state_machine/synchronizer.ts +2 -2
  42. package/src/txe_session.ts +74 -66
  43. package/src/utils/block_creation.ts +8 -6
@@ -131,13 +131,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
131
131
  }
132
132
 
133
133
  // We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
134
- utilityDebugLog(level: number, message: string, fields: Fr[]): void {
134
+ utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
135
135
  if (!LogLevels[level]) {
136
- throw new Error(`Invalid debug log level: ${level}`);
136
+ throw new Error(`Invalid log level: ${level}`);
137
137
  }
138
138
  const levelName = LogLevels[level];
139
139
 
140
140
  this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
141
+ return Promise.resolve();
141
142
  }
142
143
 
143
144
  txeGetDefaultAddress(): AztecAddress {
@@ -296,12 +297,25 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
296
297
  throw new Error(message);
297
298
  }
298
299
 
300
+ // When `from` is the zero address (used when creating a new contract account for example),
301
+ // we disable scope filtering by setting effectiveScopes to undefined. This allows these operations
302
+ // to proceed without requiring keys registered for the zero address.
303
+ const effectiveScopes = from.isZero() ? undefined : [from];
304
+
299
305
  // Sync notes before executing private function to discover notes from previous transactions
300
- const utilityExecutor = async (call: FunctionCall) => {
301
- await this.executeUtilityCall(call);
306
+ const utilityExecutor = async (call: FunctionCall, execScopes: undefined | AztecAddress[]) => {
307
+ await this.executeUtilityCall(call, execScopes);
302
308
  };
303
309
 
304
- await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, utilityExecutor);
310
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
311
+ await this.stateMachine.contractSyncService.ensureContractSynced(
312
+ targetContractAddress,
313
+ functionSelector,
314
+ utilityExecutor,
315
+ blockHeader,
316
+ this.jobId,
317
+ effectiveScopes,
318
+ );
305
319
 
306
320
  const blockNumber = await this.txeGetNextBlockNumber();
307
321
 
@@ -313,8 +327,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
313
327
 
314
328
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
315
329
 
316
- const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
317
-
318
330
  const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
319
331
  const noteCache = new ExecutionNoteCache(protocolNullifier);
320
332
  // In production, the account contract sets the min revertible counter before calling the app function.
@@ -326,43 +338,37 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
326
338
 
327
339
  const simulator = new WASMSimulator();
328
340
 
329
- const privateExecutionOracle = new PrivateExecutionOracle(
341
+ const privateExecutionOracle = new PrivateExecutionOracle({
330
342
  argsHash,
331
343
  txContext,
332
344
  callContext,
333
- /** Header of a block whose state is used during private execution (not the block the transaction is included in). */
334
- blockHeader,
345
+ anchorBlockHeader: blockHeader,
335
346
  utilityExecutor,
336
- /** List of transient auth witnesses to be used during this simulation */
337
- Array.from(this.authwits.values()),
338
- /** List of transient auth witnesses to be used during this simulation */
339
- [],
340
- HashedValuesCache.create([new HashedValues(args, argsHash)]),
347
+ authWitnesses: Array.from(this.authwits.values()),
348
+ capsules: [],
349
+ executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
341
350
  noteCache,
342
351
  taggingIndexCache,
343
- this.contractStore,
344
- this.noteStore,
345
- this.keyStore,
346
- this.addressStore,
347
- this.stateMachine.node,
348
- this.stateMachine.anchorBlockStore,
349
- this.senderTaggingStore,
350
- this.recipientTaggingStore,
351
- this.senderAddressBookStore,
352
- this.capsuleStore,
353
- this.privateEventStore,
354
- this.jobId,
355
- 0, // totalPublicArgsCount
356
- minRevertibleSideEffectCounter, // (start) sideEffectCounter
357
- undefined, // log
358
- undefined, // scopes
359
- /**
360
- * In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
361
- * contract would perform, including setting senderForTags.
362
- */
363
- from,
352
+ contractStore: this.contractStore,
353
+ noteStore: this.noteStore,
354
+ keyStore: this.keyStore,
355
+ addressStore: this.addressStore,
356
+ aztecNode: this.stateMachine.node,
357
+ senderTaggingStore: this.senderTaggingStore,
358
+ recipientTaggingStore: this.recipientTaggingStore,
359
+ senderAddressBookStore: this.senderAddressBookStore,
360
+ capsuleStore: this.capsuleStore,
361
+ privateEventStore: this.privateEventStore,
362
+ contractSyncService: this.stateMachine.contractSyncService,
363
+ jobId: this.jobId,
364
+ totalPublicCalldataCount: 0,
365
+ sideEffectCounter: minRevertibleSideEffectCounter,
366
+ scopes: effectiveScopes,
367
+ // In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
368
+ // contract would perform, including setting senderForTags.
369
+ senderForTags: from,
364
370
  simulator,
365
- );
371
+ });
366
372
 
367
373
  // 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.
368
374
  let result: PrivateExecutionResult;
@@ -401,7 +407,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
401
407
  // We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
402
408
  const { publicInputs } = await generateSimulatedProvingResult(
403
409
  result,
404
- this.contractStore,
410
+ (addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
405
411
  minRevertibleSideEffectCounter,
406
412
  );
407
413
 
@@ -414,7 +420,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
414
420
 
415
421
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
416
422
 
417
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
423
+ const bindings = this.logger.getBindings();
424
+ const contractsDB = new PublicContractsDB(
425
+ new TXEPublicContractDataSource(blockNumber, this.contractStore),
426
+ bindings,
427
+ );
418
428
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
419
429
  const config = PublicSimulatorConfig.from({
420
430
  skipFeeEnforcement: true,
@@ -427,8 +437,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
427
437
  globals,
428
438
  guardedMerkleTrees,
429
439
  contractsDB,
430
- new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config),
440
+ new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
431
441
  new TestDateProvider(),
442
+ undefined,
443
+ createLogger('simulator:public-processor', bindings),
432
444
  );
433
445
 
434
446
  const tx = await Tx.create({
@@ -525,7 +537,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
525
537
 
526
538
  const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
527
539
 
528
- const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
540
+ const bindings2 = this.logger.getBindings();
541
+ const contractsDB = new PublicContractsDB(
542
+ new TXEPublicContractDataSource(blockNumber, this.contractStore),
543
+ bindings2,
544
+ );
529
545
  const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
530
546
  const config = PublicSimulatorConfig.from({
531
547
  skipFeeEnforcement: true,
@@ -534,8 +550,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
534
550
  collectStatistics: false,
535
551
  collectCallMetadata: true,
536
552
  });
537
- const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
538
- const processor = new PublicProcessor(globals, guardedMerkleTrees, contractsDB, simulator, new TestDateProvider());
553
+ const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
554
+ const processor = new PublicProcessor(
555
+ globals,
556
+ guardedMerkleTrees,
557
+ contractsDB,
558
+ simulator,
559
+ new TestDateProvider(),
560
+ undefined,
561
+ createLogger('simulator:public-processor', bindings2),
562
+ );
539
563
 
540
564
  // We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
541
565
  // kernel init would in this case inject a nullifier with the transaction request hash as a non-revertible
@@ -645,25 +669,33 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
645
669
  }
646
670
 
647
671
  // Sync notes before executing utility function to discover notes from previous transactions
648
- await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, async call => {
649
- await this.executeUtilityCall(call);
650
- });
651
-
652
- const call = new FunctionCall(
653
- artifact.name,
672
+ const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
673
+ await this.stateMachine.contractSyncService.ensureContractSynced(
654
674
  targetContractAddress,
655
675
  functionSelector,
656
- FunctionType.UTILITY,
657
- false,
658
- false,
659
- args,
660
- [],
676
+ async (call, execScopes) => {
677
+ await this.executeUtilityCall(call, execScopes);
678
+ },
679
+ blockHeader,
680
+ this.jobId,
681
+ undefined,
661
682
  );
662
683
 
663
- return this.executeUtilityCall(call);
684
+ const call = FunctionCall.from({
685
+ name: artifact.name,
686
+ to: targetContractAddress,
687
+ selector: functionSelector,
688
+ type: FunctionType.UTILITY,
689
+ hideMsgSender: false,
690
+ isStatic: false,
691
+ args,
692
+ returnTypes: [],
693
+ });
694
+
695
+ return this.executeUtilityCall(call, undefined);
664
696
  }
665
697
 
666
- private async executeUtilityCall(call: FunctionCall): Promise<Fr[]> {
698
+ private async executeUtilityCall(call: FunctionCall, scopes: undefined | AztecAddress[]): Promise<Fr[]> {
667
699
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
668
700
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
669
701
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -676,23 +708,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
676
708
 
677
709
  try {
678
710
  const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
679
- const oracle = new UtilityExecutionOracle(
680
- call.to,
681
- [],
682
- [],
711
+ const oracle = new UtilityExecutionOracle({
712
+ contractAddress: call.to,
713
+ authWitnesses: [],
714
+ capsules: [],
683
715
  anchorBlockHeader,
684
- this.contractStore,
685
- this.noteStore,
686
- this.keyStore,
687
- this.addressStore,
688
- this.stateMachine.node,
689
- this.stateMachine.anchorBlockStore,
690
- this.recipientTaggingStore,
691
- this.senderAddressBookStore,
692
- this.capsuleStore,
693
- this.privateEventStore,
694
- this.jobId,
695
- );
716
+ contractStore: this.contractStore,
717
+ noteStore: this.noteStore,
718
+ keyStore: this.keyStore,
719
+ addressStore: this.addressStore,
720
+ aztecNode: this.stateMachine.node,
721
+ recipientTaggingStore: this.recipientTaggingStore,
722
+ senderAddressBookStore: this.senderAddressBookStore,
723
+ capsuleStore: this.capsuleStore,
724
+ privateEventStore: this.privateEventStore,
725
+ jobId: this.jobId,
726
+ scopes,
727
+ });
696
728
  const acirExecutionResult = await new WASMSimulator()
697
729
  .executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
698
730
  .catch((err: Error) => {
@@ -10,8 +10,7 @@ import {
10
10
  } from '@aztec/pxe/simulator';
11
11
  import { type ContractArtifact, EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
12
12
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
- import { L2BlockHash } from '@aztec/stdlib/block';
14
- import { MerkleTreeId } from '@aztec/stdlib/trees';
13
+ import { BlockHash } from '@aztec/stdlib/block';
15
14
 
16
15
  import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
17
16
  import type { TXESessionStateHandler } from './txe_session.js';
@@ -329,7 +328,7 @@ export class RPCTranslator {
329
328
 
330
329
  // When the argument is a slice, noir automatically adds a length field to oracle call.
331
330
  // When the argument is an array, we add the field length manually to the signature.
332
- utilityDebugLog(
331
+ async utilityLog(
333
332
  foreignLevel: ForeignCallSingle,
334
333
  foreignMessage: ForeignCallArray,
335
334
  _foreignLength: ForeignCallSingle,
@@ -341,7 +340,7 @@ export class RPCTranslator {
341
340
  .join('');
342
341
  const fields = fromArray(foreignFields);
343
342
 
344
- this.handlerAsMisc().utilityDebugLog(level, message, fields);
343
+ await this.handlerAsMisc().utilityLog(level, message, fields);
345
344
 
346
345
  return toForeignCallResult([]);
347
346
  }
@@ -352,7 +351,7 @@ export class RPCTranslator {
352
351
  foreignStartStorageSlot: ForeignCallSingle,
353
352
  foreignNumberOfElements: ForeignCallSingle,
354
353
  ) {
355
- const blockHash = L2BlockHash.fromString(foreignBlockHash);
354
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
356
355
  const contractAddress = addressFromSingle(foreignContractAddress);
357
356
  const startStorageSlot = fromSingle(foreignStartStorageSlot);
358
357
  const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
@@ -368,7 +367,7 @@ export class RPCTranslator {
368
367
  }
369
368
 
370
369
  async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
371
- const blockHash = L2BlockHash.fromString(foreignBlockHash);
370
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
372
371
  const leafSlot = fromSingle(foreignLeafSlot);
373
372
 
374
373
  const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
@@ -513,6 +512,15 @@ export class RPCTranslator {
513
512
  return toForeignCallResult([]);
514
513
  }
515
514
 
515
+ async privateIsNullifierPending(foreignInnerNullifier: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
516
+ const innerNullifier = fromSingle(foreignInnerNullifier);
517
+ const contractAddress = addressFromSingle(foreignContractAddress);
518
+
519
+ const isPending = await this.handlerAsPrivate().privateIsNullifierPending(innerNullifier, contractAddress);
520
+
521
+ return toForeignCallResult([toSingle(new Fr(isPending))]);
522
+ }
523
+
516
524
  async utilityCheckNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
517
525
  const innerNullifier = fromSingle(foreignInnerNullifier);
518
526
 
@@ -537,12 +545,23 @@ export class RPCTranslator {
537
545
  );
538
546
  }
539
547
 
540
- async utilityGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
548
+ async utilityTryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
541
549
  const address = addressFromSingle(foreignAddress);
542
550
 
543
- const { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(address);
551
+ const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(address);
544
552
 
545
- return toForeignCallResult([toArray([...publicKeys.toFields(), partialAddress])]);
553
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
554
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
555
+ if (result === undefined) {
556
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
557
+ return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
558
+ } else {
559
+ // Data was found so we set `some` to 1 and return it along with `value`.
560
+ return toForeignCallResult([
561
+ toSingle(new Fr(1)),
562
+ toArray([...result.publicKeys.toFields(), result.partialAddress]),
563
+ ]);
564
+ }
546
565
  }
547
566
 
548
567
  async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
@@ -566,7 +585,7 @@ export class RPCTranslator {
566
585
  }
567
586
 
568
587
  async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
569
- const blockHash = L2BlockHash.fromString(foreignBlockHash);
588
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
570
589
  const nullifier = fromSingle(foreignNullifier);
571
590
 
572
591
  const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
@@ -633,30 +652,43 @@ export class RPCTranslator {
633
652
  return toForeignCallResult(header.toFields().map(toSingle));
634
653
  }
635
654
 
636
- async utilityGetMembershipWitness(
655
+ async utilityGetNoteHashMembershipWitness(
656
+ foreignAnchorBlockHash: ForeignCallSingle,
657
+ foreignNoteHash: ForeignCallSingle,
658
+ ) {
659
+ const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
660
+ const noteHash = fromSingle(foreignNoteHash);
661
+
662
+ const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
663
+
664
+ if (!witness) {
665
+ throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
666
+ }
667
+ return toForeignCallResult(witness.toNoirRepresentation());
668
+ }
669
+
670
+ async utilityGetBlockHashMembershipWitness(
671
+ foreignAnchorBlockHash: ForeignCallSingle,
637
672
  foreignBlockHash: ForeignCallSingle,
638
- foreignTreeId: ForeignCallSingle,
639
- foreignLeafValue: ForeignCallSingle,
640
673
  ) {
641
- const blockHash = L2BlockHash.fromString(foreignBlockHash);
642
- const treeId = fromSingle(foreignTreeId).toNumber();
643
- const leafValue = fromSingle(foreignLeafValue);
674
+ const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
675
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
644
676
 
645
- const witness = await this.handlerAsUtility().utilityGetMembershipWitness(blockHash, treeId, leafValue);
677
+ const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
646
678
 
647
679
  if (!witness) {
648
680
  throw new Error(
649
- `Membership witness in tree ${MerkleTreeId[treeId]} not found for value ${leafValue} at block ${blockHash}.`,
681
+ `Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
650
682
  );
651
683
  }
652
- return toForeignCallResult([toSingle(witness[0]), toArray(witness.slice(1))]);
684
+ return toForeignCallResult(witness.toNoirRepresentation());
653
685
  }
654
686
 
655
687
  async utilityGetLowNullifierMembershipWitness(
656
688
  foreignBlockHash: ForeignCallSingle,
657
689
  foreignNullifier: ForeignCallSingle,
658
690
  ) {
659
- const blockHash = L2BlockHash.fromString(foreignBlockHash);
691
+ const blockHash = new BlockHash(fromSingle(foreignBlockHash));
660
692
  const nullifier = fromSingle(foreignNullifier);
661
693
 
662
694
  const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
@@ -675,7 +707,7 @@ export class RPCTranslator {
675
707
  return toForeignCallResult([]);
676
708
  }
677
709
 
678
- public async utilityValidateEnqueuedNotesAndEvents(
710
+ public async utilityValidateAndStoreEnqueuedNotesAndEvents(
679
711
  foreignContractAddress: ForeignCallSingle,
680
712
  foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
681
713
  foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
@@ -684,7 +716,7 @@ export class RPCTranslator {
684
716
  const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
685
717
  const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
686
718
 
687
- await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(
719
+ await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
688
720
  contractAddress,
689
721
  noteValidationRequestsArrayBaseSlot,
690
722
  eventValidationRequestsArrayBaseSlot,
@@ -822,10 +854,11 @@ export class RPCTranslator {
822
854
  return toForeignCallResult([]);
823
855
  }
824
856
 
825
- async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle) {
857
+ async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
826
858
  const slot = fromSingle(foreignSlot);
859
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
827
860
 
828
- const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot)).value;
861
+ const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot, contractAddress)).value;
829
862
 
830
863
  return toForeignCallResult([toSingle(new Fr(value))]);
831
864
  }
@@ -897,11 +930,10 @@ export class RPCTranslator {
897
930
  return toForeignCallResult([]);
898
931
  }
899
932
 
900
- async avmOpcodeNullifierExists(foreignInnerNullifier: ForeignCallSingle, foreignTargetAddress: ForeignCallSingle) {
901
- const innerNullifier = fromSingle(foreignInnerNullifier);
902
- const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
933
+ async avmOpcodeNullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
934
+ const siloedNullifier = fromSingle(foreignSiloedNullifier);
903
935
 
904
- const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(innerNullifier, targetAddress);
936
+ const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
905
937
 
906
938
  return toForeignCallResult([toSingle(new Fr(exists))]);
907
939
  }
@@ -17,18 +17,14 @@ export class TXEArchiver extends ArchiverDataSourceBase {
17
17
  private readonly updater = new ArchiverDataStoreUpdater(this.store);
18
18
 
19
19
  constructor(db: AztecAsyncKVStore) {
20
- const store = new KVArchiverDataStore(db, 9999);
20
+ const store = new KVArchiverDataStore(db, 9999, { epochDuration: 32 });
21
21
  super(store);
22
22
  }
23
23
 
24
- // TXE-specific method for adding checkpoints
25
- public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<boolean> {
26
- await this.updater.setNewCheckpointData(checkpoints, result);
27
- return true;
24
+ public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
25
+ await this.updater.addCheckpoints(checkpoints, result);
28
26
  }
29
27
 
30
- // Abstract method implementations
31
-
32
28
  public getRollupAddress(): Promise<EthAddress> {
33
29
  throw new Error('TXE Archiver does not implement "getRollupAddress"');
34
30
  }
@@ -63,7 +59,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
63
59
  if (!checkpointedBlock) {
64
60
  throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
65
61
  }
66
- const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber(number), 1);
62
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
63
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
64
+ const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
67
65
  if (checkpoint.length === 0) {
68
66
  throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
69
67
  }
@@ -6,6 +6,8 @@ import type {
6
6
  P2PBlockReceivedCallback,
7
7
  P2PCheckpointReceivedCallback,
8
8
  P2PConfig,
9
+ P2PDuplicateAttestationCallback,
10
+ P2PDuplicateProposalCallback,
9
11
  P2PSyncState,
10
12
  PeerId,
11
13
  ReqRespSubProtocol,
@@ -16,7 +18,7 @@ import type {
16
18
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
17
19
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
18
20
  import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
19
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
21
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
20
22
 
21
23
  export class DummyP2P implements P2P {
22
24
  public validate(_txs: Tx[]): Promise<void> {
@@ -71,8 +73,8 @@ export class DummyP2P implements P2P {
71
73
  throw new Error('DummyP2P does not implement "sendTx"');
72
74
  }
73
75
 
74
- public deleteTxs(_txHashes: TxHash[]): Promise<void> {
75
- throw new Error('DummyP2P does not implement "deleteTxs"');
76
+ public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
77
+ throw new Error('DummyP2P does not implement "handleFailedExecution"');
76
78
  }
77
79
 
78
80
  public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
@@ -133,8 +135,8 @@ export class DummyP2P implements P2P {
133
135
  throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
134
136
  }
135
137
 
136
- public addCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
137
- throw new Error('DummyP2P does not implement "addCheckpointAttestations"');
138
+ public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
139
+ throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
138
140
  }
139
141
 
140
142
  public getL2BlockHash(_number: number): Promise<string | undefined> {
@@ -157,14 +159,6 @@ export class DummyP2P implements P2P {
157
159
  throw new Error('DummyP2P does not implement "sync"');
158
160
  }
159
161
 
160
- public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
161
- throw new Error('DummyP2P does not implement "requestTxsByHash"');
162
- }
163
-
164
- public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
165
- throw new Error('DummyP2P does not implement "getTxs"');
166
- }
167
-
168
162
  public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
169
163
  throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
170
164
  }
@@ -189,8 +183,12 @@ export class DummyP2P implements P2P {
189
183
  throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
190
184
  }
191
185
 
192
- markTxsAsNonEvictable(_: TxHash[]): Promise<void> {
193
- throw new Error('DummyP2P does not implement "markTxsAsNonEvictable".');
186
+ protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
187
+ throw new Error('DummyP2P does not implement "protectTxs".');
188
+ }
189
+
190
+ prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
191
+ return Promise.resolve();
194
192
  }
195
193
 
196
194
  addReqRespSubProtocol(
@@ -206,4 +204,12 @@ export class DummyP2P implements P2P {
206
204
 
207
205
  //This is no-op
208
206
  public registerThisValidatorAddresses(_address: EthAddress[]): void {}
207
+
208
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
209
+ throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
210
+ }
211
+
212
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
213
+ throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
214
+ }
209
215
  }