@aztec/txe 0.0.1-commit.0c875d939 → 0.0.1-commit.0ec55a70b
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 +32 -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 +30 -23
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +95 -55
- package/dest/rpc_translator.d.ts +128 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +464 -164
- 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 +12 -12
- 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 +54 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +98 -29
- 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 +33 -32
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +108 -59
- package/src/rpc_translator.ts +539 -196
- package/src/state_machine/archiver.ts +9 -9
- 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 +10 -2
- package/src/state_machine/mock_epoch_cache.ts +46 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +167 -32
- 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,13 @@ 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,
|
|
19
18
|
NoteStore,
|
|
20
|
-
|
|
19
|
+
ORACLE_VERSION_MAJOR,
|
|
21
20
|
PrivateEventStore,
|
|
22
21
|
RecipientTaggingStore,
|
|
23
22
|
SenderAddressBookStore,
|
|
@@ -55,7 +54,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
55
54
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
56
55
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
57
56
|
import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
|
|
58
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
FALLBACK_TEARDOWN_DA_GAS_LIMIT,
|
|
59
|
+
FALLBACK_TEARDOWN_L2_GAS_LIMIT,
|
|
60
|
+
Gas,
|
|
61
|
+
GasFees,
|
|
62
|
+
GasSettings,
|
|
63
|
+
} from '@aztec/stdlib/gas';
|
|
59
64
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
60
65
|
import {
|
|
61
66
|
PartialPrivateTailPublicInputsForPublic,
|
|
@@ -84,7 +89,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
84
89
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
85
90
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
86
91
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
87
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
88
92
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
89
93
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
90
94
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -97,7 +101,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
97
101
|
|
|
98
102
|
constructor(
|
|
99
103
|
private stateMachine: TXEStateMachine,
|
|
100
|
-
private contractStore:
|
|
104
|
+
private contractStore: ContractStore,
|
|
101
105
|
private noteStore: NoteStore,
|
|
102
106
|
private keyStore: KeyStore,
|
|
103
107
|
private addressStore: AddressStore,
|
|
@@ -107,7 +111,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
107
111
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
108
112
|
private capsuleStore: CapsuleStore,
|
|
109
113
|
private privateEventStore: PrivateEventStore,
|
|
110
|
-
private jobId: string,
|
|
111
114
|
private nextBlockTimestamp: bigint,
|
|
112
115
|
private version: Fr,
|
|
113
116
|
private chainId: Fr,
|
|
@@ -117,22 +120,34 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
117
120
|
this.logger.debug('Entering Top Level Context');
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
private contractOracleVersion: { major: number; minor: number } | undefined;
|
|
124
|
+
|
|
125
|
+
assertCompatibleOracleVersion(major: number, minor: number): void {
|
|
126
|
+
if (major !== ORACLE_VERSION_MAJOR) {
|
|
127
|
+
const hint =
|
|
128
|
+
major > ORACLE_VERSION_MAJOR
|
|
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.';
|
|
122
131
|
throw new Error(
|
|
123
|
-
`Incompatible
|
|
132
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
|
|
124
133
|
);
|
|
125
134
|
}
|
|
135
|
+
this.contractOracleVersion = { major, minor };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
|
|
139
|
+
nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined {
|
|
140
|
+
return this.contractOracleVersion;
|
|
126
141
|
}
|
|
127
142
|
|
|
128
143
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
129
144
|
// setup.
|
|
130
|
-
|
|
145
|
+
getRandomField(): Fr {
|
|
131
146
|
return Fr.random();
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
135
|
-
|
|
150
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
136
151
|
if (!LogLevels[level]) {
|
|
137
152
|
throw new Error(`Invalid log level: ${level}`);
|
|
138
153
|
}
|
|
@@ -142,23 +157,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
142
157
|
return Promise.resolve();
|
|
143
158
|
}
|
|
144
159
|
|
|
145
|
-
|
|
160
|
+
getDefaultAddress(): AztecAddress {
|
|
146
161
|
return DEFAULT_ADDRESS;
|
|
147
162
|
}
|
|
148
163
|
|
|
149
|
-
async
|
|
164
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
150
165
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
151
166
|
}
|
|
152
167
|
|
|
153
|
-
|
|
168
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
154
169
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
|
-
async
|
|
172
|
+
async getLastBlockTimestamp() {
|
|
158
173
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
159
174
|
}
|
|
160
175
|
|
|
161
|
-
async
|
|
176
|
+
async getLastTxEffects() {
|
|
162
177
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
163
178
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
164
179
|
|
|
@@ -172,7 +187,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
172
187
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
173
188
|
}
|
|
174
189
|
|
|
175
|
-
async
|
|
190
|
+
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
191
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
192
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
197
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
198
|
+
contractAddress,
|
|
199
|
+
null,
|
|
200
|
+
async (call, execScopes) => {
|
|
201
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
202
|
+
},
|
|
203
|
+
blockHeader,
|
|
204
|
+
jobId,
|
|
205
|
+
[scope],
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
176
210
|
return (
|
|
177
211
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
178
212
|
contractAddress,
|
|
@@ -183,7 +217,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
183
217
|
).map(e => e.packedEvent);
|
|
184
218
|
}
|
|
185
219
|
|
|
186
|
-
async
|
|
220
|
+
async advanceBlocksBy(blocks: number) {
|
|
187
221
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
188
222
|
|
|
189
223
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -191,12 +225,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
191
225
|
}
|
|
192
226
|
}
|
|
193
227
|
|
|
194
|
-
|
|
228
|
+
advanceTimestampBy(duration: UInt64) {
|
|
195
229
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
196
230
|
this.nextBlockTimestamp += duration;
|
|
197
231
|
}
|
|
198
232
|
|
|
199
|
-
async
|
|
233
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
200
234
|
// Emit deployment nullifier
|
|
201
235
|
await this.mineBlock({
|
|
202
236
|
nullifiers: [
|
|
@@ -208,20 +242,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
208
242
|
});
|
|
209
243
|
|
|
210
244
|
if (!secret.equals(Fr.ZERO)) {
|
|
211
|
-
await this.
|
|
245
|
+
await this.addAccount(artifact, instance, secret);
|
|
212
246
|
} else {
|
|
213
247
|
await this.contractStore.addContractInstance(instance);
|
|
214
|
-
await this.contractStore.addContractArtifact(
|
|
248
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
215
249
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
216
250
|
}
|
|
217
251
|
}
|
|
218
252
|
|
|
219
|
-
async
|
|
253
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
220
254
|
const partialAddress = await computePartialAddress(instance);
|
|
221
255
|
|
|
222
256
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
223
257
|
await this.contractStore.addContractInstance(instance);
|
|
224
|
-
await this.contractStore.addContractArtifact(
|
|
258
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
225
259
|
|
|
226
260
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
227
261
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -231,7 +265,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
231
265
|
return completeAddress;
|
|
232
266
|
}
|
|
233
267
|
|
|
234
|
-
async
|
|
268
|
+
async createAccount(secret: Fr) {
|
|
235
269
|
// This is a foot gun !
|
|
236
270
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
237
271
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -241,7 +275,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
241
275
|
return completeAddress;
|
|
242
276
|
}
|
|
243
277
|
|
|
244
|
-
async
|
|
278
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
245
279
|
const account = await this.accountStore.getAccount(address);
|
|
246
280
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
247
281
|
|
|
@@ -254,7 +288,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
254
288
|
}
|
|
255
289
|
|
|
256
290
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
257
|
-
const blockNumber = await this.
|
|
291
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
258
292
|
|
|
259
293
|
const txEffect = TxEffect.empty();
|
|
260
294
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -278,13 +312,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
278
312
|
await this.stateMachine.handleL2Block(block);
|
|
279
313
|
}
|
|
280
314
|
|
|
281
|
-
async
|
|
315
|
+
async privateCallNewFlow(
|
|
282
316
|
from: AztecAddress,
|
|
283
317
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
284
318
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
285
319
|
args: Fr[],
|
|
286
320
|
argsHash: Fr = Fr.zero(),
|
|
287
321
|
isStaticCall: boolean = false,
|
|
322
|
+
jobId: string,
|
|
288
323
|
) {
|
|
289
324
|
this.logger.verbose(
|
|
290
325
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -303,8 +338,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
303
338
|
const effectiveScopes = from.isZero() ? [] : [from];
|
|
304
339
|
|
|
305
340
|
// 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);
|
|
341
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
342
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
308
343
|
};
|
|
309
344
|
|
|
310
345
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -313,16 +348,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
348
|
functionSelector,
|
|
314
349
|
utilityExecutor,
|
|
315
350
|
blockHeader,
|
|
316
|
-
|
|
351
|
+
jobId,
|
|
317
352
|
effectiveScopes,
|
|
318
353
|
);
|
|
319
354
|
|
|
320
|
-
const blockNumber = await this.
|
|
355
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
321
356
|
|
|
322
357
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
323
358
|
|
|
324
|
-
const gasLimits = new Gas(
|
|
325
|
-
const teardownGasLimits = new Gas(
|
|
359
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
360
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
326
361
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
327
362
|
|
|
328
363
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
@@ -357,10 +392,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
357
392
|
senderTaggingStore: this.senderTaggingStore,
|
|
358
393
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
359
394
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
360
|
-
|
|
395
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
361
396
|
privateEventStore: this.privateEventStore,
|
|
362
397
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
363
|
-
jobId
|
|
398
|
+
jobId,
|
|
364
399
|
totalPublicCalldataCount: 0,
|
|
365
400
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
366
401
|
scopes: effectiveScopes,
|
|
@@ -368,6 +403,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
368
403
|
// contract would perform, including setting senderForTags.
|
|
369
404
|
senderForTags: from,
|
|
370
405
|
simulator,
|
|
406
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
407
|
+
l2TipsStore: this.stateMachine.node,
|
|
371
408
|
});
|
|
372
409
|
|
|
373
410
|
// 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 +427,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
390
427
|
);
|
|
391
428
|
const publicFunctionsCalldata = await Promise.all(
|
|
392
429
|
publicCallRequests.map(async r => {
|
|
393
|
-
const calldata = await privateExecutionOracle.
|
|
430
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
394
431
|
return new HashedValues(calldata, r.calldataHash);
|
|
395
432
|
}),
|
|
396
433
|
);
|
|
@@ -475,11 +512,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
475
512
|
}
|
|
476
513
|
}
|
|
477
514
|
|
|
515
|
+
// Walk the nested private-call tree and collect every offchain effect the transaction emitted.
|
|
516
|
+
// PXE stores these on each `PrivateCallExecutionResult` and they never reach TXE via the
|
|
517
|
+
// `aztec_utl_emitOffchainEffect` foreign-call path (that path only fires at the top-level), so
|
|
518
|
+
// we pull them out here and the RPC wrapper will hand them to `TXESession` for buffering.
|
|
519
|
+
const offchainEffects = collectNested([executionResult], r => r.offchainEffects.map(e => e.data));
|
|
520
|
+
|
|
478
521
|
if (isStaticCall) {
|
|
479
522
|
await checkpoint!.revert();
|
|
480
523
|
|
|
481
524
|
await forkedWorldTrees.close();
|
|
482
|
-
return executionResult.returnValues ?? [];
|
|
525
|
+
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
483
526
|
}
|
|
484
527
|
|
|
485
528
|
const txEffect = TxEffect.empty();
|
|
@@ -501,10 +544,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
501
544
|
|
|
502
545
|
await forkedWorldTrees.close();
|
|
503
546
|
|
|
504
|
-
return executionResult.returnValues ?? [];
|
|
547
|
+
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
505
548
|
}
|
|
506
549
|
|
|
507
|
-
async
|
|
550
|
+
async publicCallNewFlow(
|
|
508
551
|
from: AztecAddress,
|
|
509
552
|
targetContractAddress: AztecAddress,
|
|
510
553
|
calldata: Fr[],
|
|
@@ -514,11 +557,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
514
557
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
515
558
|
);
|
|
516
559
|
|
|
517
|
-
const blockNumber = await this.
|
|
560
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
518
561
|
|
|
519
|
-
const gasLimits = new Gas(
|
|
562
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
520
563
|
|
|
521
|
-
const teardownGasLimits = new Gas(
|
|
564
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
522
565
|
|
|
523
566
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
524
567
|
|
|
@@ -591,7 +634,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
591
634
|
constantData,
|
|
592
635
|
/*gasUsed=*/ new Gas(0, 0),
|
|
593
636
|
/*feePayer=*/ AztecAddress.zero(),
|
|
594
|
-
/*
|
|
637
|
+
/*expirationTimestamp=*/ 0n,
|
|
595
638
|
inputsForPublic,
|
|
596
639
|
undefined,
|
|
597
640
|
);
|
|
@@ -659,10 +702,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
659
702
|
return returnValues ?? [];
|
|
660
703
|
}
|
|
661
704
|
|
|
662
|
-
async
|
|
705
|
+
async executeUtilityFunction(
|
|
663
706
|
targetContractAddress: AztecAddress,
|
|
664
707
|
functionSelector: FunctionSelector,
|
|
665
708
|
args: Fr[],
|
|
709
|
+
jobId: string,
|
|
666
710
|
) {
|
|
667
711
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
668
712
|
if (!artifact) {
|
|
@@ -675,11 +719,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
675
719
|
targetContractAddress,
|
|
676
720
|
functionSelector,
|
|
677
721
|
async (call, execScopes) => {
|
|
678
|
-
await this.executeUtilityCall(call, execScopes);
|
|
722
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
679
723
|
},
|
|
680
724
|
blockHeader,
|
|
681
|
-
|
|
682
|
-
|
|
725
|
+
jobId,
|
|
726
|
+
await this.keyStore.getAccounts(),
|
|
683
727
|
);
|
|
684
728
|
|
|
685
729
|
const call = FunctionCall.from({
|
|
@@ -693,10 +737,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
693
737
|
returnTypes: [],
|
|
694
738
|
});
|
|
695
739
|
|
|
696
|
-
return this.executeUtilityCall(call,
|
|
740
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
697
741
|
}
|
|
698
742
|
|
|
699
|
-
private async executeUtilityCall(call: FunctionCall, scopes:
|
|
743
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
700
744
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
701
745
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
702
746
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -709,6 +753,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
709
753
|
|
|
710
754
|
try {
|
|
711
755
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
756
|
+
const simulator = new WASMSimulator();
|
|
712
757
|
const oracle = new UtilityExecutionOracle({
|
|
713
758
|
contractAddress: call.to,
|
|
714
759
|
authWitnesses: [],
|
|
@@ -721,12 +766,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
721
766
|
aztecNode: this.stateMachine.node,
|
|
722
767
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
723
768
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
724
|
-
|
|
769
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
725
770
|
privateEventStore: this.privateEventStore,
|
|
726
|
-
|
|
771
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
772
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
773
|
+
l2TipsStore: this.stateMachine.node,
|
|
774
|
+
jobId,
|
|
727
775
|
scopes,
|
|
776
|
+
simulator,
|
|
728
777
|
});
|
|
729
|
-
const acirExecutionResult = await
|
|
778
|
+
const acirExecutionResult = await simulator
|
|
730
779
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
731
780
|
.catch((err: Error) => {
|
|
732
781
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
@@ -741,10 +790,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
741
790
|
);
|
|
742
791
|
});
|
|
743
792
|
|
|
744
|
-
this.logger.verbose(`Utility
|
|
793
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
745
794
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
746
795
|
} catch (err) {
|
|
747
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
796
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
748
797
|
}
|
|
749
798
|
}
|
|
750
799
|
|