@aztec/txe 0.0.1-commit.1bb068fb5 → 0.0.1-commit.1dcfe2301
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 +28 -23
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +78 -51
- package/dest/rpc_translator.d.ts +120 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +384 -162
- 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 +8 -6
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +12 -6
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- 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 +8 -4
- 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 +37 -25
- package/dest/util/encoding.d.ts +71 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- 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 +99 -56
- package/src/rpc_translator.ts +446 -183
- package/src/state_machine/archiver.ts +6 -5
- package/src/state_machine/dummy_p2p_client.ts +17 -9
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +9 -2
- package/src/state_machine/mock_epoch_cache.ts +46 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +48 -28
- package/src/util/encoding.ts +5 -0
- 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';
|
|
@@ -12,12 +10,14 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
12
10
|
import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
13
11
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
12
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
|
-
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
16
13
|
import {
|
|
17
14
|
AddressStore,
|
|
15
|
+
CapsuleService,
|
|
18
16
|
CapsuleStore,
|
|
17
|
+
type ContractStore,
|
|
18
|
+
type ContractSyncService,
|
|
19
19
|
NoteStore,
|
|
20
|
-
|
|
20
|
+
ORACLE_VERSION_MAJOR,
|
|
21
21
|
PrivateEventStore,
|
|
22
22
|
RecipientTaggingStore,
|
|
23
23
|
SenderAddressBookStore,
|
|
@@ -55,7 +55,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
55
55
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
56
56
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
57
57
|
import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
|
|
58
|
-
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';
|
|
59
65
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
60
66
|
import {
|
|
61
67
|
PartialPrivateTailPublicInputsForPublic,
|
|
@@ -84,7 +90,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
84
90
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
85
91
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
86
92
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
87
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
88
93
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
89
94
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
90
95
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -97,7 +102,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
97
102
|
|
|
98
103
|
constructor(
|
|
99
104
|
private stateMachine: TXEStateMachine,
|
|
100
|
-
private contractStore:
|
|
105
|
+
private contractStore: ContractStore,
|
|
101
106
|
private noteStore: NoteStore,
|
|
102
107
|
private keyStore: KeyStore,
|
|
103
108
|
private addressStore: AddressStore,
|
|
@@ -107,32 +112,44 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
107
112
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
108
113
|
private capsuleStore: CapsuleStore,
|
|
109
114
|
private privateEventStore: PrivateEventStore,
|
|
110
|
-
private jobId: string,
|
|
111
115
|
private nextBlockTimestamp: bigint,
|
|
112
116
|
private version: Fr,
|
|
113
117
|
private chainId: Fr,
|
|
114
118
|
private authwits: Map<string, AuthWitness>,
|
|
119
|
+
private readonly contractSyncService: ContractSyncService,
|
|
115
120
|
) {
|
|
116
121
|
this.logger = createLogger('txe:top_level_context');
|
|
117
122
|
this.logger.debug('Entering Top Level Context');
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
private contractOracleVersion: { major: number; minor: number } | undefined;
|
|
126
|
+
|
|
127
|
+
assertCompatibleOracleVersion(major: number, minor: number): void {
|
|
128
|
+
if (major !== ORACLE_VERSION_MAJOR) {
|
|
129
|
+
const hint =
|
|
130
|
+
major > ORACLE_VERSION_MAJOR
|
|
131
|
+
? '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.'
|
|
132
|
+
: '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.';
|
|
122
133
|
throw new Error(
|
|
123
|
-
`Incompatible
|
|
134
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
|
|
124
135
|
);
|
|
125
136
|
}
|
|
137
|
+
this.contractOracleVersion = { major, minor };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
|
|
141
|
+
nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined {
|
|
142
|
+
return this.contractOracleVersion;
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
129
146
|
// setup.
|
|
130
|
-
|
|
147
|
+
getRandomField(): Fr {
|
|
131
148
|
return Fr.random();
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
135
|
-
|
|
152
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
136
153
|
if (!LogLevels[level]) {
|
|
137
154
|
throw new Error(`Invalid log level: ${level}`);
|
|
138
155
|
}
|
|
@@ -142,23 +159,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
142
159
|
return Promise.resolve();
|
|
143
160
|
}
|
|
144
161
|
|
|
145
|
-
|
|
162
|
+
getDefaultAddress(): AztecAddress {
|
|
146
163
|
return DEFAULT_ADDRESS;
|
|
147
164
|
}
|
|
148
165
|
|
|
149
|
-
async
|
|
166
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
150
167
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
151
168
|
}
|
|
152
169
|
|
|
153
|
-
|
|
170
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
154
171
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
async
|
|
174
|
+
async getLastBlockTimestamp() {
|
|
158
175
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
159
176
|
}
|
|
160
177
|
|
|
161
|
-
async
|
|
178
|
+
async getLastTxEffects() {
|
|
162
179
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
163
180
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
164
181
|
|
|
@@ -172,7 +189,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
172
189
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
173
190
|
}
|
|
174
191
|
|
|
175
|
-
async
|
|
192
|
+
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
193
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
194
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
199
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
200
|
+
contractAddress,
|
|
201
|
+
null,
|
|
202
|
+
async (call, execScopes) => {
|
|
203
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
204
|
+
},
|
|
205
|
+
blockHeader,
|
|
206
|
+
jobId,
|
|
207
|
+
[scope],
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
176
212
|
return (
|
|
177
213
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
178
214
|
contractAddress,
|
|
@@ -183,7 +219,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
183
219
|
).map(e => e.packedEvent);
|
|
184
220
|
}
|
|
185
221
|
|
|
186
|
-
async
|
|
222
|
+
async advanceBlocksBy(blocks: number) {
|
|
187
223
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
188
224
|
|
|
189
225
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -191,12 +227,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
191
227
|
}
|
|
192
228
|
}
|
|
193
229
|
|
|
194
|
-
|
|
230
|
+
advanceTimestampBy(duration: UInt64) {
|
|
195
231
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
196
232
|
this.nextBlockTimestamp += duration;
|
|
197
233
|
}
|
|
198
234
|
|
|
199
|
-
async
|
|
235
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
200
236
|
// Emit deployment nullifier
|
|
201
237
|
await this.mineBlock({
|
|
202
238
|
nullifiers: [
|
|
@@ -208,20 +244,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
208
244
|
});
|
|
209
245
|
|
|
210
246
|
if (!secret.equals(Fr.ZERO)) {
|
|
211
|
-
await this.
|
|
247
|
+
await this.addAccount(artifact, instance, secret);
|
|
212
248
|
} else {
|
|
213
249
|
await this.contractStore.addContractInstance(instance);
|
|
214
|
-
await this.contractStore.addContractArtifact(
|
|
250
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
215
251
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
216
252
|
}
|
|
217
253
|
}
|
|
218
254
|
|
|
219
|
-
async
|
|
255
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
220
256
|
const partialAddress = await computePartialAddress(instance);
|
|
221
257
|
|
|
222
258
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
223
259
|
await this.contractStore.addContractInstance(instance);
|
|
224
|
-
await this.contractStore.addContractArtifact(
|
|
260
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
225
261
|
|
|
226
262
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
227
263
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -231,7 +267,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
231
267
|
return completeAddress;
|
|
232
268
|
}
|
|
233
269
|
|
|
234
|
-
async
|
|
270
|
+
async createAccount(secret: Fr) {
|
|
235
271
|
// This is a foot gun !
|
|
236
272
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
237
273
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -241,7 +277,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
241
277
|
return completeAddress;
|
|
242
278
|
}
|
|
243
279
|
|
|
244
|
-
async
|
|
280
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
245
281
|
const account = await this.accountStore.getAccount(address);
|
|
246
282
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
247
283
|
|
|
@@ -254,7 +290,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
254
290
|
}
|
|
255
291
|
|
|
256
292
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
257
|
-
const blockNumber = await this.
|
|
293
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
258
294
|
|
|
259
295
|
const txEffect = TxEffect.empty();
|
|
260
296
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -278,13 +314,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
278
314
|
await this.stateMachine.handleL2Block(block);
|
|
279
315
|
}
|
|
280
316
|
|
|
281
|
-
async
|
|
317
|
+
async privateCallNewFlow(
|
|
282
318
|
from: AztecAddress,
|
|
283
319
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
284
320
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
285
321
|
args: Fr[],
|
|
286
322
|
argsHash: Fr = Fr.zero(),
|
|
287
323
|
isStaticCall: boolean = false,
|
|
324
|
+
jobId: string,
|
|
288
325
|
) {
|
|
289
326
|
this.logger.verbose(
|
|
290
327
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -303,8 +340,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
303
340
|
const effectiveScopes = from.isZero() ? [] : [from];
|
|
304
341
|
|
|
305
342
|
// 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);
|
|
343
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
344
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
308
345
|
};
|
|
309
346
|
|
|
310
347
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -313,16 +350,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
350
|
functionSelector,
|
|
314
351
|
utilityExecutor,
|
|
315
352
|
blockHeader,
|
|
316
|
-
|
|
353
|
+
jobId,
|
|
317
354
|
effectiveScopes,
|
|
318
355
|
);
|
|
319
356
|
|
|
320
|
-
const blockNumber = await this.
|
|
357
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
321
358
|
|
|
322
359
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
323
360
|
|
|
324
|
-
const gasLimits = new Gas(
|
|
325
|
-
const teardownGasLimits = new Gas(
|
|
361
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
362
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
326
363
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
327
364
|
|
|
328
365
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
@@ -357,10 +394,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
357
394
|
senderTaggingStore: this.senderTaggingStore,
|
|
358
395
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
359
396
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
360
|
-
|
|
397
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
361
398
|
privateEventStore: this.privateEventStore,
|
|
362
399
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
363
|
-
jobId
|
|
400
|
+
jobId,
|
|
364
401
|
totalPublicCalldataCount: 0,
|
|
365
402
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
366
403
|
scopes: effectiveScopes,
|
|
@@ -368,6 +405,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
368
405
|
// contract would perform, including setting senderForTags.
|
|
369
406
|
senderForTags: from,
|
|
370
407
|
simulator,
|
|
408
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
409
|
+
l2TipsStore: this.stateMachine.node,
|
|
371
410
|
});
|
|
372
411
|
|
|
373
412
|
// 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 +429,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
390
429
|
);
|
|
391
430
|
const publicFunctionsCalldata = await Promise.all(
|
|
392
431
|
publicCallRequests.map(async r => {
|
|
393
|
-
const calldata = await privateExecutionOracle.
|
|
432
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
394
433
|
return new HashedValues(calldata, r.calldataHash);
|
|
395
434
|
}),
|
|
396
435
|
);
|
|
@@ -504,7 +543,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
504
543
|
return executionResult.returnValues ?? [];
|
|
505
544
|
}
|
|
506
545
|
|
|
507
|
-
async
|
|
546
|
+
async publicCallNewFlow(
|
|
508
547
|
from: AztecAddress,
|
|
509
548
|
targetContractAddress: AztecAddress,
|
|
510
549
|
calldata: Fr[],
|
|
@@ -514,11 +553,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
514
553
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
515
554
|
);
|
|
516
555
|
|
|
517
|
-
const blockNumber = await this.
|
|
556
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
518
557
|
|
|
519
|
-
const gasLimits = new Gas(
|
|
558
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
520
559
|
|
|
521
|
-
const teardownGasLimits = new Gas(
|
|
560
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
522
561
|
|
|
523
562
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
524
563
|
|
|
@@ -591,7 +630,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
591
630
|
constantData,
|
|
592
631
|
/*gasUsed=*/ new Gas(0, 0),
|
|
593
632
|
/*feePayer=*/ AztecAddress.zero(),
|
|
594
|
-
/*
|
|
633
|
+
/*expirationTimestamp=*/ 0n,
|
|
595
634
|
inputsForPublic,
|
|
596
635
|
undefined,
|
|
597
636
|
);
|
|
@@ -659,10 +698,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
659
698
|
return returnValues ?? [];
|
|
660
699
|
}
|
|
661
700
|
|
|
662
|
-
async
|
|
701
|
+
async executeUtilityFunction(
|
|
663
702
|
targetContractAddress: AztecAddress,
|
|
664
703
|
functionSelector: FunctionSelector,
|
|
665
704
|
args: Fr[],
|
|
705
|
+
jobId: string,
|
|
666
706
|
) {
|
|
667
707
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
668
708
|
if (!artifact) {
|
|
@@ -675,11 +715,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
675
715
|
targetContractAddress,
|
|
676
716
|
functionSelector,
|
|
677
717
|
async (call, execScopes) => {
|
|
678
|
-
await this.executeUtilityCall(call, execScopes);
|
|
718
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
679
719
|
},
|
|
680
720
|
blockHeader,
|
|
681
|
-
|
|
682
|
-
|
|
721
|
+
jobId,
|
|
722
|
+
await this.keyStore.getAccounts(),
|
|
683
723
|
);
|
|
684
724
|
|
|
685
725
|
const call = FunctionCall.from({
|
|
@@ -693,10 +733,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
693
733
|
returnTypes: [],
|
|
694
734
|
});
|
|
695
735
|
|
|
696
|
-
return this.executeUtilityCall(call,
|
|
736
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
697
737
|
}
|
|
698
738
|
|
|
699
|
-
private async executeUtilityCall(call: FunctionCall, scopes:
|
|
739
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
700
740
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
701
741
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
702
742
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -721,9 +761,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
721
761
|
aztecNode: this.stateMachine.node,
|
|
722
762
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
723
763
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
724
|
-
|
|
764
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
725
765
|
privateEventStore: this.privateEventStore,
|
|
726
|
-
|
|
766
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
767
|
+
contractSyncService: this.contractSyncService,
|
|
768
|
+
l2TipsStore: this.stateMachine.node,
|
|
769
|
+
jobId,
|
|
727
770
|
scopes,
|
|
728
771
|
});
|
|
729
772
|
const acirExecutionResult = await new WASMSimulator()
|
|
@@ -741,10 +784,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
741
784
|
);
|
|
742
785
|
});
|
|
743
786
|
|
|
744
|
-
this.logger.verbose(`Utility
|
|
787
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
745
788
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
746
789
|
} catch (err) {
|
|
747
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
790
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
748
791
|
}
|
|
749
792
|
}
|
|
750
793
|
|