@aztec/txe 0.0.1-commit.3d8f95d → 0.0.1-commit.3f296a7d2
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +88 -54
- package/dest/oracle/interfaces.d.ts +29 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +12 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -23
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +61 -47
- package/dest/rpc_translator.d.ts +87 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +273 -151
- 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 +5 -7
- package/dest/state_machine/dummy_p2p_client.d.ts +8 -5
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +13 -4
- package/dest/state_machine/index.d.ts +4 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +7 -3
- package/dest/state_machine/mock_epoch_cache.d.ts +17 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +32 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +10 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +36 -24
- package/dest/util/encoding.d.ts +69 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +6 -25
- package/package.json +15 -15
- package/src/index.ts +89 -52
- package/src/oracle/interfaces.ts +32 -31
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +73 -45
- package/src/rpc_translator.ts +305 -173
- package/src/state_machine/archiver.ts +5 -5
- package/src/state_machine/dummy_p2p_client.ts +19 -7
- package/src/state_machine/index.ts +7 -1
- package/src/state_machine/mock_epoch_cache.ts +42 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +43 -21
- package/src/util/txe_public_contract_data_source.ts +10 -38
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
|
@@ -12,9 +12,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
12
12
|
import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
13
13
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
14
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
|
+
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
15
16
|
import {
|
|
16
17
|
AddressStore,
|
|
17
18
|
CapsuleStore,
|
|
19
|
+
type ContractStore,
|
|
20
|
+
type ContractSyncService,
|
|
18
21
|
NoteStore,
|
|
19
22
|
ORACLE_VERSION,
|
|
20
23
|
PrivateEventStore,
|
|
@@ -83,7 +86,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
83
86
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
84
87
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
85
88
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
86
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
87
89
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
88
90
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
89
91
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -96,7 +98,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
96
98
|
|
|
97
99
|
constructor(
|
|
98
100
|
private stateMachine: TXEStateMachine,
|
|
99
|
-
private contractStore:
|
|
101
|
+
private contractStore: ContractStore,
|
|
100
102
|
private noteStore: NoteStore,
|
|
101
103
|
private keyStore: KeyStore,
|
|
102
104
|
private addressStore: AddressStore,
|
|
@@ -106,17 +108,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
106
108
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
107
109
|
private capsuleStore: CapsuleStore,
|
|
108
110
|
private privateEventStore: PrivateEventStore,
|
|
109
|
-
private jobId: string,
|
|
110
111
|
private nextBlockTimestamp: bigint,
|
|
111
112
|
private version: Fr,
|
|
112
113
|
private chainId: Fr,
|
|
113
114
|
private authwits: Map<string, AuthWitness>,
|
|
115
|
+
private readonly contractSyncService: ContractSyncService,
|
|
114
116
|
) {
|
|
115
117
|
this.logger = createLogger('txe:top_level_context');
|
|
116
118
|
this.logger.debug('Entering Top Level Context');
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
assertCompatibleOracleVersion(version: number): void {
|
|
120
122
|
if (version !== ORACLE_VERSION) {
|
|
121
123
|
throw new Error(
|
|
122
124
|
`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
|
|
@@ -126,12 +128,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
126
128
|
|
|
127
129
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
128
130
|
// setup.
|
|
129
|
-
|
|
131
|
+
getRandomField(): Fr {
|
|
130
132
|
return Fr.random();
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
|
|
136
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
137
|
if (!LogLevels[level]) {
|
|
136
138
|
throw new Error(`Invalid log level: ${level}`);
|
|
137
139
|
}
|
|
@@ -141,23 +143,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
141
143
|
return Promise.resolve();
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
getDefaultAddress(): AztecAddress {
|
|
145
147
|
return DEFAULT_ADDRESS;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
async
|
|
150
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
149
151
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
150
152
|
}
|
|
151
153
|
|
|
152
|
-
|
|
154
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
153
155
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
async
|
|
158
|
+
async getLastBlockTimestamp() {
|
|
157
159
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
async
|
|
162
|
+
async getLastTxEffects() {
|
|
161
163
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
164
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
163
165
|
|
|
@@ -171,7 +173,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
171
173
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
async
|
|
176
|
+
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
177
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
178
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
183
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
184
|
+
contractAddress,
|
|
185
|
+
null,
|
|
186
|
+
async (call, execScopes) => {
|
|
187
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
188
|
+
},
|
|
189
|
+
blockHeader,
|
|
190
|
+
jobId,
|
|
191
|
+
[scope],
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
175
196
|
return (
|
|
176
197
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
177
198
|
contractAddress,
|
|
@@ -182,7 +203,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
182
203
|
).map(e => e.packedEvent);
|
|
183
204
|
}
|
|
184
205
|
|
|
185
|
-
async
|
|
206
|
+
async advanceBlocksBy(blocks: number) {
|
|
186
207
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
187
208
|
|
|
188
209
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -190,12 +211,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
190
211
|
}
|
|
191
212
|
}
|
|
192
213
|
|
|
193
|
-
|
|
214
|
+
advanceTimestampBy(duration: UInt64) {
|
|
194
215
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
195
216
|
this.nextBlockTimestamp += duration;
|
|
196
217
|
}
|
|
197
218
|
|
|
198
|
-
async
|
|
219
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
199
220
|
// Emit deployment nullifier
|
|
200
221
|
await this.mineBlock({
|
|
201
222
|
nullifiers: [
|
|
@@ -207,20 +228,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
207
228
|
});
|
|
208
229
|
|
|
209
230
|
if (!secret.equals(Fr.ZERO)) {
|
|
210
|
-
await this.
|
|
231
|
+
await this.addAccount(artifact, instance, secret);
|
|
211
232
|
} else {
|
|
212
233
|
await this.contractStore.addContractInstance(instance);
|
|
213
|
-
await this.contractStore.addContractArtifact(
|
|
234
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
214
235
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
215
236
|
}
|
|
216
237
|
}
|
|
217
238
|
|
|
218
|
-
async
|
|
239
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
219
240
|
const partialAddress = await computePartialAddress(instance);
|
|
220
241
|
|
|
221
242
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
222
243
|
await this.contractStore.addContractInstance(instance);
|
|
223
|
-
await this.contractStore.addContractArtifact(
|
|
244
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
224
245
|
|
|
225
246
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
226
247
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -230,7 +251,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
230
251
|
return completeAddress;
|
|
231
252
|
}
|
|
232
253
|
|
|
233
|
-
async
|
|
254
|
+
async createAccount(secret: Fr) {
|
|
234
255
|
// This is a foot gun !
|
|
235
256
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
236
257
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -240,7 +261,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
240
261
|
return completeAddress;
|
|
241
262
|
}
|
|
242
263
|
|
|
243
|
-
async
|
|
264
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
244
265
|
const account = await this.accountStore.getAccount(address);
|
|
245
266
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
246
267
|
|
|
@@ -253,7 +274,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
253
274
|
}
|
|
254
275
|
|
|
255
276
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
256
|
-
const blockNumber = await this.
|
|
277
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
257
278
|
|
|
258
279
|
const txEffect = TxEffect.empty();
|
|
259
280
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -277,13 +298,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
277
298
|
await this.stateMachine.handleL2Block(block);
|
|
278
299
|
}
|
|
279
300
|
|
|
280
|
-
async
|
|
301
|
+
async privateCallNewFlow(
|
|
281
302
|
from: AztecAddress,
|
|
282
303
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
283
304
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
284
305
|
args: Fr[],
|
|
285
306
|
argsHash: Fr = Fr.zero(),
|
|
286
307
|
isStaticCall: boolean = false,
|
|
308
|
+
jobId: string,
|
|
287
309
|
) {
|
|
288
310
|
this.logger.verbose(
|
|
289
311
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -297,14 +319,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
297
319
|
throw new Error(message);
|
|
298
320
|
}
|
|
299
321
|
|
|
300
|
-
// When `from` is the zero address (
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
const effectiveScopes = from.isZero() ? undefined : [from];
|
|
322
|
+
// When `from` is the zero address (e.g. when deploying a new account contract), we return an
|
|
323
|
+
// empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
|
|
324
|
+
const effectiveScopes = from.isZero() ? [] : [from];
|
|
304
325
|
|
|
305
326
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
306
|
-
const utilityExecutor = async (call: FunctionCall) => {
|
|
307
|
-
await this.executeUtilityCall(call,
|
|
327
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AccessScopes) => {
|
|
328
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
308
329
|
};
|
|
309
330
|
|
|
310
331
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -313,10 +334,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
334
|
functionSelector,
|
|
314
335
|
utilityExecutor,
|
|
315
336
|
blockHeader,
|
|
316
|
-
|
|
337
|
+
jobId,
|
|
338
|
+
effectiveScopes,
|
|
317
339
|
);
|
|
318
340
|
|
|
319
|
-
const blockNumber = await this.
|
|
341
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
320
342
|
|
|
321
343
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
322
344
|
|
|
@@ -359,7 +381,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
359
381
|
capsuleStore: this.capsuleStore,
|
|
360
382
|
privateEventStore: this.privateEventStore,
|
|
361
383
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
362
|
-
jobId
|
|
384
|
+
jobId,
|
|
363
385
|
totalPublicCalldataCount: 0,
|
|
364
386
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
365
387
|
scopes: effectiveScopes,
|
|
@@ -367,6 +389,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
367
389
|
// contract would perform, including setting senderForTags.
|
|
368
390
|
senderForTags: from,
|
|
369
391
|
simulator,
|
|
392
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
370
393
|
});
|
|
371
394
|
|
|
372
395
|
// Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
|
|
@@ -389,7 +412,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
389
412
|
);
|
|
390
413
|
const publicFunctionsCalldata = await Promise.all(
|
|
391
414
|
publicCallRequests.map(async r => {
|
|
392
|
-
const calldata = await privateExecutionOracle.
|
|
415
|
+
const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
|
|
393
416
|
return new HashedValues(calldata, r.calldataHash);
|
|
394
417
|
}),
|
|
395
418
|
);
|
|
@@ -407,6 +430,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
407
430
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
408
431
|
result,
|
|
409
432
|
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
433
|
+
this.stateMachine.node,
|
|
410
434
|
minRevertibleSideEffectCounter,
|
|
411
435
|
);
|
|
412
436
|
|
|
@@ -502,7 +526,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
502
526
|
return executionResult.returnValues ?? [];
|
|
503
527
|
}
|
|
504
528
|
|
|
505
|
-
async
|
|
529
|
+
async publicCallNewFlow(
|
|
506
530
|
from: AztecAddress,
|
|
507
531
|
targetContractAddress: AztecAddress,
|
|
508
532
|
calldata: Fr[],
|
|
@@ -512,7 +536,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
512
536
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
513
537
|
);
|
|
514
538
|
|
|
515
|
-
const blockNumber = await this.
|
|
539
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
516
540
|
|
|
517
541
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
518
542
|
|
|
@@ -589,7 +613,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
589
613
|
constantData,
|
|
590
614
|
/*gasUsed=*/ new Gas(0, 0),
|
|
591
615
|
/*feePayer=*/ AztecAddress.zero(),
|
|
592
|
-
/*
|
|
616
|
+
/*expirationTimestamp=*/ 0n,
|
|
593
617
|
inputsForPublic,
|
|
594
618
|
undefined,
|
|
595
619
|
);
|
|
@@ -657,10 +681,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
657
681
|
return returnValues ?? [];
|
|
658
682
|
}
|
|
659
683
|
|
|
660
|
-
async
|
|
684
|
+
async executeUtilityFunction(
|
|
661
685
|
targetContractAddress: AztecAddress,
|
|
662
686
|
functionSelector: FunctionSelector,
|
|
663
687
|
args: Fr[],
|
|
688
|
+
jobId: string,
|
|
664
689
|
) {
|
|
665
690
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
666
691
|
if (!artifact) {
|
|
@@ -672,11 +697,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
672
697
|
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
673
698
|
targetContractAddress,
|
|
674
699
|
functionSelector,
|
|
675
|
-
async call => {
|
|
676
|
-
await this.executeUtilityCall(call);
|
|
700
|
+
async (call, execScopes) => {
|
|
701
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
677
702
|
},
|
|
678
703
|
blockHeader,
|
|
679
|
-
|
|
704
|
+
jobId,
|
|
705
|
+
'ALL_SCOPES',
|
|
680
706
|
);
|
|
681
707
|
|
|
682
708
|
const call = FunctionCall.from({
|
|
@@ -690,10 +716,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
690
716
|
returnTypes: [],
|
|
691
717
|
});
|
|
692
718
|
|
|
693
|
-
return this.executeUtilityCall(call);
|
|
719
|
+
return this.executeUtilityCall(call, 'ALL_SCOPES', jobId);
|
|
694
720
|
}
|
|
695
721
|
|
|
696
|
-
private async executeUtilityCall(call: FunctionCall, scopes
|
|
722
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes, jobId: string): Promise<Fr[]> {
|
|
697
723
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
698
724
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
699
725
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -720,7 +746,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
720
746
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
721
747
|
capsuleStore: this.capsuleStore,
|
|
722
748
|
privateEventStore: this.privateEventStore,
|
|
723
|
-
|
|
749
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
750
|
+
contractSyncService: this.contractSyncService,
|
|
751
|
+
jobId,
|
|
724
752
|
scopes,
|
|
725
753
|
});
|
|
726
754
|
const acirExecutionResult = await new WASMSimulator()
|
|
@@ -738,10 +766,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
738
766
|
);
|
|
739
767
|
});
|
|
740
768
|
|
|
741
|
-
this.logger.verbose(`Utility
|
|
769
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
742
770
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
743
771
|
} catch (err) {
|
|
744
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
772
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
745
773
|
}
|
|
746
774
|
}
|
|
747
775
|
|