@aztec/txe 0.0.1-commit.684755437 → 0.0.1-commit.69c59a8b3
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 +179 -50
- 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 +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- 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 +8 -4
- package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +35 -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 +71 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- 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 +44 -21
- package/src/rpc_translator.ts +224 -59
- 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 +18 -3
- package/src/state_machine/index.ts +8 -2
- package/src/state_machine/mock_epoch_cache.ts +46 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +26 -10
- package/src/util/encoding.ts +5 -0
- package/src/util/txe_public_contract_data_source.ts +0 -2
package/src/rpc_translator.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@aztec/pxe/simulator';
|
|
11
11
|
import { type ContractArtifact, EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
12
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import { BlockHash } from '@aztec/stdlib/block';
|
|
14
13
|
|
|
15
14
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
16
15
|
import type { TXESessionStateHandler } from './txe_session.js';
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
addressFromSingle,
|
|
21
20
|
arrayOfArraysToBoundedVecOfArrays,
|
|
22
21
|
arrayToBoundedVec,
|
|
22
|
+
blockHashFromSingle,
|
|
23
23
|
bufferToU8Array,
|
|
24
24
|
fromArray,
|
|
25
25
|
fromSingle,
|
|
@@ -264,10 +264,11 @@ export class RPCTranslator {
|
|
|
264
264
|
// PXE oracles
|
|
265
265
|
|
|
266
266
|
// eslint-disable-next-line camelcase
|
|
267
|
-
|
|
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,18 +379,18 @@ 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,
|
|
385
386
|
foreignNumberOfElements: ForeignCallSingle,
|
|
386
387
|
) {
|
|
387
|
-
const blockHash =
|
|
388
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
388
389
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
389
390
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
390
391
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
391
392
|
|
|
392
|
-
const values = await this.handlerAsUtility().
|
|
393
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
393
394
|
blockHash,
|
|
394
395
|
contractAddress,
|
|
395
396
|
startStorageSlot,
|
|
@@ -401,7 +402,7 @@ export class RPCTranslator {
|
|
|
401
402
|
|
|
402
403
|
// eslint-disable-next-line camelcase
|
|
403
404
|
async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
404
|
-
const blockHash =
|
|
405
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
405
406
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
406
407
|
|
|
407
408
|
const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
|
|
@@ -556,10 +557,10 @@ export class RPCTranslator {
|
|
|
556
557
|
}
|
|
557
558
|
|
|
558
559
|
// eslint-disable-next-line camelcase
|
|
559
|
-
async
|
|
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).
|
|
@@ -628,7 +629,7 @@ export class RPCTranslator {
|
|
|
628
629
|
foreignBlockHash: ForeignCallSingle,
|
|
629
630
|
foreignNullifier: ForeignCallSingle,
|
|
630
631
|
) {
|
|
631
|
-
const blockHash =
|
|
632
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
632
633
|
const nullifier = fromSingle(foreignNullifier);
|
|
633
634
|
|
|
634
635
|
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -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
|
|
|
@@ -707,7 +693,7 @@ export class RPCTranslator {
|
|
|
707
693
|
foreignAnchorBlockHash: ForeignCallSingle,
|
|
708
694
|
foreignNoteHash: ForeignCallSingle,
|
|
709
695
|
) {
|
|
710
|
-
const blockHash =
|
|
696
|
+
const blockHash = blockHashFromSingle(foreignAnchorBlockHash);
|
|
711
697
|
const noteHash = fromSingle(foreignNoteHash);
|
|
712
698
|
|
|
713
699
|
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
@@ -723,8 +709,8 @@ export class RPCTranslator {
|
|
|
723
709
|
foreignAnchorBlockHash: ForeignCallSingle,
|
|
724
710
|
foreignBlockHash: ForeignCallSingle,
|
|
725
711
|
) {
|
|
726
|
-
const anchorBlockHash =
|
|
727
|
-
const blockHash =
|
|
712
|
+
const anchorBlockHash = blockHashFromSingle(foreignAnchorBlockHash);
|
|
713
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
728
714
|
|
|
729
715
|
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
730
716
|
|
|
@@ -741,7 +727,7 @@ export class RPCTranslator {
|
|
|
741
727
|
foreignBlockHash: ForeignCallSingle,
|
|
742
728
|
foreignNullifier: ForeignCallSingle,
|
|
743
729
|
) {
|
|
744
|
-
const blockHash =
|
|
730
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
745
731
|
const nullifier = fromSingle(foreignNullifier);
|
|
746
732
|
|
|
747
733
|
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -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
|
|
|
@@ -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)[]> {
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
1
2
|
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
2
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
|
+
import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
|
|
5
7
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
6
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
type CheckpointGlobalVariables,
|
|
10
|
+
type FeeProvider,
|
|
11
|
+
type GlobalVariableBuilder,
|
|
12
|
+
GlobalVariables,
|
|
13
|
+
} from '@aztec/stdlib/tx';
|
|
7
14
|
|
|
8
|
-
|
|
15
|
+
/** Simple FeeProvider for TXE that returns zero fees. */
|
|
16
|
+
export class TXEFeeProvider implements FeeProvider {
|
|
9
17
|
public getCurrentMinFees(): Promise<GasFees> {
|
|
10
18
|
return Promise.resolve(new GasFees(0, 0));
|
|
11
19
|
}
|
|
12
20
|
|
|
21
|
+
public getPredictedMinFees(): Promise<GasFees[]> {
|
|
22
|
+
return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
13
27
|
public buildGlobalVariables(
|
|
14
28
|
_blockNumber: BlockNumber,
|
|
15
29
|
_coinbase: EthAddress,
|
|
@@ -23,6 +37,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
23
37
|
_coinbase: EthAddress,
|
|
24
38
|
_feeRecipient: AztecAddress,
|
|
25
39
|
_slotNumber: SlotNumber,
|
|
40
|
+
_simulationOverridesPlan?: SimulationOverridesPlan,
|
|
26
41
|
): Promise<CheckpointGlobalVariables> {
|
|
27
42
|
const vars = makeGlobalVariables();
|
|
28
43
|
return Promise.resolve({
|
|
@@ -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';
|
|
@@ -12,7 +13,7 @@ import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
|
12
13
|
|
|
13
14
|
import { TXEArchiver } from './archiver.js';
|
|
14
15
|
import { DummyP2P } from './dummy_p2p_client.js';
|
|
15
|
-
import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
16
|
+
import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
16
17
|
import { MockEpochCache } from './mock_epoch_cache.js';
|
|
17
18
|
import { TXESynchronizer } from './synchronizer.js';
|
|
18
19
|
|
|
@@ -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(
|
|
@@ -54,9 +56,11 @@ export class TXEStateMachine {
|
|
|
54
56
|
VERSION,
|
|
55
57
|
CHAIN_ID,
|
|
56
58
|
new TXEGlobalVariablesBuilder(),
|
|
59
|
+
new TXEFeeProvider(),
|
|
57
60
|
new MockEpochCache(),
|
|
58
61
|
getPackageVersion() ?? '',
|
|
59
62
|
new TestCircuitVerifier(),
|
|
63
|
+
new TestCircuitVerifier(),
|
|
60
64
|
undefined,
|
|
61
65
|
log,
|
|
62
66
|
);
|
|
@@ -68,7 +72,9 @@ export class TXEStateMachine {
|
|
|
68
72
|
createLogger('txe:contract_sync'),
|
|
69
73
|
);
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
const messageContextService = new MessageContextService(node);
|
|
76
|
+
|
|
77
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
public async handleL2Block(block: L2Block) {
|