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