@aztec/txe 0.0.1-commit.6b113946b → 0.0.1-commit.6bd18f1aa

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.
@@ -339,20 +339,20 @@ export class RPCTranslator {
339
339
  }
340
340
 
341
341
  // eslint-disable-next-line camelcase
342
- aztec_prv_storeInExecutionCache(foreignValues: ForeignCallArray, foreignHash: ForeignCallSingle) {
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().storeInExecutionCache(values, hash);
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 aztec_prv_loadFromExecutionCache(foreignHash: ForeignCallSingle) {
352
+ async aztec_prv_getHashPreimage(foreignHash: ForeignCallSingle) {
353
353
  const hash = fromSingle(foreignHash);
354
354
 
355
- const returns = await this.handlerAsPrivate().loadFromExecutionCache(hash);
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 aztec_utl_storageRead(
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().storageRead(
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 aztec_utl_checkNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
559
+ async aztec_utl_doesNullifierExist(foreignInnerNullifier: ForeignCallSingle) {
560
560
  const innerNullifier = fromSingle(foreignInnerNullifier);
561
561
 
562
- const exists = await this.handlerAsUtility().checkNullifierExists(innerNullifier);
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 aztec_utl_tryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
585
+ async aztec_utl_getPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
586
586
  const address = addressFromSingle(foreignAddress);
587
587
 
588
- const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(address);
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 aztec_prv_validatePublicCalldata(_foreignCalldataHash: ForeignCallSingle) {
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 aztec_prv_inRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
665
+ public async aztec_prv_isExecutionInRevertiblePhase(foreignSideEffectCounter: ForeignCallSingle) {
666
666
  const sideEffectCounter = fromSingle(foreignSideEffectCounter).toNumber();
667
- const isRevertible = await this.handlerAsPrivate().inRevertiblePhase(sideEffectCounter);
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 aztec_utl_fetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) {
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().fetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
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,75 +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 aztec_utl_bulkRetrieveLogs(
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().bulkRetrieveLogs(
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
- public async aztec_utl_utilityResolveMessageContexts(
804
+ public async aztec_utl_getMessageContextsByTxHash(
795
805
  foreignContractAddress: ForeignCallSingle,
796
806
  foreignMessageContextRequestsArrayBaseSlot: ForeignCallSingle,
797
807
  foreignMessageContextResponsesArrayBaseSlot: ForeignCallSingle,
808
+ foreignScope: ForeignCallSingle,
798
809
  ) {
799
810
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
800
811
  const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
801
812
  const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
813
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
802
814
 
803
- await this.handlerAsUtility().utilityResolveMessageContexts(
815
+ await this.handlerAsUtility().getMessageContextsByTxHash(
804
816
  contractAddress,
805
817
  messageContextRequestsArrayBaseSlot,
806
818
  messageContextResponsesArrayBaseSlot,
819
+ scope,
807
820
  );
808
821
 
809
822
  return toForeignCallResult([]);
810
823
  }
811
824
 
812
825
  // eslint-disable-next-line camelcase
813
- async aztec_utl_storeCapsule(
826
+ aztec_utl_setCapsule(
814
827
  foreignContractAddress: ForeignCallSingle,
815
828
  foreignSlot: ForeignCallSingle,
816
829
  foreignCapsule: ForeignCallArray,
830
+ foreignScope: ForeignCallSingle,
817
831
  ) {
818
832
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
819
833
  const slot = fromSingle(foreignSlot);
820
834
  const capsule = fromArray(foreignCapsule);
835
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
821
836
 
822
- await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
837
+ this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
823
838
 
824
839
  return toForeignCallResult([]);
825
840
  }
826
841
 
827
842
  // eslint-disable-next-line camelcase
828
- async aztec_utl_loadCapsule(
843
+ async aztec_utl_getCapsule(
829
844
  foreignContractAddress: ForeignCallSingle,
830
845
  foreignSlot: ForeignCallSingle,
831
846
  foreignTSize: ForeignCallSingle,
847
+ foreignScope: ForeignCallSingle,
832
848
  ) {
833
849
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
834
850
  const slot = fromSingle(foreignSlot);
835
851
  const tSize = fromSingle(foreignTSize).toNumber();
852
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
836
853
 
837
- const values = await this.handlerAsUtility().loadCapsule(contractAddress, slot);
854
+ const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
838
855
 
839
856
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
840
857
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
@@ -848,11 +865,16 @@ export class RPCTranslator {
848
865
  }
849
866
 
850
867
  // eslint-disable-next-line camelcase
851
- async aztec_utl_deleteCapsule(foreignContractAddress: ForeignCallSingle, foreignSlot: ForeignCallSingle) {
868
+ aztec_utl_deleteCapsule(
869
+ foreignContractAddress: ForeignCallSingle,
870
+ foreignSlot: ForeignCallSingle,
871
+ foreignScope: ForeignCallSingle,
872
+ ) {
852
873
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
853
874
  const slot = fromSingle(foreignSlot);
875
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
854
876
 
855
- await this.handlerAsUtility().deleteCapsule(contractAddress, slot);
877
+ this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
856
878
 
857
879
  return toForeignCallResult([]);
858
880
  }
@@ -863,13 +885,15 @@ export class RPCTranslator {
863
885
  foreignSrcSlot: ForeignCallSingle,
864
886
  foreignDstSlot: ForeignCallSingle,
865
887
  foreignNumEntries: ForeignCallSingle,
888
+ foreignScope: ForeignCallSingle,
866
889
  ) {
867
890
  const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
868
891
  const srcSlot = fromSingle(foreignSrcSlot);
869
892
  const dstSlot = fromSingle(foreignDstSlot);
870
893
  const numEntries = fromSingle(foreignNumEntries).toNumber();
894
+ const scope = AztecAddress.fromField(fromSingle(foreignScope));
871
895
 
872
- await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
896
+ await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
873
897
 
874
898
  return toForeignCallResult([]);
875
899
  }
@@ -879,7 +903,7 @@ export class RPCTranslator {
879
903
  // to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
880
904
  // existence of a txe_oracle method?
881
905
  // eslint-disable-next-line camelcase
882
- async aztec_utl_tryAes128Decrypt(
906
+ async aztec_utl_decryptAes128(
883
907
  foreignCiphertextBVecStorage: ForeignCallArray,
884
908
  foreignCiphertextLength: ForeignCallSingle,
885
909
  foreignIv: ForeignCallArray,
@@ -891,7 +915,7 @@ export class RPCTranslator {
891
915
 
892
916
  // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
893
917
  try {
894
- const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
918
+ const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
895
919
  const [storage, length] = arrayToBoundedVec(
896
920
  bufferToU8Array(plaintextBuffer),
897
921
  foreignCiphertextBVecStorage.length,
@@ -909,6 +933,7 @@ export class RPCTranslator {
909
933
  foreignEphPKField0: ForeignCallSingle,
910
934
  foreignEphPKField1: ForeignCallSingle,
911
935
  foreignEphPKField2: ForeignCallSingle,
936
+ foreignContractAddress: ForeignCallSingle,
912
937
  ) {
913
938
  const address = AztecAddress.fromField(fromSingle(foreignAddress));
914
939
  const ephPK = Point.fromFields([
@@ -916,14 +941,15 @@ export class RPCTranslator {
916
941
  fromSingle(foreignEphPKField1),
917
942
  fromSingle(foreignEphPKField2),
918
943
  ]);
944
+ const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
919
945
 
920
- const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
946
+ const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
921
947
 
922
- return toForeignCallResult(secret.toFields().map(toSingle));
948
+ return toForeignCallResult([toSingle(secret)]);
923
949
  }
924
950
 
925
951
  // eslint-disable-next-line camelcase
926
- aztec_utl_invalidateContractSyncCache(
952
+ aztec_utl_setContractSyncCacheInvalid(
927
953
  foreignContractAddress: ForeignCallSingle,
928
954
  foreignScopes: ForeignCallArray,
929
955
  foreignScopeCount: ForeignCallSingle,
@@ -934,7 +960,7 @@ export class RPCTranslator {
934
960
  .slice(0, count)
935
961
  .map(f => new AztecAddress(f));
936
962
 
937
- this.handlerAsUtility().invalidateContractSyncCache(contractAddress, scopes);
963
+ this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
938
964
 
939
965
  return Promise.resolve(toForeignCallResult([]));
940
966
  }
@@ -3,6 +3,7 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
3
3
  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
+ import type { KeyStore } from '@aztec/key-store';
6
7
  import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
7
8
  import { MessageContextService } from '@aztec/pxe/simulator';
8
9
  import { L2Block } from '@aztec/stdlib/block';
@@ -35,6 +36,7 @@ export class TXEStateMachine {
35
36
  anchorBlockStore: AnchorBlockStore,
36
37
  contractStore: ContractStore,
37
38
  noteStore: NoteStore,
39
+ keyStore: KeyStore,
38
40
  ) {
39
41
  const synchronizer = await TXESynchronizer.create();
40
42
  const aztecNodeConfig = {} as AztecNodeConfig;
@@ -59,6 +61,7 @@ export class TXEStateMachine {
59
61
  new MockEpochCache(),
60
62
  getPackageVersion() ?? '',
61
63
  new TestCircuitVerifier(),
64
+ new TestCircuitVerifier(),
62
65
  undefined,
63
66
  log,
64
67
  );
@@ -67,6 +70,7 @@ export class TXEStateMachine {
67
70
  node,
68
71
  contractStore,
69
72
  noteStore,
73
+ () => keyStore.getAccounts(),
70
74
  createLogger('txe:contract_sync'),
71
75
  );
72
76
 
@@ -7,6 +7,7 @@ import type { AccessScopes } from '@aztec/pxe/client/lazy';
7
7
  import {
8
8
  AddressStore,
9
9
  AnchorBlockStore,
10
+ CapsuleService,
10
11
  CapsuleStore,
11
12
  ContractStore,
12
13
  ContractSyncService,
@@ -179,7 +180,7 @@ export class TXESession implements TXESessionStateHandler {
179
180
 
180
181
  const archiver = new TXEArchiver(store);
181
182
  const anchorBlockStore = new AnchorBlockStore(store);
182
- const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
183
+ const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore, keyStore);
183
184
 
184
185
  const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
185
186
  const version = new Fr(await stateMachine.node.getVersion());
@@ -188,7 +189,13 @@ export class TXESession implements TXESessionStateHandler {
188
189
  const initialJobId = jobCoordinator.beginJob();
189
190
 
190
191
  const logger = createLogger('txe:session');
191
- const contractSyncService = new ContractSyncService(stateMachine.node, contractStore, noteStore, logger);
192
+ const contractSyncService = new ContractSyncService(
193
+ stateMachine.node,
194
+ contractStore,
195
+ noteStore,
196
+ () => keyStore.getAccounts(),
197
+ logger,
198
+ );
192
199
 
193
200
  const topLevelOracleHandler = new TXEOracleTopLevelContext(
194
201
  stateMachine,
@@ -372,7 +379,7 @@ export class TXESession implements TXESessionStateHandler {
372
379
  senderTaggingStore: this.senderTaggingStore,
373
380
  recipientTaggingStore: this.recipientTaggingStore,
374
381
  senderAddressBookStore: this.senderAddressBookStore,
375
- capsuleStore: this.capsuleStore,
382
+ capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
376
383
  privateEventStore: this.privateEventStore,
377
384
  contractSyncService: this.stateMachine.contractSyncService,
378
385
  jobId: this.currentJobId,
@@ -444,7 +451,7 @@ export class TXESession implements TXESessionStateHandler {
444
451
  aztecNode: this.stateMachine.node,
445
452
  recipientTaggingStore: this.recipientTaggingStore,
446
453
  senderAddressBookStore: this.senderAddressBookStore,
447
- capsuleStore: this.capsuleStore,
454
+ capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
448
455
  privateEventStore: this.privateEventStore,
449
456
  messageContextService: this.stateMachine.messageContextService,
450
457
  contractSyncService: this.contractSyncService,
@@ -537,7 +544,7 @@ export class TXESession implements TXESessionStateHandler {
537
544
  aztecNode: this.stateMachine.node,
538
545
  recipientTaggingStore: this.recipientTaggingStore,
539
546
  senderAddressBookStore: this.senderAddressBookStore,
540
- capsuleStore: this.capsuleStore,
547
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
541
548
  privateEventStore: this.privateEventStore,
542
549
  messageContextService: this.stateMachine.messageContextService,
543
550
  contractSyncService: this.contractSyncService,
@@ -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