@aztec/txe 0.0.1-commit.87a0206 → 0.0.1-commit.88e6f9396
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 +110 -52
- package/dest/rpc_translator.d.ts +88 -83
- 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 +14 -11
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +23 -14
- 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 +19 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +36 -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 +89 -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 +5 -22
- 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 +113 -91
- package/src/rpc_translator.ts +305 -173
- package/src/state_machine/archiver.ts +5 -5
- package/src/state_machine/dummy_p2p_client.ts +33 -20
- package/src/state_machine/index.ts +6 -1
- package/src/state_machine/mock_epoch_cache.ts +47 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +94 -72
- package/src/util/txe_public_contract_data_source.ts +10 -36
- 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
|
@@ -36,15 +36,15 @@ export class TXEOracleTopLevelContext {
|
|
|
36
36
|
senderAddressBookStore;
|
|
37
37
|
capsuleStore;
|
|
38
38
|
privateEventStore;
|
|
39
|
-
jobId;
|
|
40
39
|
nextBlockTimestamp;
|
|
41
40
|
version;
|
|
42
41
|
chainId;
|
|
43
42
|
authwits;
|
|
43
|
+
contractSyncService;
|
|
44
44
|
isMisc;
|
|
45
45
|
isTxe;
|
|
46
46
|
logger;
|
|
47
|
-
constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore,
|
|
47
|
+
constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, authwits, contractSyncService){
|
|
48
48
|
this.stateMachine = stateMachine;
|
|
49
49
|
this.contractStore = contractStore;
|
|
50
50
|
this.noteStore = noteStore;
|
|
@@ -56,49 +56,50 @@ export class TXEOracleTopLevelContext {
|
|
|
56
56
|
this.senderAddressBookStore = senderAddressBookStore;
|
|
57
57
|
this.capsuleStore = capsuleStore;
|
|
58
58
|
this.privateEventStore = privateEventStore;
|
|
59
|
-
this.jobId = jobId;
|
|
60
59
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
61
60
|
this.version = version;
|
|
62
61
|
this.chainId = chainId;
|
|
63
62
|
this.authwits = authwits;
|
|
63
|
+
this.contractSyncService = contractSyncService;
|
|
64
64
|
this.isMisc = true;
|
|
65
65
|
this.isTxe = true;
|
|
66
66
|
this.logger = createLogger('txe:top_level_context');
|
|
67
67
|
this.logger.debug('Entering Top Level Context');
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
assertCompatibleOracleVersion(version) {
|
|
70
70
|
if (version !== ORACLE_VERSION) {
|
|
71
71
|
throw new Error(`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
75
75
|
// setup.
|
|
76
|
-
|
|
76
|
+
getRandomField() {
|
|
77
77
|
return Fr.random();
|
|
78
78
|
}
|
|
79
79
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
80
|
-
|
|
80
|
+
log(level, message, fields) {
|
|
81
81
|
if (!LogLevels[level]) {
|
|
82
|
-
throw new Error(`Invalid
|
|
82
|
+
throw new Error(`Invalid log level: ${level}`);
|
|
83
83
|
}
|
|
84
84
|
const levelName = LogLevels[level];
|
|
85
85
|
this.logger[levelName](`${applyStringFormatting(message, fields)}`, {
|
|
86
86
|
module: `${this.logger.module}:debug_log`
|
|
87
87
|
});
|
|
88
|
+
return Promise.resolve();
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
getDefaultAddress() {
|
|
90
91
|
return DEFAULT_ADDRESS;
|
|
91
92
|
}
|
|
92
|
-
async
|
|
93
|
+
async getNextBlockNumber() {
|
|
93
94
|
return BlockNumber(await this.getLastBlockNumber() + 1);
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
getNextBlockTimestamp() {
|
|
96
97
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
97
98
|
}
|
|
98
|
-
async
|
|
99
|
+
async getLastBlockTimestamp() {
|
|
99
100
|
return (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.timestamp;
|
|
100
101
|
}
|
|
101
|
-
async
|
|
102
|
+
async getLastTxEffects() {
|
|
102
103
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
103
104
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
104
105
|
if (block.body.txEffects.length != 1) {
|
|
@@ -112,7 +113,19 @@ export class TXEOracleTopLevelContext {
|
|
|
112
113
|
nullifiers: txEffects.nullifiers
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
|
-
async
|
|
116
|
+
async syncContractNonOracleMethod(contractAddress, scope, jobId) {
|
|
117
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
118
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
122
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(contractAddress, null, async (call, execScopes)=>{
|
|
123
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
124
|
+
}, blockHeader, jobId, [
|
|
125
|
+
scope
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
async getPrivateEvents(selector, contractAddress, scope) {
|
|
116
129
|
return (await this.privateEventStore.getPrivateEvents(selector, {
|
|
117
130
|
contractAddress,
|
|
118
131
|
scopes: [
|
|
@@ -122,17 +135,17 @@ export class TXEOracleTopLevelContext {
|
|
|
122
135
|
toBlock: await this.getLastBlockNumber() + 1
|
|
123
136
|
})).map((e)=>e.packedEvent);
|
|
124
137
|
}
|
|
125
|
-
async
|
|
138
|
+
async advanceBlocksBy(blocks) {
|
|
126
139
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
127
140
|
for(let i = 0; i < blocks; i++){
|
|
128
141
|
await this.mineBlock();
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
|
-
|
|
144
|
+
advanceTimestampBy(duration) {
|
|
132
145
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
133
146
|
this.nextBlockTimestamp += duration;
|
|
134
147
|
}
|
|
135
|
-
async
|
|
148
|
+
async deploy(artifact, instance, secret) {
|
|
136
149
|
// Emit deployment nullifier
|
|
137
150
|
await this.mineBlock({
|
|
138
151
|
nullifiers: [
|
|
@@ -140,25 +153,25 @@ export class TXEOracleTopLevelContext {
|
|
|
140
153
|
]
|
|
141
154
|
});
|
|
142
155
|
if (!secret.equals(Fr.ZERO)) {
|
|
143
|
-
await this.
|
|
156
|
+
await this.addAccount(artifact, instance, secret);
|
|
144
157
|
} else {
|
|
145
158
|
await this.contractStore.addContractInstance(instance);
|
|
146
|
-
await this.contractStore.addContractArtifact(
|
|
159
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
147
160
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
148
161
|
}
|
|
149
162
|
}
|
|
150
|
-
async
|
|
163
|
+
async addAccount(artifact, instance, secret) {
|
|
151
164
|
const partialAddress = await computePartialAddress(instance);
|
|
152
165
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
153
166
|
await this.contractStore.addContractInstance(instance);
|
|
154
|
-
await this.contractStore.addContractArtifact(
|
|
167
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
155
168
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
156
169
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
157
170
|
await this.addressStore.addCompleteAddress(completeAddress);
|
|
158
171
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
159
172
|
return completeAddress;
|
|
160
173
|
}
|
|
161
|
-
async
|
|
174
|
+
async createAccount(secret) {
|
|
162
175
|
// This is a foot gun !
|
|
163
176
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
164
177
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -166,7 +179,7 @@ export class TXEOracleTopLevelContext {
|
|
|
166
179
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
167
180
|
return completeAddress;
|
|
168
181
|
}
|
|
169
|
-
async
|
|
182
|
+
async addAuthWitness(address, messageHash) {
|
|
170
183
|
const account = await this.accountStore.getAccount(address);
|
|
171
184
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
172
185
|
const schnorr = new Schnorr();
|
|
@@ -177,7 +190,7 @@ export class TXEOracleTopLevelContext {
|
|
|
177
190
|
this.authwits.set(authWitness.requestHash.toString(), authWitness);
|
|
178
191
|
}
|
|
179
192
|
async mineBlock(options = {}) {
|
|
180
|
-
const blockNumber = await this.
|
|
193
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
181
194
|
const txEffect = TxEffect.empty();
|
|
182
195
|
txEffect.nullifiers = [
|
|
183
196
|
getSingleTxBlockRequestHash(blockNumber),
|
|
@@ -199,26 +212,25 @@ export class TXEOracleTopLevelContext {
|
|
|
199
212
|
this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
|
|
200
213
|
await this.stateMachine.handleL2Block(block);
|
|
201
214
|
}
|
|
202
|
-
async
|
|
215
|
+
async privateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false, jobId) {
|
|
203
216
|
this.logger.verbose(`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`);
|
|
204
217
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
205
218
|
if (!artifact) {
|
|
206
219
|
const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)')) ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.' : 'Function Artifact does not exist';
|
|
207
220
|
throw new Error(message);
|
|
208
221
|
}
|
|
209
|
-
// When `from` is the zero address (
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
const effectiveScopes = from.isZero() ? undefined : [
|
|
222
|
+
// When `from` is the zero address (e.g. when deploying a new account contract), we return an
|
|
223
|
+
// empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
|
|
224
|
+
const effectiveScopes = from.isZero() ? [] : [
|
|
213
225
|
from
|
|
214
226
|
];
|
|
215
227
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
216
|
-
const utilityExecutor = async (call)=>{
|
|
217
|
-
await this.executeUtilityCall(call,
|
|
228
|
+
const utilityExecutor = async (call, execScopes)=>{
|
|
229
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
218
230
|
};
|
|
219
231
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
220
|
-
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader,
|
|
221
|
-
const blockNumber = await this.
|
|
232
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader, jobId, effectiveScopes);
|
|
233
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
222
234
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
223
235
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
224
236
|
const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
|
|
@@ -233,12 +245,40 @@ export class TXEOracleTopLevelContext {
|
|
|
233
245
|
await noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
234
246
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
235
247
|
const simulator = new WASMSimulator();
|
|
236
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
248
|
+
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
249
|
+
argsHash,
|
|
250
|
+
txContext,
|
|
251
|
+
callContext,
|
|
252
|
+
anchorBlockHeader: blockHeader,
|
|
253
|
+
utilityExecutor,
|
|
254
|
+
authWitnesses: Array.from(this.authwits.values()),
|
|
255
|
+
capsules: [],
|
|
256
|
+
executionCache: HashedValuesCache.create([
|
|
257
|
+
new HashedValues(args, argsHash)
|
|
258
|
+
]),
|
|
259
|
+
noteCache,
|
|
260
|
+
taggingIndexCache,
|
|
261
|
+
contractStore: this.contractStore,
|
|
262
|
+
noteStore: this.noteStore,
|
|
263
|
+
keyStore: this.keyStore,
|
|
264
|
+
addressStore: this.addressStore,
|
|
265
|
+
aztecNode: this.stateMachine.node,
|
|
266
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
267
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
268
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
269
|
+
capsuleStore: this.capsuleStore,
|
|
270
|
+
privateEventStore: this.privateEventStore,
|
|
271
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
272
|
+
jobId,
|
|
273
|
+
totalPublicCalldataCount: 0,
|
|
274
|
+
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
275
|
+
scopes: effectiveScopes,
|
|
276
|
+
// In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
|
|
277
|
+
// contract would perform, including setting senderForTags.
|
|
278
|
+
senderForTags: from,
|
|
279
|
+
simulator,
|
|
280
|
+
messageContextService: this.stateMachine.messageContextService
|
|
281
|
+
});
|
|
242
282
|
// 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.
|
|
243
283
|
let result;
|
|
244
284
|
let executionResult;
|
|
@@ -250,7 +290,7 @@ export class TXEOracleTopLevelContext {
|
|
|
250
290
|
r.publicInputs.publicTeardownCallRequest
|
|
251
291
|
]));
|
|
252
292
|
const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
|
|
253
|
-
const calldata = await privateExecutionOracle.
|
|
293
|
+
const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
|
|
254
294
|
return new HashedValues(calldata, r.calldataHash);
|
|
255
295
|
}));
|
|
256
296
|
noteCache.finish();
|
|
@@ -262,7 +302,7 @@ export class TXEOracleTopLevelContext {
|
|
|
262
302
|
// According to the protocol rules, there must be at least one nullifier in the tx. The first nullifier is used as
|
|
263
303
|
// the nonce generator for the note hashes.
|
|
264
304
|
// We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
|
|
265
|
-
const { publicInputs } = await generateSimulatedProvingResult(result, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), minRevertibleSideEffectCounter);
|
|
305
|
+
const { publicInputs } = await generateSimulatedProvingResult(result, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.stateMachine.node, minRevertibleSideEffectCounter);
|
|
266
306
|
const globals = makeGlobalVariables();
|
|
267
307
|
globals.blockNumber = blockNumber;
|
|
268
308
|
globals.timestamp = this.nextBlockTimestamp;
|
|
@@ -330,9 +370,9 @@ export class TXEOracleTopLevelContext {
|
|
|
330
370
|
await forkedWorldTrees.close();
|
|
331
371
|
return executionResult.returnValues ?? [];
|
|
332
372
|
}
|
|
333
|
-
async
|
|
373
|
+
async publicCallNewFlow(from, targetContractAddress, calldata, isStaticCall) {
|
|
334
374
|
this.logger.verbose(`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`);
|
|
335
|
-
const blockNumber = await this.
|
|
375
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
336
376
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
337
377
|
const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
|
|
338
378
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
@@ -371,7 +411,7 @@ export class TXEOracleTopLevelContext {
|
|
|
371
411
|
revertibleAccumulatedData.publicCallRequests[0] = new PublicCallRequest(from, targetContractAddress, isStaticCall, calldataHash);
|
|
372
412
|
const inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleAccumulatedData, revertibleAccumulatedData, PublicCallRequest.empty());
|
|
373
413
|
const constantData = new TxConstantData(anchorBlockHeader, txContext, Fr.zero(), Fr.zero());
|
|
374
|
-
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*
|
|
414
|
+
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*expirationTimestamp=*/ 0n, inputsForPublic, undefined);
|
|
375
415
|
const tx = await Tx.create({
|
|
376
416
|
data: txData,
|
|
377
417
|
chonkProof: ChonkProof.empty(),
|
|
@@ -424,16 +464,16 @@ export class TXEOracleTopLevelContext {
|
|
|
424
464
|
await forkedWorldTrees.close();
|
|
425
465
|
return returnValues ?? [];
|
|
426
466
|
}
|
|
427
|
-
async
|
|
467
|
+
async executeUtilityFunction(targetContractAddress, functionSelector, args, jobId) {
|
|
428
468
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
429
469
|
if (!artifact) {
|
|
430
470
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
431
471
|
}
|
|
432
472
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
433
473
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
434
|
-
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, async (call)=>{
|
|
435
|
-
await this.executeUtilityCall(call);
|
|
436
|
-
}, blockHeader,
|
|
474
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, async (call, execScopes)=>{
|
|
475
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
476
|
+
}, blockHeader, jobId, 'ALL_SCOPES');
|
|
437
477
|
const call = FunctionCall.from({
|
|
438
478
|
name: artifact.name,
|
|
439
479
|
to: targetContractAddress,
|
|
@@ -444,9 +484,9 @@ export class TXEOracleTopLevelContext {
|
|
|
444
484
|
args,
|
|
445
485
|
returnTypes: []
|
|
446
486
|
});
|
|
447
|
-
return this.executeUtilityCall(call);
|
|
487
|
+
return this.executeUtilityCall(call, 'ALL_SCOPES', jobId);
|
|
448
488
|
}
|
|
449
|
-
async executeUtilityCall(call, scopes) {
|
|
489
|
+
async executeUtilityCall(call, scopes, jobId) {
|
|
450
490
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
451
491
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
452
492
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -457,7 +497,25 @@ export class TXEOracleTopLevelContext {
|
|
|
457
497
|
});
|
|
458
498
|
try {
|
|
459
499
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
460
|
-
const oracle = new UtilityExecutionOracle(
|
|
500
|
+
const oracle = new UtilityExecutionOracle({
|
|
501
|
+
contractAddress: call.to,
|
|
502
|
+
authWitnesses: [],
|
|
503
|
+
capsules: [],
|
|
504
|
+
anchorBlockHeader,
|
|
505
|
+
contractStore: this.contractStore,
|
|
506
|
+
noteStore: this.noteStore,
|
|
507
|
+
keyStore: this.keyStore,
|
|
508
|
+
addressStore: this.addressStore,
|
|
509
|
+
aztecNode: this.stateMachine.node,
|
|
510
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
511
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
512
|
+
capsuleStore: this.capsuleStore,
|
|
513
|
+
privateEventStore: this.privateEventStore,
|
|
514
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
515
|
+
contractSyncService: this.contractSyncService,
|
|
516
|
+
jobId,
|
|
517
|
+
scopes
|
|
518
|
+
});
|
|
461
519
|
const acirExecutionResult = await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
462
520
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
463
521
|
throw new ExecutionError(err.message, {
|
|
@@ -467,10 +525,10 @@ export class TXEOracleTopLevelContext {
|
|
|
467
525
|
cause: err
|
|
468
526
|
});
|
|
469
527
|
});
|
|
470
|
-
this.logger.verbose(`Utility
|
|
528
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
471
529
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
472
530
|
} catch (err) {
|
|
473
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
531
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
474
532
|
}
|
|
475
533
|
}
|
|
476
534
|
close() {
|