@aztec/txe 0.0.1-commit.10bd49492 → 0.0.1-commit.11bf3dd6e

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 (45) hide show
  1. package/dest/oracle/txe_oracle_top_level_context.d.ts +10 -4
  2. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  3. package/dest/oracle/txe_oracle_top_level_context.js +32 -17
  4. package/dest/rpc_translator.d.ts +55 -19
  5. package/dest/rpc_translator.d.ts.map +1 -1
  6. package/dest/rpc_translator.js +170 -47
  7. package/dest/state_machine/archiver.d.ts +1 -1
  8. package/dest/state_machine/archiver.d.ts.map +1 -1
  9. package/dest/state_machine/archiver.js +2 -1
  10. package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
  11. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  12. package/dest/state_machine/dummy_p2p_client.js +5 -2
  13. package/dest/state_machine/global_variable_builder.d.ts +9 -4
  14. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  15. package/dest/state_machine/global_variable_builder.js +9 -3
  16. package/dest/state_machine/index.d.ts +1 -1
  17. package/dest/state_machine/index.d.ts.map +1 -1
  18. package/dest/state_machine/index.js +2 -2
  19. package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
  20. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  21. package/dest/state_machine/mock_epoch_cache.js +35 -2
  22. package/dest/state_machine/synchronizer.d.ts +5 -5
  23. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  24. package/dest/state_machine/synchronizer.js +3 -3
  25. package/dest/txe_session.d.ts +4 -3
  26. package/dest/txe_session.d.ts.map +1 -1
  27. package/dest/txe_session.js +21 -12
  28. package/dest/util/encoding.d.ts +71 -1
  29. package/dest/util/encoding.d.ts.map +1 -1
  30. package/dest/util/encoding.js +4 -0
  31. package/dest/util/txe_public_contract_data_source.d.ts +1 -1
  32. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  33. package/dest/util/txe_public_contract_data_source.js +1 -3
  34. package/package.json +15 -15
  35. package/src/oracle/txe_oracle_top_level_context.ts +42 -21
  36. package/src/rpc_translator.ts +200 -45
  37. package/src/state_machine/archiver.ts +1 -0
  38. package/src/state_machine/dummy_p2p_client.ts +6 -2
  39. package/src/state_machine/global_variable_builder.ts +18 -3
  40. package/src/state_machine/index.ts +3 -1
  41. package/src/state_machine/mock_epoch_cache.ts +46 -3
  42. package/src/state_machine/synchronizer.ts +4 -4
  43. package/src/txe_session.ts +23 -10
  44. package/src/util/encoding.ts +5 -0
  45. package/src/util/txe_public_contract_data_source.ts +0 -2
@@ -10,7 +10,6 @@ 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 { BlockHash } from '@aztec/stdlib/block';
14
13
 
15
14
  import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
16
15
  import type { TXESessionStateHandler } from './txe_session.js';
@@ -20,6 +19,7 @@ import {
20
19
  addressFromSingle,
21
20
  arrayOfArraysToBoundedVecOfArrays,
22
21
  arrayToBoundedVec,
22
+ blockHashFromSingle,
23
23
  bufferToU8Array,
24
24
  fromArray,
25
25
  fromSingle,
@@ -264,10 +264,11 @@ export class RPCTranslator {
264
264
  // PXE oracles
265
265
 
266
266
  // eslint-disable-next-line camelcase
267
- aztec_utl_assertCompatibleOracleVersion(foreignVersion: ForeignCallSingle) {
268
- const version = fromSingle(foreignVersion).toNumber();
267
+ aztec_utl_assertCompatibleOracleVersionV2(foreignMajor: ForeignCallSingle, foreignMinor: ForeignCallSingle) {
268
+ const major = fromSingle(foreignMajor).toNumber();
269
+ const minor = fromSingle(foreignMinor).toNumber();
269
270
 
270
- this.handlerAsMisc().assertCompatibleOracleVersion(version);
271
+ this.handlerAsMisc().assertCompatibleOracleVersion(major, minor);
271
272
 
272
273
  return toForeignCallResult([]);
273
274
  }
@@ -339,20 +340,20 @@ export class RPCTranslator {
339
340
  }
340
341
 
341
342
  // eslint-disable-next-line camelcase
342
- aztec_prv_storeInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
343
+ aztec_prv_setHashPreimage(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
343
344
  const values = fromArray(foreignValues);
344
345
  const hash = fromSingle(foreignHash);
345
346
 
346
- this.handlerAsPrivate().storeInExecutionCache(values, hash);
347
+ this.handlerAsPrivate().setHashPreimage(values, hash);
347
348
 
348
349
  return toForeignCallResult([]);
349
350
  }
350
351
 
351
352
  // eslint-disable-next-line camelcase
352
- async aztec_prv_loadFromExecutionCache(foreignHash: ForeignCallSingle) {
353
+ async aztec_prv_getHashPreimage(foreignHash: ForeignCallSingle) {
353
354
  const hash = fromSingle(foreignHash);
354
355
 
355
- const returns = await this.handlerAsPrivate().loadFromExecutionCache(hash);
356
+ const returns = await this.handlerAsPrivate().getHashPreimage(hash);
356
357
 
357
358
  return toForeignCallResult([toArray(returns)]);
358
359
  }
@@ -378,18 +379,18 @@ export class RPCTranslator {
378
379
  }
379
380
 
380
381
  // eslint-disable-next-line camelcase
381
- async aztec_utl_storageRead(
382
+ async aztec_utl_getFromPublicStorage(
382
383
  foreignBlockHash: ForeignCallSingle,
383
384
  foreignContractAddress: ForeignCallSingle,
384
385
  foreignStartStorageSlot: ForeignCallSingle,
385
386
  foreignNumberOfElements: ForeignCallSingle,
386
387
  ) {
387
- const blockHash = new BlockHash(fromSingle(foreignBlockHash));
388
+ const blockHash = blockHashFromSingle(foreignBlockHash);
388
389
  const contractAddress = addressFromSingle(foreignContractAddress);
389
390
  const startStorageSlot = fromSingle(foreignStartStorageSlot);
390
391
  const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
391
392
 
392
- const values = await this.handlerAsUtility().storageRead(
393
+ const values = await this.handlerAsUtility().getFromPublicStorage(
393
394
  blockHash,
394
395
  contractAddress,
395
396
  startStorageSlot,
@@ -401,7 +402,7 @@ export class RPCTranslator {
401
402
 
402
403
  // eslint-disable-next-line camelcase
403
404
  async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
404
- const blockHash = new BlockHash(fromSingle(foreignBlockHash));
405
+ const blockHash = blockHashFromSingle(foreignBlockHash);
405
406
  const leafSlot = fromSingle(foreignLeafSlot);
406
407
 
407
408
  const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
@@ -556,10 +557,10 @@ export class RPCTranslator {
556
557
  }
557
558
 
558
559
  // eslint-disable-next-line camelcase
559
- async aztec_utl_checkNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
560
+ async aztec_utl_doesNullifierExist(foreignInnerNullifier: ForeignCallSingle) {
560
561
  const innerNullifier = fromSingle(foreignInnerNullifier);
561
562
 
562
- const exists = await this.handlerAsUtility().checkNullifierExists(innerNullifier);
563
+ const exists = await this.handlerAsUtility().doesNullifierExist(innerNullifier);
563
564
 
564
565
  return toForeignCallResult([toSingle(new Fr(exists))]);
565
566
  }
@@ -582,10 +583,10 @@ export class RPCTranslator {
582
583
  }
583
584
 
584
585
  // eslint-disable-next-line camelcase
585
- async aztec_utl_tryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
586
+ async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
586
587
  const address = addressFromSingle(foreignAddress);
587
588
 
588
- const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(address);
589
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(address);
589
590
 
590
591
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
591
592
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -628,7 +629,7 @@ export class RPCTranslator {
628
629
  foreignBlockHash: ForeignCallSingle,
629
630
  foreignNullifier: ForeignCallSingle,
630
631
  ) {
631
- const blockHash = new BlockHash(fromSingle(foreignBlockHash));
632
+ const blockHash = blockHashFromSingle(foreignBlockHash);
632
633
  const nullifier = fromSingle(foreignNullifier);
633
634
 
634
635
  const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
@@ -652,7 +653,7 @@ export class RPCTranslator {
652
653
  }
653
654
 
654
655
  // eslint-disable-next-line camelcase
655
- public aztec_prv_validatePublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
656
+ public aztec_prv_assertValidPublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
656
657
  throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
657
658
  }
658
659
 
@@ -662,9 +663,9 @@ export class RPCTranslator {
662
663
  }
663
664
 
664
665
  // eslint-disable-next-line camelcase
665
- public async aztec_prv_inRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
666
+ public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
666
667
  const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
667
- const isRevertible = await this.handlerAsPrivate().inRevertiblePhase(sideEffectCounter);
668
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
668
669
  return toForeignCallResult([toSingle(new Fr(isRevertible))]);
669
670
  }
670
671
 
@@ -692,7 +693,7 @@ export class RPCTranslator {
692
693
  foreignAnchorBlockHash: ForeignCallSingle,
693
694
  foreignNoteHash: ForeignCallSingle,
694
695
  ) {
695
- const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
696
+ const blockHash = blockHashFromSingle(foreignAnchorBlockHash);
696
697
  const noteHash = fromSingle(foreignNoteHash);
697
698
 
698
699
  const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
@@ -708,8 +709,8 @@ export class RPCTranslator {
708
709
  foreignAnchorBlockHash: ForeignCallSingle,
709
710
  foreignBlockHash: ForeignCallSingle,
710
711
  ) {
711
- const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
712
- const blockHash = new BlockHash(fromSingle(foreignBlockHash));
712
+ const anchorBlockHash = blockHashFromSingle(foreignAnchorBlockHash);
713
+ const blockHash = blockHashFromSingle(foreignBlockHash);
713
714
 
714
715
  const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
715
716
 
@@ -726,7 +727,7 @@ export class RPCTranslator {
726
727
  foreignBlockHash: ForeignCallSingle,
727
728
  foreignNullifier: ForeignCallSingle,
728
729
  ) {
729
- const blockHash = new BlockHash(fromSingle(foreignBlockHash));
730
+ const blockHash = blockHashFromSingle(foreignBlockHash);
730
731
  const nullifier = fromSingle(foreignNullifier);
731
732
 
732
733
  const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
@@ -738,14 +739,25 @@ export class RPCTranslator {
738
739
  }
739
740
 
740
741
  // eslint-disable-next-line camelcase
741
- async aztec_utl_fetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
742
+ async aztec_utl_getPendingTaggedLogs(
743
+ foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle,
744
+ foreignScope: ForeignCallSingle,
745
+ ) {
742
746
  const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
747
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
743
748
 
744
- await this.handlerAsUtility().fetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
749
+ await this.handlerAsUtility().getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot, scope);
745
750
 
746
751
  return toForeignCallResult([]);
747
752
  }
748
753
 
754
+ // eslint-disable-next-line camelcase
755
+ async aztec_utl_getPendingTaggedLogs_v2(foreignScope: ForeignCallSingle) {
756
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
757
+ const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(scope);
758
+ return toForeignCallResult([toSingle(slot)]);
759
+ }
760
+
749
761
  // eslint-disable-next-line camelcase
750
762
  public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
751
763
  foreignContractAddress: ForeignCallSingle,
@@ -753,12 +765,14 @@ export class RPCTranslator {
753
765
  foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
754
766
  foreignMaxNotePackedLen: ForeignCallSingle,
755
767
  foreignMaxEventSerializedLen: ForeignCallSingle,
768
+ foreignScope: ForeignCallSingle,
756
769
  ) {
757
770
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
758
771
  const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
759
772
  const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
760
773
  const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
761
774
  const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
775
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
762
776
 
763
777
  await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
764
778
  contractAddress,
@@ -766,75 +780,125 @@ export class RPCTranslator {
766
780
  eventValidationRequestsArrayBaseSlot,
767
781
  maxNotePackedLen,
768
782
  maxEventSerializedLen,
783
+ scope,
769
784
  );
770
785
 
771
786
  return toForeignCallResult([]);
772
787
  }
773
788
 
774
789
  // eslint-disable-next-line camelcase
775
- public async aztec_utl_bulkRetrieveLogs(
790
+ public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
791
+ foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
792
+ foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
793
+ foreignMaxNotePackedLen: ForeignCallSingle,
794
+ foreignMaxEventSerializedLen: ForeignCallSingle,
795
+ foreignScope: ForeignCallSingle,
796
+ ) {
797
+ const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
798
+ const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
799
+ const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
800
+ const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
801
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
802
+
803
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
804
+ noteValidationRequestsArrayBaseSlot,
805
+ eventValidationRequestsArrayBaseSlot,
806
+ maxNotePackedLen,
807
+ maxEventSerializedLen,
808
+ scope,
809
+ );
810
+
811
+ return toForeignCallResult([]);
812
+ }
813
+
814
+ // eslint-disable-next-line camelcase
815
+ public async aztec_utl_getLogsByTag(
776
816
  foreignContractAddress: ForeignCallSingle,
777
817
  foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
778
818
  foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
819
+ foreignScope: ForeignCallSingle,
779
820
  ) {
780
821
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
781
822
  const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
782
823
  const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
824
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
783
825
 
784
- await this.handlerAsUtility().bulkRetrieveLogs(
826
+ await this.handlerAsUtility().getLogsByTag(
785
827
  contractAddress,
786
828
  logRetrievalRequestsArrayBaseSlot,
787
829
  logRetrievalResponsesArrayBaseSlot,
830
+ scope,
788
831
  );
789
832
 
790
833
  return toForeignCallResult([]);
791
834
  }
792
835
 
793
836
  // eslint-disable-next-line camelcase
794
- public async aztec_utl_utilityResolveMessageContexts(
837
+ public async aztec_utl_getMessageContextsByTxHash(
795
838
  foreignContractAddress: ForeignCallSingle,
796
839
  foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
797
840
  foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
841
+ foreignScope: ForeignCallSingle,
798
842
  ) {
799
843
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
800
844
  const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
801
845
  const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
846
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
802
847
 
803
- await this.handlerAsUtility().utilityResolveMessageContexts(
848
+ await this.handlerAsUtility().getMessageContextsByTxHash(
804
849
  contractAddress,
805
850
  messageContextRequestsArrayBaseSlot,
806
851
  messageContextResponsesArrayBaseSlot,
852
+ scope,
807
853
  );
808
854
 
809
855
  return toForeignCallResult([]);
810
856
  }
811
857
 
812
858
  // eslint-disable-next-line camelcase
813
- async aztec_utl_storeCapsule(
859
+ async aztec_utl_getLogsByTag_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
860
+ const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
861
+ const responseSlot = await this.handlerAsUtility().getLogsByTagV2(requestArrayBaseSlot);
862
+ return toForeignCallResult([toSingle(responseSlot)]);
863
+ }
864
+
865
+ // eslint-disable-next-line camelcase
866
+ async aztec_utl_getMessageContextsByTxHash_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
867
+ const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
868
+ const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(requestArrayBaseSlot);
869
+ return toForeignCallResult([toSingle(responseSlot)]);
870
+ }
871
+
872
+ // eslint-disable-next-line camelcase
873
+ aztec_utl_setCapsule(
814
874
  foreignContractAddress: ForeignCallSingle,
815
875
  foreignSlot: ForeignCallSingle,
816
876
  foreignCapsule: ForeignCallArray,
877
+ foreignScope: ForeignCallSingle,
817
878
  ) {
818
879
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
819
880
  const slot = fromSingle(foreignSlot);
820
881
  const capsule = fromArray(foreignCapsule);
882
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
821
883
 
822
- await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
884
+ this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
823
885
 
824
886
  return toForeignCallResult([]);
825
887
  }
826
888
 
827
889
  // eslint-disable-next-line camelcase
828
- async aztec_utl_loadCapsule(
890
+ async aztec_utl_getCapsule(
829
891
  foreignContractAddress: ForeignCallSingle,
830
892
  foreignSlot: ForeignCallSingle,
831
893
  foreignTSize: ForeignCallSingle,
894
+ foreignScope: ForeignCallSingle,
832
895
  ) {
833
896
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
834
897
  const slot = fromSingle(foreignSlot);
835
898
  const tSize = fromSingle(foreignTSize).toNumber();
899
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
836
900
 
837
- const values = await this.handlerAsUtility().loadCapsule(contractAddress, slot);
901
+ const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
838
902
 
839
903
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
840
904
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -848,11 +912,16 @@ export class RPCTranslator {
848
912
  }
849
913
 
850
914
  // eslint-disable-next-line camelcase
851
- async aztec_utl_deleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
915
+ aztec_utl_deleteCapsule(
916
+ foreignContractAddress: ForeignCallSingle,
917
+ foreignSlot: ForeignCallSingle,
918
+ foreignScope: ForeignCallSingle,
919
+ ) {
852
920
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
853
921
  const slot = fromSingle(foreignSlot);
922
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
854
923
 
855
- await this.handlerAsUtility().deleteCapsule(contractAddress, slot);
924
+ this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
856
925
 
857
926
  return toForeignCallResult([]);
858
927
  }
@@ -863,14 +932,74 @@ export class RPCTranslator {
863
932
  foreignSrcSlot: ForeignCallSingle,
864
933
  foreignDstSlot: ForeignCallSingle,
865
934
  foreignNumEntries: ForeignCallSingle,
935
+ foreignScope: ForeignCallSingle,
866
936
  ) {
867
937
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
868
938
  const srcSlot = fromSingle(foreignSrcSlot);
869
939
  const dstSlot = fromSingle(foreignDstSlot);
870
940
  const numEntries = fromSingle(foreignNumEntries).toNumber();
941
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
942
+
943
+ await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
944
+
945
+ return toForeignCallResult([]);
946
+ }
947
+
948
+ // eslint-disable-next-line camelcase
949
+ aztec_utl_pushEphemeral(foreignSlot: ForeignCallSingle, foreignElements: ForeignCallArray) {
950
+ const slot = fromSingle(foreignSlot);
951
+ const elements = fromArray(foreignElements);
952
+ const newLen = this.handlerAsUtility().pushEphemeral(slot, elements);
953
+ return toForeignCallResult([toSingle(new Fr(newLen))]);
954
+ }
955
+
956
+ // eslint-disable-next-line camelcase
957
+ aztec_utl_popEphemeral(foreignSlot: ForeignCallSingle) {
958
+ const slot = fromSingle(foreignSlot);
959
+ const element = this.handlerAsUtility().popEphemeral(slot);
960
+ return toForeignCallResult([toArray(element)]);
961
+ }
871
962
 
872
- await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
963
+ // eslint-disable-next-line camelcase
964
+ aztec_utl_getEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
965
+ const slot = fromSingle(foreignSlot);
966
+ const index = fromSingle(foreignIndex).toNumber();
967
+ const element = this.handlerAsUtility().getEphemeral(slot, index);
968
+ return toForeignCallResult([toArray(element)]);
969
+ }
873
970
 
971
+ // eslint-disable-next-line camelcase
972
+ aztec_utl_setEphemeral(
973
+ foreignSlot: ForeignCallSingle,
974
+ foreignIndex: ForeignCallSingle,
975
+ foreignElements: ForeignCallArray,
976
+ ) {
977
+ const slot = fromSingle(foreignSlot);
978
+ const index = fromSingle(foreignIndex).toNumber();
979
+ const elements = fromArray(foreignElements);
980
+ this.handlerAsUtility().setEphemeral(slot, index, elements);
981
+ return toForeignCallResult([]);
982
+ }
983
+
984
+ // eslint-disable-next-line camelcase
985
+ aztec_utl_getEphemeralLen(foreignSlot: ForeignCallSingle) {
986
+ const slot = fromSingle(foreignSlot);
987
+ const len = this.handlerAsUtility().getEphemeralLen(slot);
988
+ return toForeignCallResult([toSingle(new Fr(len))]);
989
+ }
990
+
991
+ // eslint-disable-next-line camelcase
992
+ aztec_utl_removeEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
993
+ const slot = fromSingle(foreignSlot);
994
+ const index = fromSingle(foreignIndex).toNumber();
995
+ this.handlerAsUtility().removeEphemeral(slot, index);
996
+ return toForeignCallResult([]);
997
+ }
998
+
999
+ // eslint-disable-next-line camelcase
1000
+ aztec_utl_clearEphemeral(foreignSlot: ForeignCallSingle) {
1001
+ const slot = fromSingle(foreignSlot);
1002
+ this.handlerAsUtility().clearEphemeral(slot);
874
1003
  return toForeignCallResult([]);
875
1004
  }
876
1005
 
@@ -879,7 +1008,7 @@ export class RPCTranslator {
879
1008
  // to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
880
1009
  // existence of a txe_oracle method?
881
1010
  // eslint-disable-next-line camelcase
882
- async aztec_utl_aes128Decrypt(
1011
+ async aztec_utl_decryptAes128(
883
1012
  foreignCiphertextBVecStorage: ForeignCallArray,
884
1013
  foreignCiphertextLength: ForeignCallSingle,
885
1014
  foreignIv: ForeignCallArray,
@@ -889,11 +1018,18 @@ export class RPCTranslator {
889
1018
  const iv = fromUintArray(foreignIv, 8);
890
1019
  const symKey = fromUintArray(foreignSymKey, 8);
891
1020
 
892
- const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
893
-
894
- return toForeignCallResult(
895
- arrayToBoundedVec(bufferToU8Array(plaintextBuffer), foreignCiphertextBVecStorage.length),
896
- );
1021
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
1022
+ try {
1023
+ const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
1024
+ const [storage, length] = arrayToBoundedVec(
1025
+ bufferToU8Array(plaintextBuffer),
1026
+ foreignCiphertextBVecStorage.length,
1027
+ );
1028
+ return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
1029
+ } catch {
1030
+ const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
1031
+ return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
1032
+ }
897
1033
  }
898
1034
 
899
1035
  // eslint-disable-next-line camelcase
@@ -902,6 +1038,7 @@ export class RPCTranslator {
902
1038
  foreignEphPKField0: ForeignCallSingle,
903
1039
  foreignEphPKField1: ForeignCallSingle,
904
1040
  foreignEphPKField2: ForeignCallSingle,
1041
+ foreignContractAddress: ForeignCallSingle,
905
1042
  ) {
906
1043
  const address = AztecAddress.fromField(fromSingle(foreignAddress));
907
1044
  const ephPK = Point.fromFields([
@@ -909,10 +1046,28 @@ export class RPCTranslator {
909
1046
  fromSingle(foreignEphPKField1),
910
1047
  fromSingle(foreignEphPKField2),
911
1048
  ]);
1049
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
1050
+
1051
+ const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
1052
+
1053
+ return toForeignCallResult([toSingle(secret)]);
1054
+ }
1055
+
1056
+ // eslint-disable-next-line camelcase
1057
+ aztec_utl_setContractSyncCacheInvalid(
1058
+ foreignContractAddress: ForeignCallSingle,
1059
+ foreignScopes: ForeignCallArray,
1060
+ foreignScopeCount: ForeignCallSingle,
1061
+ ) {
1062
+ const contractAddress = addressFromSingle(foreignContractAddress);
1063
+ const count = fromSingle(foreignScopeCount).toNumber();
1064
+ const scopes = fromArray(foreignScopes)
1065
+ .slice(0, count)
1066
+ .map(f => new AztecAddress(f));
912
1067
 
913
- const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
1068
+ this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
914
1069
 
915
- return toForeignCallResult(secret.toFields().map(toSingle));
1070
+ return Promise.resolve(toForeignCallResult([]));
916
1071
  }
917
1072
 
918
1073
  // eslint-disable-next-line camelcase
@@ -76,6 +76,7 @@ export class TXEArchiver extends ArchiverDataSourceBase {
76
76
  proven: tipId,
77
77
  finalized: tipId,
78
78
  checkpointed: tipId,
79
+ proposedCheckpoint: tipId,
79
80
  };
80
81
  }
81
82
 
@@ -61,8 +61,12 @@ export class DummyP2P implements P2P {
61
61
  throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
62
62
  }
63
63
 
64
- public registerCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
65
- throw new Error('DummyP2P does not implement "registerCheckpointProposalHandler"');
64
+ public registerValidatorCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
65
+ throw new Error('DummyP2P does not implement "registerValidatorCheckpointProposalHandler"');
66
+ }
67
+
68
+ public registerAllNodesCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
69
+ throw new Error('DummyP2P does not implement "registerAllNodesCheckpointProposalHandler"');
66
70
  }
67
71
 
68
72
  public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
@@ -1,15 +1,29 @@
1
+ import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
1
2
  import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
2
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
5
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { GasFees } from '@aztec/stdlib/gas';
6
+ import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
5
7
  import { makeGlobalVariables } from '@aztec/stdlib/testing';
6
- import { type CheckpointGlobalVariables, type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
8
+ import {
9
+ type CheckpointGlobalVariables,
10
+ type FeeProvider,
11
+ type GlobalVariableBuilder,
12
+ GlobalVariables,
13
+ } from '@aztec/stdlib/tx';
7
14
 
8
- export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
15
+ /** Simple FeeProvider for TXE that returns zero fees. */
16
+ export class TXEFeeProvider implements FeeProvider {
9
17
  public getCurrentMinFees(): Promise<GasFees> {
10
18
  return Promise.resolve(new GasFees(0, 0));
11
19
  }
12
20
 
21
+ public getPredictedMinFees(): Promise<GasFees[]> {
22
+ return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
23
+ }
24
+ }
25
+
26
+ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
13
27
  public buildGlobalVariables(
14
28
  _blockNumber: BlockNumber,
15
29
  _coinbase: EthAddress,
@@ -23,6 +37,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
23
37
  _coinbase: EthAddress,
24
38
  _feeRecipient: AztecAddress,
25
39
  _slotNumber: SlotNumber,
40
+ _simulationOverridesPlan?: SimulationOverridesPlan,
26
41
  ): Promise<CheckpointGlobalVariables> {
27
42
  const vars = makeGlobalVariables();
28
43
  return Promise.resolve({
@@ -13,7 +13,7 @@ import { getPackageVersion } from '@aztec/stdlib/update-checker';
13
13
 
14
14
  import { TXEArchiver } from './archiver.js';
15
15
  import { DummyP2P } from './dummy_p2p_client.js';
16
- import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
16
+ import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
17
17
  import { MockEpochCache } from './mock_epoch_cache.js';
18
18
  import { TXESynchronizer } from './synchronizer.js';
19
19
 
@@ -56,9 +56,11 @@ export class TXEStateMachine {
56
56
  VERSION,
57
57
  CHAIN_ID,
58
58
  new TXEGlobalVariablesBuilder(),
59
+ new TXEFeeProvider(),
59
60
  new MockEpochCache(),
60
61
  getPackageVersion() ?? '',
61
62
  new TestCircuitVerifier(),
63
+ new TestCircuitVerifier(),
62
64
  undefined,
63
65
  log,
64
66
  );