@aztec/txe 0.0.1-commit.64b6bbb → 0.0.1-commit.69c59a8b3
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 +84 -58
- 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 +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 +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 +42 -27
- 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 +105 -59
- package/src/rpc_translator.ts +446 -183
- 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 +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 +49 -24
- 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';
|
|
@@ -14,9 +12,12 @@ 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_MAJOR,
|
|
20
21
|
PrivateEventStore,
|
|
21
22
|
RecipientTaggingStore,
|
|
22
23
|
SenderAddressBookStore,
|
|
@@ -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,44 @@ 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
|
-
|
|
120
|
-
|
|
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.';
|
|
121
133
|
throw new Error(
|
|
122
|
-
`Incompatible
|
|
134
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
|
|
123
135
|
);
|
|
124
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;
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
128
146
|
// setup.
|
|
129
|
-
|
|
147
|
+
getRandomField(): Fr {
|
|
130
148
|
return Fr.random();
|
|
131
149
|
}
|
|
132
150
|
|
|
133
151
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
|
|
152
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
153
|
if (!LogLevels[level]) {
|
|
136
154
|
throw new Error(`Invalid log level: ${level}`);
|
|
137
155
|
}
|
|
@@ -141,23 +159,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
141
159
|
return Promise.resolve();
|
|
142
160
|
}
|
|
143
161
|
|
|
144
|
-
|
|
162
|
+
getDefaultAddress(): AztecAddress {
|
|
145
163
|
return DEFAULT_ADDRESS;
|
|
146
164
|
}
|
|
147
165
|
|
|
148
|
-
async
|
|
166
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
149
167
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
150
168
|
}
|
|
151
169
|
|
|
152
|
-
|
|
170
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
153
171
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
154
172
|
}
|
|
155
173
|
|
|
156
|
-
async
|
|
174
|
+
async getLastBlockTimestamp() {
|
|
157
175
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
158
176
|
}
|
|
159
177
|
|
|
160
|
-
async
|
|
178
|
+
async getLastTxEffects() {
|
|
161
179
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
180
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
163
181
|
|
|
@@ -171,7 +189,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
171
189
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
172
190
|
}
|
|
173
191
|
|
|
174
|
-
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) {
|
|
175
212
|
return (
|
|
176
213
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
177
214
|
contractAddress,
|
|
@@ -182,7 +219,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
182
219
|
).map(e => e.packedEvent);
|
|
183
220
|
}
|
|
184
221
|
|
|
185
|
-
async
|
|
222
|
+
async advanceBlocksBy(blocks: number) {
|
|
186
223
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
187
224
|
|
|
188
225
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -190,12 +227,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
190
227
|
}
|
|
191
228
|
}
|
|
192
229
|
|
|
193
|
-
|
|
230
|
+
advanceTimestampBy(duration: UInt64) {
|
|
194
231
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
195
232
|
this.nextBlockTimestamp += duration;
|
|
196
233
|
}
|
|
197
234
|
|
|
198
|
-
async
|
|
235
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
199
236
|
// Emit deployment nullifier
|
|
200
237
|
await this.mineBlock({
|
|
201
238
|
nullifiers: [
|
|
@@ -207,20 +244,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
207
244
|
});
|
|
208
245
|
|
|
209
246
|
if (!secret.equals(Fr.ZERO)) {
|
|
210
|
-
await this.
|
|
247
|
+
await this.addAccount(artifact, instance, secret);
|
|
211
248
|
} else {
|
|
212
249
|
await this.contractStore.addContractInstance(instance);
|
|
213
|
-
await this.contractStore.addContractArtifact(
|
|
250
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
214
251
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
215
252
|
}
|
|
216
253
|
}
|
|
217
254
|
|
|
218
|
-
async
|
|
255
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
219
256
|
const partialAddress = await computePartialAddress(instance);
|
|
220
257
|
|
|
221
258
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
222
259
|
await this.contractStore.addContractInstance(instance);
|
|
223
|
-
await this.contractStore.addContractArtifact(
|
|
260
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
224
261
|
|
|
225
262
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
226
263
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -230,7 +267,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
230
267
|
return completeAddress;
|
|
231
268
|
}
|
|
232
269
|
|
|
233
|
-
async
|
|
270
|
+
async createAccount(secret: Fr) {
|
|
234
271
|
// This is a foot gun !
|
|
235
272
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
236
273
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -240,7 +277,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
240
277
|
return completeAddress;
|
|
241
278
|
}
|
|
242
279
|
|
|
243
|
-
async
|
|
280
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
244
281
|
const account = await this.accountStore.getAccount(address);
|
|
245
282
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
246
283
|
|
|
@@ -253,7 +290,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
253
290
|
}
|
|
254
291
|
|
|
255
292
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
256
|
-
const blockNumber = await this.
|
|
293
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
257
294
|
|
|
258
295
|
const txEffect = TxEffect.empty();
|
|
259
296
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -277,13 +314,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
277
314
|
await this.stateMachine.handleL2Block(block);
|
|
278
315
|
}
|
|
279
316
|
|
|
280
|
-
async
|
|
317
|
+
async privateCallNewFlow(
|
|
281
318
|
from: AztecAddress,
|
|
282
319
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
283
320
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
284
321
|
args: Fr[],
|
|
285
322
|
argsHash: Fr = Fr.zero(),
|
|
286
323
|
isStaticCall: boolean = false,
|
|
324
|
+
jobId: string,
|
|
287
325
|
) {
|
|
288
326
|
this.logger.verbose(
|
|
289
327
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -297,14 +335,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
297
335
|
throw new Error(message);
|
|
298
336
|
}
|
|
299
337
|
|
|
300
|
-
// When `from` is the zero address (
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
const effectiveScopes = from.isZero() ? undefined : [from];
|
|
338
|
+
// When `from` is the zero address (e.g. when deploying a new account contract), we return an
|
|
339
|
+
// empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
|
|
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) => {
|
|
307
|
-
await this.executeUtilityCall(call,
|
|
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,15 +350,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
350
|
functionSelector,
|
|
314
351
|
utilityExecutor,
|
|
315
352
|
blockHeader,
|
|
316
|
-
|
|
353
|
+
jobId,
|
|
354
|
+
effectiveScopes,
|
|
317
355
|
);
|
|
318
356
|
|
|
319
|
-
const blockNumber = await this.
|
|
357
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
320
358
|
|
|
321
359
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
322
360
|
|
|
323
|
-
const gasLimits = new Gas(
|
|
324
|
-
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);
|
|
325
363
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
326
364
|
|
|
327
365
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
@@ -356,10 +394,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
356
394
|
senderTaggingStore: this.senderTaggingStore,
|
|
357
395
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
358
396
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
359
|
-
|
|
397
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
360
398
|
privateEventStore: this.privateEventStore,
|
|
361
399
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
362
|
-
jobId
|
|
400
|
+
jobId,
|
|
363
401
|
totalPublicCalldataCount: 0,
|
|
364
402
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
365
403
|
scopes: effectiveScopes,
|
|
@@ -367,6 +405,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
367
405
|
// contract would perform, including setting senderForTags.
|
|
368
406
|
senderForTags: from,
|
|
369
407
|
simulator,
|
|
408
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
409
|
+
l2TipsStore: this.stateMachine.node,
|
|
370
410
|
});
|
|
371
411
|
|
|
372
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.
|
|
@@ -389,7 +429,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
389
429
|
);
|
|
390
430
|
const publicFunctionsCalldata = await Promise.all(
|
|
391
431
|
publicCallRequests.map(async r => {
|
|
392
|
-
const calldata = await privateExecutionOracle.
|
|
432
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
393
433
|
return new HashedValues(calldata, r.calldataHash);
|
|
394
434
|
}),
|
|
395
435
|
);
|
|
@@ -407,6 +447,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
407
447
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
408
448
|
result,
|
|
409
449
|
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
450
|
+
this.stateMachine.node,
|
|
410
451
|
minRevertibleSideEffectCounter,
|
|
411
452
|
);
|
|
412
453
|
|
|
@@ -502,7 +543,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
502
543
|
return executionResult.returnValues ?? [];
|
|
503
544
|
}
|
|
504
545
|
|
|
505
|
-
async
|
|
546
|
+
async publicCallNewFlow(
|
|
506
547
|
from: AztecAddress,
|
|
507
548
|
targetContractAddress: AztecAddress,
|
|
508
549
|
calldata: Fr[],
|
|
@@ -512,11 +553,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
512
553
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
513
554
|
);
|
|
514
555
|
|
|
515
|
-
const blockNumber = await this.
|
|
556
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
516
557
|
|
|
517
|
-
const gasLimits = new Gas(
|
|
558
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
518
559
|
|
|
519
|
-
const teardownGasLimits = new Gas(
|
|
560
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
520
561
|
|
|
521
562
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
522
563
|
|
|
@@ -589,7 +630,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
589
630
|
constantData,
|
|
590
631
|
/*gasUsed=*/ new Gas(0, 0),
|
|
591
632
|
/*feePayer=*/ AztecAddress.zero(),
|
|
592
|
-
/*
|
|
633
|
+
/*expirationTimestamp=*/ 0n,
|
|
593
634
|
inputsForPublic,
|
|
594
635
|
undefined,
|
|
595
636
|
);
|
|
@@ -657,10 +698,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
657
698
|
return returnValues ?? [];
|
|
658
699
|
}
|
|
659
700
|
|
|
660
|
-
async
|
|
701
|
+
async executeUtilityFunction(
|
|
661
702
|
targetContractAddress: AztecAddress,
|
|
662
703
|
functionSelector: FunctionSelector,
|
|
663
704
|
args: Fr[],
|
|
705
|
+
jobId: string,
|
|
664
706
|
) {
|
|
665
707
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
666
708
|
if (!artifact) {
|
|
@@ -672,11 +714,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
672
714
|
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
673
715
|
targetContractAddress,
|
|
674
716
|
functionSelector,
|
|
675
|
-
async call => {
|
|
676
|
-
await this.executeUtilityCall(call);
|
|
717
|
+
async (call, execScopes) => {
|
|
718
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
677
719
|
},
|
|
678
720
|
blockHeader,
|
|
679
|
-
|
|
721
|
+
jobId,
|
|
722
|
+
await this.keyStore.getAccounts(),
|
|
680
723
|
);
|
|
681
724
|
|
|
682
725
|
const call = FunctionCall.from({
|
|
@@ -690,10 +733,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
690
733
|
returnTypes: [],
|
|
691
734
|
});
|
|
692
735
|
|
|
693
|
-
return this.executeUtilityCall(call);
|
|
736
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
694
737
|
}
|
|
695
738
|
|
|
696
|
-
private async executeUtilityCall(call: FunctionCall, scopes
|
|
739
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
697
740
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
698
741
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
699
742
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -718,9 +761,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
718
761
|
aztecNode: this.stateMachine.node,
|
|
719
762
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
720
763
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
721
|
-
|
|
764
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
722
765
|
privateEventStore: this.privateEventStore,
|
|
723
|
-
|
|
766
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
767
|
+
contractSyncService: this.contractSyncService,
|
|
768
|
+
l2TipsStore: this.stateMachine.node,
|
|
769
|
+
jobId,
|
|
724
770
|
scopes,
|
|
725
771
|
});
|
|
726
772
|
const acirExecutionResult = await new WASMSimulator()
|
|
@@ -738,10 +784,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
738
784
|
);
|
|
739
785
|
});
|
|
740
786
|
|
|
741
|
-
this.logger.verbose(`Utility
|
|
787
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
742
788
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
743
789
|
} catch (err) {
|
|
744
|
-
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'));
|
|
745
791
|
}
|
|
746
792
|
}
|
|
747
793
|
|