@aztec/txe 0.0.1-commit.d1da697d6 → 0.0.1-commit.d20b825a7
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/interfaces.d.ts +5 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +13 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +34 -12
- package/dest/rpc_translator.d.ts +44 -3
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +191 -24
- 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 +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +2 -2
- package/dest/state_machine/mock_epoch_cache.d.ts +2 -1
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +3 -0
- package/dest/txe_session.d.ts +48 -4
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +69 -13
- package/dest/util/encoding.d.ts +3 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +1 -1
- package/src/oracle/txe_oracle_top_level_context.ts +24 -10
- package/src/rpc_translator.ts +221 -36
- package/src/state_machine/global_variable_builder.ts +13 -4
- package/src/state_machine/index.ts +2 -1
- package/src/state_machine/mock_epoch_cache.ts +4 -0
- package/src/txe_session.ts +125 -11
- package/src/util/encoding.ts +5 -0
package/src/rpc_translator.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { Fr, Point } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
3
|
+
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, PRIVATE_LOG_CIPHERTEXT_LEN } from '@aztec/constants';
|
|
4
4
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
5
5
|
import {
|
|
6
6
|
type IMiscOracle,
|
|
@@ -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
|
}
|
|
@@ -297,6 +298,46 @@ export class RPCTranslator {
|
|
|
297
298
|
]);
|
|
298
299
|
}
|
|
299
300
|
|
|
301
|
+
// eslint-disable-next-line camelcase
|
|
302
|
+
aztec_txe_getLastCallOffchainEffects() {
|
|
303
|
+
// This oracle returns all offchain effect payloads (messages, authwit requests, etc.) emitted by the last top-level call,
|
|
304
|
+
// MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY is arbitrarily set at 64 because we need a bound. Nothing inherent about it.
|
|
305
|
+
const MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY = 64;
|
|
306
|
+
// Must match MAX_OFFCHAIN_EFFECT_LEN in txe_oracles.nr.
|
|
307
|
+
const MAX_OFFCHAIN_EFFECT_LEN = 2 + PRIVATE_LOG_CIPHERTEXT_LEN;
|
|
308
|
+
|
|
309
|
+
const { effects } = this.stateHandler.getLastCallOffchainEffects();
|
|
310
|
+
|
|
311
|
+
if (effects.length > MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY) {
|
|
312
|
+
throw new Error(`${effects.length} offchain effects exceed max ${MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY}`);
|
|
313
|
+
}
|
|
314
|
+
if (effects.some(e => e.length > MAX_OFFCHAIN_EFFECT_LEN)) {
|
|
315
|
+
throw new Error(`Some offchain effect has length larger than max ${MAX_OFFCHAIN_EFFECT_LEN}`);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const rawArrayStorage = effects
|
|
319
|
+
.map(e => e.concat(Array(MAX_OFFCHAIN_EFFECT_LEN - e.length).fill(new Fr(0))))
|
|
320
|
+
.concat(
|
|
321
|
+
Array(MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY - effects.length).fill(Array(MAX_OFFCHAIN_EFFECT_LEN).fill(new Fr(0))),
|
|
322
|
+
)
|
|
323
|
+
.flat();
|
|
324
|
+
|
|
325
|
+
const effectLengths = effects
|
|
326
|
+
.map(e => new Fr(e.length))
|
|
327
|
+
.concat(Array(MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY - effects.length).fill(new Fr(0)));
|
|
328
|
+
|
|
329
|
+
const count = new Fr(effects.length);
|
|
330
|
+
|
|
331
|
+
return toForeignCallResult([toArray(rawArrayStorage), toArray(effectLengths), toSingle(count)]);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// eslint-disable-next-line camelcase
|
|
335
|
+
aztec_txe_getLastCallContext() {
|
|
336
|
+
const { txHash, anchorBlockTimestamp } = this.stateHandler.getLastCallContext();
|
|
337
|
+
const isSome = txHash.isZero() ? 0 : 1;
|
|
338
|
+
return toForeignCallResult([toSingle(isSome), toSingle(txHash), toSingle(new Fr(anchorBlockTimestamp))]);
|
|
339
|
+
}
|
|
340
|
+
|
|
300
341
|
// eslint-disable-next-line camelcase
|
|
301
342
|
async aztec_txe_getPrivateEvents(
|
|
302
343
|
foreignSelector: ForeignCallSingle,
|
|
@@ -384,7 +425,7 @@ export class RPCTranslator {
|
|
|
384
425
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
385
426
|
foreignNumberOfElements: ForeignCallSingle,
|
|
386
427
|
) {
|
|
387
|
-
const blockHash =
|
|
428
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
388
429
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
389
430
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
390
431
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
@@ -401,7 +442,7 @@ export class RPCTranslator {
|
|
|
401
442
|
|
|
402
443
|
// eslint-disable-next-line camelcase
|
|
403
444
|
async aztec_utl_getPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
404
|
-
const blockHash =
|
|
445
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
405
446
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
406
447
|
|
|
407
448
|
const witness = await this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot);
|
|
@@ -628,7 +669,7 @@ export class RPCTranslator {
|
|
|
628
669
|
foreignBlockHash: ForeignCallSingle,
|
|
629
670
|
foreignNullifier: ForeignCallSingle,
|
|
630
671
|
) {
|
|
631
|
-
const blockHash =
|
|
672
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
632
673
|
const nullifier = fromSingle(foreignNullifier);
|
|
633
674
|
|
|
634
675
|
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -692,7 +733,7 @@ export class RPCTranslator {
|
|
|
692
733
|
foreignAnchorBlockHash: ForeignCallSingle,
|
|
693
734
|
foreignNoteHash: ForeignCallSingle,
|
|
694
735
|
) {
|
|
695
|
-
const blockHash =
|
|
736
|
+
const blockHash = blockHashFromSingle(foreignAnchorBlockHash);
|
|
696
737
|
const noteHash = fromSingle(foreignNoteHash);
|
|
697
738
|
|
|
698
739
|
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
@@ -708,8 +749,8 @@ export class RPCTranslator {
|
|
|
708
749
|
foreignAnchorBlockHash: ForeignCallSingle,
|
|
709
750
|
foreignBlockHash: ForeignCallSingle,
|
|
710
751
|
) {
|
|
711
|
-
const anchorBlockHash =
|
|
712
|
-
const blockHash =
|
|
752
|
+
const anchorBlockHash = blockHashFromSingle(foreignAnchorBlockHash);
|
|
753
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
713
754
|
|
|
714
755
|
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
715
756
|
|
|
@@ -726,7 +767,7 @@ export class RPCTranslator {
|
|
|
726
767
|
foreignBlockHash: ForeignCallSingle,
|
|
727
768
|
foreignNullifier: ForeignCallSingle,
|
|
728
769
|
) {
|
|
729
|
-
const blockHash =
|
|
770
|
+
const blockHash = blockHashFromSingle(foreignBlockHash);
|
|
730
771
|
const nullifier = fromSingle(foreignNullifier);
|
|
731
772
|
|
|
732
773
|
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -750,6 +791,13 @@ export class RPCTranslator {
|
|
|
750
791
|
return toForeignCallResult([]);
|
|
751
792
|
}
|
|
752
793
|
|
|
794
|
+
// eslint-disable-next-line camelcase
|
|
795
|
+
async aztec_utl_getPendingTaggedLogs_v2(foreignScope: ForeignCallSingle) {
|
|
796
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
797
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(scope);
|
|
798
|
+
return toForeignCallResult([toSingle(slot)]);
|
|
799
|
+
}
|
|
800
|
+
|
|
753
801
|
// eslint-disable-next-line camelcase
|
|
754
802
|
public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
755
803
|
foreignContractAddress: ForeignCallSingle,
|
|
@@ -778,6 +826,31 @@ export class RPCTranslator {
|
|
|
778
826
|
return toForeignCallResult([]);
|
|
779
827
|
}
|
|
780
828
|
|
|
829
|
+
// eslint-disable-next-line camelcase
|
|
830
|
+
public async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
|
|
831
|
+
foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
832
|
+
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
833
|
+
foreignMaxNotePackedLen: ForeignCallSingle,
|
|
834
|
+
foreignMaxEventSerializedLen: ForeignCallSingle,
|
|
835
|
+
foreignScope: ForeignCallSingle,
|
|
836
|
+
) {
|
|
837
|
+
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
838
|
+
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
839
|
+
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
840
|
+
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
841
|
+
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
842
|
+
|
|
843
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
|
|
844
|
+
noteValidationRequestsArrayBaseSlot,
|
|
845
|
+
eventValidationRequestsArrayBaseSlot,
|
|
846
|
+
maxNotePackedLen,
|
|
847
|
+
maxEventSerializedLen,
|
|
848
|
+
scope,
|
|
849
|
+
);
|
|
850
|
+
|
|
851
|
+
return toForeignCallResult([]);
|
|
852
|
+
}
|
|
853
|
+
|
|
781
854
|
// eslint-disable-next-line camelcase
|
|
782
855
|
public async aztec_utl_getLogsByTag(
|
|
783
856
|
foreignContractAddress: ForeignCallSingle,
|
|
@@ -822,6 +895,20 @@ export class RPCTranslator {
|
|
|
822
895
|
return toForeignCallResult([]);
|
|
823
896
|
}
|
|
824
897
|
|
|
898
|
+
// eslint-disable-next-line camelcase
|
|
899
|
+
async aztec_utl_getLogsByTag_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
|
|
900
|
+
const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
|
|
901
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(requestArrayBaseSlot);
|
|
902
|
+
return toForeignCallResult([toSingle(responseSlot)]);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// eslint-disable-next-line camelcase
|
|
906
|
+
async aztec_utl_getMessageContextsByTxHash_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
|
|
907
|
+
const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
|
|
908
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(requestArrayBaseSlot);
|
|
909
|
+
return toForeignCallResult([toSingle(responseSlot)]);
|
|
910
|
+
}
|
|
911
|
+
|
|
825
912
|
// eslint-disable-next-line camelcase
|
|
826
913
|
aztec_utl_setCapsule(
|
|
827
914
|
foreignContractAddress: ForeignCallSingle,
|
|
@@ -898,6 +985,64 @@ export class RPCTranslator {
|
|
|
898
985
|
return toForeignCallResult([]);
|
|
899
986
|
}
|
|
900
987
|
|
|
988
|
+
// eslint-disable-next-line camelcase
|
|
989
|
+
aztec_utl_pushEphemeral(foreignSlot: ForeignCallSingle, foreignElements: ForeignCallArray) {
|
|
990
|
+
const slot = fromSingle(foreignSlot);
|
|
991
|
+
const elements = fromArray(foreignElements);
|
|
992
|
+
const newLen = this.handlerAsUtility().pushEphemeral(slot, elements);
|
|
993
|
+
return toForeignCallResult([toSingle(new Fr(newLen))]);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// eslint-disable-next-line camelcase
|
|
997
|
+
aztec_utl_popEphemeral(foreignSlot: ForeignCallSingle) {
|
|
998
|
+
const slot = fromSingle(foreignSlot);
|
|
999
|
+
const element = this.handlerAsUtility().popEphemeral(slot);
|
|
1000
|
+
return toForeignCallResult([toArray(element)]);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// eslint-disable-next-line camelcase
|
|
1004
|
+
aztec_utl_getEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
|
|
1005
|
+
const slot = fromSingle(foreignSlot);
|
|
1006
|
+
const index = fromSingle(foreignIndex).toNumber();
|
|
1007
|
+
const element = this.handlerAsUtility().getEphemeral(slot, index);
|
|
1008
|
+
return toForeignCallResult([toArray(element)]);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// eslint-disable-next-line camelcase
|
|
1012
|
+
aztec_utl_setEphemeral(
|
|
1013
|
+
foreignSlot: ForeignCallSingle,
|
|
1014
|
+
foreignIndex: ForeignCallSingle,
|
|
1015
|
+
foreignElements: ForeignCallArray,
|
|
1016
|
+
) {
|
|
1017
|
+
const slot = fromSingle(foreignSlot);
|
|
1018
|
+
const index = fromSingle(foreignIndex).toNumber();
|
|
1019
|
+
const elements = fromArray(foreignElements);
|
|
1020
|
+
this.handlerAsUtility().setEphemeral(slot, index, elements);
|
|
1021
|
+
return toForeignCallResult([]);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// eslint-disable-next-line camelcase
|
|
1025
|
+
aztec_utl_getEphemeralLen(foreignSlot: ForeignCallSingle) {
|
|
1026
|
+
const slot = fromSingle(foreignSlot);
|
|
1027
|
+
const len = this.handlerAsUtility().getEphemeralLen(slot);
|
|
1028
|
+
return toForeignCallResult([toSingle(new Fr(len))]);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// eslint-disable-next-line camelcase
|
|
1032
|
+
aztec_utl_removeEphemeral(foreignSlot: ForeignCallSingle, foreignIndex: ForeignCallSingle) {
|
|
1033
|
+
const slot = fromSingle(foreignSlot);
|
|
1034
|
+
const index = fromSingle(foreignIndex).toNumber();
|
|
1035
|
+
this.handlerAsUtility().removeEphemeral(slot, index);
|
|
1036
|
+
return toForeignCallResult([]);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// eslint-disable-next-line camelcase
|
|
1040
|
+
aztec_utl_clearEphemeral(foreignSlot: ForeignCallSingle) {
|
|
1041
|
+
const slot = fromSingle(foreignSlot);
|
|
1042
|
+
this.handlerAsUtility().clearEphemeral(slot);
|
|
1043
|
+
return toForeignCallResult([]);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
901
1046
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
902
1047
|
// 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
|
|
903
1048
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
@@ -966,8 +1111,13 @@ export class RPCTranslator {
|
|
|
966
1111
|
}
|
|
967
1112
|
|
|
968
1113
|
// eslint-disable-next-line camelcase
|
|
969
|
-
aztec_utl_emitOffchainEffect(
|
|
970
|
-
|
|
1114
|
+
aztec_utl_emitOffchainEffect(foreignData: ForeignCallArray) {
|
|
1115
|
+
// Record the raw payload against the currently-executing top-level call. The Noir side
|
|
1116
|
+
// (via `env.offchain_messages()`) is responsible for decoding the protocol-reserved prefix
|
|
1117
|
+
// (`OFFCHAIN_MESSAGE_IDENTIFIER`, recipient) and turning each payload into an `OffchainMessage` struct suitable
|
|
1118
|
+
// for `offchain_receive`.
|
|
1119
|
+
this.stateHandler.recordOffchainEffect(fromArray(foreignData));
|
|
1120
|
+
return Promise.resolve(toForeignCallResult([]));
|
|
971
1121
|
}
|
|
972
1122
|
|
|
973
1123
|
// AVM opcodes
|
|
@@ -1176,18 +1326,38 @@ export class RPCTranslator {
|
|
|
1176
1326
|
const argsHash = fromSingle(foreignArgsHash);
|
|
1177
1327
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1178
1328
|
|
|
1179
|
-
const returnValues = await this.
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1329
|
+
const returnValues = await this.stateHandler.withTopLevelCallTracking(async () => {
|
|
1330
|
+
const { returnValues, offchainEffects } = await this.handlerAsTxe().privateCallNewFlow(
|
|
1331
|
+
from,
|
|
1332
|
+
targetContractAddress,
|
|
1333
|
+
functionSelector,
|
|
1334
|
+
args,
|
|
1335
|
+
argsHash,
|
|
1336
|
+
isStaticCall,
|
|
1337
|
+
this.stateHandler.getCurrentJob(),
|
|
1338
|
+
);
|
|
1339
|
+
|
|
1340
|
+
// Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than
|
|
1341
|
+
// round-tripping them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty
|
|
1342
|
+
// at this point. Drain the effects from the execution tree into the session buffer so the
|
|
1343
|
+
// next `env.offchain_messages()` call in the test sees them.
|
|
1344
|
+
for (const data of offchainEffects) {
|
|
1345
|
+
this.stateHandler.recordOffchainEffect(data);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1349
|
+
await this.stateHandler.cycleJob();
|
|
1350
|
+
|
|
1351
|
+
if (isStaticCall) {
|
|
1352
|
+
// Static calls revert their checkpoint and mine no block, so there is no tx hash to tag
|
|
1353
|
+
// offchain effects with. Querying `getLastTxEffects()` here would return an unrelated
|
|
1354
|
+
// predecessor tx.
|
|
1355
|
+
return { result: returnValues };
|
|
1356
|
+
}
|
|
1357
|
+
const { txHash } = await this.handlerAsTxe().getLastTxEffects();
|
|
1358
|
+
return { result: returnValues, txHash: txHash.hash };
|
|
1359
|
+
});
|
|
1188
1360
|
|
|
1189
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1190
|
-
await this.stateHandler.cycleJob();
|
|
1191
1361
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1192
1362
|
}
|
|
1193
1363
|
|
|
@@ -1201,15 +1371,20 @@ export class RPCTranslator {
|
|
|
1201
1371
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1202
1372
|
const args = fromArray(foreignArgs);
|
|
1203
1373
|
|
|
1204
|
-
const returnValues = await this.
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1374
|
+
const returnValues = await this.stateHandler.withTopLevelCallTracking(async () => {
|
|
1375
|
+
const returnValues = await this.handlerAsTxe().executeUtilityFunction(
|
|
1376
|
+
targetContractAddress,
|
|
1377
|
+
functionSelector,
|
|
1378
|
+
args,
|
|
1379
|
+
this.stateHandler.getCurrentJob(),
|
|
1380
|
+
);
|
|
1381
|
+
|
|
1382
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1383
|
+
await this.stateHandler.cycleJob();
|
|
1384
|
+
|
|
1385
|
+
return { result: returnValues };
|
|
1386
|
+
});
|
|
1210
1387
|
|
|
1211
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1212
|
-
await this.stateHandler.cycleJob();
|
|
1213
1388
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1214
1389
|
}
|
|
1215
1390
|
|
|
@@ -1225,10 +1400,20 @@ export class RPCTranslator {
|
|
|
1225
1400
|
const calldata = fromArray(foreignCalldata);
|
|
1226
1401
|
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1227
1402
|
|
|
1228
|
-
const returnValues = await this.
|
|
1403
|
+
const returnValues = await this.stateHandler.withTopLevelCallTracking(async () => {
|
|
1404
|
+
const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
|
|
1405
|
+
|
|
1406
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1407
|
+
await this.stateHandler.cycleJob();
|
|
1408
|
+
|
|
1409
|
+
if (isStaticCall) {
|
|
1410
|
+
// See equivalent branch in `aztec_txe_privateCallNewFlow`.
|
|
1411
|
+
return { result: returnValues };
|
|
1412
|
+
}
|
|
1413
|
+
const { txHash } = await this.handlerAsTxe().getLastTxEffects();
|
|
1414
|
+
return { result: returnValues, txHash: txHash.hash };
|
|
1415
|
+
});
|
|
1229
1416
|
|
|
1230
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1231
|
-
await this.stateHandler.cycleJob();
|
|
1232
1417
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1233
1418
|
}
|
|
1234
1419
|
|
|
@@ -1,20 +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
8
|
import {
|
|
7
|
-
type BuildCheckpointGlobalVariablesOpts,
|
|
8
9
|
type CheckpointGlobalVariables,
|
|
10
|
+
type FeeProvider,
|
|
9
11
|
type GlobalVariableBuilder,
|
|
10
12
|
GlobalVariables,
|
|
11
13
|
} from '@aztec/stdlib/tx';
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
/** Simple FeeProvider for TXE that returns zero fees. */
|
|
16
|
+
export class TXEFeeProvider implements FeeProvider {
|
|
14
17
|
public getCurrentMinFees(): Promise<GasFees> {
|
|
15
18
|
return Promise.resolve(new GasFees(0, 0));
|
|
16
19
|
}
|
|
17
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 {
|
|
18
27
|
public buildGlobalVariables(
|
|
19
28
|
_blockNumber: BlockNumber,
|
|
20
29
|
_coinbase: EthAddress,
|
|
@@ -28,7 +37,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
28
37
|
_coinbase: EthAddress,
|
|
29
38
|
_feeRecipient: AztecAddress,
|
|
30
39
|
_slotNumber: SlotNumber,
|
|
31
|
-
|
|
40
|
+
_simulationOverridesPlan?: SimulationOverridesPlan,
|
|
32
41
|
): Promise<CheckpointGlobalVariables> {
|
|
33
42
|
const vars = makeGlobalVariables();
|
|
34
43
|
return Promise.resolve({
|
|
@@ -13,7 +13,7 @@ import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
|
13
13
|
|
|
14
14
|
import { TXEArchiver } from './archiver.js';
|
|
15
15
|
import { DummyP2P } from './dummy_p2p_client.js';
|
|
16
|
-
import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
16
|
+
import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
17
17
|
import { MockEpochCache } from './mock_epoch_cache.js';
|
|
18
18
|
import { TXESynchronizer } from './synchronizer.js';
|
|
19
19
|
|
|
@@ -56,6 +56,7 @@ export class TXEStateMachine {
|
|
|
56
56
|
VERSION,
|
|
57
57
|
CHAIN_ID,
|
|
58
58
|
new TXEGlobalVariablesBuilder(),
|
|
59
|
+
new TXEFeeProvider(),
|
|
59
60
|
new MockEpochCache(),
|
|
60
61
|
getPackageVersion() ?? '',
|
|
61
62
|
new TestCircuitVerifier(),
|
|
@@ -59,6 +59,10 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
pipeliningOffset(): number {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
63
67
|
return '0x00';
|
|
64
68
|
}
|