@aztec/txe 0.0.1-commit.0c875d939 → 0.0.1-commit.0dc957cde
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,10 +1,10 @@
|
|
|
1
|
-
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
|
-
import {
|
|
7
|
+
import { CapsuleService, ORACLE_VERSION_MAJOR, enrichPublicSimulationError } from '@aztec/pxe/server';
|
|
8
8
|
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle, executePrivateFunction, generateSimulatedProvingResult } from '@aztec/pxe/simulator';
|
|
9
9
|
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
|
|
10
10
|
import { CppPublicTxSimulator, GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor } from '@aztec/simulator/server';
|
|
@@ -13,7 +13,7 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
13
13
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
15
|
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
16
|
-
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
16
|
+
import { FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT, Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
17
17
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
18
18
|
import { PartialPrivateTailPublicInputsForPublic, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
19
19
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
@@ -36,15 +36,15 @@ export class TXEOracleTopLevelContext {
|
|
|
36
36
|
senderAddressBookStore;
|
|
37
37
|
capsuleStore;
|
|
38
38
|
privateEventStore;
|
|
39
|
-
jobId;
|
|
40
39
|
nextBlockTimestamp;
|
|
41
40
|
version;
|
|
42
41
|
chainId;
|
|
43
42
|
authwits;
|
|
43
|
+
contractSyncService;
|
|
44
44
|
isMisc;
|
|
45
45
|
isTxe;
|
|
46
46
|
logger;
|
|
47
|
-
constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore,
|
|
47
|
+
constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, authwits, contractSyncService){
|
|
48
48
|
this.stateMachine = stateMachine;
|
|
49
49
|
this.contractStore = contractStore;
|
|
50
50
|
this.noteStore = noteStore;
|
|
@@ -56,28 +56,38 @@ export class TXEOracleTopLevelContext {
|
|
|
56
56
|
this.senderAddressBookStore = senderAddressBookStore;
|
|
57
57
|
this.capsuleStore = capsuleStore;
|
|
58
58
|
this.privateEventStore = privateEventStore;
|
|
59
|
-
this.jobId = jobId;
|
|
60
59
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
61
60
|
this.version = version;
|
|
62
61
|
this.chainId = chainId;
|
|
63
62
|
this.authwits = authwits;
|
|
63
|
+
this.contractSyncService = contractSyncService;
|
|
64
64
|
this.isMisc = true;
|
|
65
65
|
this.isTxe = true;
|
|
66
66
|
this.logger = createLogger('txe:top_level_context');
|
|
67
67
|
this.logger.debug('Entering Top Level Context');
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
contractOracleVersion;
|
|
70
|
+
assertCompatibleOracleVersion(major, minor) {
|
|
71
|
+
if (major !== ORACLE_VERSION_MAJOR) {
|
|
72
|
+
const hint = major > ORACLE_VERSION_MAJOR ? '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.' : '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.';
|
|
73
|
+
throw new Error(`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`);
|
|
72
74
|
}
|
|
75
|
+
this.contractOracleVersion = {
|
|
76
|
+
major,
|
|
77
|
+
minor
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
|
|
81
|
+
nonOracleFunctionGetContractOracleVersion() {
|
|
82
|
+
return this.contractOracleVersion;
|
|
73
83
|
}
|
|
74
84
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
75
85
|
// setup.
|
|
76
|
-
|
|
86
|
+
getRandomField() {
|
|
77
87
|
return Fr.random();
|
|
78
88
|
}
|
|
79
89
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
80
|
-
|
|
90
|
+
log(level, message, fields) {
|
|
81
91
|
if (!LogLevels[level]) {
|
|
82
92
|
throw new Error(`Invalid log level: ${level}`);
|
|
83
93
|
}
|
|
@@ -87,19 +97,19 @@ export class TXEOracleTopLevelContext {
|
|
|
87
97
|
});
|
|
88
98
|
return Promise.resolve();
|
|
89
99
|
}
|
|
90
|
-
|
|
100
|
+
getDefaultAddress() {
|
|
91
101
|
return DEFAULT_ADDRESS;
|
|
92
102
|
}
|
|
93
|
-
async
|
|
103
|
+
async getNextBlockNumber() {
|
|
94
104
|
return BlockNumber(await this.getLastBlockNumber() + 1);
|
|
95
105
|
}
|
|
96
|
-
|
|
106
|
+
getNextBlockTimestamp() {
|
|
97
107
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
98
108
|
}
|
|
99
|
-
async
|
|
109
|
+
async getLastBlockTimestamp() {
|
|
100
110
|
return (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.timestamp;
|
|
101
111
|
}
|
|
102
|
-
async
|
|
112
|
+
async getLastTxEffects() {
|
|
103
113
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
104
114
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
105
115
|
if (block.body.txEffects.length != 1) {
|
|
@@ -113,7 +123,19 @@ export class TXEOracleTopLevelContext {
|
|
|
113
123
|
nullifiers: txEffects.nullifiers
|
|
114
124
|
};
|
|
115
125
|
}
|
|
116
|
-
async
|
|
126
|
+
async syncContractNonOracleMethod(contractAddress, scope, jobId) {
|
|
127
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
128
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
132
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(contractAddress, null, async (call, execScopes)=>{
|
|
133
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
134
|
+
}, blockHeader, jobId, [
|
|
135
|
+
scope
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
async getPrivateEvents(selector, contractAddress, scope) {
|
|
117
139
|
return (await this.privateEventStore.getPrivateEvents(selector, {
|
|
118
140
|
contractAddress,
|
|
119
141
|
scopes: [
|
|
@@ -123,17 +145,17 @@ export class TXEOracleTopLevelContext {
|
|
|
123
145
|
toBlock: await this.getLastBlockNumber() + 1
|
|
124
146
|
})).map((e)=>e.packedEvent);
|
|
125
147
|
}
|
|
126
|
-
async
|
|
148
|
+
async advanceBlocksBy(blocks) {
|
|
127
149
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
128
150
|
for(let i = 0; i < blocks; i++){
|
|
129
151
|
await this.mineBlock();
|
|
130
152
|
}
|
|
131
153
|
}
|
|
132
|
-
|
|
154
|
+
advanceTimestampBy(duration) {
|
|
133
155
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
134
156
|
this.nextBlockTimestamp += duration;
|
|
135
157
|
}
|
|
136
|
-
async
|
|
158
|
+
async deploy(artifact, instance, secret) {
|
|
137
159
|
// Emit deployment nullifier
|
|
138
160
|
await this.mineBlock({
|
|
139
161
|
nullifiers: [
|
|
@@ -141,25 +163,25 @@ export class TXEOracleTopLevelContext {
|
|
|
141
163
|
]
|
|
142
164
|
});
|
|
143
165
|
if (!secret.equals(Fr.ZERO)) {
|
|
144
|
-
await this.
|
|
166
|
+
await this.addAccount(artifact, instance, secret);
|
|
145
167
|
} else {
|
|
146
168
|
await this.contractStore.addContractInstance(instance);
|
|
147
|
-
await this.contractStore.addContractArtifact(
|
|
169
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
148
170
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
149
171
|
}
|
|
150
172
|
}
|
|
151
|
-
async
|
|
173
|
+
async addAccount(artifact, instance, secret) {
|
|
152
174
|
const partialAddress = await computePartialAddress(instance);
|
|
153
175
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
154
176
|
await this.contractStore.addContractInstance(instance);
|
|
155
|
-
await this.contractStore.addContractArtifact(
|
|
177
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
156
178
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
157
179
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
158
180
|
await this.addressStore.addCompleteAddress(completeAddress);
|
|
159
181
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
160
182
|
return completeAddress;
|
|
161
183
|
}
|
|
162
|
-
async
|
|
184
|
+
async createAccount(secret) {
|
|
163
185
|
// This is a foot gun !
|
|
164
186
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
165
187
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -167,7 +189,7 @@ export class TXEOracleTopLevelContext {
|
|
|
167
189
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
168
190
|
return completeAddress;
|
|
169
191
|
}
|
|
170
|
-
async
|
|
192
|
+
async addAuthWitness(address, messageHash) {
|
|
171
193
|
const account = await this.accountStore.getAccount(address);
|
|
172
194
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
173
195
|
const schnorr = new Schnorr();
|
|
@@ -178,7 +200,7 @@ export class TXEOracleTopLevelContext {
|
|
|
178
200
|
this.authwits.set(authWitness.requestHash.toString(), authWitness);
|
|
179
201
|
}
|
|
180
202
|
async mineBlock(options = {}) {
|
|
181
|
-
const blockNumber = await this.
|
|
203
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
182
204
|
const txEffect = TxEffect.empty();
|
|
183
205
|
txEffect.nullifiers = [
|
|
184
206
|
getSingleTxBlockRequestHash(blockNumber),
|
|
@@ -200,7 +222,7 @@ export class TXEOracleTopLevelContext {
|
|
|
200
222
|
this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
|
|
201
223
|
await this.stateMachine.handleL2Block(block);
|
|
202
224
|
}
|
|
203
|
-
async
|
|
225
|
+
async privateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false, jobId) {
|
|
204
226
|
this.logger.verbose(`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`);
|
|
205
227
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
206
228
|
if (!artifact) {
|
|
@@ -214,14 +236,14 @@ export class TXEOracleTopLevelContext {
|
|
|
214
236
|
];
|
|
215
237
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
216
238
|
const utilityExecutor = async (call, execScopes)=>{
|
|
217
|
-
await this.executeUtilityCall(call, execScopes);
|
|
239
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
218
240
|
};
|
|
219
241
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
220
|
-
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader,
|
|
221
|
-
const blockNumber = await this.
|
|
242
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, utilityExecutor, blockHeader, jobId, effectiveScopes);
|
|
243
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
222
244
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
223
|
-
const gasLimits = new Gas(
|
|
224
|
-
const teardownGasLimits = new Gas(
|
|
245
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
246
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
225
247
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
226
248
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
227
249
|
const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
|
|
@@ -254,17 +276,19 @@ export class TXEOracleTopLevelContext {
|
|
|
254
276
|
senderTaggingStore: this.senderTaggingStore,
|
|
255
277
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
256
278
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
257
|
-
|
|
279
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
258
280
|
privateEventStore: this.privateEventStore,
|
|
259
281
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
260
|
-
jobId
|
|
282
|
+
jobId,
|
|
261
283
|
totalPublicCalldataCount: 0,
|
|
262
284
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
263
285
|
scopes: effectiveScopes,
|
|
264
286
|
// In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
|
|
265
287
|
// contract would perform, including setting senderForTags.
|
|
266
288
|
senderForTags: from,
|
|
267
|
-
simulator
|
|
289
|
+
simulator,
|
|
290
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
291
|
+
l2TipsStore: this.stateMachine.node
|
|
268
292
|
});
|
|
269
293
|
// 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.
|
|
270
294
|
let result;
|
|
@@ -277,7 +301,7 @@ export class TXEOracleTopLevelContext {
|
|
|
277
301
|
r.publicInputs.publicTeardownCallRequest
|
|
278
302
|
]));
|
|
279
303
|
const publicFunctionsCalldata = await Promise.all(publicCallRequests.map(async (r)=>{
|
|
280
|
-
const calldata = await privateExecutionOracle.
|
|
304
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
281
305
|
return new HashedValues(calldata, r.calldataHash);
|
|
282
306
|
}));
|
|
283
307
|
noteCache.finish();
|
|
@@ -357,11 +381,11 @@ export class TXEOracleTopLevelContext {
|
|
|
357
381
|
await forkedWorldTrees.close();
|
|
358
382
|
return executionResult.returnValues ?? [];
|
|
359
383
|
}
|
|
360
|
-
async
|
|
384
|
+
async publicCallNewFlow(from, targetContractAddress, calldata, isStaticCall) {
|
|
361
385
|
this.logger.verbose(`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`);
|
|
362
|
-
const blockNumber = await this.
|
|
363
|
-
const gasLimits = new Gas(
|
|
364
|
-
const teardownGasLimits = new Gas(
|
|
386
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
387
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
388
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
365
389
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
366
390
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
367
391
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -398,7 +422,7 @@ export class TXEOracleTopLevelContext {
|
|
|
398
422
|
revertibleAccumulatedData.publicCallRequests[0] = new PublicCallRequest(from, targetContractAddress, isStaticCall, calldataHash);
|
|
399
423
|
const inputsForPublic = new PartialPrivateTailPublicInputsForPublic(nonRevertibleAccumulatedData, revertibleAccumulatedData, PublicCallRequest.empty());
|
|
400
424
|
const constantData = new TxConstantData(anchorBlockHeader, txContext, Fr.zero(), Fr.zero());
|
|
401
|
-
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*
|
|
425
|
+
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ new Gas(0, 0), /*feePayer=*/ AztecAddress.zero(), /*expirationTimestamp=*/ 0n, inputsForPublic, undefined);
|
|
402
426
|
const tx = await Tx.create({
|
|
403
427
|
data: txData,
|
|
404
428
|
chonkProof: ChonkProof.empty(),
|
|
@@ -451,7 +475,7 @@ export class TXEOracleTopLevelContext {
|
|
|
451
475
|
await forkedWorldTrees.close();
|
|
452
476
|
return returnValues ?? [];
|
|
453
477
|
}
|
|
454
|
-
async
|
|
478
|
+
async executeUtilityFunction(targetContractAddress, functionSelector, args, jobId) {
|
|
455
479
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
456
480
|
if (!artifact) {
|
|
457
481
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
@@ -459,8 +483,8 @@ export class TXEOracleTopLevelContext {
|
|
|
459
483
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
460
484
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
461
485
|
await this.stateMachine.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, async (call, execScopes)=>{
|
|
462
|
-
await this.executeUtilityCall(call, execScopes);
|
|
463
|
-
}, blockHeader,
|
|
486
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
487
|
+
}, blockHeader, jobId, await this.keyStore.getAccounts());
|
|
464
488
|
const call = FunctionCall.from({
|
|
465
489
|
name: artifact.name,
|
|
466
490
|
to: targetContractAddress,
|
|
@@ -471,9 +495,9 @@ export class TXEOracleTopLevelContext {
|
|
|
471
495
|
args,
|
|
472
496
|
returnTypes: []
|
|
473
497
|
});
|
|
474
|
-
return this.executeUtilityCall(call,
|
|
498
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
475
499
|
}
|
|
476
|
-
async executeUtilityCall(call, scopes) {
|
|
500
|
+
async executeUtilityCall(call, scopes, jobId) {
|
|
477
501
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
478
502
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
479
503
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -496,9 +520,12 @@ export class TXEOracleTopLevelContext {
|
|
|
496
520
|
aztecNode: this.stateMachine.node,
|
|
497
521
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
498
522
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
499
|
-
|
|
523
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
500
524
|
privateEventStore: this.privateEventStore,
|
|
501
|
-
|
|
525
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
526
|
+
contractSyncService: this.contractSyncService,
|
|
527
|
+
l2TipsStore: this.stateMachine.node,
|
|
528
|
+
jobId,
|
|
502
529
|
scopes
|
|
503
530
|
});
|
|
504
531
|
const acirExecutionResult = await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
@@ -510,10 +537,10 @@ export class TXEOracleTopLevelContext {
|
|
|
510
537
|
cause: err
|
|
511
538
|
});
|
|
512
539
|
});
|
|
513
|
-
this.logger.verbose(`Utility
|
|
540
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
514
541
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
515
542
|
} catch (err) {
|
|
516
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
543
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
517
544
|
}
|
|
518
545
|
}
|
|
519
546
|
close() {
|