@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.1142ef1
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 +4 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +3 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +15 -13
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +61 -51
- package/dest/state_machine/archiver.d.ts +6 -4
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +35 -12
- package/dest/state_machine/dummy_p2p_client.d.ts +8 -7
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +13 -10
- package/dest/state_machine/global_variable_builder.d.ts +2 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +1 -1
- package/dest/state_machine/index.d.ts +4 -4
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +7 -7
- package/dest/state_machine/mock_epoch_cache.d.ts +2 -1
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +3 -0
- package/dest/txe_session.d.ts +15 -14
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +68 -46
- 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 +1 -1
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +1 -2
- package/package.json +15 -15
- package/src/constants.ts +4 -0
- package/src/index.ts +1 -1
- package/src/oracle/txe_oracle_top_level_context.ts +89 -67
- package/src/state_machine/archiver.ts +37 -6
- package/src/state_machine/dummy_p2p_client.ts +18 -13
- package/src/state_machine/global_variable_builder.ts +1 -1
- package/src/state_machine/index.ts +5 -5
- package/src/state_machine/mock_epoch_cache.ts +4 -0
- package/src/txe_session.ts +138 -79
- 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 +2 -2
- 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
|
@@ -6,7 +6,7 @@ import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
|
6
6
|
import { type CheckpointGlobalVariables, type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
8
|
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
9
|
-
public
|
|
9
|
+
public getCurrentMinFees(): Promise<GasFees> {
|
|
10
10
|
return Promise.resolve(new GasFees(0, 0));
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -2,7 +2,7 @@ import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
|
2
2
|
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
|
-
import {
|
|
5
|
+
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
6
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
8
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -22,13 +22,13 @@ export class TXEStateMachine {
|
|
|
22
22
|
public node: AztecNode,
|
|
23
23
|
public synchronizer: TXESynchronizer,
|
|
24
24
|
public archiver: TXEArchiver,
|
|
25
|
-
public
|
|
25
|
+
public anchorBlockStore: AnchorBlockStore,
|
|
26
26
|
) {}
|
|
27
27
|
|
|
28
28
|
public static async create(db: AztecAsyncKVStore) {
|
|
29
29
|
const archiver = new TXEArchiver(db);
|
|
30
30
|
const synchronizer = await TXESynchronizer.create();
|
|
31
|
-
const
|
|
31
|
+
const anchorBlockStore = new AnchorBlockStore(db);
|
|
32
32
|
|
|
33
33
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
34
34
|
|
|
@@ -55,7 +55,7 @@ export class TXEStateMachine {
|
|
|
55
55
|
log,
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
return new this(node, synchronizer, archiver,
|
|
58
|
+
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public async handleL2Block(block: L2Block) {
|
|
@@ -72,7 +72,7 @@ export class TXEStateMachine {
|
|
|
72
72
|
await Promise.all([
|
|
73
73
|
this.synchronizer.handleL2Block(block.toL2Block()),
|
|
74
74
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
75
|
-
this.
|
|
75
|
+
this.anchorBlockStore.setHeader(block.getBlockHeader()),
|
|
76
76
|
]);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -54,6 +54,10 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
58
|
+
return Promise.resolve(undefined);
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean> {
|
|
58
62
|
return Promise.resolve(false);
|
|
59
63
|
}
|
package/src/txe_session.ts
CHANGED
|
@@ -5,13 +5,14 @@ import { KeyStore } from '@aztec/key-store';
|
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
6
|
import type { ProtocolContract } from '@aztec/protocol-contracts';
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
NoteDataProvider,
|
|
8
|
+
AddressStore,
|
|
9
|
+
CapsuleStore,
|
|
11
10
|
NoteService,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
NoteStore,
|
|
12
|
+
PrivateEventStore,
|
|
13
|
+
RecipientTaggingStore,
|
|
14
|
+
SenderAddressBookStore,
|
|
15
|
+
SenderTaggingStore,
|
|
15
16
|
} from '@aztec/pxe/server';
|
|
16
17
|
import {
|
|
17
18
|
ExecutionNoteCache,
|
|
@@ -19,10 +20,19 @@ import {
|
|
|
19
20
|
HashedValuesCache,
|
|
20
21
|
type IPrivateExecutionOracle,
|
|
21
22
|
type IUtilityExecutionOracle,
|
|
23
|
+
Oracle,
|
|
22
24
|
PrivateExecutionOracle,
|
|
23
25
|
UtilityExecutionOracle,
|
|
24
26
|
} from '@aztec/pxe/simulator';
|
|
25
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
ExecutionError,
|
|
29
|
+
WASMSimulator,
|
|
30
|
+
createSimulationError,
|
|
31
|
+
extractCallStack,
|
|
32
|
+
resolveAssertionMessageFromError,
|
|
33
|
+
toACVMWitness,
|
|
34
|
+
} from '@aztec/simulator/client';
|
|
35
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
26
36
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
27
37
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
28
38
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -33,14 +43,15 @@ import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
|
|
|
33
43
|
|
|
34
44
|
import { z } from 'zod';
|
|
35
45
|
|
|
46
|
+
import { DEFAULT_ADDRESS, TXE_JOB_ID } from './constants.js';
|
|
36
47
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
37
48
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
38
49
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
39
50
|
import { RPCTranslator } from './rpc_translator.js';
|
|
40
51
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
41
52
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
53
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
54
|
+
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
44
55
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
45
56
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
46
57
|
|
|
@@ -102,8 +113,6 @@ export interface TXESessionStateHandler {
|
|
|
102
113
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
103
114
|
}
|
|
104
115
|
|
|
105
|
-
export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
106
|
-
|
|
107
116
|
/**
|
|
108
117
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
109
118
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -120,15 +129,16 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
120
129
|
| IPrivateExecutionOracle
|
|
121
130
|
| IAvmExecutionOracle
|
|
122
131
|
| ITxeExecutionOracle,
|
|
123
|
-
private
|
|
124
|
-
private
|
|
132
|
+
private contractStore: TXEContractStore,
|
|
133
|
+
private noteStore: NoteStore,
|
|
125
134
|
private keyStore: KeyStore,
|
|
126
|
-
private
|
|
127
|
-
private
|
|
128
|
-
private
|
|
129
|
-
private
|
|
130
|
-
private
|
|
131
|
-
private
|
|
135
|
+
private addressStore: AddressStore,
|
|
136
|
+
private accountStore: TXEAccountStore,
|
|
137
|
+
private senderTaggingStore: SenderTaggingStore,
|
|
138
|
+
private recipientTaggingStore: RecipientTaggingStore,
|
|
139
|
+
private senderAddressBookStore: SenderAddressBookStore,
|
|
140
|
+
private capsuleStore: CapsuleStore,
|
|
141
|
+
private privateEventStore: PrivateEventStore,
|
|
132
142
|
private chainId: Fr,
|
|
133
143
|
private version: Fr,
|
|
134
144
|
private nextBlockTimestamp: bigint,
|
|
@@ -137,20 +147,21 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
137
147
|
static async init(protocolContracts: ProtocolContract[]) {
|
|
138
148
|
const store = await openTmpStore('txe-session');
|
|
139
149
|
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
150
|
+
const addressStore = new AddressStore(store);
|
|
151
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
152
|
+
const contractStore = new TXEContractStore(store);
|
|
153
|
+
const noteStore = await NoteStore.create(store);
|
|
154
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
155
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
156
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
157
|
+
const capsuleStore = new CapsuleStore(store);
|
|
147
158
|
const keyStore = new KeyStore(store);
|
|
148
|
-
const
|
|
159
|
+
const accountStore = new TXEAccountStore(store);
|
|
149
160
|
|
|
150
161
|
// Register protocol contracts.
|
|
151
162
|
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
152
|
-
await
|
|
153
|
-
await
|
|
163
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
164
|
+
await contractStore.addContractInstance(instance);
|
|
154
165
|
}
|
|
155
166
|
|
|
156
167
|
const stateMachine = await TXEStateMachine.create(store);
|
|
@@ -161,15 +172,16 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
161
172
|
|
|
162
173
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
163
174
|
stateMachine,
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
contractStore,
|
|
176
|
+
noteStore,
|
|
166
177
|
keyStore,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
addressStore,
|
|
179
|
+
accountStore,
|
|
180
|
+
senderTaggingStore,
|
|
181
|
+
recipientTaggingStore,
|
|
182
|
+
senderAddressBookStore,
|
|
183
|
+
capsuleStore,
|
|
184
|
+
privateEventStore,
|
|
173
185
|
nextBlockTimestamp,
|
|
174
186
|
version,
|
|
175
187
|
chainId,
|
|
@@ -181,15 +193,16 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
181
193
|
createLogger('txe:session'),
|
|
182
194
|
stateMachine,
|
|
183
195
|
topLevelOracleHandler,
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
contractStore,
|
|
197
|
+
noteStore,
|
|
186
198
|
keyStore,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
199
|
+
addressStore,
|
|
200
|
+
accountStore,
|
|
201
|
+
senderTaggingStore,
|
|
202
|
+
recipientTaggingStore,
|
|
203
|
+
senderAddressBookStore,
|
|
204
|
+
capsuleStore,
|
|
205
|
+
privateEventStore,
|
|
193
206
|
version,
|
|
194
207
|
chainId,
|
|
195
208
|
nextBlockTimestamp,
|
|
@@ -251,15 +264,16 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
251
264
|
|
|
252
265
|
this.oracleHandler = new TXEOracleTopLevelContext(
|
|
253
266
|
this.stateMachine,
|
|
254
|
-
this.
|
|
255
|
-
this.
|
|
267
|
+
this.contractStore,
|
|
268
|
+
this.noteStore,
|
|
256
269
|
this.keyStore,
|
|
257
|
-
this.
|
|
258
|
-
this.
|
|
259
|
-
this.
|
|
260
|
-
this.
|
|
261
|
-
this.
|
|
262
|
-
this.
|
|
270
|
+
this.addressStore,
|
|
271
|
+
this.accountStore,
|
|
272
|
+
this.senderTaggingStore,
|
|
273
|
+
this.recipientTaggingStore,
|
|
274
|
+
this.senderAddressBookStore,
|
|
275
|
+
this.capsuleStore,
|
|
276
|
+
this.privateEventStore,
|
|
263
277
|
this.nextBlockTimestamp,
|
|
264
278
|
this.version,
|
|
265
279
|
this.chainId,
|
|
@@ -276,15 +290,10 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
276
290
|
): Promise<PrivateContextInputs> {
|
|
277
291
|
this.exitTopLevelState();
|
|
278
292
|
|
|
279
|
-
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
280
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
281
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
282
|
-
// be removed from the database.
|
|
283
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
284
293
|
await new NoteService(
|
|
285
|
-
this.
|
|
294
|
+
this.noteStore,
|
|
286
295
|
this.stateMachine.node,
|
|
287
|
-
this.stateMachine.
|
|
296
|
+
this.stateMachine.anchorBlockStore,
|
|
288
297
|
).syncNoteNullifiers(contractAddress);
|
|
289
298
|
|
|
290
299
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
@@ -305,26 +314,30 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
305
314
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
306
315
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
307
316
|
|
|
317
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
308
318
|
this.oracleHandler = new PrivateExecutionOracle(
|
|
309
319
|
Fr.ZERO,
|
|
310
320
|
new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
311
321
|
new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
312
322
|
anchorBlock!,
|
|
323
|
+
utilityExecutor,
|
|
313
324
|
[],
|
|
314
325
|
[],
|
|
315
326
|
new HashedValuesCache(),
|
|
316
327
|
noteCache,
|
|
317
328
|
taggingIndexCache,
|
|
318
|
-
this.
|
|
319
|
-
this.
|
|
329
|
+
this.contractStore,
|
|
330
|
+
this.noteStore,
|
|
320
331
|
this.keyStore,
|
|
321
|
-
this.
|
|
332
|
+
this.addressStore,
|
|
322
333
|
this.stateMachine.node,
|
|
323
|
-
this.stateMachine.
|
|
324
|
-
this.
|
|
325
|
-
this.
|
|
326
|
-
this.
|
|
327
|
-
this.
|
|
334
|
+
this.stateMachine.anchorBlockStore,
|
|
335
|
+
this.senderTaggingStore,
|
|
336
|
+
this.recipientTaggingStore,
|
|
337
|
+
this.senderAddressBookStore,
|
|
338
|
+
this.capsuleStore,
|
|
339
|
+
this.privateEventStore,
|
|
340
|
+
TXE_JOB_ID,
|
|
328
341
|
);
|
|
329
342
|
|
|
330
343
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -371,28 +384,29 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
371
384
|
// be removed from the database.
|
|
372
385
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
373
386
|
await new NoteService(
|
|
374
|
-
this.
|
|
387
|
+
this.noteStore,
|
|
375
388
|
this.stateMachine.node,
|
|
376
|
-
this.stateMachine.
|
|
389
|
+
this.stateMachine.anchorBlockStore,
|
|
377
390
|
).syncNoteNullifiers(contractAddress);
|
|
378
391
|
|
|
379
|
-
const anchorBlockHeader = await this.stateMachine.
|
|
392
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
380
393
|
|
|
381
394
|
this.oracleHandler = new UtilityExecutionOracle(
|
|
382
395
|
contractAddress,
|
|
383
396
|
[],
|
|
384
397
|
[],
|
|
385
398
|
anchorBlockHeader,
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
399
|
+
this.contractStore,
|
|
400
|
+
this.noteStore,
|
|
388
401
|
this.keyStore,
|
|
389
|
-
this.
|
|
402
|
+
this.addressStore,
|
|
390
403
|
this.stateMachine.node,
|
|
391
|
-
this.stateMachine.
|
|
392
|
-
this.
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
395
|
-
this.
|
|
404
|
+
this.stateMachine.anchorBlockStore,
|
|
405
|
+
this.recipientTaggingStore,
|
|
406
|
+
this.senderAddressBookStore,
|
|
407
|
+
this.capsuleStore,
|
|
408
|
+
this.privateEventStore,
|
|
409
|
+
TXE_JOB_ID,
|
|
396
410
|
);
|
|
397
411
|
|
|
398
412
|
this.state = { name: 'UTILITY' };
|
|
@@ -463,4 +477,49 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
463
477
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
464
478
|
}
|
|
465
479
|
}
|
|
480
|
+
|
|
481
|
+
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
482
|
+
return async (call: FunctionCall) => {
|
|
483
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
484
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
485
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
try {
|
|
489
|
+
const oracle = new UtilityExecutionOracle(
|
|
490
|
+
call.to,
|
|
491
|
+
[],
|
|
492
|
+
[],
|
|
493
|
+
anchorBlock!,
|
|
494
|
+
this.contractStore,
|
|
495
|
+
this.noteStore,
|
|
496
|
+
this.keyStore,
|
|
497
|
+
this.addressStore,
|
|
498
|
+
this.stateMachine.node,
|
|
499
|
+
this.stateMachine.anchorBlockStore,
|
|
500
|
+
this.recipientTaggingStore,
|
|
501
|
+
this.senderAddressBookStore,
|
|
502
|
+
this.capsuleStore,
|
|
503
|
+
this.privateEventStore,
|
|
504
|
+
TXE_JOB_ID,
|
|
505
|
+
);
|
|
506
|
+
await new WASMSimulator()
|
|
507
|
+
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
508
|
+
.catch((err: Error) => {
|
|
509
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
510
|
+
throw new ExecutionError(
|
|
511
|
+
err.message,
|
|
512
|
+
{
|
|
513
|
+
contractAddress: call.to,
|
|
514
|
+
functionSelector: call.selector,
|
|
515
|
+
},
|
|
516
|
+
extractCallStack(err, entryPointArtifact.debug),
|
|
517
|
+
{ cause: err },
|
|
518
|
+
);
|
|
519
|
+
});
|
|
520
|
+
} catch (err) {
|
|
521
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
}
|
|
466
525
|
}
|
|
@@ -2,7 +2,7 @@ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
4
|
|
|
5
|
-
export class
|
|
5
|
+
export class TXEAccountStore {
|
|
6
6
|
#accounts: AztecAsyncMap<string, Buffer>;
|
|
7
7
|
|
|
8
8
|
constructor(store: AztecAsyncKVStore) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
2
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import {
|
|
3
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
4
4
|
|
|
5
5
|
export type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* A contract
|
|
8
|
+
* A contract store that stores contract artifacts with their hashes. Since
|
|
9
9
|
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
10
10
|
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
11
11
|
*/
|
|
12
|
-
export class
|
|
12
|
+
export class TXEContractStore extends ContractStore {
|
|
13
13
|
#artifactHashes: Map<string, Buffer> = new Map();
|
|
14
14
|
|
|
15
15
|
public override async addContractArtifact(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
4
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import {
|
|
@@ -16,7 +16,7 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
16
16
|
#privateFunctionsRoot: Map<string, Buffer> = new Map();
|
|
17
17
|
constructor(
|
|
18
18
|
private blockNumber: BlockNumber,
|
|
19
|
-
private
|
|
19
|
+
private contractStore: ContractStore,
|
|
20
20
|
) {}
|
|
21
21
|
|
|
22
22
|
getBlockNumber(): Promise<BlockNumber> {
|
|
@@ -24,11 +24,11 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
27
|
-
const contractClass = await this.
|
|
27
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
28
28
|
if (!contractClass) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const artifact = await this.
|
|
31
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
32
32
|
if (!artifact) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -58,12 +58,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
61
|
-
const contractClass = await this.
|
|
61
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
62
62
|
return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
66
|
-
const instance = await this.
|
|
66
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
67
67
|
return instance && { ...instance, address };
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -72,12 +72,12 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
async getContractArtifact(address: AztecAddress): Promise<ContractArtifact | undefined> {
|
|
75
|
-
const instance = await this.
|
|
76
|
-
return instance && this.
|
|
75
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
76
|
+
return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
80
|
-
return await this.
|
|
80
|
+
return await this.contractStore.getDebugFunctionName(address, selector);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
registerContractFunctionSignatures(_signatures: []): Promise<void> {
|
|
@@ -8,7 +8,6 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
10
|
import { Body, L2Block, L2BlockHeader } from '@aztec/stdlib/block';
|
|
11
|
-
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
12
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
13
12
|
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
14
13
|
|
|
@@ -53,7 +52,8 @@ export async function makeTXEBlockHeader(
|
|
|
53
52
|
|
|
54
53
|
return new L2BlockHeader(
|
|
55
54
|
new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
56
|
-
|
|
55
|
+
Fr.ZERO,
|
|
56
|
+
Fr.ZERO,
|
|
57
57
|
stateReference,
|
|
58
58
|
globalVariables,
|
|
59
59
|
Fr.ZERO,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
-
export declare class TXEAccountDataProvider {
|
|
5
|
-
#private;
|
|
6
|
-
constructor(store: AztecAsyncKVStore);
|
|
7
|
-
getAccount(key: AztecAddress): Promise<CompleteAddress>;
|
|
8
|
-
setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfZGF0YV9wcm92aWRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX2FjY291bnRfZGF0YV9wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsc0JBQXNCOztJQUdqQyxZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"txe_account_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,sBAAsB;;IAGjC,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { ContractDataProvider } from '@aztec/pxe/server';
|
|
4
|
-
export type ContractArtifactWithHash = ContractArtifact & {
|
|
5
|
-
artifactHash: Fr;
|
|
6
|
-
};
|
|
7
|
-
export declare class TXEContractDataProvider extends ContractDataProvider {
|
|
8
|
-
#private;
|
|
9
|
-
addContractArtifact(id: Fr, artifact: ContractArtifact | ContractArtifactWithHash): Promise<void>;
|
|
10
|
-
getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | ContractArtifactWithHash | undefined>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X2RhdGFfcHJvdmlkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9jb250cmFjdF9kYXRhX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzVDLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRXpELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLHVCQUF3QixTQUFRLG9CQUFvQjs7SUFHekMsbUJBQW1CLENBQ3ZDLEVBQUUsRUFBRSxFQUFFLEVBQ04sUUFBUSxFQUFFLGdCQUFnQixHQUFHLHdCQUF3QixHQUNwRCxPQUFPLENBQUMsSUFBSSxDQUFDLENBS2Y7SUFFcUIsbUJBQW1CLENBQ3ZDLGVBQWUsRUFBRSxFQUFFLEdBQ2xCLE9BQU8sQ0FBQyxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FBRyxTQUFTLENBQUMsQ0FRbEU7Q0FDRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"txe_contract_data_provider.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,uBAAwB,SAAQ,oBAAoB;;IAGzC,mBAAmB,CACvC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,gBAAgB,GAAG,wBAAwB,GACpD,OAAO,CAAC,IAAI,CAAC,CAKf;IAEqB,mBAAmB,CACvC,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,gBAAgB,GAAG,wBAAwB,GAAG,SAAS,CAAC,CAQlE;CACF"}
|