@aztec/txe 3.0.3 → 4.0.0-devnet.1-patch.1
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/constants.d.ts +3 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +2 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -2
- package/dest/oracle/interfaces.d.ts +6 -4
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +4 -4
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +9 -11
- package/dest/oracle/txe_oracle_top_level_context.d.ts +20 -11
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +164 -65
- package/dest/rpc_translator.d.ts +27 -15
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +108 -53
- package/dest/state_machine/archiver.d.ts +20 -55
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +62 -103
- package/dest/state_machine/dummy_p2p_client.d.ts +14 -12
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +29 -21
- package/dest/state_machine/global_variable_builder.d.ts +4 -3
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +13 -1
- package/dest/state_machine/index.d.ts +7 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +40 -23
- package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +14 -7
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/txe_session.d.ts +17 -9
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +147 -45
- package/dest/util/encoding.d.ts +617 -18
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/txe_account_store.d.ts +10 -0
- package/dest/util/txe_account_store.d.ts.map +1 -0
- package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
- package/dest/util/txe_contract_store.d.ts +12 -0
- package/dest/util/txe_contract_store.d.ts.map +1 -0
- package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
- package/dest/util/txe_public_contract_data_source.d.ts +4 -4
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +10 -10
- package/dest/utils/block_creation.d.ts +18 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +37 -3
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/package.json +16 -16
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +5 -3
- package/src/oracle/txe_oracle_public_context.ts +9 -16
- package/src/oracle/txe_oracle_top_level_context.ts +196 -105
- package/src/rpc_translator.ts +123 -55
- package/src/state_machine/archiver.ts +58 -126
- package/src/state_machine/dummy_p2p_client.ts +40 -27
- package/src/state_machine/global_variable_builder.ts +19 -2
- package/src/state_machine/index.ts +60 -22
- package/src/state_machine/mock_epoch_cache.ts +15 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +197 -87
- package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
- package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
- package/src/util/txe_public_contract_data_source.ts +9 -9
- package/src/utils/block_creation.ts +47 -14
- package/src/utils/tx_effect_creation.ts +3 -11
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
package/dest/txe_session.js
CHANGED
|
@@ -3,25 +3,26 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
-
import {
|
|
7
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
|
-
import {
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
|
+
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
|
+
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
9
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
12
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
13
|
-
import {
|
|
13
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
14
14
|
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
+
import { DEFAULT_ADDRESS } from './constants.js';
|
|
16
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
17
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
18
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
20
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
19
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees,
|
|
22
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
23
|
+
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
24
|
+
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
23
25
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
24
|
-
const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
25
26
|
/**
|
|
26
27
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
27
28
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -29,28 +30,42 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
29
30
|
logger;
|
|
30
31
|
stateMachine;
|
|
31
32
|
oracleHandler;
|
|
32
|
-
|
|
33
|
+
contractStore;
|
|
34
|
+
noteStore;
|
|
33
35
|
keyStore;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
addressStore;
|
|
37
|
+
accountStore;
|
|
38
|
+
senderTaggingStore;
|
|
39
|
+
recipientTaggingStore;
|
|
40
|
+
senderAddressBookStore;
|
|
41
|
+
capsuleStore;
|
|
42
|
+
privateEventStore;
|
|
43
|
+
jobCoordinator;
|
|
44
|
+
currentJobId;
|
|
36
45
|
chainId;
|
|
37
46
|
version;
|
|
38
47
|
nextBlockTimestamp;
|
|
39
|
-
pxeOracleInterface;
|
|
40
48
|
state;
|
|
41
49
|
authwits;
|
|
42
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
50
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp){
|
|
43
51
|
this.logger = logger;
|
|
44
52
|
this.stateMachine = stateMachine;
|
|
45
53
|
this.oracleHandler = oracleHandler;
|
|
46
|
-
this.
|
|
54
|
+
this.contractStore = contractStore;
|
|
55
|
+
this.noteStore = noteStore;
|
|
47
56
|
this.keyStore = keyStore;
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
57
|
+
this.addressStore = addressStore;
|
|
58
|
+
this.accountStore = accountStore;
|
|
59
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
60
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
61
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
62
|
+
this.capsuleStore = capsuleStore;
|
|
63
|
+
this.privateEventStore = privateEventStore;
|
|
64
|
+
this.jobCoordinator = jobCoordinator;
|
|
65
|
+
this.currentJobId = currentJobId;
|
|
50
66
|
this.chainId = chainId;
|
|
51
67
|
this.version = version;
|
|
52
68
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
53
|
-
this.pxeOracleInterface = pxeOracleInterface;
|
|
54
69
|
this.state = {
|
|
55
70
|
name: 'TOP_LEVEL'
|
|
56
71
|
};
|
|
@@ -58,27 +73,40 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
58
73
|
}
|
|
59
74
|
static async init(protocolContracts) {
|
|
60
75
|
const store = await openTmpStore('txe-session');
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
76
|
+
const addressStore = new AddressStore(store);
|
|
77
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
78
|
+
const contractStore = new TXEContractStore(store);
|
|
79
|
+
const noteStore = new NoteStore(store);
|
|
80
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
81
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
82
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
83
|
+
const capsuleStore = new CapsuleStore(store);
|
|
67
84
|
const keyStore = new KeyStore(store);
|
|
68
|
-
const
|
|
85
|
+
const accountStore = new TXEAccountStore(store);
|
|
86
|
+
// Create job coordinator and register staged stores
|
|
87
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
88
|
+
jobCoordinator.registerStores([
|
|
89
|
+
capsuleStore,
|
|
90
|
+
senderTaggingStore,
|
|
91
|
+
recipientTaggingStore,
|
|
92
|
+
privateEventStore,
|
|
93
|
+
noteStore
|
|
94
|
+
]);
|
|
69
95
|
// Register protocol contracts.
|
|
70
96
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
71
|
-
await
|
|
72
|
-
await
|
|
97
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
98
|
+
await contractStore.addContractInstance(instance);
|
|
73
99
|
}
|
|
74
|
-
const
|
|
100
|
+
const archiver = new TXEArchiver(store);
|
|
101
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
102
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
75
103
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
76
104
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
77
105
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
78
|
-
const
|
|
79
|
-
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine,
|
|
106
|
+
const initialJobId = jobCoordinator.beginJob();
|
|
107
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, initialJobId, nextBlockTimestamp, version, chainId, new Map());
|
|
80
108
|
await topLevelOracleHandler.txeAdvanceBlocksBy(1);
|
|
81
|
-
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler,
|
|
109
|
+
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp);
|
|
82
110
|
}
|
|
83
111
|
/**
|
|
84
112
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -127,7 +155,10 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
127
155
|
this.state;
|
|
128
156
|
}
|
|
129
157
|
}
|
|
130
|
-
|
|
158
|
+
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
159
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
160
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
161
|
+
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId, this.nextBlockTimestamp, this.version, this.chainId, this.authwits);
|
|
131
162
|
this.state = {
|
|
132
163
|
name: 'TOP_LEVEL'
|
|
133
164
|
};
|
|
@@ -135,16 +166,11 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
135
166
|
}
|
|
136
167
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
137
168
|
this.exitTopLevelState();
|
|
138
|
-
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
139
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
140
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
141
|
-
// be removed from the database.
|
|
142
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
143
|
-
await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
|
|
144
169
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
145
170
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
146
171
|
// a single transaction with the effects of what was done in the test.
|
|
147
172
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
173
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
148
174
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
149
175
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
150
176
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
@@ -156,7 +182,31 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
156
182
|
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
157
183
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
158
184
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
159
|
-
|
|
185
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
186
|
+
this.oracleHandler = new PrivateExecutionOracle({
|
|
187
|
+
argsHash: Fr.ZERO,
|
|
188
|
+
txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
189
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
190
|
+
anchorBlockHeader: anchorBlock,
|
|
191
|
+
utilityExecutor,
|
|
192
|
+
authWitnesses: [],
|
|
193
|
+
capsules: [],
|
|
194
|
+
executionCache: new HashedValuesCache(),
|
|
195
|
+
noteCache,
|
|
196
|
+
taggingIndexCache,
|
|
197
|
+
contractStore: this.contractStore,
|
|
198
|
+
noteStore: this.noteStore,
|
|
199
|
+
keyStore: this.keyStore,
|
|
200
|
+
addressStore: this.addressStore,
|
|
201
|
+
aztecNode: this.stateMachine.node,
|
|
202
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
203
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
204
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
205
|
+
capsuleStore: this.capsuleStore,
|
|
206
|
+
privateEventStore: this.privateEventStore,
|
|
207
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
208
|
+
jobId: this.currentJobId
|
|
209
|
+
});
|
|
160
210
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
161
211
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
162
212
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -165,7 +215,6 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
165
215
|
this.state = {
|
|
166
216
|
name: 'PRIVATE',
|
|
167
217
|
nextBlockGlobalVariables,
|
|
168
|
-
protocolNullifier,
|
|
169
218
|
noteCache,
|
|
170
219
|
taggingIndexCache
|
|
171
220
|
};
|
|
@@ -191,13 +240,29 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
191
240
|
}
|
|
192
241
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
193
242
|
this.exitTopLevelState();
|
|
243
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
194
244
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
195
245
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
196
246
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
197
247
|
// be removed from the database.
|
|
198
248
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
199
|
-
await this.
|
|
200
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
249
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
250
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
251
|
+
contractAddress,
|
|
252
|
+
authWitnesses: [],
|
|
253
|
+
capsules: [],
|
|
254
|
+
anchorBlockHeader,
|
|
255
|
+
contractStore: this.contractStore,
|
|
256
|
+
noteStore: this.noteStore,
|
|
257
|
+
keyStore: this.keyStore,
|
|
258
|
+
addressStore: this.addressStore,
|
|
259
|
+
aztecNode: this.stateMachine.node,
|
|
260
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
261
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
262
|
+
capsuleStore: this.capsuleStore,
|
|
263
|
+
privateEventStore: this.privateEventStore,
|
|
264
|
+
jobId: this.currentJobId
|
|
265
|
+
});
|
|
201
266
|
this.state = {
|
|
202
267
|
name: 'UTILITY'
|
|
203
268
|
};
|
|
@@ -227,13 +292,13 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
227
292
|
});
|
|
228
293
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
229
294
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
230
|
-
const txEffect = await makeTxEffect(this.state.noteCache, this.state.
|
|
295
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
231
296
|
// We build a block holding just this transaction
|
|
232
297
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
233
298
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
234
|
-
const block =
|
|
299
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
|
|
235
300
|
txEffect
|
|
236
|
-
])
|
|
301
|
+
]);
|
|
237
302
|
await this.stateMachine.handleL2Block(block);
|
|
238
303
|
await forkedWorldTrees.close();
|
|
239
304
|
this.logger.debug('Exited PublicContext with built block', {
|
|
@@ -253,4 +318,41 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
253
318
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
254
319
|
}
|
|
255
320
|
}
|
|
321
|
+
utilityExecutorForContractSync(anchorBlock) {
|
|
322
|
+
return async (call)=>{
|
|
323
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
324
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
325
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
const oracle = new UtilityExecutionOracle({
|
|
329
|
+
contractAddress: call.to,
|
|
330
|
+
authWitnesses: [],
|
|
331
|
+
capsules: [],
|
|
332
|
+
anchorBlockHeader: anchorBlock,
|
|
333
|
+
contractStore: this.contractStore,
|
|
334
|
+
noteStore: this.noteStore,
|
|
335
|
+
keyStore: this.keyStore,
|
|
336
|
+
addressStore: this.addressStore,
|
|
337
|
+
aztecNode: this.stateMachine.node,
|
|
338
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
339
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
340
|
+
capsuleStore: this.capsuleStore,
|
|
341
|
+
privateEventStore: this.privateEventStore,
|
|
342
|
+
jobId: this.currentJobId
|
|
343
|
+
});
|
|
344
|
+
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
345
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
346
|
+
throw new ExecutionError(err.message, {
|
|
347
|
+
contractAddress: call.to,
|
|
348
|
+
functionSelector: call.selector
|
|
349
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
350
|
+
cause: err
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
} catch (err) {
|
|
354
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
256
358
|
}
|