@aztec/txe 0.0.1-commit.24de95ac → 0.0.1-commit.2e2504e2
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/bin/index.d.ts +1 -1
- 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 +11 -8
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +7 -7
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +10 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +22 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +128 -79
- package/dest/rpc_translator.d.ts +32 -17
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +134 -60
- package/dest/state_machine/archiver.d.ts +21 -51
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +63 -94
- package/dest/state_machine/dummy_p2p_client.d.ts +9 -6
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +16 -8
- package/dest/state_machine/global_variable_builder.d.ts +6 -4
- 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 +39 -22
- package/dest/state_machine/mock_epoch_cache.d.ts +12 -10
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +17 -13
- package/dest/state_machine/synchronizer.d.ts +3 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +21 -13
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +101 -49
- package/dest/util/encoding.d.ts +615 -16
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +1 -1
- package/dest/util/expected_failure_error.d.ts +1 -1
- package/dest/util/expected_failure_error.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 +7 -6
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +11 -11
- package/dest/utils/block_creation.d.ts +21 -6
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +38 -4
- package/dest/utils/tx_effect_creation.d.ts +3 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +4 -7
- package/package.json +18 -17
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +10 -7
- package/src/oracle/txe_oracle_public_context.ts +12 -19
- package/src/oracle/txe_oracle_top_level_context.ts +205 -107
- package/src/rpc_translator.ts +159 -63
- package/src/state_machine/archiver.ts +63 -117
- package/src/state_machine/dummy_p2p_client.ts +22 -10
- package/src/state_machine/global_variable_builder.ts +22 -4
- package/src/state_machine/index.ts +59 -21
- package/src/state_machine/mock_epoch_cache.ts +20 -20
- package/src/state_machine/synchronizer.ts +6 -5
- package/src/txe_session.ts +197 -85
- package/src/util/encoding.ts +1 -1
- 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 +13 -12
- package/src/utils/block_creation.ts +49 -14
- package/src/utils/tx_effect_creation.ts +5 -12
- 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
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { KeyStore } from '@aztec/key-store';
|
|
4
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
5
|
-
import {
|
|
6
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
7
|
-
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';
|
|
8
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
10
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
11
|
-
import {
|
|
12
|
+
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
13
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
12
14
|
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
13
15
|
import { z } from 'zod';
|
|
16
|
+
import { DEFAULT_ADDRESS } from './constants.js';
|
|
14
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
15
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
16
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
20
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
17
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
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';
|
|
21
25
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
22
|
-
const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
23
26
|
/**
|
|
24
27
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
25
28
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -27,28 +30,42 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
27
30
|
logger;
|
|
28
31
|
stateMachine;
|
|
29
32
|
oracleHandler;
|
|
30
|
-
|
|
33
|
+
contractStore;
|
|
34
|
+
noteStore;
|
|
31
35
|
keyStore;
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
addressStore;
|
|
37
|
+
accountStore;
|
|
38
|
+
senderTaggingStore;
|
|
39
|
+
recipientTaggingStore;
|
|
40
|
+
senderAddressBookStore;
|
|
41
|
+
capsuleStore;
|
|
42
|
+
privateEventStore;
|
|
43
|
+
jobCoordinator;
|
|
44
|
+
currentJobId;
|
|
34
45
|
chainId;
|
|
35
46
|
version;
|
|
36
47
|
nextBlockTimestamp;
|
|
37
|
-
pxeOracleInterface;
|
|
38
48
|
state;
|
|
39
49
|
authwits;
|
|
40
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
50
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp){
|
|
41
51
|
this.logger = logger;
|
|
42
52
|
this.stateMachine = stateMachine;
|
|
43
53
|
this.oracleHandler = oracleHandler;
|
|
44
|
-
this.
|
|
54
|
+
this.contractStore = contractStore;
|
|
55
|
+
this.noteStore = noteStore;
|
|
45
56
|
this.keyStore = keyStore;
|
|
46
|
-
this.
|
|
47
|
-
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;
|
|
48
66
|
this.chainId = chainId;
|
|
49
67
|
this.version = version;
|
|
50
68
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
51
|
-
this.pxeOracleInterface = pxeOracleInterface;
|
|
52
69
|
this.state = {
|
|
53
70
|
name: 'TOP_LEVEL'
|
|
54
71
|
};
|
|
@@ -56,27 +73,40 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
56
73
|
}
|
|
57
74
|
static async init(protocolContracts) {
|
|
58
75
|
const store = await openTmpStore('txe-session');
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
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);
|
|
65
84
|
const keyStore = new KeyStore(store);
|
|
66
|
-
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
|
+
]);
|
|
67
95
|
// Register protocol contracts.
|
|
68
96
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
69
|
-
await
|
|
70
|
-
await
|
|
97
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
98
|
+
await contractStore.addContractInstance(instance);
|
|
71
99
|
}
|
|
72
|
-
const
|
|
100
|
+
const archiver = new TXEArchiver(store);
|
|
101
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
102
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
73
103
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
74
104
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
75
105
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
76
|
-
const
|
|
77
|
-
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());
|
|
78
108
|
await topLevelOracleHandler.txeAdvanceBlocksBy(1);
|
|
79
|
-
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);
|
|
80
110
|
}
|
|
81
111
|
/**
|
|
82
112
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -125,7 +155,10 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
125
155
|
this.state;
|
|
126
156
|
}
|
|
127
157
|
}
|
|
128
|
-
|
|
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);
|
|
129
162
|
this.state = {
|
|
130
163
|
name: 'TOP_LEVEL'
|
|
131
164
|
};
|
|
@@ -133,27 +166,24 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
133
166
|
}
|
|
134
167
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
135
168
|
this.exitTopLevelState();
|
|
136
|
-
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
137
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
138
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
139
|
-
// be removed from the database.
|
|
140
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
141
|
-
await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
|
|
142
169
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
143
170
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
144
171
|
// a single transaction with the effects of what was done in the test.
|
|
145
172
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
173
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
146
174
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
147
175
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
148
|
-
blockNumber: latestBlock.globalVariables.blockNumber + 1,
|
|
176
|
+
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
149
177
|
timestamp: this.nextBlockTimestamp,
|
|
150
178
|
version: this.version,
|
|
151
179
|
chainId: this.chainId
|
|
152
180
|
});
|
|
153
181
|
const txRequestHash = getSingleTxBlockRequestHash(nextBlockGlobalVariables.blockNumber);
|
|
154
|
-
const
|
|
182
|
+
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
183
|
+
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
155
184
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
156
|
-
|
|
185
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
186
|
+
this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, utilityExecutor, [], [], new HashedValuesCache(), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.stateMachine.contractSyncService, this.currentJobId);
|
|
157
187
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
158
188
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
159
189
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -162,7 +192,6 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
162
192
|
this.state = {
|
|
163
193
|
name: 'PRIVATE',
|
|
164
194
|
nextBlockGlobalVariables,
|
|
165
|
-
txRequestHash,
|
|
166
195
|
noteCache,
|
|
167
196
|
taggingIndexCache
|
|
168
197
|
};
|
|
@@ -175,7 +204,7 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
175
204
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
176
205
|
const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.blockNumber;
|
|
177
206
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
178
|
-
blockNumber: latestBlockNumber + 1,
|
|
207
|
+
blockNumber: BlockNumber(latestBlockNumber + 1),
|
|
179
208
|
timestamp: this.nextBlockTimestamp,
|
|
180
209
|
version: this.version,
|
|
181
210
|
chainId: this.chainId
|
|
@@ -188,13 +217,14 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
188
217
|
}
|
|
189
218
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
190
219
|
this.exitTopLevelState();
|
|
220
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
191
221
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
192
222
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
193
223
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
194
224
|
// be removed from the database.
|
|
195
225
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
196
|
-
await this.
|
|
197
|
-
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], this.
|
|
226
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
227
|
+
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId);
|
|
198
228
|
this.state = {
|
|
199
229
|
name: 'UTILITY'
|
|
200
230
|
};
|
|
@@ -224,13 +254,13 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
224
254
|
});
|
|
225
255
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
226
256
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
227
|
-
const txEffect = await makeTxEffect(this.state.noteCache, this.state.
|
|
257
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
228
258
|
// We build a block holding just this transaction
|
|
229
259
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
230
260
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
231
|
-
const block =
|
|
261
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
|
|
232
262
|
txEffect
|
|
233
|
-
])
|
|
263
|
+
]);
|
|
234
264
|
await this.stateMachine.handleL2Block(block);
|
|
235
265
|
await forkedWorldTrees.close();
|
|
236
266
|
this.logger.debug('Exited PublicContext with built block', {
|
|
@@ -250,4 +280,26 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
250
280
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
251
281
|
}
|
|
252
282
|
}
|
|
283
|
+
utilityExecutorForContractSync(anchorBlock) {
|
|
284
|
+
return async (call)=>{
|
|
285
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
286
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
287
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlock, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId);
|
|
291
|
+
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
292
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
293
|
+
throw new ExecutionError(err.message, {
|
|
294
|
+
contractAddress: call.to,
|
|
295
|
+
functionSelector: call.selector
|
|
296
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
297
|
+
cause: err
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
} catch (err) {
|
|
301
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
253
305
|
}
|