@aztec/txe 0.0.1-commit.ffe5b04ea → 0.0.1-commit.fff30aa
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 +10 -4
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +34 -17
- package/dest/rpc_translator.d.ts +58 -20
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +171 -41
- package/dest/state_machine/archiver.d.ts +3 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +5 -7
- package/dest/state_machine/index.d.ts +4 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +6 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +4 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +24 -12
- package/dest/util/encoding.d.ts +40 -41
- package/dest/util/encoding.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/oracle/txe_oracle_top_level_context.ts +44 -21
- package/src/rpc_translator.ts +216 -51
- package/src/state_machine/archiver.ts +5 -5
- package/src/state_machine/index.ts +5 -1
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +26 -10
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,34 +653,19 @@ export class RPCTranslator {
|
|
|
652
653
|
}
|
|
653
654
|
|
|
654
655
|
// eslint-disable-next-line camelcase
|
|
655
|
-
public
|
|
656
|
-
_foreignTargetContractAddress: ForeignCallSingle,
|
|
657
|
-
_foreignCalldataHash: ForeignCallSingle,
|
|
658
|
-
_foreignSideEffectCounter: ForeignCallSingle,
|
|
659
|
-
_foreignIsStaticCall: ForeignCallSingle,
|
|
660
|
-
) {
|
|
661
|
-
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// eslint-disable-next-line camelcase
|
|
665
|
-
public aztec_prv_notifySetPublicTeardownFunctionCall(
|
|
666
|
-
_foreignTargetContractAddress: ForeignCallSingle,
|
|
667
|
-
_foreignCalldataHash: ForeignCallSingle,
|
|
668
|
-
_foreignSideEffectCounter: ForeignCallSingle,
|
|
669
|
-
_foreignIsStaticCall: ForeignCallSingle,
|
|
670
|
-
) {
|
|
656
|
+
public aztec_prv_assertValidPublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
|
|
671
657
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
672
658
|
}
|
|
673
659
|
|
|
674
660
|
// eslint-disable-next-line camelcase
|
|
675
|
-
public
|
|
661
|
+
public aztec_prv_notifyRevertiblePhaseStart(_foreignMinRevertibleSideEffectCounter: ForeignCallSingle) {
|
|
676
662
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
677
663
|
}
|
|
678
664
|
|
|
679
665
|
// eslint-disable-next-line camelcase
|
|
680
|
-
public async
|
|
666
|
+
public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
|
|
681
667
|
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
682
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
668
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
|
|
683
669
|
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
684
670
|
}
|
|
685
671
|
|
|
@@ -753,78 +739,166 @@ export class RPCTranslator {
|
|
|
753
739
|
}
|
|
754
740
|
|
|
755
741
|
// eslint-disable-next-line camelcase
|
|
756
|
-
async
|
|
742
|
+
async aztec_utl_getPendingTaggedLogs(
|
|
743
|
+
foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle,
|
|
744
|
+
foreignScope: ForeignCallSingle,
|
|
745
|
+
) {
|
|
757
746
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
747
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
758
748
|
|
|
759
|
-
await this.handlerAsUtility().
|
|
749
|
+
await this.handlerAsUtility().getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot, scope);
|
|
760
750
|
|
|
761
751
|
return toForeignCallResult([]);
|
|
762
752
|
}
|
|
763
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
|
+
|
|
764
761
|
// eslint-disable-next-line camelcase
|
|
765
762
|
public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
766
763
|
foreignContractAddress: ForeignCallSingle,
|
|
767
764
|
foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
768
765
|
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
766
|
+
foreignMaxNotePackedLen: ForeignCallSingle,
|
|
767
|
+
foreignMaxEventSerializedLen: ForeignCallSingle,
|
|
768
|
+
foreignScope: ForeignCallSingle,
|
|
769
769
|
) {
|
|
770
770
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
771
771
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
772
772
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
773
|
+
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
774
|
+
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
775
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
773
776
|
|
|
774
777
|
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
775
778
|
contractAddress,
|
|
776
779
|
noteValidationRequestsArrayBaseSlot,
|
|
777
780
|
eventValidationRequestsArrayBaseSlot,
|
|
781
|
+
maxNotePackedLen,
|
|
782
|
+
maxEventSerializedLen,
|
|
783
|
+
scope,
|
|
784
|
+
);
|
|
785
|
+
|
|
786
|
+
return toForeignCallResult([]);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// eslint-disable-next-line camelcase
|
|
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,
|
|
778
809
|
);
|
|
779
810
|
|
|
780
811
|
return toForeignCallResult([]);
|
|
781
812
|
}
|
|
782
813
|
|
|
783
814
|
// eslint-disable-next-line camelcase
|
|
784
|
-
public async
|
|
815
|
+
public async aztec_utl_getLogsByTag(
|
|
785
816
|
foreignContractAddress: ForeignCallSingle,
|
|
786
817
|
foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
|
|
787
818
|
foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
|
|
819
|
+
foreignScope: ForeignCallSingle,
|
|
788
820
|
) {
|
|
789
821
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
790
822
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
791
823
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
824
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
792
825
|
|
|
793
|
-
await this.handlerAsUtility().
|
|
826
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
794
827
|
contractAddress,
|
|
795
828
|
logRetrievalRequestsArrayBaseSlot,
|
|
796
829
|
logRetrievalResponsesArrayBaseSlot,
|
|
830
|
+
scope,
|
|
797
831
|
);
|
|
798
832
|
|
|
799
833
|
return toForeignCallResult([]);
|
|
800
834
|
}
|
|
801
835
|
|
|
802
836
|
// eslint-disable-next-line camelcase
|
|
803
|
-
async
|
|
837
|
+
public async aztec_utl_getMessageContextsByTxHash(
|
|
838
|
+
foreignContractAddress: ForeignCallSingle,
|
|
839
|
+
foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
|
|
840
|
+
foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
|
|
841
|
+
foreignScope: ForeignCallSingle,
|
|
842
|
+
) {
|
|
843
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
844
|
+
const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
|
|
845
|
+
const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
|
|
846
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
847
|
+
|
|
848
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
849
|
+
contractAddress,
|
|
850
|
+
messageContextRequestsArrayBaseSlot,
|
|
851
|
+
messageContextResponsesArrayBaseSlot,
|
|
852
|
+
scope,
|
|
853
|
+
);
|
|
854
|
+
|
|
855
|
+
return toForeignCallResult([]);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// eslint-disable-next-line camelcase
|
|
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(
|
|
804
874
|
foreignContractAddress: ForeignCallSingle,
|
|
805
875
|
foreignSlot: ForeignCallSingle,
|
|
806
876
|
foreignCapsule: ForeignCallArray,
|
|
877
|
+
foreignScope: ForeignCallSingle,
|
|
807
878
|
) {
|
|
808
879
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
809
880
|
const slot = fromSingle(foreignSlot);
|
|
810
881
|
const capsule = fromArray(foreignCapsule);
|
|
882
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
811
883
|
|
|
812
|
-
|
|
884
|
+
this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
|
|
813
885
|
|
|
814
886
|
return toForeignCallResult([]);
|
|
815
887
|
}
|
|
816
888
|
|
|
817
889
|
// eslint-disable-next-line camelcase
|
|
818
|
-
async
|
|
890
|
+
async aztec_utl_getCapsule(
|
|
819
891
|
foreignContractAddress: ForeignCallSingle,
|
|
820
892
|
foreignSlot: ForeignCallSingle,
|
|
821
893
|
foreignTSize: ForeignCallSingle,
|
|
894
|
+
foreignScope: ForeignCallSingle,
|
|
822
895
|
) {
|
|
823
896
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
824
897
|
const slot = fromSingle(foreignSlot);
|
|
825
898
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
899
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
826
900
|
|
|
827
|
-
const values = await this.handlerAsUtility().
|
|
901
|
+
const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
|
|
828
902
|
|
|
829
903
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
830
904
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -838,11 +912,16 @@ export class RPCTranslator {
|
|
|
838
912
|
}
|
|
839
913
|
|
|
840
914
|
// eslint-disable-next-line camelcase
|
|
841
|
-
|
|
915
|
+
aztec_utl_deleteCapsule(
|
|
916
|
+
foreignContractAddress: ForeignCallSingle,
|
|
917
|
+
foreignSlot: ForeignCallSingle,
|
|
918
|
+
foreignScope: ForeignCallSingle,
|
|
919
|
+
) {
|
|
842
920
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
843
921
|
const slot = fromSingle(foreignSlot);
|
|
922
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
844
923
|
|
|
845
|
-
|
|
924
|
+
this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
|
|
846
925
|
|
|
847
926
|
return toForeignCallResult([]);
|
|
848
927
|
}
|
|
@@ -853,23 +932,83 @@ export class RPCTranslator {
|
|
|
853
932
|
foreignSrcSlot: ForeignCallSingle,
|
|
854
933
|
foreignDstSlot: ForeignCallSingle,
|
|
855
934
|
foreignNumEntries: ForeignCallSingle,
|
|
935
|
+
foreignScope: ForeignCallSingle,
|
|
856
936
|
) {
|
|
857
937
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
858
938
|
const srcSlot = fromSingle(foreignSrcSlot);
|
|
859
939
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
860
940
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
941
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
861
942
|
|
|
862
|
-
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
943
|
+
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
|
|
863
944
|
|
|
864
945
|
return toForeignCallResult([]);
|
|
865
946
|
}
|
|
866
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
|
+
}
|
|
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);
|
|
1003
|
+
return toForeignCallResult([]);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
867
1006
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
868
1007
|
// The compiler didn't throw an error, so it took me a while to learn of the existence of this file, and that I need
|
|
869
1008
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
870
1009
|
// existence of a txe_oracle method?
|
|
871
1010
|
// eslint-disable-next-line camelcase
|
|
872
|
-
async
|
|
1011
|
+
async aztec_utl_decryptAes128(
|
|
873
1012
|
foreignCiphertextBVecStorage: ForeignCallArray,
|
|
874
1013
|
foreignCiphertextLength: ForeignCallSingle,
|
|
875
1014
|
foreignIv: ForeignCallArray,
|
|
@@ -879,11 +1018,18 @@ export class RPCTranslator {
|
|
|
879
1018
|
const iv = fromUintArray(foreignIv, 8);
|
|
880
1019
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
881
1020
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
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
|
+
}
|
|
887
1033
|
}
|
|
888
1034
|
|
|
889
1035
|
// eslint-disable-next-line camelcase
|
|
@@ -892,6 +1038,7 @@ export class RPCTranslator {
|
|
|
892
1038
|
foreignEphPKField0: ForeignCallSingle,
|
|
893
1039
|
foreignEphPKField1: ForeignCallSingle,
|
|
894
1040
|
foreignEphPKField2: ForeignCallSingle,
|
|
1041
|
+
foreignContractAddress: ForeignCallSingle,
|
|
895
1042
|
) {
|
|
896
1043
|
const address = AztecAddress.fromField(fromSingle(foreignAddress));
|
|
897
1044
|
const ephPK = Point.fromFields([
|
|
@@ -899,10 +1046,28 @@ export class RPCTranslator {
|
|
|
899
1046
|
fromSingle(foreignEphPKField1),
|
|
900
1047
|
fromSingle(foreignEphPKField2),
|
|
901
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));
|
|
902
1067
|
|
|
903
|
-
|
|
1068
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
|
|
904
1069
|
|
|
905
|
-
return
|
|
1070
|
+
return Promise.resolve(toForeignCallResult([]));
|
|
906
1071
|
}
|
|
907
1072
|
|
|
908
1073
|
// eslint-disable-next-line camelcase
|
|
@@ -17,7 +17,7 @@ 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);
|
|
21
21
|
super(store);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -79,12 +79,12 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
public
|
|
83
|
-
throw new Error('TXE Archiver does not implement "
|
|
82
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
83
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
public
|
|
87
|
-
throw new Error('TXE Archiver does not implement "
|
|
86
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
87
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
@@ -4,6 +4,7 @@ import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
7
|
+
import { MessageContextService } from '@aztec/pxe/simulator';
|
|
7
8
|
import { L2Block } from '@aztec/stdlib/block';
|
|
8
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,6 +27,7 @@ export class TXEStateMachine {
|
|
|
26
27
|
public archiver: TXEArchiver,
|
|
27
28
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
29
|
public contractSyncService: ContractSyncService,
|
|
30
|
+
public messageContextService: MessageContextService,
|
|
29
31
|
) {}
|
|
30
32
|
|
|
31
33
|
public static async create(
|
|
@@ -68,7 +70,9 @@ export class TXEStateMachine {
|
|
|
68
70
|
createLogger('txe:contract_sync'),
|
|
69
71
|
);
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
const messageContextService = new MessageContextService(node);
|
|
74
|
+
|
|
75
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
public async handleL2Block(block: L2Block) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
4
|
+
import type { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -33,12 +33,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
36
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
37
37
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
38
|
-
* @param
|
|
38
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
|
|
39
39
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
40
40
|
*/
|
|
41
|
-
public syncImmediate(_minBlockNumber?: BlockNumber,
|
|
41
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber> {
|
|
42
42
|
return Promise.resolve(this.blockNumber);
|
|
43
43
|
}
|
|
44
44
|
|
package/src/txe_session.ts
CHANGED
|
@@ -3,12 +3,13 @@ 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
|
+
ContractSyncService,
|
|
12
13
|
JobCoordinator,
|
|
13
14
|
NoteService,
|
|
14
15
|
NoteStore,
|
|
@@ -150,6 +151,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
150
151
|
private chainId: Fr,
|
|
151
152
|
private version: Fr,
|
|
152
153
|
private nextBlockTimestamp: bigint,
|
|
154
|
+
private contractSyncService: ContractSyncService,
|
|
153
155
|
) {}
|
|
154
156
|
|
|
155
157
|
static async init(contractStore: ContractStore) {
|
|
@@ -185,6 +187,9 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
185
187
|
|
|
186
188
|
const initialJobId = jobCoordinator.beginJob();
|
|
187
189
|
|
|
190
|
+
const logger = createLogger('txe:session');
|
|
191
|
+
const contractSyncService = new ContractSyncService(stateMachine.node, contractStore, noteStore, logger);
|
|
192
|
+
|
|
188
193
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
189
194
|
stateMachine,
|
|
190
195
|
contractStore,
|
|
@@ -201,11 +206,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
201
206
|
version,
|
|
202
207
|
chainId,
|
|
203
208
|
new Map(),
|
|
209
|
+
contractSyncService,
|
|
204
210
|
);
|
|
205
211
|
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
206
212
|
|
|
207
213
|
return new TXESession(
|
|
208
|
-
|
|
214
|
+
logger,
|
|
209
215
|
stateMachine,
|
|
210
216
|
topLevelOracleHandler,
|
|
211
217
|
contractStore,
|
|
@@ -223,6 +229,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
223
229
|
version,
|
|
224
230
|
chainId,
|
|
225
231
|
nextBlockTimestamp,
|
|
232
|
+
contractSyncService,
|
|
226
233
|
);
|
|
227
234
|
}
|
|
228
235
|
|
|
@@ -309,6 +316,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
309
316
|
this.version,
|
|
310
317
|
this.chainId,
|
|
311
318
|
this.authwits,
|
|
319
|
+
this.contractSyncService,
|
|
312
320
|
);
|
|
313
321
|
|
|
314
322
|
this.state = { name: 'TOP_LEVEL' };
|
|
@@ -328,7 +336,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
328
336
|
|
|
329
337
|
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
330
338
|
contractAddress,
|
|
331
|
-
|
|
339
|
+
await this.keyStore.getAccounts(),
|
|
332
340
|
);
|
|
333
341
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
334
342
|
|
|
@@ -364,11 +372,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
364
372
|
senderTaggingStore: this.senderTaggingStore,
|
|
365
373
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
366
374
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
367
|
-
|
|
375
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
368
376
|
privateEventStore: this.privateEventStore,
|
|
369
377
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
378
|
+
l2TipsStore: this.stateMachine.node,
|
|
370
379
|
jobId: this.currentJobId,
|
|
371
|
-
scopes:
|
|
380
|
+
scopes: await this.keyStore.getAccounts(),
|
|
381
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
372
382
|
});
|
|
373
383
|
|
|
374
384
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -421,7 +431,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
421
431
|
this.stateMachine.node,
|
|
422
432
|
anchorBlockHeader,
|
|
423
433
|
this.currentJobId,
|
|
424
|
-
).syncNoteNullifiers(contractAddress,
|
|
434
|
+
).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
425
435
|
|
|
426
436
|
this.oracleHandler = new UtilityExecutionOracle({
|
|
427
437
|
contractAddress,
|
|
@@ -435,10 +445,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
435
445
|
aztecNode: this.stateMachine.node,
|
|
436
446
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
437
447
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
438
|
-
|
|
448
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
439
449
|
privateEventStore: this.privateEventStore,
|
|
450
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
451
|
+
contractSyncService: this.contractSyncService,
|
|
452
|
+
l2TipsStore: this.stateMachine.node,
|
|
440
453
|
jobId: this.currentJobId,
|
|
441
|
-
scopes:
|
|
454
|
+
scopes: await this.keyStore.getAccounts(),
|
|
442
455
|
});
|
|
443
456
|
|
|
444
457
|
this.state = { name: 'UTILITY' };
|
|
@@ -507,7 +520,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
507
520
|
}
|
|
508
521
|
|
|
509
522
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
510
|
-
return async (call: FunctionCall, scopes:
|
|
523
|
+
return async (call: FunctionCall, scopes: AztecAddress[]) => {
|
|
511
524
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
512
525
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
513
526
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -526,8 +539,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
526
539
|
aztecNode: this.stateMachine.node,
|
|
527
540
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
528
541
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
529
|
-
|
|
542
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
530
543
|
privateEventStore: this.privateEventStore,
|
|
544
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
545
|
+
contractSyncService: this.contractSyncService,
|
|
546
|
+
l2TipsStore: this.stateMachine.node,
|
|
531
547
|
jobId: this.currentJobId,
|
|
532
548
|
scopes,
|
|
533
549
|
});
|