@aztec/txe 0.82.0 → 0.82.1
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/bin/index.js +1 -1
- package/dest/oracle/txe_oracle.d.ts +5 -5
- package/dest/oracle/txe_oracle.d.ts.map +1 -1
- package/dest/oracle/txe_oracle.js +31 -42
- package/dest/txe_service/txe_service.d.ts +7 -5
- package/dest/txe_service/txe_service.d.ts.map +1 -1
- package/dest/txe_service/txe_service.js +10 -15
- package/dest/util/encoding.d.ts +2 -2
- 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 +15 -32
- package/package.json +12 -12
- package/src/bin/index.ts +1 -1
- package/src/oracle/txe_oracle.ts +55 -56
- package/src/txe_service/txe_service.ts +14 -17
- package/src/util/txe_public_contract_data_source.ts +21 -32
package/dest/bin/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { createTXERpcServer } from '../index.js';
|
|
|
18
18
|
logger.info(`Setting up TXE...`);
|
|
19
19
|
const txeServer = createTXERpcServer(logger);
|
|
20
20
|
const { port } = await startHttpRpcServer(txeServer, {
|
|
21
|
-
host: '
|
|
21
|
+
host: '127.0.0.1',
|
|
22
22
|
port: TXE_PORT,
|
|
23
23
|
timeoutMs: 1e3 * 60 * 5
|
|
24
24
|
});
|
|
@@ -96,8 +96,8 @@ export declare class TXE implements TypedOracle {
|
|
|
96
96
|
setIsStaticCall(isStatic: boolean): void;
|
|
97
97
|
getIsStaticCall(): boolean;
|
|
98
98
|
getRandomField(): Fr;
|
|
99
|
-
storeInExecutionCache(values: Fr[]):
|
|
100
|
-
loadFromExecutionCache(
|
|
99
|
+
storeInExecutionCache(values: Fr[], hash: Fr): void;
|
|
100
|
+
loadFromExecutionCache(hash: Fr): Promise<Fr[]>;
|
|
101
101
|
getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
|
|
102
102
|
getContractInstance(address: AztecAddress): Promise<ContractInstance>;
|
|
103
103
|
getMembershipWitness(blockNumber: number, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[] | undefined>;
|
|
@@ -126,8 +126,8 @@ export declare class TXE implements TypedOracle {
|
|
|
126
126
|
getInitialWitness(abi: FunctionAbi, argsHash: Fr, sideEffectCounter: number, isStaticCall: boolean): Promise<Map<number, string>>;
|
|
127
127
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
128
128
|
private executePublicFunction;
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
notifyEnqueuedPublicFunctionCall(targetContractAddress: AztecAddress, calldataHash: Fr, _sideEffectCounter: number, isStaticCall: boolean, isTeardown?: boolean): Promise<void>;
|
|
130
|
+
notifySetPublicTeardownFunctionCall(targetContractAddress: AztecAddress, calldataHash: Fr, sideEffectCounter: number, isStaticCall: boolean): Promise<void>;
|
|
131
131
|
notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
|
|
132
132
|
debugLog(message: string, fields: Fr[]): void;
|
|
133
133
|
incrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<void>;
|
|
@@ -135,7 +135,7 @@ export declare class TXE implements TypedOracle {
|
|
|
135
135
|
syncNotes(): Promise<void>;
|
|
136
136
|
deliverNote(contractAddress: AztecAddress, storageSlot: Fr, nonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: Fr, recipient: AztecAddress): Promise<void>;
|
|
137
137
|
getLogByTag(tag: Fr): Promise<LogWithTxData | null>;
|
|
138
|
-
avmOpcodeCall(targetContractAddress: AztecAddress,
|
|
138
|
+
avmOpcodeCall(targetContractAddress: AztecAddress, calldata: Fr[], isStaticCall: boolean): Promise<PublicTxResult>;
|
|
139
139
|
avmOpcodeSuccessCopy(): boolean;
|
|
140
140
|
avmOpcodeReturndataSize(): number;
|
|
141
141
|
avmOpcodeReturndataCopy(rdOffset: number, copySize: number): Fr[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_oracle.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"txe_oracle.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,wBAAwB,EAQ9B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,KAAK,MAAM,EAAyB,MAAM,uBAAuB,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,mBAAmB,EAEnB,oBAAoB,EAMrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EAEb,KAAK,WAAW,EAOjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,gBAAgB,EAChB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAU5F,OAAO,KAAK,EAA4B,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;A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AAG,OAAO,CAAC,MAAM,CAAC;IAK9E,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAGrE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Body, L2Block, Note } from '@aztec/aztec.js';
|
|
2
|
-
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PRIVATE_CONTEXT_INPUTS_LENGTH
|
|
2
|
+
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PRIVATE_CONTEXT_INPUTS_LENGTH } from '@aztec/constants';
|
|
3
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
4
|
import { Aes128, Schnorr, poseidon2Hash } from '@aztec/foundation/crypto';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -17,11 +17,11 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
17
17
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
18
18
|
import { Gas, GasFees } from '@aztec/stdlib/gas';
|
|
19
19
|
import { computeNoteHashNonce, computePublicDataTreeLeafSlot, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
20
|
-
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
20
|
+
import { PrivateContextInputs, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
21
21
|
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
22
22
|
import { makeAppendOnlyTreeSnapshot, makeContentCommitment, makeGlobalVariables, makeHeader } from '@aztec/stdlib/testing';
|
|
23
23
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, NullifierMembershipWitness, PublicDataTreeLeaf, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
24
|
-
import { BlockHeader, CallContext, GlobalVariables,
|
|
24
|
+
import { BlockHeader, CallContext, GlobalVariables, PublicCallRequestWithCalldata, TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
25
25
|
import { ForkCheckpoint, NativeWorldStateService } from '@aztec/world-state/native';
|
|
26
26
|
import { TXENode } from '../node/txe_node.js';
|
|
27
27
|
import { TXEAccountDataProvider } from '../util/txe_account_data_provider.js';
|
|
@@ -261,11 +261,15 @@ export class TXE {
|
|
|
261
261
|
getRandomField() {
|
|
262
262
|
return Fr.random();
|
|
263
263
|
}
|
|
264
|
-
storeInExecutionCache(values) {
|
|
265
|
-
return this.executionCache.store(values);
|
|
264
|
+
storeInExecutionCache(values, hash) {
|
|
265
|
+
return this.executionCache.store(values, hash);
|
|
266
266
|
}
|
|
267
|
-
loadFromExecutionCache(
|
|
268
|
-
|
|
267
|
+
loadFromExecutionCache(hash) {
|
|
268
|
+
const preimage = this.executionCache.getPreimage(hash);
|
|
269
|
+
if (!preimage) {
|
|
270
|
+
throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
|
|
271
|
+
}
|
|
272
|
+
return Promise.resolve(preimage);
|
|
269
273
|
}
|
|
270
274
|
getKeyValidationRequest(pkMHash) {
|
|
271
275
|
return this.keyStore.getKeyValidationRequest(pkMHash, this.contractAddress);
|
|
@@ -547,6 +551,9 @@ export class TXE {
|
|
|
547
551
|
this.setContractAddress(targetContractAddress);
|
|
548
552
|
this.setFunctionSelector(functionSelector);
|
|
549
553
|
const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
554
|
+
if (!artifact) {
|
|
555
|
+
throw new Error(`Artifact not found when calling private function. Contract address: ${targetContractAddress}.`);
|
|
556
|
+
}
|
|
550
557
|
const initialWitness = await this.getInitialWitness(artifact, argsHash, sideEffectCounter, isStaticCall);
|
|
551
558
|
const acvmCallback = new Oracle(this);
|
|
552
559
|
const timer = new Timer();
|
|
@@ -587,7 +594,7 @@ export class TXE {
|
|
|
587
594
|
async getInitialWitness(abi, argsHash, sideEffectCounter, isStaticCall) {
|
|
588
595
|
const argumentsSize = countArgumentsSize(abi);
|
|
589
596
|
const args = this.executionCache.getPreimage(argsHash);
|
|
590
|
-
if (args
|
|
597
|
+
if (args?.length !== argumentsSize) {
|
|
591
598
|
throw new Error('Invalid arguments size');
|
|
592
599
|
}
|
|
593
600
|
const privateContextInputs = await this.getPrivateContextInputs(this.blockNumber - 1, sideEffectCounter, isStaticCall);
|
|
@@ -602,26 +609,11 @@ export class TXE {
|
|
|
602
609
|
return toACVMWitness(0, fields);
|
|
603
610
|
}
|
|
604
611
|
async getDebugFunctionName(address, selector) {
|
|
605
|
-
|
|
606
|
-
if (!instance) {
|
|
607
|
-
return undefined;
|
|
608
|
-
}
|
|
609
|
-
const artifact = await this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
|
|
610
|
-
if (!artifact) {
|
|
611
|
-
return undefined;
|
|
612
|
-
}
|
|
613
|
-
const functionSelectorsAndNames = await Promise.all(artifact.functions.map(async (f)=>({
|
|
614
|
-
name: f.name,
|
|
615
|
-
selector: await FunctionSelector.fromNameAndParameters(f.name, f.parameters)
|
|
616
|
-
})));
|
|
617
|
-
const functionSelectorAndName = functionSelectorsAndNames.find((f)=>f.selector.equals(selector));
|
|
618
|
-
if (!functionSelectorAndName) {
|
|
619
|
-
return undefined;
|
|
620
|
-
}
|
|
621
|
-
return `${artifact.name}:${functionSelectorAndName.name}`;
|
|
612
|
+
return await this.contractDataProvider.getDebugFunctionName(address, selector);
|
|
622
613
|
}
|
|
623
|
-
async executePublicFunction(
|
|
624
|
-
const
|
|
614
|
+
async executePublicFunction(calldata, msgSender, contractAddress, isStaticCall, isTeardown = false) {
|
|
615
|
+
const callRequest = await PublicCallRequest.fromCalldata(msgSender, contractAddress, isStaticCall, calldata);
|
|
616
|
+
const executionRequest = new PublicCallRequestWithCalldata(callRequest, calldata);
|
|
625
617
|
const db = this.baseFork;
|
|
626
618
|
const globalVariables = GlobalVariables.empty();
|
|
627
619
|
globalVariables.chainId = new Fr(await this.node.getChainId());
|
|
@@ -641,7 +633,7 @@ export class TXE {
|
|
|
641
633
|
// When setting up a teardown call, we tell it that
|
|
642
634
|
// private execution used Gas(1, 1) so it can compute a tx fee.
|
|
643
635
|
const gasUsedByPrivate = isTeardown ? new Gas(1, 1) : Gas.empty();
|
|
644
|
-
const tx =
|
|
636
|
+
const tx = createTxForPublicCalls(firstNullifier, /*setupExecutionRequests=*/ [], /*appExecutionRequests=*/ isTeardown ? [] : [
|
|
645
637
|
executionRequest
|
|
646
638
|
], /*teardownExecutionRequests=*/ isTeardown ? executionRequest : undefined, /*feePayer=*/ AztecAddress.zero(), gasUsedByPrivate);
|
|
647
639
|
result = await simulator.simulate(tx);
|
|
@@ -661,21 +653,20 @@ export class TXE {
|
|
|
661
653
|
this.addPublicLogs(result.avmProvingRequest.inputs.publicInputs.accumulatedData.publicLogs.filter((log)=>!log.contractAddress.equals(AztecAddress.ZERO)));
|
|
662
654
|
return Promise.resolve(result);
|
|
663
655
|
}
|
|
664
|
-
async
|
|
656
|
+
async notifyEnqueuedPublicFunctionCall(targetContractAddress, calldataHash, _sideEffectCounter, isStaticCall, isTeardown = false) {
|
|
665
657
|
// Store and modify env
|
|
666
658
|
const currentContractAddress = this.contractAddress;
|
|
667
659
|
const currentMessageSender = this.msgSender;
|
|
668
660
|
const currentFunctionSelector = FunctionSelector.fromField(this.functionSelector.toField());
|
|
661
|
+
const calldata = this.executionCache.getPreimage(calldataHash);
|
|
662
|
+
if (!calldata) {
|
|
663
|
+
throw new Error('Calldata for enqueued call not found in cache');
|
|
664
|
+
}
|
|
665
|
+
const functionSelector = FunctionSelector.fromField(calldata[0]);
|
|
669
666
|
this.setMsgSender(this.contractAddress);
|
|
670
667
|
this.setContractAddress(targetContractAddress);
|
|
671
668
|
this.setFunctionSelector(functionSelector);
|
|
672
|
-
const
|
|
673
|
-
const args = [
|
|
674
|
-
this.functionSelector.toField(),
|
|
675
|
-
...this.executionCache.getPreimage(argsHash)
|
|
676
|
-
];
|
|
677
|
-
const newArgsHash = await this.executionCache.store(args);
|
|
678
|
-
const executionResult = await this.executePublicFunction(args, callContext, isTeardown);
|
|
669
|
+
const executionResult = await this.executePublicFunction(calldata, /* msgSender */ currentContractAddress, targetContractAddress, isStaticCall, isTeardown);
|
|
679
670
|
// Poor man's revert handling
|
|
680
671
|
if (!executionResult.revertCode.isOK()) {
|
|
681
672
|
if (executionResult.revertReason && executionResult.revertReason instanceof SimulationError) {
|
|
@@ -695,12 +686,11 @@ export class TXE {
|
|
|
695
686
|
this.setContractAddress(currentContractAddress);
|
|
696
687
|
this.setMsgSender(currentMessageSender);
|
|
697
688
|
this.setFunctionSelector(currentFunctionSelector);
|
|
698
|
-
return newArgsHash;
|
|
699
689
|
}
|
|
700
|
-
async
|
|
690
|
+
async notifySetPublicTeardownFunctionCall(targetContractAddress, calldataHash, sideEffectCounter, isStaticCall) {
|
|
701
691
|
// Definitely not right, in that the teardown should always be last.
|
|
702
692
|
// But useful for executing flows.
|
|
703
|
-
|
|
693
|
+
await this.notifyEnqueuedPublicFunctionCall(targetContractAddress, calldataHash, sideEffectCounter, isStaticCall, /*isTeardown=*/ true);
|
|
704
694
|
}
|
|
705
695
|
async notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter) {
|
|
706
696
|
await this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
@@ -731,14 +721,13 @@ export class TXE {
|
|
|
731
721
|
return await this.pxeOracleInterface.getLogByTag(tag);
|
|
732
722
|
}
|
|
733
723
|
// AVM oracles
|
|
734
|
-
async avmOpcodeCall(targetContractAddress,
|
|
724
|
+
async avmOpcodeCall(targetContractAddress, calldata, isStaticCall) {
|
|
735
725
|
// Store and modify env
|
|
736
726
|
const currentContractAddress = this.contractAddress;
|
|
737
727
|
const currentMessageSender = this.msgSender;
|
|
738
728
|
this.setMsgSender(this.contractAddress);
|
|
739
729
|
this.setContractAddress(targetContractAddress);
|
|
740
|
-
const
|
|
741
|
-
const executionResult = await this.executePublicFunction(args, callContext);
|
|
730
|
+
const executionResult = await this.executePublicFunction(calldata, /* msgSender */ currentContractAddress, targetContractAddress, isStaticCall);
|
|
742
731
|
// Save return/revert data for later.
|
|
743
732
|
this.nestedCallReturndata = executionResult.processedPhases[0].returnValues[0].values;
|
|
744
733
|
this.nestedCallSuccess = executionResult.revertCode.isOK();
|
|
@@ -54,9 +54,9 @@ export declare class TXEService {
|
|
|
54
54
|
getBlockNumber(): Promise<{
|
|
55
55
|
values: (string | ForeignCallArray)[];
|
|
56
56
|
}>;
|
|
57
|
-
storeInExecutionCache(_length: ForeignCallSingle, values: ForeignCallArray):
|
|
57
|
+
storeInExecutionCache(_length: ForeignCallSingle, values: ForeignCallArray, hash: ForeignCallSingle): {
|
|
58
58
|
values: (string | ForeignCallArray)[];
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
60
|
loadFromExecutionCache(hash: ForeignCallSingle): Promise<{
|
|
61
61
|
values: (string | ForeignCallArray)[];
|
|
62
62
|
}>;
|
|
@@ -105,13 +105,15 @@ export declare class TXEService {
|
|
|
105
105
|
getAuthWitness(messageHash: ForeignCallSingle): Promise<{
|
|
106
106
|
values: (string | ForeignCallArray)[];
|
|
107
107
|
}>;
|
|
108
|
-
|
|
108
|
+
notifyEnqueuedPublicFunctionCall(targetContractAddress: ForeignCallSingle, calldataHash: ForeignCallSingle, sideEffectCounter: ForeignCallSingle, isStaticCall: ForeignCallSingle): Promise<{
|
|
109
109
|
values: (string | ForeignCallArray)[];
|
|
110
110
|
}>;
|
|
111
|
-
|
|
111
|
+
notifySetPublicTeardownFunctionCall(targetContractAddress: ForeignCallSingle, calldataHash: ForeignCallSingle, sideEffectCounter: ForeignCallSingle, isStaticCall: ForeignCallSingle): Promise<{
|
|
112
112
|
values: (string | ForeignCallArray)[];
|
|
113
113
|
}>;
|
|
114
|
-
notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: ForeignCallSingle):
|
|
114
|
+
notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: ForeignCallSingle): {
|
|
115
|
+
values: (string | ForeignCallArray)[];
|
|
116
|
+
};
|
|
115
117
|
getChainId(): Promise<{
|
|
116
118
|
values: (string | ForeignCallArray)[];
|
|
117
119
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_service.d.ts","sourceRoot":"","sources":["../../src/txe_service/txe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,2BAA2B,EAAa,MAAM,iBAAiB,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,KAAK,gBAAgB,EAAkC,MAAM,mBAAmB,CAAC;AAU1F,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAYvB,MAAM,qBAAqB,CAAC;AAG7B,qBAAa,UAAU;IACT,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,WAAW;gBAAnC,MAAM,EAAE,MAAM,EAAU,WAAW,EAAE,WAAW;WAEvD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;IAWjE,uBAAuB,CAAC,WAAW,EAAE,iBAAiB;;;IAKtD,eAAe,CAAC,MAAM,EAAE,iBAAiB;;;IAY/C,kBAAkB,CAAC,OAAO,EAAE,iBAAiB;;;IAMvC,UAAU,CAAC,MAAM,EAAE,iBAAiB;;;IAKpC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,2BAA2B,EAAE,MAAM,EAAE,iBAAiB;;;IAyBnG,kBAAkB,CACtB,eAAe,EAAE,iBAAiB,EAClC,gBAAgB,EAAE,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AgB;;;IAyBlB,mBAAmB,CACvB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,gBAAgB;;;IAyBxB,oBAAoB;;;CAIrB"}
|
|
@@ -172,11 +172,9 @@ export class TXEService {
|
|
|
172
172
|
]);
|
|
173
173
|
}
|
|
174
174
|
// Since the argument is a slice, noir automatically adds a length field to oracle call.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return toForeignCallResult([
|
|
178
|
-
toSingle(returnsHash)
|
|
179
|
-
]);
|
|
175
|
+
storeInExecutionCache(_length, values, hash) {
|
|
176
|
+
this.typedOracle.storeInExecutionCache(fromArray(values), fromSingle(hash));
|
|
177
|
+
return toForeignCallResult([]);
|
|
180
178
|
}
|
|
181
179
|
async loadFromExecutionCache(hash) {
|
|
182
180
|
const returns = await this.typedOracle.loadFromExecutionCache(fromSingle(hash));
|
|
@@ -315,20 +313,17 @@ export class TXEService {
|
|
|
315
313
|
toArray(authWitness)
|
|
316
314
|
]);
|
|
317
315
|
}
|
|
318
|
-
async
|
|
319
|
-
|
|
320
|
-
return toForeignCallResult([
|
|
321
|
-
toSingle(newArgsHash)
|
|
322
|
-
]);
|
|
316
|
+
async notifyEnqueuedPublicFunctionCall(targetContractAddress, calldataHash, sideEffectCounter, isStaticCall) {
|
|
317
|
+
await this.typedOracle.notifyEnqueuedPublicFunctionCall(addressFromSingle(targetContractAddress), fromSingle(calldataHash), fromSingle(sideEffectCounter).toNumber(), fromSingle(isStaticCall).toBool());
|
|
318
|
+
return toForeignCallResult([]);
|
|
323
319
|
}
|
|
324
|
-
async
|
|
325
|
-
|
|
326
|
-
return toForeignCallResult([
|
|
327
|
-
toSingle(newArgsHash)
|
|
328
|
-
]);
|
|
320
|
+
async notifySetPublicTeardownFunctionCall(targetContractAddress, calldataHash, sideEffectCounter, isStaticCall) {
|
|
321
|
+
await this.typedOracle.notifySetPublicTeardownFunctionCall(addressFromSingle(targetContractAddress), fromSingle(calldataHash), fromSingle(sideEffectCounter).toNumber(), fromSingle(isStaticCall).toBool());
|
|
322
|
+
return toForeignCallResult([]);
|
|
329
323
|
}
|
|
330
324
|
notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter) {
|
|
331
325
|
this.typedOracle.notifySetMinRevertibleSideEffectCounter(fromSingle(minRevertibleSideEffectCounter).toNumber());
|
|
326
|
+
return toForeignCallResult([]);
|
|
332
327
|
}
|
|
333
328
|
async getChainId() {
|
|
334
329
|
return toForeignCallResult([
|
package/dest/util/encoding.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
|
|
|
70
70
|
masterIncomingViewingPublicKey: string;
|
|
71
71
|
masterOutgoingViewingPublicKey: string;
|
|
72
72
|
masterTaggingPublicKey: string;
|
|
73
|
-
}>, import("@aztec/
|
|
73
|
+
}>, import("@aztec/stdlib/keys").PublicKeys, {
|
|
74
74
|
masterNullifierPublicKey: string;
|
|
75
75
|
masterIncomingViewingPublicKey: string;
|
|
76
76
|
masterOutgoingViewingPublicKey: string;
|
|
@@ -83,7 +83,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
|
|
|
83
83
|
currentContractClassId: Fr;
|
|
84
84
|
originalContractClassId: Fr;
|
|
85
85
|
initializationHash: Fr;
|
|
86
|
-
publicKeys: import("@aztec/
|
|
86
|
+
publicKeys: import("@aztec/stdlib/keys").PublicKeys;
|
|
87
87
|
}, {
|
|
88
88
|
version: 1;
|
|
89
89
|
publicKeys: {
|
|
@@ -12,7 +12,7 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
12
12
|
getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
13
13
|
getContractClassIds(): Promise<Fr[]>;
|
|
14
14
|
getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined>;
|
|
15
|
-
|
|
15
|
+
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
16
16
|
registerContractFunctionSignatures(_address: AztecAddress, _signatures: []): Promise<void>;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=txe_public_contract_data_source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAEnD,qBAAa,2BAA4B,YAAW,kBAAkB;IACxD,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,GAAG;IAElC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3B,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IA4BlE,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAKtD,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC;IAK1F,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IAI9B,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAKjF,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI1G,kCAAkC,CAAC,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3F"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { PrivateFunctionsTree } from '@aztec/pxe/server';
|
|
4
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
-
import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
1
|
+
import { FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
+
import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
|
|
6
3
|
export class TXEPublicContractDataSource {
|
|
7
4
|
txeOracle;
|
|
8
5
|
constructor(txeOracle){
|
|
@@ -13,22 +10,20 @@ export class TXEPublicContractDataSource {
|
|
|
13
10
|
}
|
|
14
11
|
async getContractClass(id) {
|
|
15
12
|
const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
|
|
13
|
+
if (!contractClass) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
16
|
const artifact = await this.txeOracle.getContractDataProvider().getContractArtifact(id);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const publicFunctions = [];
|
|
20
|
-
if (contractClass.packedBytecode.length > 0) {
|
|
21
|
-
publicFunctions.push({
|
|
22
|
-
selector: FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
23
|
-
bytecode: contractClass.packedBytecode
|
|
24
|
-
});
|
|
17
|
+
if (!artifact) {
|
|
18
|
+
return;
|
|
25
19
|
}
|
|
20
|
+
const privateFunctions = await Promise.all(artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE).map((fn)=>getContractClassPrivateFunctionFromArtifact(fn)));
|
|
21
|
+
const privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
26
22
|
return {
|
|
27
23
|
id,
|
|
28
24
|
artifactHash: contractClass.artifactHash,
|
|
29
25
|
packedBytecode: contractClass.packedBytecode,
|
|
30
|
-
|
|
31
|
-
privateFunctionsRoot: new Fr(privateFunctionsRoot.root),
|
|
26
|
+
privateFunctionsRoot,
|
|
32
27
|
version: contractClass.version,
|
|
33
28
|
privateFunctions: [],
|
|
34
29
|
unconstrainedFunctions: []
|
|
@@ -36,11 +31,11 @@ export class TXEPublicContractDataSource {
|
|
|
36
31
|
}
|
|
37
32
|
async getBytecodeCommitment(id) {
|
|
38
33
|
const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
|
|
39
|
-
return computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
34
|
+
return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
40
35
|
}
|
|
41
36
|
async getContract(address) {
|
|
42
37
|
const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
|
|
43
|
-
return {
|
|
38
|
+
return instance && {
|
|
44
39
|
...instance,
|
|
45
40
|
address
|
|
46
41
|
};
|
|
@@ -50,22 +45,10 @@ export class TXEPublicContractDataSource {
|
|
|
50
45
|
}
|
|
51
46
|
async getContractArtifact(address) {
|
|
52
47
|
const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
|
|
53
|
-
return this.txeOracle.getContractDataProvider().getContractArtifact(instance.currentContractClassId);
|
|
48
|
+
return instance && this.txeOracle.getContractDataProvider().getContractArtifact(instance.currentContractClassId);
|
|
54
49
|
}
|
|
55
|
-
async
|
|
56
|
-
|
|
57
|
-
if (!artifact) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
const functionSelectorsAndNames = await Promise.all(artifact.functions.map(async (f)=>({
|
|
61
|
-
name: f.name,
|
|
62
|
-
selector: await FunctionSelector.fromNameAndParameters({
|
|
63
|
-
name: f.name,
|
|
64
|
-
parameters: f.parameters
|
|
65
|
-
})
|
|
66
|
-
})));
|
|
67
|
-
const func = functionSelectorsAndNames.find((f)=>f.selector.equals(selector));
|
|
68
|
-
return Promise.resolve(func?.name);
|
|
50
|
+
async getDebugFunctionName(address, selector) {
|
|
51
|
+
return await this.txeOracle.getContractDataProvider().getDebugFunctionName(address, selector);
|
|
69
52
|
}
|
|
70
53
|
registerContractFunctionSignatures(_address, _signatures) {
|
|
71
54
|
return Promise.resolve();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "0.82.
|
|
3
|
+
"version": "0.82.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aztec/accounts": "0.82.
|
|
63
|
-
"@aztec/aztec.js": "0.82.
|
|
64
|
-
"@aztec/constants": "0.82.
|
|
65
|
-
"@aztec/foundation": "0.82.
|
|
66
|
-
"@aztec/key-store": "0.82.
|
|
67
|
-
"@aztec/kv-store": "0.82.
|
|
68
|
-
"@aztec/protocol-contracts": "0.82.
|
|
69
|
-
"@aztec/pxe": "0.82.
|
|
70
|
-
"@aztec/simulator": "0.82.
|
|
71
|
-
"@aztec/stdlib": "0.82.
|
|
72
|
-
"@aztec/world-state": "0.82.
|
|
62
|
+
"@aztec/accounts": "0.82.1",
|
|
63
|
+
"@aztec/aztec.js": "0.82.1",
|
|
64
|
+
"@aztec/constants": "0.82.1",
|
|
65
|
+
"@aztec/foundation": "0.82.1",
|
|
66
|
+
"@aztec/key-store": "0.82.1",
|
|
67
|
+
"@aztec/kv-store": "0.82.1",
|
|
68
|
+
"@aztec/protocol-contracts": "0.82.1",
|
|
69
|
+
"@aztec/pxe": "0.82.1",
|
|
70
|
+
"@aztec/simulator": "0.82.1",
|
|
71
|
+
"@aztec/stdlib": "0.82.1",
|
|
72
|
+
"@aztec/world-state": "0.82.1",
|
|
73
73
|
"zod": "^3.23.8"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
package/src/bin/index.ts
CHANGED
package/src/oracle/txe_oracle.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
9
9
|
PRIVATE_CONTEXT_INPUTS_LENGTH,
|
|
10
10
|
type PUBLIC_DATA_TREE_HEIGHT,
|
|
11
|
-
PUBLIC_DISPATCH_SELECTOR,
|
|
12
11
|
} from '@aztec/constants';
|
|
13
12
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
14
13
|
import { Aes128, Schnorr, poseidon2Hash } from '@aztec/foundation/crypto';
|
|
@@ -72,7 +71,7 @@ import {
|
|
|
72
71
|
siloNullifier,
|
|
73
72
|
} from '@aztec/stdlib/hash';
|
|
74
73
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
75
|
-
import { type KeyValidationRequest, PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
74
|
+
import { type KeyValidationRequest, PrivateContextInputs, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
76
75
|
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
77
76
|
import {
|
|
78
77
|
ContractClassLog,
|
|
@@ -98,7 +97,14 @@ import {
|
|
|
98
97
|
type PublicDataTreeLeafPreimage,
|
|
99
98
|
PublicDataWitness,
|
|
100
99
|
} from '@aztec/stdlib/trees';
|
|
101
|
-
import {
|
|
100
|
+
import {
|
|
101
|
+
BlockHeader,
|
|
102
|
+
CallContext,
|
|
103
|
+
GlobalVariables,
|
|
104
|
+
PublicCallRequestWithCalldata,
|
|
105
|
+
TxEffect,
|
|
106
|
+
TxHash,
|
|
107
|
+
} from '@aztec/stdlib/tx';
|
|
102
108
|
import { ForkCheckpoint, NativeWorldStateService } from '@aztec/world-state/native';
|
|
103
109
|
|
|
104
110
|
import { TXENode } from '../node/txe_node.js';
|
|
@@ -404,12 +410,16 @@ export class TXE implements TypedOracle {
|
|
|
404
410
|
return Fr.random();
|
|
405
411
|
}
|
|
406
412
|
|
|
407
|
-
storeInExecutionCache(values: Fr[]) {
|
|
408
|
-
return this.executionCache.store(values);
|
|
413
|
+
storeInExecutionCache(values: Fr[], hash: Fr) {
|
|
414
|
+
return this.executionCache.store(values, hash);
|
|
409
415
|
}
|
|
410
416
|
|
|
411
|
-
loadFromExecutionCache(
|
|
412
|
-
|
|
417
|
+
loadFromExecutionCache(hash: Fr) {
|
|
418
|
+
const preimage = this.executionCache.getPreimage(hash);
|
|
419
|
+
if (!preimage) {
|
|
420
|
+
throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
|
|
421
|
+
}
|
|
422
|
+
return Promise.resolve(preimage);
|
|
413
423
|
}
|
|
414
424
|
|
|
415
425
|
getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
|
|
@@ -825,6 +835,9 @@ export class TXE implements TypedOracle {
|
|
|
825
835
|
this.setFunctionSelector(functionSelector);
|
|
826
836
|
|
|
827
837
|
const artifact = await this.contractDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
838
|
+
if (!artifact) {
|
|
839
|
+
throw new Error(`Artifact not found when calling private function. Contract address: ${targetContractAddress}.`);
|
|
840
|
+
}
|
|
828
841
|
|
|
829
842
|
const initialWitness = await this.getInitialWitness(artifact, argsHash, sideEffectCounter, isStaticCall);
|
|
830
843
|
const acvmCallback = new Oracle(this);
|
|
@@ -880,7 +893,7 @@ export class TXE implements TypedOracle {
|
|
|
880
893
|
|
|
881
894
|
const args = this.executionCache.getPreimage(argsHash);
|
|
882
895
|
|
|
883
|
-
if (args
|
|
896
|
+
if (args?.length !== argumentsSize) {
|
|
884
897
|
throw new Error('Invalid arguments size');
|
|
885
898
|
}
|
|
886
899
|
|
|
@@ -899,30 +912,18 @@ export class TXE implements TypedOracle {
|
|
|
899
912
|
}
|
|
900
913
|
|
|
901
914
|
public async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
902
|
-
|
|
903
|
-
if (!instance) {
|
|
904
|
-
return undefined;
|
|
905
|
-
}
|
|
906
|
-
const artifact = await this.contractDataProvider.getContractArtifact(instance!.currentContractClassId);
|
|
907
|
-
if (!artifact) {
|
|
908
|
-
return undefined;
|
|
909
|
-
}
|
|
910
|
-
const functionSelectorsAndNames = await Promise.all(
|
|
911
|
-
artifact.functions.map(async f => ({
|
|
912
|
-
name: f.name,
|
|
913
|
-
selector: await FunctionSelector.fromNameAndParameters(f.name, f.parameters),
|
|
914
|
-
})),
|
|
915
|
-
);
|
|
916
|
-
const functionSelectorAndName = functionSelectorsAndNames.find(f => f.selector.equals(selector));
|
|
917
|
-
if (!functionSelectorAndName) {
|
|
918
|
-
return undefined;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
return `${artifact.name}:${functionSelectorAndName.name}`;
|
|
915
|
+
return await this.contractDataProvider.getDebugFunctionName(address, selector);
|
|
922
916
|
}
|
|
923
917
|
|
|
924
|
-
private async executePublicFunction(
|
|
925
|
-
|
|
918
|
+
private async executePublicFunction(
|
|
919
|
+
calldata: Fr[],
|
|
920
|
+
msgSender: AztecAddress,
|
|
921
|
+
contractAddress: AztecAddress,
|
|
922
|
+
isStaticCall: boolean,
|
|
923
|
+
isTeardown: boolean = false,
|
|
924
|
+
) {
|
|
925
|
+
const callRequest = await PublicCallRequest.fromCalldata(msgSender, contractAddress, isStaticCall, calldata);
|
|
926
|
+
const executionRequest = new PublicCallRequestWithCalldata(callRequest, calldata);
|
|
926
927
|
|
|
927
928
|
const db = this.baseFork;
|
|
928
929
|
|
|
@@ -949,7 +950,7 @@ export class TXE implements TypedOracle {
|
|
|
949
950
|
// When setting up a teardown call, we tell it that
|
|
950
951
|
// private execution used Gas(1, 1) so it can compute a tx fee.
|
|
951
952
|
const gasUsedByPrivate = isTeardown ? new Gas(1, 1) : Gas.empty();
|
|
952
|
-
const tx =
|
|
953
|
+
const tx = createTxForPublicCalls(
|
|
953
954
|
firstNullifier,
|
|
954
955
|
/*setupExecutionRequests=*/ [],
|
|
955
956
|
/*appExecutionRequests=*/ isTeardown ? [] : [executionRequest],
|
|
@@ -989,34 +990,34 @@ export class TXE implements TypedOracle {
|
|
|
989
990
|
return Promise.resolve(result);
|
|
990
991
|
}
|
|
991
992
|
|
|
992
|
-
async
|
|
993
|
+
async notifyEnqueuedPublicFunctionCall(
|
|
993
994
|
targetContractAddress: AztecAddress,
|
|
994
|
-
|
|
995
|
-
argsHash: Fr,
|
|
995
|
+
calldataHash: Fr,
|
|
996
996
|
_sideEffectCounter: number,
|
|
997
997
|
isStaticCall: boolean,
|
|
998
998
|
isTeardown = false,
|
|
999
|
-
): Promise<
|
|
999
|
+
): Promise<void> {
|
|
1000
1000
|
// Store and modify env
|
|
1001
1001
|
const currentContractAddress = this.contractAddress;
|
|
1002
1002
|
const currentMessageSender = this.msgSender;
|
|
1003
1003
|
const currentFunctionSelector = FunctionSelector.fromField(this.functionSelector.toField());
|
|
1004
|
+
const calldata = this.executionCache.getPreimage(calldataHash);
|
|
1005
|
+
if (!calldata) {
|
|
1006
|
+
throw new Error('Calldata for enqueued call not found in cache');
|
|
1007
|
+
}
|
|
1008
|
+
const functionSelector = FunctionSelector.fromField(calldata[0]);
|
|
1004
1009
|
this.setMsgSender(this.contractAddress);
|
|
1005
1010
|
this.setContractAddress(targetContractAddress);
|
|
1006
1011
|
this.setFunctionSelector(functionSelector);
|
|
1007
1012
|
|
|
1008
|
-
const
|
|
1013
|
+
const executionResult = await this.executePublicFunction(
|
|
1014
|
+
calldata,
|
|
1009
1015
|
/* msgSender */ currentContractAddress,
|
|
1010
1016
|
targetContractAddress,
|
|
1011
|
-
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
1012
1017
|
isStaticCall,
|
|
1018
|
+
isTeardown,
|
|
1013
1019
|
);
|
|
1014
1020
|
|
|
1015
|
-
const args = [this.functionSelector.toField(), ...this.executionCache.getPreimage(argsHash)];
|
|
1016
|
-
const newArgsHash = await this.executionCache.store(args);
|
|
1017
|
-
|
|
1018
|
-
const executionResult = await this.executePublicFunction(args, callContext, isTeardown);
|
|
1019
|
-
|
|
1020
1021
|
// Poor man's revert handling
|
|
1021
1022
|
if (!executionResult.revertCode.isOK()) {
|
|
1022
1023
|
if (executionResult.revertReason && executionResult.revertReason instanceof SimulationError) {
|
|
@@ -1040,23 +1041,19 @@ export class TXE implements TypedOracle {
|
|
|
1040
1041
|
this.setContractAddress(currentContractAddress);
|
|
1041
1042
|
this.setMsgSender(currentMessageSender);
|
|
1042
1043
|
this.setFunctionSelector(currentFunctionSelector);
|
|
1043
|
-
|
|
1044
|
-
return newArgsHash;
|
|
1045
1044
|
}
|
|
1046
1045
|
|
|
1047
|
-
async
|
|
1046
|
+
async notifySetPublicTeardownFunctionCall(
|
|
1048
1047
|
targetContractAddress: AztecAddress,
|
|
1049
|
-
|
|
1050
|
-
argsHash: Fr,
|
|
1048
|
+
calldataHash: Fr,
|
|
1051
1049
|
sideEffectCounter: number,
|
|
1052
1050
|
isStaticCall: boolean,
|
|
1053
|
-
): Promise<
|
|
1051
|
+
): Promise<void> {
|
|
1054
1052
|
// Definitely not right, in that the teardown should always be last.
|
|
1055
1053
|
// But useful for executing flows.
|
|
1056
|
-
|
|
1054
|
+
await this.notifyEnqueuedPublicFunctionCall(
|
|
1057
1055
|
targetContractAddress,
|
|
1058
|
-
|
|
1059
|
-
argsHash,
|
|
1056
|
+
calldataHash,
|
|
1060
1057
|
sideEffectCounter,
|
|
1061
1058
|
isStaticCall,
|
|
1062
1059
|
/*isTeardown=*/ true,
|
|
@@ -1127,21 +1124,23 @@ export class TXE implements TypedOracle {
|
|
|
1127
1124
|
|
|
1128
1125
|
// AVM oracles
|
|
1129
1126
|
|
|
1130
|
-
async avmOpcodeCall(
|
|
1127
|
+
async avmOpcodeCall(
|
|
1128
|
+
targetContractAddress: AztecAddress,
|
|
1129
|
+
calldata: Fr[],
|
|
1130
|
+
isStaticCall: boolean,
|
|
1131
|
+
): Promise<PublicTxResult> {
|
|
1131
1132
|
// Store and modify env
|
|
1132
1133
|
const currentContractAddress = this.contractAddress;
|
|
1133
1134
|
const currentMessageSender = this.msgSender;
|
|
1134
1135
|
this.setMsgSender(this.contractAddress);
|
|
1135
1136
|
this.setContractAddress(targetContractAddress);
|
|
1136
1137
|
|
|
1137
|
-
const
|
|
1138
|
+
const executionResult = await this.executePublicFunction(
|
|
1139
|
+
calldata,
|
|
1138
1140
|
/* msgSender */ currentContractAddress,
|
|
1139
1141
|
targetContractAddress,
|
|
1140
|
-
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
1141
1142
|
isStaticCall,
|
|
1142
1143
|
);
|
|
1143
|
-
|
|
1144
|
-
const executionResult = await this.executePublicFunction(args, callContext);
|
|
1145
1144
|
// Save return/revert data for later.
|
|
1146
1145
|
this.nestedCallReturndata = executionResult.processedPhases[0]!.returnValues[0].values!;
|
|
1147
1146
|
this.nestedCallSuccess = executionResult.revertCode.isOK();
|
|
@@ -223,9 +223,9 @@ export class TXEService {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// Since the argument is a slice, noir automatically adds a length field to oracle call.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return toForeignCallResult([
|
|
226
|
+
storeInExecutionCache(_length: ForeignCallSingle, values: ForeignCallArray, hash: ForeignCallSingle) {
|
|
227
|
+
this.typedOracle.storeInExecutionCache(fromArray(values), fromSingle(hash));
|
|
228
|
+
return toForeignCallResult([]);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
async loadFromExecutionCache(hash: ForeignCallSingle) {
|
|
@@ -434,42 +434,39 @@ export class TXEService {
|
|
|
434
434
|
return toForeignCallResult([toArray(authWitness)]);
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
async
|
|
437
|
+
public async notifyEnqueuedPublicFunctionCall(
|
|
438
438
|
targetContractAddress: ForeignCallSingle,
|
|
439
|
-
|
|
440
|
-
argsHash: ForeignCallSingle,
|
|
439
|
+
calldataHash: ForeignCallSingle,
|
|
441
440
|
sideEffectCounter: ForeignCallSingle,
|
|
442
441
|
isStaticCall: ForeignCallSingle,
|
|
443
442
|
) {
|
|
444
|
-
|
|
443
|
+
await this.typedOracle.notifyEnqueuedPublicFunctionCall(
|
|
445
444
|
addressFromSingle(targetContractAddress),
|
|
446
|
-
|
|
447
|
-
fromSingle(argsHash),
|
|
445
|
+
fromSingle(calldataHash),
|
|
448
446
|
fromSingle(sideEffectCounter).toNumber(),
|
|
449
447
|
fromSingle(isStaticCall).toBool(),
|
|
450
448
|
);
|
|
451
|
-
return toForeignCallResult([
|
|
449
|
+
return toForeignCallResult([]);
|
|
452
450
|
}
|
|
453
451
|
|
|
454
|
-
public async
|
|
452
|
+
public async notifySetPublicTeardownFunctionCall(
|
|
455
453
|
targetContractAddress: ForeignCallSingle,
|
|
456
|
-
|
|
457
|
-
argsHash: ForeignCallSingle,
|
|
454
|
+
calldataHash: ForeignCallSingle,
|
|
458
455
|
sideEffectCounter: ForeignCallSingle,
|
|
459
456
|
isStaticCall: ForeignCallSingle,
|
|
460
457
|
) {
|
|
461
|
-
|
|
458
|
+
await this.typedOracle.notifySetPublicTeardownFunctionCall(
|
|
462
459
|
addressFromSingle(targetContractAddress),
|
|
463
|
-
|
|
464
|
-
fromSingle(argsHash),
|
|
460
|
+
fromSingle(calldataHash),
|
|
465
461
|
fromSingle(sideEffectCounter).toNumber(),
|
|
466
462
|
fromSingle(isStaticCall).toBool(),
|
|
467
463
|
);
|
|
468
|
-
return toForeignCallResult([
|
|
464
|
+
return toForeignCallResult([]);
|
|
469
465
|
}
|
|
470
466
|
|
|
471
467
|
public notifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: ForeignCallSingle) {
|
|
472
468
|
this.typedOracle.notifySetMinRevertibleSideEffectCounter(fromSingle(minRevertibleSideEffectCounter).toNumber());
|
|
469
|
+
return toForeignCallResult([]);
|
|
473
470
|
}
|
|
474
471
|
|
|
475
472
|
async getChainId() {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import {
|
|
4
|
-
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
+
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
5
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
4
|
import {
|
|
7
5
|
type ContractClassPublic,
|
|
8
6
|
type ContractDataSource,
|
|
9
7
|
type ContractInstanceWithAddress,
|
|
10
|
-
|
|
8
|
+
computePrivateFunctionsRoot,
|
|
11
9
|
computePublicBytecodeCommitment,
|
|
10
|
+
getContractClassPrivateFunctionFromArtifact,
|
|
12
11
|
} from '@aztec/stdlib/contract';
|
|
13
12
|
|
|
14
13
|
import type { TXE } from '../oracle/txe_oracle.js';
|
|
@@ -22,24 +21,26 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
22
21
|
|
|
23
22
|
async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
24
23
|
const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
|
|
24
|
+
if (!contractClass) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
25
27
|
const artifact = await this.txeOracle.getContractDataProvider().getContractArtifact(id);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const publicFunctions: PublicFunction[] = [];
|
|
30
|
-
if (contractClass!.packedBytecode.length > 0) {
|
|
31
|
-
publicFunctions.push({
|
|
32
|
-
selector: FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
33
|
-
bytecode: contractClass!.packedBytecode,
|
|
34
|
-
});
|
|
28
|
+
if (!artifact) {
|
|
29
|
+
return;
|
|
35
30
|
}
|
|
36
31
|
|
|
32
|
+
const privateFunctions = await Promise.all(
|
|
33
|
+
artifact.functions
|
|
34
|
+
.filter(fn => fn.functionType === FunctionType.PRIVATE)
|
|
35
|
+
.map(fn => getContractClassPrivateFunctionFromArtifact(fn)),
|
|
36
|
+
);
|
|
37
|
+
const privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
38
|
+
|
|
37
39
|
return {
|
|
38
40
|
id,
|
|
39
41
|
artifactHash: contractClass!.artifactHash,
|
|
40
42
|
packedBytecode: contractClass!.packedBytecode,
|
|
41
|
-
|
|
42
|
-
privateFunctionsRoot: new Fr(privateFunctionsRoot!.root),
|
|
43
|
+
privateFunctionsRoot,
|
|
43
44
|
version: contractClass!.version,
|
|
44
45
|
privateFunctions: [],
|
|
45
46
|
unconstrainedFunctions: [],
|
|
@@ -48,12 +49,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
48
49
|
|
|
49
50
|
async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
50
51
|
const contractClass = await this.txeOracle.getContractDataProvider().getContractClass(id);
|
|
51
|
-
return computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
52
|
+
return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
55
56
|
const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
|
|
56
|
-
return { ...instance, address };
|
|
57
|
+
return instance && { ...instance, address };
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
getContractClassIds(): Promise<Fr[]> {
|
|
@@ -62,23 +63,11 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
62
63
|
|
|
63
64
|
async getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
|
|
64
65
|
const instance = await this.txeOracle.getContractDataProvider().getContractInstance(address);
|
|
65
|
-
return this.txeOracle.getContractDataProvider().getContractArtifact(instance.currentContractClassId);
|
|
66
|
+
return instance && this.txeOracle.getContractDataProvider().getContractArtifact(instance.currentContractClassId);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
async
|
|
69
|
-
|
|
70
|
-
if (!artifact) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const functionSelectorsAndNames = await Promise.all(
|
|
74
|
-
artifact.functions.map(async f => ({
|
|
75
|
-
name: f.name,
|
|
76
|
-
selector: await FunctionSelector.fromNameAndParameters({ name: f.name, parameters: f.parameters }),
|
|
77
|
-
})),
|
|
78
|
-
);
|
|
79
|
-
const func = functionSelectorsAndNames.find(f => f.selector.equals(selector));
|
|
80
|
-
|
|
81
|
-
return Promise.resolve(func?.name);
|
|
69
|
+
async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
70
|
+
return await this.txeOracle.getContractDataProvider().getDebugFunctionName(address, selector);
|
|
82
71
|
}
|
|
83
72
|
|
|
84
73
|
registerContractFunctionSignatures(_address: AztecAddress, _signatures: []): Promise<void> {
|