@aztec/txe 0.0.1-commit.88e6f9396 → 0.0.1-commit.8c0b8ff
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.
- package/dest/oracle/txe_oracle_top_level_context.d.ts +7 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +28 -16
- package/dest/rpc_translator.d.ts +53 -20
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +140 -39
- package/dest/state_machine/mock_epoch_cache.d.ts +3 -17
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +2 -32
- package/dest/txe_session.d.ts +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +11 -8
- package/dest/util/encoding.d.ts +18 -87
- package/dest/util/encoding.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/oracle/txe_oracle_top_level_context.ts +39 -21
- package/src/rpc_translator.ts +166 -35
- package/src/state_machine/mock_epoch_cache.ts +3 -42
- package/src/txe_session.ts +12 -9
package/src/rpc_translator.ts
CHANGED
|
@@ -264,10 +264,11 @@ export class RPCTranslator {
|
|
|
264
264
|
// PXE oracles
|
|
265
265
|
|
|
266
266
|
// eslint-disable-next-line camelcase
|
|
267
|
-
|
|
268
|
-
const
|
|
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(
|
|
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
|
-
|
|
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().
|
|
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
|
|
353
|
+
async aztec_prv_getHashPreimage(foreignHash: ForeignCallSingle) {
|
|
353
354
|
const hash = fromSingle(foreignHash);
|
|
354
355
|
|
|
355
|
-
const returns = await this.handlerAsPrivate().
|
|
356
|
+
const returns = await this.handlerAsPrivate().getHashPreimage(hash);
|
|
356
357
|
|
|
357
358
|
return toForeignCallResult([toArray(returns)]);
|
|
358
359
|
}
|
|
@@ -378,7 +379,7 @@ export class RPCTranslator {
|
|
|
378
379
|
}
|
|
379
380
|
|
|
380
381
|
// eslint-disable-next-line camelcase
|
|
381
|
-
async
|
|
382
|
+
async aztec_utl_getFromPublicStorage(
|
|
382
383
|
foreignBlockHash: ForeignCallSingle,
|
|
383
384
|
foreignContractAddress: ForeignCallSingle,
|
|
384
385
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
@@ -389,7 +390,7 @@ export class RPCTranslator {
|
|
|
389
390
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
390
391
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
391
392
|
|
|
392
|
-
const values = await this.handlerAsUtility().
|
|
393
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
393
394
|
blockHash,
|
|
394
395
|
contractAddress,
|
|
395
396
|
startStorageSlot,
|
|
@@ -556,10 +557,10 @@ export class RPCTranslator {
|
|
|
556
557
|
}
|
|
557
558
|
|
|
558
559
|
// eslint-disable-next-line camelcase
|
|
559
|
-
async
|
|
560
|
+
async aztec_utl_doesNullifierExist(foreignInnerNullifier: ForeignCallSingle) {
|
|
560
561
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
561
562
|
|
|
562
|
-
const exists = await this.handlerAsUtility().
|
|
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
|
|
586
|
+
async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
586
587
|
const address = addressFromSingle(foreignAddress);
|
|
587
588
|
|
|
588
|
-
const result = await this.handlerAsUtility().
|
|
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).
|
|
@@ -652,7 +653,7 @@ export class RPCTranslator {
|
|
|
652
653
|
}
|
|
653
654
|
|
|
654
655
|
// eslint-disable-next-line camelcase
|
|
655
|
-
public
|
|
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
|
|
666
|
+
public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
|
|
666
667
|
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
667
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
668
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
|
|
668
669
|
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
669
670
|
}
|
|
670
671
|
|
|
@@ -738,14 +739,25 @@ export class RPCTranslator {
|
|
|
738
739
|
}
|
|
739
740
|
|
|
740
741
|
// eslint-disable-next-line camelcase
|
|
741
|
-
async
|
|
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().
|
|
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
|
|
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().
|
|
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
|
|
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().
|
|
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
|
|
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
|
-
|
|
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
|
|
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().
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
962
|
+
|
|
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
|
+
}
|
|
871
970
|
|
|
872
|
-
|
|
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
|
+
}
|
|
873
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
|
|
1011
|
+
async aztec_utl_decryptAes128(
|
|
883
1012
|
foreignCiphertextBVecStorage: ForeignCallArray,
|
|
884
1013
|
foreignCiphertextLength: ForeignCallSingle,
|
|
885
1014
|
foreignIv: ForeignCallArray,
|
|
@@ -891,7 +1020,7 @@ export class RPCTranslator {
|
|
|
891
1020
|
|
|
892
1021
|
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
893
1022
|
try {
|
|
894
|
-
const plaintextBuffer = await this.handlerAsUtility().
|
|
1023
|
+
const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
|
|
895
1024
|
const [storage, length] = arrayToBoundedVec(
|
|
896
1025
|
bufferToU8Array(plaintextBuffer),
|
|
897
1026
|
foreignCiphertextBVecStorage.length,
|
|
@@ -909,6 +1038,7 @@ export class RPCTranslator {
|
|
|
909
1038
|
foreignEphPKField0: ForeignCallSingle,
|
|
910
1039
|
foreignEphPKField1: ForeignCallSingle,
|
|
911
1040
|
foreignEphPKField2: ForeignCallSingle,
|
|
1041
|
+
foreignContractAddress: ForeignCallSingle,
|
|
912
1042
|
) {
|
|
913
1043
|
const address = AztecAddress.fromField(fromSingle(foreignAddress));
|
|
914
1044
|
const ephPK = Point.fromFields([
|
|
@@ -916,14 +1046,15 @@ export class RPCTranslator {
|
|
|
916
1046
|
fromSingle(foreignEphPKField1),
|
|
917
1047
|
fromSingle(foreignEphPKField2),
|
|
918
1048
|
]);
|
|
1049
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
919
1050
|
|
|
920
|
-
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
|
|
1051
|
+
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
|
|
921
1052
|
|
|
922
|
-
return toForeignCallResult(secret
|
|
1053
|
+
return toForeignCallResult([toSingle(secret)]);
|
|
923
1054
|
}
|
|
924
1055
|
|
|
925
1056
|
// eslint-disable-next-line camelcase
|
|
926
|
-
|
|
1057
|
+
aztec_utl_setContractSyncCacheInvalid(
|
|
927
1058
|
foreignContractAddress: ForeignCallSingle,
|
|
928
1059
|
foreignScopes: ForeignCallArray,
|
|
929
1060
|
foreignScopeCount: ForeignCallSingle,
|
|
@@ -934,7 +1065,7 @@ export class RPCTranslator {
|
|
|
934
1065
|
.slice(0, count)
|
|
935
1066
|
.map(f => new AztecAddress(f));
|
|
936
1067
|
|
|
937
|
-
this.handlerAsUtility().
|
|
1068
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
|
|
938
1069
|
|
|
939
1070
|
return Promise.resolve(toForeignCallResult([]));
|
|
940
1071
|
}
|
|
@@ -8,7 +8,7 @@ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/ep
|
|
|
8
8
|
* Since in TXE we don't validate transactions, mock suffices here.
|
|
9
9
|
*/
|
|
10
10
|
export class MockEpochCache implements EpochCacheInterface {
|
|
11
|
-
getCommittee(
|
|
11
|
+
getCommittee(): Promise<EpochCommitteeInfo> {
|
|
12
12
|
return Promise.resolve({
|
|
13
13
|
committee: undefined,
|
|
14
14
|
seed: 0n,
|
|
@@ -17,22 +17,6 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
getSlotNow(): SlotNumber {
|
|
21
|
-
return SlotNumber(0);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
getTargetSlot(): SlotNumber {
|
|
25
|
-
return SlotNumber(0);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getEpochNow(): EpochNumber {
|
|
29
|
-
return EpochNumber.ZERO;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getTargetEpoch(): EpochNumber {
|
|
33
|
-
return EpochNumber.ZERO;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
20
|
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
37
21
|
return {
|
|
38
22
|
epoch: EpochNumber.ZERO,
|
|
@@ -42,23 +26,15 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
42
26
|
};
|
|
43
27
|
}
|
|
44
28
|
|
|
45
|
-
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
29
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint } {
|
|
46
30
|
return {
|
|
47
31
|
epoch: EpochNumber.ZERO,
|
|
48
32
|
slot: SlotNumber(0),
|
|
49
33
|
ts: 0n,
|
|
50
|
-
|
|
34
|
+
now: 0n,
|
|
51
35
|
};
|
|
52
36
|
}
|
|
53
37
|
|
|
54
|
-
getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
55
|
-
return this.getEpochAndSlotInNextL1Slot();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
isProposerPipeliningEnabled(): boolean {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
38
|
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
63
39
|
return '0x00';
|
|
64
40
|
}
|
|
@@ -74,13 +50,6 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
74
50
|
};
|
|
75
51
|
}
|
|
76
52
|
|
|
77
|
-
getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
78
|
-
return {
|
|
79
|
-
targetSlot: SlotNumber(0),
|
|
80
|
-
nextSlot: SlotNumber(0),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
53
|
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
85
54
|
return Promise.resolve(undefined);
|
|
86
55
|
}
|
|
@@ -97,14 +66,6 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
97
66
|
return Promise.resolve([]);
|
|
98
67
|
}
|
|
99
68
|
|
|
100
|
-
isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean> {
|
|
101
|
-
return Promise.resolve(false);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
isEscapeHatchOpenAtSlot(_slot: SlotTag): Promise<boolean> {
|
|
105
|
-
return Promise.resolve(false);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
69
|
getL1Constants(): L1RollupConstants {
|
|
109
70
|
return EmptyL1RollupConstants;
|
|
110
71
|
}
|
package/src/txe_session.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
-
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
7
6
|
import {
|
|
8
7
|
AddressStore,
|
|
9
8
|
AnchorBlockStore,
|
|
9
|
+
CapsuleService,
|
|
10
10
|
CapsuleStore,
|
|
11
11
|
ContractStore,
|
|
12
12
|
ContractSyncService,
|
|
@@ -336,7 +336,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
336
336
|
|
|
337
337
|
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
338
338
|
contractAddress,
|
|
339
|
-
|
|
339
|
+
await this.keyStore.getAccounts(),
|
|
340
340
|
);
|
|
341
341
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
342
342
|
|
|
@@ -372,11 +372,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
372
372
|
senderTaggingStore: this.senderTaggingStore,
|
|
373
373
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
374
374
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
375
|
-
|
|
375
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
376
376
|
privateEventStore: this.privateEventStore,
|
|
377
377
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
378
|
+
l2TipsStore: this.stateMachine.node,
|
|
378
379
|
jobId: this.currentJobId,
|
|
379
|
-
scopes:
|
|
380
|
+
scopes: await this.keyStore.getAccounts(),
|
|
380
381
|
messageContextService: this.stateMachine.messageContextService,
|
|
381
382
|
});
|
|
382
383
|
|
|
@@ -430,7 +431,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
430
431
|
this.stateMachine.node,
|
|
431
432
|
anchorBlockHeader,
|
|
432
433
|
this.currentJobId,
|
|
433
|
-
).syncNoteNullifiers(contractAddress,
|
|
434
|
+
).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
434
435
|
|
|
435
436
|
this.oracleHandler = new UtilityExecutionOracle({
|
|
436
437
|
contractAddress,
|
|
@@ -444,12 +445,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
444
445
|
aztecNode: this.stateMachine.node,
|
|
445
446
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
446
447
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
447
|
-
|
|
448
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
448
449
|
privateEventStore: this.privateEventStore,
|
|
449
450
|
messageContextService: this.stateMachine.messageContextService,
|
|
450
451
|
contractSyncService: this.contractSyncService,
|
|
452
|
+
l2TipsStore: this.stateMachine.node,
|
|
451
453
|
jobId: this.currentJobId,
|
|
452
|
-
scopes:
|
|
454
|
+
scopes: await this.keyStore.getAccounts(),
|
|
453
455
|
});
|
|
454
456
|
|
|
455
457
|
this.state = { name: 'UTILITY' };
|
|
@@ -518,7 +520,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
518
520
|
}
|
|
519
521
|
|
|
520
522
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
521
|
-
return async (call: FunctionCall, scopes:
|
|
523
|
+
return async (call: FunctionCall, scopes: AztecAddress[]) => {
|
|
522
524
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
523
525
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
524
526
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -537,10 +539,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
537
539
|
aztecNode: this.stateMachine.node,
|
|
538
540
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
539
541
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
540
|
-
|
|
542
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
541
543
|
privateEventStore: this.privateEventStore,
|
|
542
544
|
messageContextService: this.stateMachine.messageContextService,
|
|
543
545
|
contractSyncService: this.contractSyncService,
|
|
546
|
+
l2TipsStore: this.stateMachine.node,
|
|
544
547
|
jobId: this.currentJobId,
|
|
545
548
|
scopes,
|
|
546
549
|
});
|