@aztec/txe 3.0.0-nightly.20260105 → 3.0.0-nightly.20260106
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/oracle/txe_oracle_top_level_context.d.ts +15 -14
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +61 -53
- 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/txe_session.d.ts +15 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +68 -49
- 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/package.json +15 -15
- package/src/constants.ts +3 -0
- package/src/index.ts +1 -1
- package/src/oracle/txe_oracle_top_level_context.ts +87 -70
- package/src/state_machine/index.ts +5 -5
- package/src/txe_session.ts +135 -86
- 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/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,24 +3,25 @@ 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, CapsuleStore, 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
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
11
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
12
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';
|
|
18
20
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
22
|
+
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
21
23
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
22
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
23
|
-
export 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,35 +29,35 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
28
29
|
logger;
|
|
29
30
|
stateMachine;
|
|
30
31
|
oracleHandler;
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
contractStore;
|
|
33
|
+
noteStore;
|
|
33
34
|
keyStore;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
addressStore;
|
|
36
|
+
accountStore;
|
|
37
|
+
senderTaggingStore;
|
|
38
|
+
recipientTaggingStore;
|
|
39
|
+
senderAddressBookStore;
|
|
40
|
+
capsuleStore;
|
|
41
|
+
privateEventStore;
|
|
41
42
|
chainId;
|
|
42
43
|
version;
|
|
43
44
|
nextBlockTimestamp;
|
|
44
45
|
state;
|
|
45
46
|
authwits;
|
|
46
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
47
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, chainId, version, nextBlockTimestamp){
|
|
47
48
|
this.logger = logger;
|
|
48
49
|
this.stateMachine = stateMachine;
|
|
49
50
|
this.oracleHandler = oracleHandler;
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
51
|
+
this.contractStore = contractStore;
|
|
52
|
+
this.noteStore = noteStore;
|
|
52
53
|
this.keyStore = keyStore;
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
54
|
+
this.addressStore = addressStore;
|
|
55
|
+
this.accountStore = accountStore;
|
|
56
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
57
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
58
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
59
|
+
this.capsuleStore = capsuleStore;
|
|
60
|
+
this.privateEventStore = privateEventStore;
|
|
60
61
|
this.chainId = chainId;
|
|
61
62
|
this.version = version;
|
|
62
63
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
@@ -67,28 +68,28 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
67
68
|
}
|
|
68
69
|
static async init(protocolContracts) {
|
|
69
70
|
const store = await openTmpStore('txe-session');
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
71
|
+
const addressStore = new AddressStore(store);
|
|
72
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
73
|
+
const contractStore = new TXEContractStore(store);
|
|
74
|
+
const noteStore = await NoteStore.create(store);
|
|
75
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
76
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
77
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
78
|
+
const capsuleStore = new CapsuleStore(store);
|
|
78
79
|
const keyStore = new KeyStore(store);
|
|
79
|
-
const
|
|
80
|
+
const accountStore = new TXEAccountStore(store);
|
|
80
81
|
// Register protocol contracts.
|
|
81
82
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
82
|
-
await
|
|
83
|
-
await
|
|
83
|
+
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
84
|
+
await contractStore.addContractInstance(instance);
|
|
84
85
|
}
|
|
85
86
|
const stateMachine = await TXEStateMachine.create(store);
|
|
86
87
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
87
88
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
88
89
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
89
|
-
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine,
|
|
90
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map());
|
|
90
91
|
await topLevelOracleHandler.txeAdvanceBlocksBy(1);
|
|
91
|
-
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler,
|
|
92
|
+
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, version, chainId, nextBlockTimestamp);
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -137,7 +138,7 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
137
138
|
this.state;
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
|
-
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.
|
|
141
|
+
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.nextBlockTimestamp, this.version, this.chainId, this.authwits);
|
|
141
142
|
this.state = {
|
|
142
143
|
name: 'TOP_LEVEL'
|
|
143
144
|
};
|
|
@@ -145,12 +146,7 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
145
146
|
}
|
|
146
147
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
147
148
|
this.exitTopLevelState();
|
|
148
|
-
|
|
149
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
150
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
151
|
-
// be removed from the database.
|
|
152
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
153
|
-
await new NoteService(this.noteDataProvider, this.stateMachine.node, this.stateMachine.anchorBlockDataProvider).syncNoteNullifiers(contractAddress);
|
|
149
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
154
150
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
155
151
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
156
152
|
// a single transaction with the effects of what was done in the test.
|
|
@@ -166,7 +162,8 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
166
162
|
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
167
163
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
168
164
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
169
|
-
|
|
165
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
166
|
+
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.stateMachine.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
170
167
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
171
168
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
172
169
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -206,9 +203,9 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
206
203
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
207
204
|
// be removed from the database.
|
|
208
205
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
209
|
-
await new NoteService(this.
|
|
210
|
-
const anchorBlockHeader = await this.stateMachine.
|
|
211
|
-
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.
|
|
206
|
+
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
207
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
208
|
+
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
212
209
|
this.state = {
|
|
213
210
|
name: 'UTILITY'
|
|
214
211
|
};
|
|
@@ -264,4 +261,26 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
264
261
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
265
262
|
}
|
|
266
263
|
}
|
|
264
|
+
utilityExecutorForContractSync(anchorBlock) {
|
|
265
|
+
return async (call)=>{
|
|
266
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
267
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
268
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlock, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
272
|
+
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
273
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
274
|
+
throw new ExecutionError(err.message, {
|
|
275
|
+
contractAddress: call.to,
|
|
276
|
+
functionSelector: call.selector
|
|
277
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
278
|
+
cause: err
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
} catch (err) {
|
|
282
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
267
286
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 TXEAccountStore {
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9hY2NvdW50X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RCxxQkFBYSxlQUFlOztJQUcxQixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txe_account_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_store.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,eAAe;;IAG1B,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
4
|
+
export type ContractArtifactWithHash = ContractArtifact & {
|
|
5
|
+
artifactHash: Fr;
|
|
6
|
+
};
|
|
7
|
+
export declare class TXEContractStore extends ContractStore {
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbC90eGVfY29udHJhY3Rfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM1RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUMsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWxELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLGdCQUFpQixTQUFRLGFBQWE7O0lBRzNCLG1CQUFtQixDQUN2QyxFQUFFLEVBQUUsRUFBRSxFQUNOLFFBQVEsRUFBRSxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FDcEQsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUtmO0lBRXFCLG1CQUFtQixDQUN2QyxlQUFlLEVBQUUsRUFBRSxHQUNsQixPQUFPLENBQUMsZ0JBQWdCLEdBQUcsd0JBQXdCLEdBQUcsU0FBUyxDQUFDLENBUWxFO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txe_contract_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,gBAAiB,SAAQ,aAAa;;IAG3B,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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
-
import {
|
|
2
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
3
3
|
/*
|
|
4
|
-
* A contract
|
|
4
|
+
* A contract store that stores contract artifacts with their hashes. Since
|
|
5
5
|
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
6
6
|
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
7
|
-
*/ export class
|
|
7
|
+
*/ export class TXEContractStore extends ContractStore {
|
|
8
8
|
#artifactHashes = new Map();
|
|
9
9
|
async addContractArtifact(id, artifact) {
|
|
10
10
|
if ('artifactHash' in artifact) {
|
|
@@ -1,14 +1,14 @@
|
|
|
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 } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
7
|
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
8
8
|
#private;
|
|
9
9
|
private blockNumber;
|
|
10
|
-
private
|
|
11
|
-
constructor(blockNumber: BlockNumber,
|
|
10
|
+
private contractStore;
|
|
11
|
+
constructor(blockNumber: BlockNumber, contractStore: ContractStore);
|
|
12
12
|
getBlockNumber(): Promise<BlockNumber>;
|
|
13
13
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
14
14
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
@@ -18,4 +18,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
18
18
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
19
19
|
registerContractFunctionSignatures(_signatures: []): Promise<void>;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFnQixNQUFNLG1CQUFtQixDQUFDO0FBQzFGLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFDTCxLQUFLLG1CQUFtQixFQUN4QixLQUFLLGtCQUFrQixFQUN2QixLQUFLLDJCQUEyQixFQUlqQyxNQUFNLHdCQUF3QixDQUFDO0FBRWhDLHFCQUFhLDJCQUE0QixZQUFXLGtCQUFrQjs7SUFHbEUsT0FBTyxDQUFDLFdBQVc7SUFDbkIsT0FBTyxDQUFDLGFBQWE7SUFGdkIsWUFDVSxXQUFXLEVBQUUsV0FBVyxFQUN4QixhQUFhLEVBQUUsYUFBYSxFQUNsQztJQUVKLGNBQWMsSUFBSSxPQUFPLENBQUMsV0FBVyxDQUFDLENBRXJDO0lBRUssZ0JBQWdCLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsbUJBQW1CLEdBQUcsU0FBUyxDQUFDLENBZ0N2RTtJQUVLLHFCQUFxQixDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FHM0Q7SUFFSyxXQUFXLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsMkJBQTJCLEdBQUcsU0FBUyxDQUFDLENBR3pGO0lBRUQsbUJBQW1CLElBQUksT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBRW5DO0lBRUssbUJBQW1CLENBQUMsT0FBTyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsZ0JBQWdCLEdBQUcsU0FBUyxDQUFDLENBR3RGO0lBRUssb0JBQW9CLENBQUMsT0FBTyxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUMsQ0FFekc7SUFFRCxrQ0FBa0MsQ0FBQyxXQUFXLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFakU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,2BAA4B,YAAW,kBAAkB;;IAGlE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IAFvB,YACU,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAClC;IAEJ,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAErC;IAEK,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAgCvE;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAG3D;IAEK,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAGzF;IAED,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAEnC;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAGtF;IAEK,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEzG;IAED,kCAAkC,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;CACF"}
|
|
@@ -3,22 +3,22 @@ import { FunctionType } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
|
|
4
4
|
export class TXEPublicContractDataSource {
|
|
5
5
|
blockNumber;
|
|
6
|
-
|
|
6
|
+
contractStore;
|
|
7
7
|
#privateFunctionsRoot;
|
|
8
|
-
constructor(blockNumber,
|
|
8
|
+
constructor(blockNumber, contractStore){
|
|
9
9
|
this.blockNumber = blockNumber;
|
|
10
|
-
this.
|
|
10
|
+
this.contractStore = contractStore;
|
|
11
11
|
this.#privateFunctionsRoot = new Map();
|
|
12
12
|
}
|
|
13
13
|
getBlockNumber() {
|
|
14
14
|
return Promise.resolve(this.blockNumber);
|
|
15
15
|
}
|
|
16
16
|
async getContractClass(id) {
|
|
17
|
-
const contractClass = await this.
|
|
17
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
18
18
|
if (!contractClass) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const artifact = await this.
|
|
21
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
22
22
|
if (!artifact) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -41,11 +41,11 @@ export class TXEPublicContractDataSource {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async getBytecodeCommitment(id) {
|
|
44
|
-
const contractClass = await this.
|
|
44
|
+
const contractClass = await this.contractStore.getContractClass(id);
|
|
45
45
|
return contractClass && computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
46
46
|
}
|
|
47
47
|
async getContract(address) {
|
|
48
|
-
const instance = await this.
|
|
48
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
49
49
|
return instance && {
|
|
50
50
|
...instance,
|
|
51
51
|
address
|
|
@@ -55,11 +55,11 @@ export class TXEPublicContractDataSource {
|
|
|
55
55
|
throw new Error('Method not implemented.');
|
|
56
56
|
}
|
|
57
57
|
async getContractArtifact(address) {
|
|
58
|
-
const instance = await this.
|
|
59
|
-
return instance && this.
|
|
58
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
59
|
+
return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
60
60
|
}
|
|
61
61
|
async getDebugFunctionName(address, selector) {
|
|
62
|
-
return await this.
|
|
62
|
+
return await this.contractStore.getDebugFunctionName(address, selector);
|
|
63
63
|
}
|
|
64
64
|
registerContractFunctionSignatures(_signatures) {
|
|
65
65
|
return Promise.resolve();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20260106",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/accounts": "3.0.0-nightly.
|
|
65
|
-
"@aztec/archiver": "3.0.0-nightly.
|
|
66
|
-
"@aztec/aztec-node": "3.0.0-nightly.
|
|
67
|
-
"@aztec/aztec.js": "3.0.0-nightly.
|
|
68
|
-
"@aztec/bb-prover": "3.0.0-nightly.
|
|
69
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
70
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
71
|
-
"@aztec/key-store": "3.0.0-nightly.
|
|
72
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
73
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
74
|
-
"@aztec/pxe": "3.0.0-nightly.
|
|
75
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
76
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
77
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
64
|
+
"@aztec/accounts": "3.0.0-nightly.20260106",
|
|
65
|
+
"@aztec/archiver": "3.0.0-nightly.20260106",
|
|
66
|
+
"@aztec/aztec-node": "3.0.0-nightly.20260106",
|
|
67
|
+
"@aztec/aztec.js": "3.0.0-nightly.20260106",
|
|
68
|
+
"@aztec/bb-prover": "3.0.0-nightly.20260106",
|
|
69
|
+
"@aztec/constants": "3.0.0-nightly.20260106",
|
|
70
|
+
"@aztec/foundation": "3.0.0-nightly.20260106",
|
|
71
|
+
"@aztec/key-store": "3.0.0-nightly.20260106",
|
|
72
|
+
"@aztec/kv-store": "3.0.0-nightly.20260106",
|
|
73
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20260106",
|
|
74
|
+
"@aztec/pxe": "3.0.0-nightly.20260106",
|
|
75
|
+
"@aztec/simulator": "3.0.0-nightly.20260106",
|
|
76
|
+
"@aztec/stdlib": "3.0.0-nightly.20260106",
|
|
77
|
+
"@aztec/world-state": "3.0.0-nightly.20260106",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/constants.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
fromSingle,
|
|
34
34
|
toSingle,
|
|
35
35
|
} from './util/encoding.js';
|
|
36
|
-
import type { ContractArtifactWithHash } from './util/
|
|
36
|
+
import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
|
|
37
37
|
|
|
38
38
|
const sessions = new Map<number, TXESession>();
|
|
39
39
|
|