@aztec/txe 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2
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 +52 -37
- 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 +2 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +1 -1
- 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 +28 -19
- 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 +65 -36
- package/src/rpc_translator.ts +305 -173
- package/src/state_machine/archiver.ts +5 -5
- package/src/state_machine/dummy_p2p_client.ts +1 -1
- package/src/state_machine/index.ts +6 -1
- package/src/state_machine/mock_epoch_cache.ts +42 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +36 -19
- 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
|
@@ -39,46 +39,46 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
address(): Promise<AztecAddress> {
|
|
43
43
|
return Promise.resolve(this.contractAddress);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
sender(): Promise<AztecAddress> {
|
|
47
47
|
return Promise.resolve(AztecAddress.ZERO); // todo: change?
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
blockNumber(): Promise<BlockNumber> {
|
|
51
51
|
return Promise.resolve(this.globalVariables.blockNumber);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
timestamp(): Promise<bigint> {
|
|
55
55
|
return Promise.resolve(this.globalVariables.timestamp);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
isStaticCall(): Promise<boolean> {
|
|
59
59
|
return Promise.resolve(false);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
chainId(): Promise<Fr> {
|
|
63
63
|
return Promise.resolve(this.globalVariables.chainId);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
version(): Promise<Fr> {
|
|
67
67
|
return Promise.resolve(this.globalVariables.version);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
async
|
|
70
|
+
async emitNullifier(nullifier: Fr) {
|
|
71
71
|
const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
|
|
72
72
|
this.transientSiloedNullifiers.push(siloedNullifier);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
async
|
|
75
|
+
async emitNoteHash(noteHash: Fr) {
|
|
76
76
|
const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
|
|
77
77
|
// TODO: make the note hash unique - they are only siloed right now
|
|
78
78
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
async
|
|
81
|
+
async nullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
82
82
|
const treeIndex = (
|
|
83
83
|
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
84
84
|
)[0];
|
|
@@ -87,7 +87,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
87
87
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
async
|
|
90
|
+
async storageWrite(slot: Fr, value: Fr) {
|
|
91
91
|
this.logger.debug('AVM storage write', { slot, value });
|
|
92
92
|
|
|
93
93
|
const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
|
|
@@ -99,7 +99,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
99
99
|
]);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
async
|
|
102
|
+
async storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
103
103
|
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
104
104
|
|
|
105
105
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
@@ -16,6 +16,8 @@ import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
|
16
16
|
import {
|
|
17
17
|
AddressStore,
|
|
18
18
|
CapsuleStore,
|
|
19
|
+
type ContractStore,
|
|
20
|
+
type ContractSyncService,
|
|
19
21
|
NoteStore,
|
|
20
22
|
ORACLE_VERSION,
|
|
21
23
|
PrivateEventStore,
|
|
@@ -84,7 +86,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
84
86
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
85
87
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
86
88
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
87
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
88
89
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
89
90
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
90
91
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -97,7 +98,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
97
98
|
|
|
98
99
|
constructor(
|
|
99
100
|
private stateMachine: TXEStateMachine,
|
|
100
|
-
private contractStore:
|
|
101
|
+
private contractStore: ContractStore,
|
|
101
102
|
private noteStore: NoteStore,
|
|
102
103
|
private keyStore: KeyStore,
|
|
103
104
|
private addressStore: AddressStore,
|
|
@@ -107,17 +108,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
107
108
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
108
109
|
private capsuleStore: CapsuleStore,
|
|
109
110
|
private privateEventStore: PrivateEventStore,
|
|
110
|
-
private jobId: string,
|
|
111
111
|
private nextBlockTimestamp: bigint,
|
|
112
112
|
private version: Fr,
|
|
113
113
|
private chainId: Fr,
|
|
114
114
|
private authwits: Map<string, AuthWitness>,
|
|
115
|
+
private readonly contractSyncService: ContractSyncService,
|
|
115
116
|
) {
|
|
116
117
|
this.logger = createLogger('txe:top_level_context');
|
|
117
118
|
this.logger.debug('Entering Top Level Context');
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
assertCompatibleOracleVersion(version: number): void {
|
|
121
122
|
if (version !== ORACLE_VERSION) {
|
|
122
123
|
throw new Error(
|
|
123
124
|
`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
|
|
@@ -127,12 +128,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
127
128
|
|
|
128
129
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
129
130
|
// setup.
|
|
130
|
-
|
|
131
|
+
getRandomField(): Fr {
|
|
131
132
|
return Fr.random();
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
135
|
-
|
|
136
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
136
137
|
if (!LogLevels[level]) {
|
|
137
138
|
throw new Error(`Invalid log level: ${level}`);
|
|
138
139
|
}
|
|
@@ -142,23 +143,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
142
143
|
return Promise.resolve();
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
|
|
146
|
+
getDefaultAddress(): AztecAddress {
|
|
146
147
|
return DEFAULT_ADDRESS;
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
async
|
|
150
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
150
151
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
154
155
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
async
|
|
158
|
+
async getLastBlockTimestamp() {
|
|
158
159
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
async
|
|
162
|
+
async getLastTxEffects() {
|
|
162
163
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
163
164
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
164
165
|
|
|
@@ -172,7 +173,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
172
173
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
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) {
|
|
176
196
|
return (
|
|
177
197
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
178
198
|
contractAddress,
|
|
@@ -183,7 +203,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
183
203
|
).map(e => e.packedEvent);
|
|
184
204
|
}
|
|
185
205
|
|
|
186
|
-
async
|
|
206
|
+
async advanceBlocksBy(blocks: number) {
|
|
187
207
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
188
208
|
|
|
189
209
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -191,12 +211,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
191
211
|
}
|
|
192
212
|
}
|
|
193
213
|
|
|
194
|
-
|
|
214
|
+
advanceTimestampBy(duration: UInt64) {
|
|
195
215
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
196
216
|
this.nextBlockTimestamp += duration;
|
|
197
217
|
}
|
|
198
218
|
|
|
199
|
-
async
|
|
219
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
200
220
|
// Emit deployment nullifier
|
|
201
221
|
await this.mineBlock({
|
|
202
222
|
nullifiers: [
|
|
@@ -208,20 +228,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
208
228
|
});
|
|
209
229
|
|
|
210
230
|
if (!secret.equals(Fr.ZERO)) {
|
|
211
|
-
await this.
|
|
231
|
+
await this.addAccount(artifact, instance, secret);
|
|
212
232
|
} else {
|
|
213
233
|
await this.contractStore.addContractInstance(instance);
|
|
214
|
-
await this.contractStore.addContractArtifact(
|
|
234
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
215
235
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
216
236
|
}
|
|
217
237
|
}
|
|
218
238
|
|
|
219
|
-
async
|
|
239
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
220
240
|
const partialAddress = await computePartialAddress(instance);
|
|
221
241
|
|
|
222
242
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
223
243
|
await this.contractStore.addContractInstance(instance);
|
|
224
|
-
await this.contractStore.addContractArtifact(
|
|
244
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
225
245
|
|
|
226
246
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
227
247
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -231,7 +251,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
231
251
|
return completeAddress;
|
|
232
252
|
}
|
|
233
253
|
|
|
234
|
-
async
|
|
254
|
+
async createAccount(secret: Fr) {
|
|
235
255
|
// This is a foot gun !
|
|
236
256
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
237
257
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -241,7 +261,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
241
261
|
return completeAddress;
|
|
242
262
|
}
|
|
243
263
|
|
|
244
|
-
async
|
|
264
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
245
265
|
const account = await this.accountStore.getAccount(address);
|
|
246
266
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
247
267
|
|
|
@@ -254,7 +274,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
254
274
|
}
|
|
255
275
|
|
|
256
276
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
257
|
-
const blockNumber = await this.
|
|
277
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
258
278
|
|
|
259
279
|
const txEffect = TxEffect.empty();
|
|
260
280
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -278,13 +298,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
278
298
|
await this.stateMachine.handleL2Block(block);
|
|
279
299
|
}
|
|
280
300
|
|
|
281
|
-
async
|
|
301
|
+
async privateCallNewFlow(
|
|
282
302
|
from: AztecAddress,
|
|
283
303
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
284
304
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
285
305
|
args: Fr[],
|
|
286
306
|
argsHash: Fr = Fr.zero(),
|
|
287
307
|
isStaticCall: boolean = false,
|
|
308
|
+
jobId: string,
|
|
288
309
|
) {
|
|
289
310
|
this.logger.verbose(
|
|
290
311
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -304,7 +325,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
304
325
|
|
|
305
326
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
306
327
|
const utilityExecutor = async (call: FunctionCall, execScopes: AccessScopes) => {
|
|
307
|
-
await this.executeUtilityCall(call, execScopes);
|
|
328
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
308
329
|
};
|
|
309
330
|
|
|
310
331
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -313,11 +334,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
334
|
functionSelector,
|
|
314
335
|
utilityExecutor,
|
|
315
336
|
blockHeader,
|
|
316
|
-
|
|
337
|
+
jobId,
|
|
317
338
|
effectiveScopes,
|
|
318
339
|
);
|
|
319
340
|
|
|
320
|
-
const blockNumber = await this.
|
|
341
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
321
342
|
|
|
322
343
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
323
344
|
|
|
@@ -360,7 +381,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
360
381
|
capsuleStore: this.capsuleStore,
|
|
361
382
|
privateEventStore: this.privateEventStore,
|
|
362
383
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
363
|
-
jobId
|
|
384
|
+
jobId,
|
|
364
385
|
totalPublicCalldataCount: 0,
|
|
365
386
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
366
387
|
scopes: effectiveScopes,
|
|
@@ -368,6 +389,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
368
389
|
// contract would perform, including setting senderForTags.
|
|
369
390
|
senderForTags: from,
|
|
370
391
|
simulator,
|
|
392
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
371
393
|
});
|
|
372
394
|
|
|
373
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.
|
|
@@ -390,7 +412,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
390
412
|
);
|
|
391
413
|
const publicFunctionsCalldata = await Promise.all(
|
|
392
414
|
publicCallRequests.map(async r => {
|
|
393
|
-
const calldata = await privateExecutionOracle.
|
|
415
|
+
const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
|
|
394
416
|
return new HashedValues(calldata, r.calldataHash);
|
|
395
417
|
}),
|
|
396
418
|
);
|
|
@@ -504,7 +526,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
504
526
|
return executionResult.returnValues ?? [];
|
|
505
527
|
}
|
|
506
528
|
|
|
507
|
-
async
|
|
529
|
+
async publicCallNewFlow(
|
|
508
530
|
from: AztecAddress,
|
|
509
531
|
targetContractAddress: AztecAddress,
|
|
510
532
|
calldata: Fr[],
|
|
@@ -514,7 +536,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
514
536
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
515
537
|
);
|
|
516
538
|
|
|
517
|
-
const blockNumber = await this.
|
|
539
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
518
540
|
|
|
519
541
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
520
542
|
|
|
@@ -659,7 +681,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
659
681
|
return returnValues ?? [];
|
|
660
682
|
}
|
|
661
683
|
|
|
662
|
-
async
|
|
684
|
+
async executeUtilityFunction(
|
|
685
|
+
targetContractAddress: AztecAddress,
|
|
686
|
+
functionSelector: FunctionSelector,
|
|
687
|
+
args: Fr[],
|
|
688
|
+
jobId: string,
|
|
689
|
+
) {
|
|
663
690
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
664
691
|
if (!artifact) {
|
|
665
692
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
@@ -671,10 +698,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
671
698
|
targetContractAddress,
|
|
672
699
|
functionSelector,
|
|
673
700
|
async (call, execScopes) => {
|
|
674
|
-
await this.executeUtilityCall(call, execScopes);
|
|
701
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
675
702
|
},
|
|
676
703
|
blockHeader,
|
|
677
|
-
|
|
704
|
+
jobId,
|
|
678
705
|
'ALL_SCOPES',
|
|
679
706
|
);
|
|
680
707
|
|
|
@@ -689,10 +716,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
689
716
|
returnTypes: [],
|
|
690
717
|
});
|
|
691
718
|
|
|
692
|
-
return this.executeUtilityCall(call, 'ALL_SCOPES');
|
|
719
|
+
return this.executeUtilityCall(call, 'ALL_SCOPES', jobId);
|
|
693
720
|
}
|
|
694
721
|
|
|
695
|
-
private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes): Promise<Fr[]> {
|
|
722
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes, jobId: string): Promise<Fr[]> {
|
|
696
723
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
697
724
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
698
725
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -719,7 +746,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
719
746
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
720
747
|
capsuleStore: this.capsuleStore,
|
|
721
748
|
privateEventStore: this.privateEventStore,
|
|
722
|
-
|
|
749
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
750
|
+
contractSyncService: this.contractSyncService,
|
|
751
|
+
jobId,
|
|
723
752
|
scopes,
|
|
724
753
|
});
|
|
725
754
|
const acirExecutionResult = await new WASMSimulator()
|