@aztec/txe 0.0.1-commit.e2b2873ed → 0.0.1-commit.e304674f1
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 +70 -55
- package/dest/rpc_translator.d.ts +87 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +285 -152
- 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 +7 -8
- package/dest/state_machine/dummy_p2p_client.d.ts +10 -6
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +18 -6
- package/dest/state_machine/global_variable_builder.d.ts +3 -3
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.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 +18 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +35 -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 -25
- 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 +91 -57
- package/src/rpc_translator.ts +332 -174
- package/src/state_machine/archiver.ts +6 -5
- package/src/state_machine/dummy_p2p_client.ts +25 -9
- package/src/state_machine/global_variable_builder.ts +7 -1
- package/src/state_machine/index.ts +7 -1
- package/src/state_machine/mock_epoch_cache.ts +46 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +45 -24
- 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
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
6
|
-
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
3
|
+
MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
|
|
4
|
+
MAX_PROCESSABLE_L2_GAS,
|
|
7
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
8
6
|
} from '@aztec/constants';
|
|
9
7
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
@@ -14,7 +12,10 @@ import { TestDateProvider } from '@aztec/foundation/timer';
|
|
|
14
12
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
13
|
import {
|
|
16
14
|
AddressStore,
|
|
15
|
+
CapsuleService,
|
|
17
16
|
CapsuleStore,
|
|
17
|
+
type ContractStore,
|
|
18
|
+
type ContractSyncService,
|
|
18
19
|
NoteStore,
|
|
19
20
|
ORACLE_VERSION,
|
|
20
21
|
PrivateEventStore,
|
|
@@ -54,7 +55,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
54
55
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
55
56
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
56
57
|
import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
|
|
57
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
FALLBACK_TEARDOWN_DA_GAS_LIMIT,
|
|
60
|
+
FALLBACK_TEARDOWN_L2_GAS_LIMIT,
|
|
61
|
+
Gas,
|
|
62
|
+
GasFees,
|
|
63
|
+
GasSettings,
|
|
64
|
+
} from '@aztec/stdlib/gas';
|
|
58
65
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
59
66
|
import {
|
|
60
67
|
PartialPrivateTailPublicInputsForPublic,
|
|
@@ -83,7 +90,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
83
90
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
84
91
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
85
92
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
86
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
87
93
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
88
94
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
89
95
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -96,7 +102,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
96
102
|
|
|
97
103
|
constructor(
|
|
98
104
|
private stateMachine: TXEStateMachine,
|
|
99
|
-
private contractStore:
|
|
105
|
+
private contractStore: ContractStore,
|
|
100
106
|
private noteStore: NoteStore,
|
|
101
107
|
private keyStore: KeyStore,
|
|
102
108
|
private addressStore: AddressStore,
|
|
@@ -106,32 +112,36 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
106
112
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
107
113
|
private capsuleStore: CapsuleStore,
|
|
108
114
|
private privateEventStore: PrivateEventStore,
|
|
109
|
-
private jobId: string,
|
|
110
115
|
private nextBlockTimestamp: bigint,
|
|
111
116
|
private version: Fr,
|
|
112
117
|
private chainId: Fr,
|
|
113
118
|
private authwits: Map<string, AuthWitness>,
|
|
119
|
+
private readonly contractSyncService: ContractSyncService,
|
|
114
120
|
) {
|
|
115
121
|
this.logger = createLogger('txe:top_level_context');
|
|
116
122
|
this.logger.debug('Entering Top Level Context');
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
|
|
125
|
+
assertCompatibleOracleVersion(version: number): void {
|
|
120
126
|
if (version !== ORACLE_VERSION) {
|
|
127
|
+
const hint =
|
|
128
|
+
version > ORACLE_VERSION
|
|
129
|
+
? 'The contract was compiled with a newer version of Aztec.nr than this aztec cli version supports. Upgrade your aztec cli version to a compatible version.'
|
|
130
|
+
: 'The contract was compiled with an older version of Aztec.nr than this aztec cli version supports. Recompile the contract with a compatible version of Aztec.nr.';
|
|
121
131
|
throw new Error(
|
|
122
|
-
`Incompatible
|
|
132
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle version ${ORACLE_VERSION}, got ${version})`,
|
|
123
133
|
);
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
128
138
|
// setup.
|
|
129
|
-
|
|
139
|
+
getRandomField(): Fr {
|
|
130
140
|
return Fr.random();
|
|
131
141
|
}
|
|
132
142
|
|
|
133
143
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
|
|
144
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
145
|
if (!LogLevels[level]) {
|
|
136
146
|
throw new Error(`Invalid log level: ${level}`);
|
|
137
147
|
}
|
|
@@ -141,23 +151,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
141
151
|
return Promise.resolve();
|
|
142
152
|
}
|
|
143
153
|
|
|
144
|
-
|
|
154
|
+
getDefaultAddress(): AztecAddress {
|
|
145
155
|
return DEFAULT_ADDRESS;
|
|
146
156
|
}
|
|
147
157
|
|
|
148
|
-
async
|
|
158
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
149
159
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
150
160
|
}
|
|
151
161
|
|
|
152
|
-
|
|
162
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
153
163
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
154
164
|
}
|
|
155
165
|
|
|
156
|
-
async
|
|
166
|
+
async getLastBlockTimestamp() {
|
|
157
167
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
158
168
|
}
|
|
159
169
|
|
|
160
|
-
async
|
|
170
|
+
async getLastTxEffects() {
|
|
161
171
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
172
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
163
173
|
|
|
@@ -171,7 +181,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
171
181
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
172
182
|
}
|
|
173
183
|
|
|
174
|
-
async
|
|
184
|
+
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
185
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
186
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
191
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
192
|
+
contractAddress,
|
|
193
|
+
null,
|
|
194
|
+
async (call, execScopes) => {
|
|
195
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
196
|
+
},
|
|
197
|
+
blockHeader,
|
|
198
|
+
jobId,
|
|
199
|
+
[scope],
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
175
204
|
return (
|
|
176
205
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
177
206
|
contractAddress,
|
|
@@ -182,7 +211,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
182
211
|
).map(e => e.packedEvent);
|
|
183
212
|
}
|
|
184
213
|
|
|
185
|
-
async
|
|
214
|
+
async advanceBlocksBy(blocks: number) {
|
|
186
215
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
187
216
|
|
|
188
217
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -190,12 +219,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
190
219
|
}
|
|
191
220
|
}
|
|
192
221
|
|
|
193
|
-
|
|
222
|
+
advanceTimestampBy(duration: UInt64) {
|
|
194
223
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
195
224
|
this.nextBlockTimestamp += duration;
|
|
196
225
|
}
|
|
197
226
|
|
|
198
|
-
async
|
|
227
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
199
228
|
// Emit deployment nullifier
|
|
200
229
|
await this.mineBlock({
|
|
201
230
|
nullifiers: [
|
|
@@ -207,20 +236,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
207
236
|
});
|
|
208
237
|
|
|
209
238
|
if (!secret.equals(Fr.ZERO)) {
|
|
210
|
-
await this.
|
|
239
|
+
await this.addAccount(artifact, instance, secret);
|
|
211
240
|
} else {
|
|
212
241
|
await this.contractStore.addContractInstance(instance);
|
|
213
|
-
await this.contractStore.addContractArtifact(
|
|
242
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
214
243
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
215
244
|
}
|
|
216
245
|
}
|
|
217
246
|
|
|
218
|
-
async
|
|
247
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
219
248
|
const partialAddress = await computePartialAddress(instance);
|
|
220
249
|
|
|
221
250
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
222
251
|
await this.contractStore.addContractInstance(instance);
|
|
223
|
-
await this.contractStore.addContractArtifact(
|
|
252
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
224
253
|
|
|
225
254
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
226
255
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -230,7 +259,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
230
259
|
return completeAddress;
|
|
231
260
|
}
|
|
232
261
|
|
|
233
|
-
async
|
|
262
|
+
async createAccount(secret: Fr) {
|
|
234
263
|
// This is a foot gun !
|
|
235
264
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
236
265
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -240,7 +269,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
240
269
|
return completeAddress;
|
|
241
270
|
}
|
|
242
271
|
|
|
243
|
-
async
|
|
272
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
244
273
|
const account = await this.accountStore.getAccount(address);
|
|
245
274
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
246
275
|
|
|
@@ -253,7 +282,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
253
282
|
}
|
|
254
283
|
|
|
255
284
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
256
|
-
const blockNumber = await this.
|
|
285
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
257
286
|
|
|
258
287
|
const txEffect = TxEffect.empty();
|
|
259
288
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -277,13 +306,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
277
306
|
await this.stateMachine.handleL2Block(block);
|
|
278
307
|
}
|
|
279
308
|
|
|
280
|
-
async
|
|
309
|
+
async privateCallNewFlow(
|
|
281
310
|
from: AztecAddress,
|
|
282
311
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
283
312
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
284
313
|
args: Fr[],
|
|
285
314
|
argsHash: Fr = Fr.zero(),
|
|
286
315
|
isStaticCall: boolean = false,
|
|
316
|
+
jobId: string,
|
|
287
317
|
) {
|
|
288
318
|
this.logger.verbose(
|
|
289
319
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -297,14 +327,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
297
327
|
throw new Error(message);
|
|
298
328
|
}
|
|
299
329
|
|
|
300
|
-
// When `from` is the zero address (
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
const effectiveScopes = from.isZero() ? undefined : [from];
|
|
330
|
+
// When `from` is the zero address (e.g. when deploying a new account contract), we return an
|
|
331
|
+
// empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
|
|
332
|
+
const effectiveScopes = from.isZero() ? [] : [from];
|
|
304
333
|
|
|
305
334
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
306
|
-
const utilityExecutor = async (call: FunctionCall, execScopes:
|
|
307
|
-
await this.executeUtilityCall(call, execScopes);
|
|
335
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
336
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
308
337
|
};
|
|
309
338
|
|
|
310
339
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -313,16 +342,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
342
|
functionSelector,
|
|
314
343
|
utilityExecutor,
|
|
315
344
|
blockHeader,
|
|
316
|
-
|
|
345
|
+
jobId,
|
|
317
346
|
effectiveScopes,
|
|
318
347
|
);
|
|
319
348
|
|
|
320
|
-
const blockNumber = await this.
|
|
349
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
321
350
|
|
|
322
351
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
323
352
|
|
|
324
|
-
const gasLimits = new Gas(
|
|
325
|
-
const teardownGasLimits = new Gas(
|
|
353
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
354
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
326
355
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
327
356
|
|
|
328
357
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
@@ -357,10 +386,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
357
386
|
senderTaggingStore: this.senderTaggingStore,
|
|
358
387
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
359
388
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
360
|
-
|
|
389
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
361
390
|
privateEventStore: this.privateEventStore,
|
|
362
391
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
363
|
-
jobId
|
|
392
|
+
jobId,
|
|
364
393
|
totalPublicCalldataCount: 0,
|
|
365
394
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
366
395
|
scopes: effectiveScopes,
|
|
@@ -368,6 +397,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
368
397
|
// contract would perform, including setting senderForTags.
|
|
369
398
|
senderForTags: from,
|
|
370
399
|
simulator,
|
|
400
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
371
401
|
});
|
|
372
402
|
|
|
373
403
|
// 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 +420,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
390
420
|
);
|
|
391
421
|
const publicFunctionsCalldata = await Promise.all(
|
|
392
422
|
publicCallRequests.map(async r => {
|
|
393
|
-
const calldata = await privateExecutionOracle.
|
|
423
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
394
424
|
return new HashedValues(calldata, r.calldataHash);
|
|
395
425
|
}),
|
|
396
426
|
);
|
|
@@ -408,6 +438,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
408
438
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
409
439
|
result,
|
|
410
440
|
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
441
|
+
this.stateMachine.node,
|
|
411
442
|
minRevertibleSideEffectCounter,
|
|
412
443
|
);
|
|
413
444
|
|
|
@@ -503,7 +534,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
503
534
|
return executionResult.returnValues ?? [];
|
|
504
535
|
}
|
|
505
536
|
|
|
506
|
-
async
|
|
537
|
+
async publicCallNewFlow(
|
|
507
538
|
from: AztecAddress,
|
|
508
539
|
targetContractAddress: AztecAddress,
|
|
509
540
|
calldata: Fr[],
|
|
@@ -513,11 +544,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
513
544
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
514
545
|
);
|
|
515
546
|
|
|
516
|
-
const blockNumber = await this.
|
|
547
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
517
548
|
|
|
518
|
-
const gasLimits = new Gas(
|
|
549
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
519
550
|
|
|
520
|
-
const teardownGasLimits = new Gas(
|
|
551
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
521
552
|
|
|
522
553
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
523
554
|
|
|
@@ -590,7 +621,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
590
621
|
constantData,
|
|
591
622
|
/*gasUsed=*/ new Gas(0, 0),
|
|
592
623
|
/*feePayer=*/ AztecAddress.zero(),
|
|
593
|
-
/*
|
|
624
|
+
/*expirationTimestamp=*/ 0n,
|
|
594
625
|
inputsForPublic,
|
|
595
626
|
undefined,
|
|
596
627
|
);
|
|
@@ -658,10 +689,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
658
689
|
return returnValues ?? [];
|
|
659
690
|
}
|
|
660
691
|
|
|
661
|
-
async
|
|
692
|
+
async executeUtilityFunction(
|
|
662
693
|
targetContractAddress: AztecAddress,
|
|
663
694
|
functionSelector: FunctionSelector,
|
|
664
695
|
args: Fr[],
|
|
696
|
+
jobId: string,
|
|
665
697
|
) {
|
|
666
698
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
667
699
|
if (!artifact) {
|
|
@@ -674,11 +706,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
674
706
|
targetContractAddress,
|
|
675
707
|
functionSelector,
|
|
676
708
|
async (call, execScopes) => {
|
|
677
|
-
await this.executeUtilityCall(call, execScopes);
|
|
709
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
678
710
|
},
|
|
679
711
|
blockHeader,
|
|
680
|
-
|
|
681
|
-
|
|
712
|
+
jobId,
|
|
713
|
+
await this.keyStore.getAccounts(),
|
|
682
714
|
);
|
|
683
715
|
|
|
684
716
|
const call = FunctionCall.from({
|
|
@@ -692,10 +724,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
692
724
|
returnTypes: [],
|
|
693
725
|
});
|
|
694
726
|
|
|
695
|
-
return this.executeUtilityCall(call,
|
|
727
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
696
728
|
}
|
|
697
729
|
|
|
698
|
-
private async executeUtilityCall(call: FunctionCall, scopes:
|
|
730
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
699
731
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
700
732
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
701
733
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -720,9 +752,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
720
752
|
aztecNode: this.stateMachine.node,
|
|
721
753
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
722
754
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
723
|
-
|
|
755
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
724
756
|
privateEventStore: this.privateEventStore,
|
|
725
|
-
|
|
757
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
758
|
+
contractSyncService: this.contractSyncService,
|
|
759
|
+
jobId,
|
|
726
760
|
scopes,
|
|
727
761
|
});
|
|
728
762
|
const acirExecutionResult = await new WASMSimulator()
|
|
@@ -740,10 +774,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
740
774
|
);
|
|
741
775
|
});
|
|
742
776
|
|
|
743
|
-
this.logger.verbose(`Utility
|
|
777
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
744
778
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
745
779
|
} catch (err) {
|
|
746
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
780
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
747
781
|
}
|
|
748
782
|
}
|
|
749
783
|
|