@aztec/txe 0.0.1-commit.d117d021b → 0.0.1-commit.d1da697d6
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 +4 -3
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +21 -15
- package/dest/rpc_translator.d.ts +23 -17
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +75 -33
- 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 +7 -8
- package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +5 -2
- package/dest/state_machine/global_variable_builder.d.ts +3 -3
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +1 -1
- 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 +7 -3
- package/dest/state_machine/mock_epoch_cache.d.ts +17 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +32 -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 +21 -12
- package/dest/util/encoding.d.ts +69 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +1 -3
- package/package.json +15 -15
- package/src/oracle/txe_oracle_top_level_context.ts +31 -18
- package/src/rpc_translator.ts +101 -32
- package/src/state_machine/archiver.ts +6 -5
- package/src/state_machine/dummy_p2p_client.ts +6 -2
- package/src/state_machine/global_variable_builder.ts +7 -1
- package/src/state_machine/index.ts +6 -1
- package/src/state_machine/mock_epoch_cache.ts +42 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +23 -10
- package/src/util/txe_public_contract_data_source.ts +0 -2
package/src/rpc_translator.ts
CHANGED
|
@@ -339,20 +339,20 @@ export class RPCTranslator {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// eslint-disable-next-line camelcase
|
|
342
|
-
|
|
342
|
+
aztec_prv_setHashPreimage(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
|
|
343
343
|
const values = fromArray(foreignValues);
|
|
344
344
|
const hash = fromSingle(foreignHash);
|
|
345
345
|
|
|
346
|
-
this.handlerAsPrivate().
|
|
346
|
+
this.handlerAsPrivate().setHashPreimage(values, hash);
|
|
347
347
|
|
|
348
348
|
return toForeignCallResult([]);
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
// eslint-disable-next-line camelcase
|
|
352
|
-
async
|
|
352
|
+
async aztec_prv_getHashPreimage(foreignHash: ForeignCallSingle) {
|
|
353
353
|
const hash = fromSingle(foreignHash);
|
|
354
354
|
|
|
355
|
-
const returns = await this.handlerAsPrivate().
|
|
355
|
+
const returns = await this.handlerAsPrivate().getHashPreimage(hash);
|
|
356
356
|
|
|
357
357
|
return toForeignCallResult([toArray(returns)]);
|
|
358
358
|
}
|
|
@@ -378,7 +378,7 @@ export class RPCTranslator {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
// eslint-disable-next-line camelcase
|
|
381
|
-
async
|
|
381
|
+
async aztec_utl_getFromPublicStorage(
|
|
382
382
|
foreignBlockHash: ForeignCallSingle,
|
|
383
383
|
foreignContractAddress: ForeignCallSingle,
|
|
384
384
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
@@ -389,7 +389,7 @@ export class RPCTranslator {
|
|
|
389
389
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
390
390
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
391
391
|
|
|
392
|
-
const values = await this.handlerAsUtility().
|
|
392
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
393
393
|
blockHash,
|
|
394
394
|
contractAddress,
|
|
395
395
|
startStorageSlot,
|
|
@@ -556,10 +556,10 @@ export class RPCTranslator {
|
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
// eslint-disable-next-line camelcase
|
|
559
|
-
async
|
|
559
|
+
async aztec_utl_doesNullifierExist(foreignInnerNullifier: ForeignCallSingle) {
|
|
560
560
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
561
561
|
|
|
562
|
-
const exists = await this.handlerAsUtility().
|
|
562
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(innerNullifier);
|
|
563
563
|
|
|
564
564
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
565
565
|
}
|
|
@@ -582,10 +582,10 @@ export class RPCTranslator {
|
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
// eslint-disable-next-line camelcase
|
|
585
|
-
async
|
|
585
|
+
async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
586
586
|
const address = addressFromSingle(foreignAddress);
|
|
587
587
|
|
|
588
|
-
const result = await this.handlerAsUtility().
|
|
588
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(address);
|
|
589
589
|
|
|
590
590
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
591
591
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -652,7 +652,7 @@ export class RPCTranslator {
|
|
|
652
652
|
}
|
|
653
653
|
|
|
654
654
|
// eslint-disable-next-line camelcase
|
|
655
|
-
public
|
|
655
|
+
public aztec_prv_assertValidPublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
|
|
656
656
|
throw new Error('Enqueueing public calls is not supported in TestEnvironment::private_context');
|
|
657
657
|
}
|
|
658
658
|
|
|
@@ -662,9 +662,9 @@ export class RPCTranslator {
|
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
// eslint-disable-next-line camelcase
|
|
665
|
-
public async
|
|
665
|
+
public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
|
|
666
666
|
const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
|
|
667
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
667
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter);
|
|
668
668
|
return toForeignCallResult([toSingle(new Fr(isRevertible))]);
|
|
669
669
|
}
|
|
670
670
|
|
|
@@ -738,10 +738,14 @@ export class RPCTranslator {
|
|
|
738
738
|
}
|
|
739
739
|
|
|
740
740
|
// eslint-disable-next-line camelcase
|
|
741
|
-
async
|
|
741
|
+
async aztec_utl_getPendingTaggedLogs(
|
|
742
|
+
foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle,
|
|
743
|
+
foreignScope: ForeignCallSingle,
|
|
744
|
+
) {
|
|
742
745
|
const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot);
|
|
746
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
743
747
|
|
|
744
|
-
await this.handlerAsUtility().
|
|
748
|
+
await this.handlerAsUtility().getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot, scope);
|
|
745
749
|
|
|
746
750
|
return toForeignCallResult([]);
|
|
747
751
|
}
|
|
@@ -753,12 +757,14 @@ export class RPCTranslator {
|
|
|
753
757
|
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
754
758
|
foreignMaxNotePackedLen: ForeignCallSingle,
|
|
755
759
|
foreignMaxEventSerializedLen: ForeignCallSingle,
|
|
760
|
+
foreignScope: ForeignCallSingle,
|
|
756
761
|
) {
|
|
757
762
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
758
763
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
759
764
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
760
765
|
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
761
766
|
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
767
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
762
768
|
|
|
763
769
|
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
764
770
|
contractAddress,
|
|
@@ -766,56 +772,86 @@ export class RPCTranslator {
|
|
|
766
772
|
eventValidationRequestsArrayBaseSlot,
|
|
767
773
|
maxNotePackedLen,
|
|
768
774
|
maxEventSerializedLen,
|
|
775
|
+
scope,
|
|
769
776
|
);
|
|
770
777
|
|
|
771
778
|
return toForeignCallResult([]);
|
|
772
779
|
}
|
|
773
780
|
|
|
774
781
|
// eslint-disable-next-line camelcase
|
|
775
|
-
public async
|
|
782
|
+
public async aztec_utl_getLogsByTag(
|
|
776
783
|
foreignContractAddress: ForeignCallSingle,
|
|
777
784
|
foreignLogRetrievalRequestsArrayBaseSlot: ForeignCallSingle,
|
|
778
785
|
foreignLogRetrievalResponsesArrayBaseSlot: ForeignCallSingle,
|
|
786
|
+
foreignScope: ForeignCallSingle,
|
|
779
787
|
) {
|
|
780
788
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
781
789
|
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
782
790
|
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
791
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
783
792
|
|
|
784
|
-
await this.handlerAsUtility().
|
|
793
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
785
794
|
contractAddress,
|
|
786
795
|
logRetrievalRequestsArrayBaseSlot,
|
|
787
796
|
logRetrievalResponsesArrayBaseSlot,
|
|
797
|
+
scope,
|
|
788
798
|
);
|
|
789
799
|
|
|
790
800
|
return toForeignCallResult([]);
|
|
791
801
|
}
|
|
792
802
|
|
|
793
803
|
// eslint-disable-next-line camelcase
|
|
794
|
-
async
|
|
804
|
+
public async aztec_utl_getMessageContextsByTxHash(
|
|
805
|
+
foreignContractAddress: ForeignCallSingle,
|
|
806
|
+
foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
|
|
807
|
+
foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
|
|
808
|
+
foreignScope: ForeignCallSingle,
|
|
809
|
+
) {
|
|
810
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
811
|
+
const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
|
|
812
|
+
const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
|
|
813
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
814
|
+
|
|
815
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
816
|
+
contractAddress,
|
|
817
|
+
messageContextRequestsArrayBaseSlot,
|
|
818
|
+
messageContextResponsesArrayBaseSlot,
|
|
819
|
+
scope,
|
|
820
|
+
);
|
|
821
|
+
|
|
822
|
+
return toForeignCallResult([]);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// eslint-disable-next-line camelcase
|
|
826
|
+
aztec_utl_setCapsule(
|
|
795
827
|
foreignContractAddress: ForeignCallSingle,
|
|
796
828
|
foreignSlot: ForeignCallSingle,
|
|
797
829
|
foreignCapsule: ForeignCallArray,
|
|
830
|
+
foreignScope: ForeignCallSingle,
|
|
798
831
|
) {
|
|
799
832
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
800
833
|
const slot = fromSingle(foreignSlot);
|
|
801
834
|
const capsule = fromArray(foreignCapsule);
|
|
835
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
802
836
|
|
|
803
|
-
|
|
837
|
+
this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
|
|
804
838
|
|
|
805
839
|
return toForeignCallResult([]);
|
|
806
840
|
}
|
|
807
841
|
|
|
808
842
|
// eslint-disable-next-line camelcase
|
|
809
|
-
async
|
|
843
|
+
async aztec_utl_getCapsule(
|
|
810
844
|
foreignContractAddress: ForeignCallSingle,
|
|
811
845
|
foreignSlot: ForeignCallSingle,
|
|
812
846
|
foreignTSize: ForeignCallSingle,
|
|
847
|
+
foreignScope: ForeignCallSingle,
|
|
813
848
|
) {
|
|
814
849
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
815
850
|
const slot = fromSingle(foreignSlot);
|
|
816
851
|
const tSize = fromSingle(foreignTSize).toNumber();
|
|
852
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
817
853
|
|
|
818
|
-
const values = await this.handlerAsUtility().
|
|
854
|
+
const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
|
|
819
855
|
|
|
820
856
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
821
857
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -829,11 +865,16 @@ export class RPCTranslator {
|
|
|
829
865
|
}
|
|
830
866
|
|
|
831
867
|
// eslint-disable-next-line camelcase
|
|
832
|
-
|
|
868
|
+
aztec_utl_deleteCapsule(
|
|
869
|
+
foreignContractAddress: ForeignCallSingle,
|
|
870
|
+
foreignSlot: ForeignCallSingle,
|
|
871
|
+
foreignScope: ForeignCallSingle,
|
|
872
|
+
) {
|
|
833
873
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
834
874
|
const slot = fromSingle(foreignSlot);
|
|
875
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
835
876
|
|
|
836
|
-
|
|
877
|
+
this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
|
|
837
878
|
|
|
838
879
|
return toForeignCallResult([]);
|
|
839
880
|
}
|
|
@@ -844,13 +885,15 @@ export class RPCTranslator {
|
|
|
844
885
|
foreignSrcSlot: ForeignCallSingle,
|
|
845
886
|
foreignDstSlot: ForeignCallSingle,
|
|
846
887
|
foreignNumEntries: ForeignCallSingle,
|
|
888
|
+
foreignScope: ForeignCallSingle,
|
|
847
889
|
) {
|
|
848
890
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
849
891
|
const srcSlot = fromSingle(foreignSrcSlot);
|
|
850
892
|
const dstSlot = fromSingle(foreignDstSlot);
|
|
851
893
|
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
894
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
852
895
|
|
|
853
|
-
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
896
|
+
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
|
|
854
897
|
|
|
855
898
|
return toForeignCallResult([]);
|
|
856
899
|
}
|
|
@@ -860,7 +903,7 @@ export class RPCTranslator {
|
|
|
860
903
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
861
904
|
// existence of a txe_oracle method?
|
|
862
905
|
// eslint-disable-next-line camelcase
|
|
863
|
-
async
|
|
906
|
+
async aztec_utl_decryptAes128(
|
|
864
907
|
foreignCiphertextBVecStorage: ForeignCallArray,
|
|
865
908
|
foreignCiphertextLength: ForeignCallSingle,
|
|
866
909
|
foreignIv: ForeignCallArray,
|
|
@@ -870,11 +913,18 @@ export class RPCTranslator {
|
|
|
870
913
|
const iv = fromUintArray(foreignIv, 8);
|
|
871
914
|
const symKey = fromUintArray(foreignSymKey, 8);
|
|
872
915
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
916
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
917
|
+
try {
|
|
918
|
+
const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
|
|
919
|
+
const [storage, length] = arrayToBoundedVec(
|
|
920
|
+
bufferToU8Array(plaintextBuffer),
|
|
921
|
+
foreignCiphertextBVecStorage.length,
|
|
922
|
+
);
|
|
923
|
+
return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
|
|
924
|
+
} catch {
|
|
925
|
+
const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
|
|
926
|
+
return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
|
|
927
|
+
}
|
|
878
928
|
}
|
|
879
929
|
|
|
880
930
|
// eslint-disable-next-line camelcase
|
|
@@ -883,6 +933,7 @@ export class RPCTranslator {
|
|
|
883
933
|
foreignEphPKField0: ForeignCallSingle,
|
|
884
934
|
foreignEphPKField1: ForeignCallSingle,
|
|
885
935
|
foreignEphPKField2: ForeignCallSingle,
|
|
936
|
+
foreignContractAddress: ForeignCallSingle,
|
|
886
937
|
) {
|
|
887
938
|
const address = AztecAddress.fromField(fromSingle(foreignAddress));
|
|
888
939
|
const ephPK = Point.fromFields([
|
|
@@ -890,10 +941,28 @@ export class RPCTranslator {
|
|
|
890
941
|
fromSingle(foreignEphPKField1),
|
|
891
942
|
fromSingle(foreignEphPKField2),
|
|
892
943
|
]);
|
|
944
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
945
|
+
|
|
946
|
+
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
|
|
947
|
+
|
|
948
|
+
return toForeignCallResult([toSingle(secret)]);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// eslint-disable-next-line camelcase
|
|
952
|
+
aztec_utl_setContractSyncCacheInvalid(
|
|
953
|
+
foreignContractAddress: ForeignCallSingle,
|
|
954
|
+
foreignScopes: ForeignCallArray,
|
|
955
|
+
foreignScopeCount: ForeignCallSingle,
|
|
956
|
+
) {
|
|
957
|
+
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
958
|
+
const count = fromSingle(foreignScopeCount).toNumber();
|
|
959
|
+
const scopes = fromArray(foreignScopes)
|
|
960
|
+
.slice(0, count)
|
|
961
|
+
.map(f => new AztecAddress(f));
|
|
893
962
|
|
|
894
|
-
|
|
963
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
|
|
895
964
|
|
|
896
|
-
return
|
|
965
|
+
return Promise.resolve(toForeignCallResult([]));
|
|
897
966
|
}
|
|
898
967
|
|
|
899
968
|
// 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
|
|
|
@@ -76,15 +76,16 @@ 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
|
|
|
82
|
-
public
|
|
83
|
-
throw new Error('TXE Archiver does not implement "
|
|
83
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
84
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
public
|
|
87
|
-
throw new Error('TXE Archiver does not implement "
|
|
87
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
88
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
@@ -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
|
|
65
|
-
throw new Error('DummyP2P does not implement "
|
|
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)[]> {
|
|
@@ -3,7 +3,12 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
5
5
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type BuildCheckpointGlobalVariablesOpts,
|
|
8
|
+
type CheckpointGlobalVariables,
|
|
9
|
+
type GlobalVariableBuilder,
|
|
10
|
+
GlobalVariables,
|
|
11
|
+
} from '@aztec/stdlib/tx';
|
|
7
12
|
|
|
8
13
|
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
9
14
|
public getCurrentMinFees(): Promise<GasFees> {
|
|
@@ -23,6 +28,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
23
28
|
_coinbase: EthAddress,
|
|
24
29
|
_feeRecipient: AztecAddress,
|
|
25
30
|
_slotNumber: SlotNumber,
|
|
31
|
+
_opts?: BuildCheckpointGlobalVariablesOpts,
|
|
26
32
|
): Promise<CheckpointGlobalVariables> {
|
|
27
33
|
const vars = makeGlobalVariables();
|
|
28
34
|
return Promise.resolve({
|
|
@@ -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(
|
|
@@ -57,6 +59,7 @@ export class TXEStateMachine {
|
|
|
57
59
|
new MockEpochCache(),
|
|
58
60
|
getPackageVersion() ?? '',
|
|
59
61
|
new TestCircuitVerifier(),
|
|
62
|
+
new TestCircuitVerifier(),
|
|
60
63
|
undefined,
|
|
61
64
|
log,
|
|
62
65
|
);
|
|
@@ -68,7 +71,9 @@ export class TXEStateMachine {
|
|
|
68
71
|
createLogger('txe:contract_sync'),
|
|
69
72
|
);
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
const messageContextService = new MessageContextService(node);
|
|
75
|
+
|
|
76
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
public async handleL2Block(block: L2Block) {
|
|
@@ -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(): Promise<EpochCommitteeInfo> {
|
|
11
|
+
getCommittee(_slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
|
|
12
12
|
return Promise.resolve({
|
|
13
13
|
committee: undefined,
|
|
14
14
|
seed: 0n,
|
|
@@ -17,6 +17,22 @@ 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
|
+
|
|
20
36
|
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
21
37
|
return {
|
|
22
38
|
epoch: EpochNumber.ZERO,
|
|
@@ -26,15 +42,23 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
26
42
|
};
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
45
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
30
46
|
return {
|
|
31
47
|
epoch: EpochNumber.ZERO,
|
|
32
48
|
slot: SlotNumber(0),
|
|
33
49
|
ts: 0n,
|
|
34
|
-
|
|
50
|
+
nowSeconds: 0n,
|
|
35
51
|
};
|
|
36
52
|
}
|
|
37
53
|
|
|
54
|
+
getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
55
|
+
return this.getEpochAndSlotInNextL1Slot();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isProposerPipeliningEnabled(): boolean {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
39
63
|
return '0x00';
|
|
40
64
|
}
|
|
@@ -50,6 +74,13 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
50
74
|
};
|
|
51
75
|
}
|
|
52
76
|
|
|
77
|
+
getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
78
|
+
return {
|
|
79
|
+
targetSlot: SlotNumber(0),
|
|
80
|
+
nextSlot: SlotNumber(0),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
53
84
|
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
54
85
|
return Promise.resolve(undefined);
|
|
55
86
|
}
|
|
@@ -66,6 +97,14 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
66
97
|
return Promise.resolve([]);
|
|
67
98
|
}
|
|
68
99
|
|
|
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
|
+
|
|
69
108
|
getL1Constants(): L1RollupConstants {
|
|
70
109
|
return EmptyL1RollupConstants;
|
|
71
110
|
}
|
|
@@ -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,12 @@ 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,
|
|
370
378
|
jobId: this.currentJobId,
|
|
371
|
-
scopes:
|
|
379
|
+
scopes: await this.keyStore.getAccounts(),
|
|
380
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
372
381
|
});
|
|
373
382
|
|
|
374
383
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -421,7 +430,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
421
430
|
this.stateMachine.node,
|
|
422
431
|
anchorBlockHeader,
|
|
423
432
|
this.currentJobId,
|
|
424
|
-
).syncNoteNullifiers(contractAddress,
|
|
433
|
+
).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
425
434
|
|
|
426
435
|
this.oracleHandler = new UtilityExecutionOracle({
|
|
427
436
|
contractAddress,
|
|
@@ -435,10 +444,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
435
444
|
aztecNode: this.stateMachine.node,
|
|
436
445
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
437
446
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
438
|
-
|
|
447
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
439
448
|
privateEventStore: this.privateEventStore,
|
|
449
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
450
|
+
contractSyncService: this.contractSyncService,
|
|
440
451
|
jobId: this.currentJobId,
|
|
441
|
-
scopes:
|
|
452
|
+
scopes: await this.keyStore.getAccounts(),
|
|
442
453
|
});
|
|
443
454
|
|
|
444
455
|
this.state = { name: 'UTILITY' };
|
|
@@ -507,7 +518,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
507
518
|
}
|
|
508
519
|
|
|
509
520
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
510
|
-
return async (call: FunctionCall, scopes:
|
|
521
|
+
return async (call: FunctionCall, scopes: AztecAddress[]) => {
|
|
511
522
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
512
523
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
513
524
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -526,8 +537,10 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
526
537
|
aztecNode: this.stateMachine.node,
|
|
527
538
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
528
539
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
529
|
-
|
|
540
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
530
541
|
privateEventStore: this.privateEventStore,
|
|
542
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
543
|
+
contractSyncService: this.contractSyncService,
|
|
531
544
|
jobId: this.currentJobId,
|
|
532
545
|
scopes,
|
|
533
546
|
});
|
|
@@ -26,8 +26,6 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
26
26
|
packedBytecode: contractClass.packedBytecode,
|
|
27
27
|
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
28
28
|
version: contractClass.version,
|
|
29
|
-
privateFunctions: [],
|
|
30
|
-
utilityFunctions: [],
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
|