@aztec/txe 4.0.0-rc.2 → 4.0.0-rc.4
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +82 -50
- package/dest/oracle/txe_oracle_top_level_context.d.ts +3 -4
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +2 -2
- package/dest/txe_session.d.ts +4 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +1 -8
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +5 -22
- package/package.json +15 -15
- package/src/index.ts +83 -49
- package/src/oracle/txe_oracle_top_level_context.ts +4 -4
- package/src/txe_session.ts +3 -11
- package/src/util/txe_public_contract_data_source.ts +10 -36
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
package/dest/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
5
5
|
* @returns A TXE RPC server.
|
|
6
6
|
*/
|
|
7
7
|
export declare function createTXERpcServer(logger: Logger): import("@aztec/foundation/json-rpc/server").SafeJsonRpcServer;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFVQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQWtRcEQ7Ozs7R0FJRztBQUNILHdCQUFnQixrQkFBa0IsQ0FBQyxNQUFNLEVBQUUsTUFBTSxpRUFJaEQifQ==
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAkQpD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,iEAIhD"}
|
package/dest/index.js
CHANGED
|
@@ -5,8 +5,10 @@ import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/cont
|
|
|
5
5
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
6
|
import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
|
|
7
7
|
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
8
|
+
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
9
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
9
10
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
11
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
10
12
|
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
11
13
|
import { zodFor } from '@aztec/stdlib/schemas';
|
|
12
14
|
import { createHash } from 'crypto';
|
|
@@ -19,8 +21,12 @@ import { ForeignCallArgsSchema, ForeignCallResultSchema, fromArray, fromSingle,
|
|
|
19
21
|
const sessions = new Map();
|
|
20
22
|
/*
|
|
21
23
|
* TXE typically has to load the same contract artifacts over and over again for multiple tests,
|
|
22
|
-
* so we cache them here to avoid
|
|
24
|
+
* so we cache them here to avoid loading from disk repeatedly.
|
|
25
|
+
*
|
|
26
|
+
* The in-flight map coalesces concurrent requests for the same cache key so that
|
|
27
|
+
* computeArtifactHash (very expensive) is only run once even under parallelism.
|
|
23
28
|
*/ const TXEArtifactsCache = new Map();
|
|
29
|
+
const TXEArtifactsCacheInFlight = new Map();
|
|
24
30
|
const TXEForeignCallInputSchema = zodFor()(z.object({
|
|
25
31
|
// eslint-disable-next-line camelcase
|
|
26
32
|
session_id: z.number().int().nonnegative(),
|
|
@@ -33,7 +39,7 @@ const TXEForeignCallInputSchema = zodFor()(z.object({
|
|
|
33
39
|
}));
|
|
34
40
|
class TXEDispatcher {
|
|
35
41
|
logger;
|
|
36
|
-
|
|
42
|
+
contractStore;
|
|
37
43
|
constructor(logger){
|
|
38
44
|
this.logger = logger;
|
|
39
45
|
}
|
|
@@ -85,28 +91,37 @@ class TXEDispatcher {
|
|
|
85
91
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
86
92
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey));
|
|
87
93
|
} else {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
95
|
+
this.logger.debug(`Loading compiled artifact ${artifactPath}`);
|
|
96
|
+
const compute = async ()=>{
|
|
97
|
+
const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8'));
|
|
98
|
+
const artifactWithoutHash = loadContractArtifact(artifactJSON);
|
|
99
|
+
const computedArtifact = {
|
|
100
|
+
...artifactWithoutHash,
|
|
101
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
102
|
+
// and the TXE contract data provider can cache it
|
|
103
|
+
artifactHash: await computeArtifactHash(artifactWithoutHash)
|
|
104
|
+
};
|
|
105
|
+
this.logger.debug(`Deploy ${computedArtifact.name} with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`);
|
|
106
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
107
|
+
constructorArgs: decodedArgs,
|
|
108
|
+
skipArgsDecoding: true,
|
|
109
|
+
salt: Fr.ONE,
|
|
110
|
+
publicKeys,
|
|
111
|
+
constructorArtifact: initializer ? initializer : undefined,
|
|
112
|
+
deployer: AztecAddress.ZERO
|
|
113
|
+
});
|
|
114
|
+
const result = {
|
|
115
|
+
artifact: computedArtifact,
|
|
116
|
+
instance: computedInstance
|
|
117
|
+
};
|
|
118
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
119
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
120
|
+
return result;
|
|
121
|
+
};
|
|
122
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
123
|
+
}
|
|
124
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey));
|
|
110
125
|
}
|
|
111
126
|
inputs.splice(0, 1, artifact, instance, toSingle(secret));
|
|
112
127
|
}
|
|
@@ -119,29 +134,38 @@ class TXEDispatcher {
|
|
|
119
134
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
120
135
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey));
|
|
121
136
|
} else {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
138
|
+
const compute = async ()=>{
|
|
139
|
+
const keys = await deriveKeys(secret);
|
|
140
|
+
const args = [
|
|
141
|
+
keys.publicKeys.masterIncomingViewingPublicKey.x,
|
|
142
|
+
keys.publicKeys.masterIncomingViewingPublicKey.y
|
|
143
|
+
];
|
|
144
|
+
const computedArtifact = {
|
|
145
|
+
...SchnorrAccountContractArtifact,
|
|
146
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
147
|
+
// and the TXE contract data provider can cache it
|
|
148
|
+
artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact)
|
|
149
|
+
};
|
|
150
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
151
|
+
constructorArgs: args,
|
|
152
|
+
skipArgsDecoding: true,
|
|
153
|
+
salt: Fr.ONE,
|
|
154
|
+
publicKeys: keys.publicKeys,
|
|
155
|
+
constructorArtifact: 'constructor',
|
|
156
|
+
deployer: AztecAddress.ZERO
|
|
157
|
+
});
|
|
158
|
+
const result = {
|
|
159
|
+
artifact: computedArtifact,
|
|
160
|
+
instance: computedInstance
|
|
161
|
+
};
|
|
162
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
163
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
166
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
167
|
+
}
|
|
168
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey));
|
|
145
169
|
}
|
|
146
170
|
inputs.splice(0, 0, artifact, instance);
|
|
147
171
|
}
|
|
@@ -151,10 +175,18 @@ class TXEDispatcher {
|
|
|
151
175
|
this.logger.debug(`Calling ${functionName} on session ${sessionId}`);
|
|
152
176
|
if (!sessions.has(sessionId)) {
|
|
153
177
|
this.logger.debug(`Creating new session ${sessionId}`);
|
|
154
|
-
if (!this.
|
|
155
|
-
|
|
178
|
+
if (!this.contractStore) {
|
|
179
|
+
const kvStore = await openTmpStore('txe-contracts');
|
|
180
|
+
this.contractStore = new ContractStore(kvStore);
|
|
181
|
+
const provider = new BundledProtocolContractsProvider();
|
|
182
|
+
for (const name of protocolContractNames){
|
|
183
|
+
const { instance, artifact } = await provider.getProtocolContractArtifact(name);
|
|
184
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
185
|
+
await this.contractStore.addContractInstance(instance);
|
|
186
|
+
}
|
|
187
|
+
this.logger.debug('Registered protocol contracts in shared contract store');
|
|
156
188
|
}
|
|
157
|
-
sessions.set(sessionId, await TXESession.init(this.
|
|
189
|
+
sessions.set(sessionId, await TXESession.init(this.contractStore));
|
|
158
190
|
}
|
|
159
191
|
switch(functionName){
|
|
160
192
|
case 'txeDeploy':
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
|
-
import { AddressStore, CapsuleStore, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
4
|
+
import { AddressStore, CapsuleStore, type ContractStore, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
5
5
|
import { type IMiscOracle } from '@aztec/pxe/simulator';
|
|
6
6
|
import { type ContractArtifact, EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -11,7 +11,6 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
11
11
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
12
12
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
13
13
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
14
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
15
14
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
16
15
|
export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
|
|
17
16
|
private stateMachine;
|
|
@@ -33,7 +32,7 @@ export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecut
|
|
|
33
32
|
isMisc: true;
|
|
34
33
|
isTxe: true;
|
|
35
34
|
private logger;
|
|
36
|
-
constructor(stateMachine: TXEStateMachine, contractStore:
|
|
35
|
+
constructor(stateMachine: TXEStateMachine, contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, accountStore: TXEAccountStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, jobId: string, nextBlockTimestamp: bigint, version: Fr, chainId: Fr, authwits: Map<string, AuthWitness>);
|
|
37
36
|
utilityAssertCompatibleOracleVersion(version: number): void;
|
|
38
37
|
utilityGetRandomField(): Fr;
|
|
39
38
|
utilityLog(level: number, message: string, fields: Fr[]): Promise<void>;
|
|
@@ -63,4 +62,4 @@ export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecut
|
|
|
63
62
|
close(): [bigint, Map<string, AuthWitness>];
|
|
64
63
|
private getLastBlockNumber;
|
|
65
64
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX29yYWNsZV90b3BfbGV2ZWxfY29udGV4dC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29yYWNsZS90eGVfb3JhY2xlX3RvcF9sZXZlbF9jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQ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EAAE,YAAY,EAClB,qBAAqB,EAAE,YAAY,EACnC,QAAQ,EAAE,EAAE,EAAE,EACd,YAAY,EAAE,OAAO,iBAqJtB;IAEK,0BAA0B,CAC9B,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,EAAE,EAAE,iBAgCX;YAEa,kBAAkB;IAoDhC,KAAK,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAG1C;YAEa,kBAAkB;CAIjC"}
|
|
@@ -144,7 +144,7 @@ export class TXEOracleTopLevelContext {
|
|
|
144
144
|
await this.txeAddAccount(artifact, instance, secret);
|
|
145
145
|
} else {
|
|
146
146
|
await this.contractStore.addContractInstance(instance);
|
|
147
|
-
await this.contractStore.addContractArtifact(
|
|
147
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
148
148
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -152,7 +152,7 @@ export class TXEOracleTopLevelContext {
|
|
|
152
152
|
const partialAddress = await computePartialAddress(instance);
|
|
153
153
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
154
154
|
await this.contractStore.addContractInstance(instance);
|
|
155
|
-
await this.contractStore.addContractArtifact(
|
|
155
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
156
156
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
157
157
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
158
158
|
await this.addressStore.addCompleteAddress(completeAddress);
|
package/dest/txe_session.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import
|
|
6
|
-
import { AddressStore, CapsuleStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
5
|
+
import { AddressStore, CapsuleStore, ContractStore, JobCoordinator, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
6
|
import { type IPrivateExecutionOracle, type IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
8
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
@@ -12,7 +11,6 @@ import { RPCTranslator } from './rpc_translator.js';
|
|
|
12
11
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
13
12
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
14
13
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
15
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
16
14
|
type MethodNames<T> = {
|
|
17
15
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
18
16
|
}[keyof T];
|
|
@@ -52,8 +50,8 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
52
50
|
private nextBlockTimestamp;
|
|
53
51
|
private state;
|
|
54
52
|
private authwits;
|
|
55
|
-
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle, contractStore:
|
|
56
|
-
static init(
|
|
53
|
+
constructor(logger: Logger, stateMachine: TXEStateMachine, oracleHandler: IUtilityExecutionOracle | IPrivateExecutionOracle | IAvmExecutionOracle | ITxeExecutionOracle, contractStore: ContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, accountStore: TXEAccountStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, jobCoordinator: JobCoordinator, currentJobId: string, chainId: Fr, version: Fr, nextBlockTimestamp: bigint);
|
|
54
|
+
static init(contractStore: ContractStore): Promise<TXESession>;
|
|
57
55
|
/**
|
|
58
56
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
59
57
|
* @param functionName The name of the oracle.
|
|
@@ -72,4 +70,4 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
72
70
|
private utilityExecutorForContractSync;
|
|
73
71
|
}
|
|
74
72
|
export {};
|
|
75
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUNsRSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFHNUMsT0FBTyxFQUNMLFlBQVksRUFFWixZQUFZLEVBQ1osYUFBYSxFQUNiLGNBQWMsRUFFZCxTQUFTLEVBQ1QsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUNyQixzQkFBc0IsRUFDdEIsa0JBQWtCLEVBQ25CLE1BQU0sbUJBQW1CLENBQUM7QUFDM0IsT0FBTyxFQUlMLEtBQUssdUJBQXVCLEVBQzVCLEtBQUssdUJBQXVCLEVBSTdCLE1BQU0sc0JBQXNCLENBQUM7QUFXOUIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE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AuC;IAEvD,YACU,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,eAAe,EAC7B,aAAa,EACjB,uBAAuB,GACvB,uBAAuB,GACvB,mBAAmB,GACnB,mBAAmB,EACf,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,EAC7B,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,kBAAkB,EAAE,MAAM,EAChC;IAEJ,OAAa,IAAI,CAAC,aAAa,EAAE,aAAa,uBAyE7C;IAED;;;;;OAKG;IACH,eAAe,CAAC,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuBxG;IAEK,kBAAkB,kBA+CvB;IAEK,iBAAiB,CACrB,eAAe,GAAE,YAA8B,EAC/C,iBAAiB,CAAC,EAAE,WAAW,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CA8D/B;IAEK,gBAAgB,CAAC,eAAe,CAAC,EAAE,YAAY,iBAsBpD;IAEK,iBAAiB,CAAC,eAAe,GAAE,YAA8B,iBAqCtE;IAED,OAAO,CAAC,iBAAiB;YAiBX,gBAAgB;YA6BhB,eAAe;IAS7B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,8BAA8B;CA4CvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -20,7 +20,6 @@ import { RPCTranslator } from './rpc_translator.js';
|
|
|
20
20
|
import { TXEArchiver } from './state_machine/archiver.js';
|
|
21
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
22
22
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
23
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
24
23
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
25
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
26
25
|
/**
|
|
@@ -71,11 +70,10 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
71
70
|
};
|
|
72
71
|
this.authwits = new Map();
|
|
73
72
|
}
|
|
74
|
-
static async init(
|
|
73
|
+
static async init(contractStore) {
|
|
75
74
|
const store = await openTmpStore('txe-session');
|
|
76
75
|
const addressStore = new AddressStore(store);
|
|
77
76
|
const privateEventStore = new PrivateEventStore(store);
|
|
78
|
-
const contractStore = new TXEContractStore(store);
|
|
79
77
|
const noteStore = new NoteStore(store);
|
|
80
78
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
81
79
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
@@ -92,11 +90,6 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
92
90
|
privateEventStore,
|
|
93
91
|
noteStore
|
|
94
92
|
]);
|
|
95
|
-
// Register protocol contracts.
|
|
96
|
-
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
97
|
-
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
98
|
-
await contractStore.addContractInstance(instance);
|
|
99
|
-
}
|
|
100
93
|
const archiver = new TXEArchiver(store);
|
|
101
94
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
102
95
|
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
@@ -3,9 +3,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
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
|
-
import {
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
7
|
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
8
|
-
#private;
|
|
9
8
|
private blockNumber;
|
|
10
9
|
private contractStore;
|
|
11
10
|
constructor(blockNumber: BlockNumber, contractStore: ContractStore);
|
|
@@ -18,4 +17,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
18
17
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
19
18
|
registerContractFunctionSignatures(_signatures: []): Promise<void>;
|
|
20
19
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDNUUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsa0JBQWtCLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV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,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"}
|
|
@@ -1,48 +1,31 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
-
import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
|
|
4
1
|
export class TXEPublicContractDataSource {
|
|
5
2
|
blockNumber;
|
|
6
3
|
contractStore;
|
|
7
|
-
#privateFunctionsRoot;
|
|
8
4
|
constructor(blockNumber, contractStore){
|
|
9
5
|
this.blockNumber = blockNumber;
|
|
10
6
|
this.contractStore = contractStore;
|
|
11
|
-
this.#privateFunctionsRoot = new Map();
|
|
12
7
|
}
|
|
13
8
|
getBlockNumber() {
|
|
14
9
|
return Promise.resolve(this.blockNumber);
|
|
15
10
|
}
|
|
16
11
|
async getContractClass(id) {
|
|
17
|
-
const contractClass = await this.contractStore.
|
|
12
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
18
13
|
if (!contractClass) {
|
|
19
14
|
return;
|
|
20
15
|
}
|
|
21
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
22
|
-
if (!artifact) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
let privateFunctionsRoot;
|
|
26
|
-
if (!this.#privateFunctionsRoot.has(id.toString())) {
|
|
27
|
-
const privateFunctions = await Promise.all(artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE).map((fn)=>getContractClassPrivateFunctionFromArtifact(fn)));
|
|
28
|
-
privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
29
|
-
this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
|
|
30
|
-
} else {
|
|
31
|
-
privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString()));
|
|
32
|
-
}
|
|
33
16
|
return {
|
|
34
|
-
id,
|
|
17
|
+
id: contractClass.id,
|
|
35
18
|
artifactHash: contractClass.artifactHash,
|
|
36
19
|
packedBytecode: contractClass.packedBytecode,
|
|
37
|
-
privateFunctionsRoot,
|
|
20
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
38
21
|
version: contractClass.version,
|
|
39
22
|
privateFunctions: [],
|
|
40
23
|
utilityFunctions: []
|
|
41
24
|
};
|
|
42
25
|
}
|
|
43
26
|
async getBytecodeCommitment(id) {
|
|
44
|
-
const contractClass = await this.contractStore.
|
|
45
|
-
return contractClass
|
|
27
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
28
|
+
return contractClass?.publicBytecodeCommitment;
|
|
46
29
|
}
|
|
47
30
|
async getContract(address) {
|
|
48
31
|
const instance = await this.contractStore.getContractInstance(address);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.4",
|
|
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": "4.0.0-rc.
|
|
65
|
-
"@aztec/archiver": "4.0.0-rc.
|
|
66
|
-
"@aztec/aztec-node": "4.0.0-rc.
|
|
67
|
-
"@aztec/aztec.js": "4.0.0-rc.
|
|
68
|
-
"@aztec/bb-prover": "4.0.0-rc.
|
|
69
|
-
"@aztec/constants": "4.0.0-rc.
|
|
70
|
-
"@aztec/foundation": "4.0.0-rc.
|
|
71
|
-
"@aztec/key-store": "4.0.0-rc.
|
|
72
|
-
"@aztec/kv-store": "4.0.0-rc.
|
|
73
|
-
"@aztec/protocol-contracts": "4.0.0-rc.
|
|
74
|
-
"@aztec/pxe": "4.0.0-rc.
|
|
75
|
-
"@aztec/simulator": "4.0.0-rc.
|
|
76
|
-
"@aztec/stdlib": "4.0.0-rc.
|
|
77
|
-
"@aztec/world-state": "4.0.0-rc.
|
|
64
|
+
"@aztec/accounts": "4.0.0-rc.4",
|
|
65
|
+
"@aztec/archiver": "4.0.0-rc.4",
|
|
66
|
+
"@aztec/aztec-node": "4.0.0-rc.4",
|
|
67
|
+
"@aztec/aztec.js": "4.0.0-rc.4",
|
|
68
|
+
"@aztec/bb-prover": "4.0.0-rc.4",
|
|
69
|
+
"@aztec/constants": "4.0.0-rc.4",
|
|
70
|
+
"@aztec/foundation": "4.0.0-rc.4",
|
|
71
|
+
"@aztec/key-store": "4.0.0-rc.4",
|
|
72
|
+
"@aztec/kv-store": "4.0.0-rc.4",
|
|
73
|
+
"@aztec/protocol-contracts": "4.0.0-rc.4",
|
|
74
|
+
"@aztec/pxe": "4.0.0-rc.4",
|
|
75
|
+
"@aztec/simulator": "4.0.0-rc.4",
|
|
76
|
+
"@aztec/stdlib": "4.0.0-rc.4",
|
|
77
|
+
"@aztec/world-state": "4.0.0-rc.4",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,12 @@ import { Fr } from '@aztec/aztec.js/fields';
|
|
|
9
9
|
import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
|
|
10
10
|
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
11
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
12
|
-
import {
|
|
12
|
+
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
13
|
+
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
13
14
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
15
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
14
16
|
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
17
|
+
import type { ContractArtifactWithHash } from '@aztec/stdlib/contract';
|
|
15
18
|
import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
|
|
16
19
|
import { zodFor } from '@aztec/stdlib/schemas';
|
|
17
20
|
|
|
@@ -33,18 +36,24 @@ import {
|
|
|
33
36
|
fromSingle,
|
|
34
37
|
toSingle,
|
|
35
38
|
} from './util/encoding.js';
|
|
36
|
-
import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
|
|
37
39
|
|
|
38
40
|
const sessions = new Map<number, TXESession>();
|
|
39
41
|
|
|
40
42
|
/*
|
|
41
43
|
* TXE typically has to load the same contract artifacts over and over again for multiple tests,
|
|
42
|
-
* so we cache them here to avoid
|
|
44
|
+
* so we cache them here to avoid loading from disk repeatedly.
|
|
45
|
+
*
|
|
46
|
+
* The in-flight map coalesces concurrent requests for the same cache key so that
|
|
47
|
+
* computeArtifactHash (very expensive) is only run once even under parallelism.
|
|
43
48
|
*/
|
|
44
49
|
const TXEArtifactsCache = new Map<
|
|
45
50
|
string,
|
|
46
51
|
{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }
|
|
47
52
|
>();
|
|
53
|
+
const TXEArtifactsCacheInFlight = new Map<
|
|
54
|
+
string,
|
|
55
|
+
Promise<{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }>
|
|
56
|
+
>();
|
|
48
57
|
|
|
49
58
|
type TXEForeignCallInput = {
|
|
50
59
|
session_id: number;
|
|
@@ -68,7 +77,7 @@ const TXEForeignCallInputSchema = zodFor<TXEForeignCallInput>()(
|
|
|
68
77
|
);
|
|
69
78
|
|
|
70
79
|
class TXEDispatcher {
|
|
71
|
-
private
|
|
80
|
+
private contractStore!: ContractStore;
|
|
72
81
|
|
|
73
82
|
constructor(private logger: Logger) {}
|
|
74
83
|
|
|
@@ -135,29 +144,36 @@ class TXEDispatcher {
|
|
|
135
144
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
136
145
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
|
|
137
146
|
} else {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
148
|
+
this.logger.debug(`Loading compiled artifact ${artifactPath}`);
|
|
149
|
+
const compute = async () => {
|
|
150
|
+
const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8')) as NoirCompiledContract;
|
|
151
|
+
const artifactWithoutHash = loadContractArtifact(artifactJSON);
|
|
152
|
+
const computedArtifact: ContractArtifactWithHash = {
|
|
153
|
+
...artifactWithoutHash,
|
|
154
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
155
|
+
// and the TXE contract data provider can cache it
|
|
156
|
+
artifactHash: await computeArtifactHash(artifactWithoutHash),
|
|
157
|
+
};
|
|
158
|
+
this.logger.debug(
|
|
159
|
+
`Deploy ${computedArtifact.name} with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`,
|
|
160
|
+
);
|
|
161
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
162
|
+
constructorArgs: decodedArgs,
|
|
163
|
+
skipArgsDecoding: true,
|
|
164
|
+
salt: Fr.ONE,
|
|
165
|
+
publicKeys,
|
|
166
|
+
constructorArtifact: initializer ? initializer : undefined,
|
|
167
|
+
deployer: AztecAddress.ZERO,
|
|
168
|
+
});
|
|
169
|
+
const result = { artifact: computedArtifact, instance: computedInstance };
|
|
170
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
171
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
172
|
+
return result;
|
|
173
|
+
};
|
|
174
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
175
|
+
}
|
|
176
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
|
|
161
177
|
}
|
|
162
178
|
|
|
163
179
|
inputs.splice(0, 1, artifact, instance, toSingle(secret));
|
|
@@ -175,23 +191,35 @@ class TXEDispatcher {
|
|
|
175
191
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
176
192
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
|
|
177
193
|
} else {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
195
|
+
const compute = async () => {
|
|
196
|
+
const keys = await deriveKeys(secret);
|
|
197
|
+
const args = [
|
|
198
|
+
keys.publicKeys.masterIncomingViewingPublicKey.x,
|
|
199
|
+
keys.publicKeys.masterIncomingViewingPublicKey.y,
|
|
200
|
+
];
|
|
201
|
+
const computedArtifact: ContractArtifactWithHash = {
|
|
202
|
+
...SchnorrAccountContractArtifact,
|
|
203
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
204
|
+
// and the TXE contract data provider can cache it
|
|
205
|
+
artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact),
|
|
206
|
+
};
|
|
207
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
208
|
+
constructorArgs: args,
|
|
209
|
+
skipArgsDecoding: true,
|
|
210
|
+
salt: Fr.ONE,
|
|
211
|
+
publicKeys: keys.publicKeys,
|
|
212
|
+
constructorArtifact: 'constructor',
|
|
213
|
+
deployer: AztecAddress.ZERO,
|
|
214
|
+
});
|
|
215
|
+
const result = { artifact: computedArtifact, instance: computedInstance };
|
|
216
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
217
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
218
|
+
return result;
|
|
219
|
+
};
|
|
220
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
221
|
+
}
|
|
222
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
|
|
195
223
|
}
|
|
196
224
|
|
|
197
225
|
inputs.splice(0, 0, artifact, instance);
|
|
@@ -204,12 +232,18 @@ class TXEDispatcher {
|
|
|
204
232
|
|
|
205
233
|
if (!sessions.has(sessionId)) {
|
|
206
234
|
this.logger.debug(`Creating new session ${sessionId}`);
|
|
207
|
-
if (!this.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
);
|
|
235
|
+
if (!this.contractStore) {
|
|
236
|
+
const kvStore = await openTmpStore('txe-contracts');
|
|
237
|
+
this.contractStore = new ContractStore(kvStore);
|
|
238
|
+
const provider = new BundledProtocolContractsProvider();
|
|
239
|
+
for (const name of protocolContractNames) {
|
|
240
|
+
const { instance, artifact } = await provider.getProtocolContractArtifact(name);
|
|
241
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
242
|
+
await this.contractStore.addContractInstance(instance);
|
|
243
|
+
}
|
|
244
|
+
this.logger.debug('Registered protocol contracts in shared contract store');
|
|
211
245
|
}
|
|
212
|
-
sessions.set(sessionId, await TXESession.init(this.
|
|
246
|
+
sessions.set(sessionId, await TXESession.init(this.contractStore));
|
|
213
247
|
}
|
|
214
248
|
|
|
215
249
|
switch (functionName) {
|
|
@@ -16,6 +16,7 @@ import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
|
16
16
|
import {
|
|
17
17
|
AddressStore,
|
|
18
18
|
CapsuleStore,
|
|
19
|
+
type ContractStore,
|
|
19
20
|
NoteStore,
|
|
20
21
|
ORACLE_VERSION,
|
|
21
22
|
PrivateEventStore,
|
|
@@ -84,7 +85,6 @@ import { ForkCheckpoint } from '@aztec/world-state';
|
|
|
84
85
|
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
85
86
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
86
87
|
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
87
|
-
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
88
88
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
89
89
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
90
90
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -97,7 +97,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
97
97
|
|
|
98
98
|
constructor(
|
|
99
99
|
private stateMachine: TXEStateMachine,
|
|
100
|
-
private contractStore:
|
|
100
|
+
private contractStore: ContractStore,
|
|
101
101
|
private noteStore: NoteStore,
|
|
102
102
|
private keyStore: KeyStore,
|
|
103
103
|
private addressStore: AddressStore,
|
|
@@ -211,7 +211,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
211
211
|
await this.txeAddAccount(artifact, instance, secret);
|
|
212
212
|
} else {
|
|
213
213
|
await this.contractStore.addContractInstance(instance);
|
|
214
|
-
await this.contractStore.addContractArtifact(
|
|
214
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
215
215
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
@@ -221,7 +221,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
221
221
|
|
|
222
222
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
223
223
|
await this.contractStore.addContractInstance(instance);
|
|
224
|
-
await this.contractStore.addContractArtifact(
|
|
224
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
225
225
|
|
|
226
226
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
227
227
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
package/src/txe_session.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, 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 type { ProtocolContract } from '@aztec/protocol-contracts';
|
|
7
6
|
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
8
7
|
import {
|
|
9
8
|
AddressStore,
|
|
10
9
|
AnchorBlockStore,
|
|
11
10
|
CapsuleStore,
|
|
11
|
+
ContractStore,
|
|
12
12
|
JobCoordinator,
|
|
13
13
|
NoteService,
|
|
14
14
|
NoteStore,
|
|
@@ -55,7 +55,6 @@ import { TXEArchiver } from './state_machine/archiver.js';
|
|
|
55
55
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
56
56
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
57
57
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
58
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
59
58
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
60
59
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
61
60
|
|
|
@@ -132,7 +131,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
132
131
|
| IPrivateExecutionOracle
|
|
133
132
|
| IAvmExecutionOracle
|
|
134
133
|
| ITxeExecutionOracle,
|
|
135
|
-
private contractStore:
|
|
134
|
+
private contractStore: ContractStore,
|
|
136
135
|
private noteStore: NoteStore,
|
|
137
136
|
private keyStore: KeyStore,
|
|
138
137
|
private addressStore: AddressStore,
|
|
@@ -149,12 +148,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
149
148
|
private nextBlockTimestamp: bigint,
|
|
150
149
|
) {}
|
|
151
150
|
|
|
152
|
-
static async init(
|
|
151
|
+
static async init(contractStore: ContractStore) {
|
|
153
152
|
const store = await openTmpStore('txe-session');
|
|
154
153
|
|
|
155
154
|
const addressStore = new AddressStore(store);
|
|
156
155
|
const privateEventStore = new PrivateEventStore(store);
|
|
157
|
-
const contractStore = new TXEContractStore(store);
|
|
158
156
|
const noteStore = new NoteStore(store);
|
|
159
157
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
160
158
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
@@ -173,12 +171,6 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
173
171
|
noteStore,
|
|
174
172
|
]);
|
|
175
173
|
|
|
176
|
-
// Register protocol contracts.
|
|
177
|
-
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
178
|
-
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
179
|
-
await contractStore.addContractInstance(instance);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
174
|
const archiver = new TXEArchiver(store);
|
|
183
175
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
184
176
|
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
|
-
import { type ContractArtifact, FunctionSelector
|
|
4
|
+
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
7
|
-
type ContractClassPublic,
|
|
8
|
-
type ContractDataSource,
|
|
9
|
-
type ContractInstanceWithAddress,
|
|
10
|
-
computePrivateFunctionsRoot,
|
|
11
|
-
computePublicBytecodeCommitment,
|
|
12
|
-
getContractClassPrivateFunctionFromArtifact,
|
|
13
|
-
} from '@aztec/stdlib/contract';
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
14
7
|
|
|
15
8
|
export class TXEPublicContractDataSource implements ContractDataSource {
|
|
16
|
-
#privateFunctionsRoot: Map<string, Buffer> = new Map();
|
|
17
9
|
constructor(
|
|
18
10
|
private blockNumber: BlockNumber,
|
|
19
11
|
private contractStore: ContractStore,
|
|
@@ -24,42 +16,24 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
24
16
|
}
|
|
25
17
|
|
|
26
18
|
async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
27
|
-
const contractClass = await this.contractStore.
|
|
19
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
28
20
|
if (!contractClass) {
|
|
29
21
|
return;
|
|
30
22
|
}
|
|
31
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
32
|
-
if (!artifact) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let privateFunctionsRoot;
|
|
37
|
-
if (!this.#privateFunctionsRoot.has(id.toString())) {
|
|
38
|
-
const privateFunctions = await Promise.all(
|
|
39
|
-
artifact.functions
|
|
40
|
-
.filter(fn => fn.functionType === FunctionType.PRIVATE)
|
|
41
|
-
.map(fn => getContractClassPrivateFunctionFromArtifact(fn)),
|
|
42
|
-
);
|
|
43
|
-
privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
44
|
-
this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
|
|
45
|
-
} else {
|
|
46
|
-
privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString())!);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
23
|
return {
|
|
50
|
-
id,
|
|
51
|
-
artifactHash: contractClass
|
|
52
|
-
packedBytecode: contractClass
|
|
53
|
-
privateFunctionsRoot,
|
|
54
|
-
version: contractClass
|
|
24
|
+
id: contractClass.id,
|
|
25
|
+
artifactHash: contractClass.artifactHash,
|
|
26
|
+
packedBytecode: contractClass.packedBytecode,
|
|
27
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
28
|
+
version: contractClass.version,
|
|
55
29
|
privateFunctions: [],
|
|
56
30
|
utilityFunctions: [],
|
|
57
31
|
};
|
|
58
32
|
}
|
|
59
33
|
|
|
60
34
|
async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
61
|
-
const contractClass = await this.contractStore.
|
|
62
|
-
return contractClass
|
|
35
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
36
|
+
return contractClass?.publicBytecodeCommitment;
|
|
63
37
|
}
|
|
64
38
|
|
|
65
39
|
async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
@@ -1,12 +0,0 @@
|
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHh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,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,22 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
-
import { ContractStore } from '@aztec/pxe/server';
|
|
3
|
-
/*
|
|
4
|
-
* A contract store that stores contract artifacts with their hashes. Since
|
|
5
|
-
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
6
|
-
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
7
|
-
*/ export class TXEContractStore extends ContractStore {
|
|
8
|
-
#artifactHashes = new Map();
|
|
9
|
-
async addContractArtifact(id, artifact) {
|
|
10
|
-
if ('artifactHash' in artifact) {
|
|
11
|
-
this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
|
|
12
|
-
}
|
|
13
|
-
await super.addContractArtifact(id, artifact);
|
|
14
|
-
}
|
|
15
|
-
async getContractArtifact(contractClassId) {
|
|
16
|
-
const artifact = await super.getContractArtifact(contractClassId);
|
|
17
|
-
if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
|
|
18
|
-
artifact.artifactHash = Fr.fromBuffer(this.#artifactHashes.get(contractClassId.toString()));
|
|
19
|
-
}
|
|
20
|
-
return artifact;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
|
|
5
|
-
export type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* A contract store that stores contract artifacts with their hashes. Since
|
|
9
|
-
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
10
|
-
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
11
|
-
*/
|
|
12
|
-
export class TXEContractStore extends ContractStore {
|
|
13
|
-
#artifactHashes: Map<string, Buffer> = new Map();
|
|
14
|
-
|
|
15
|
-
public override async addContractArtifact(
|
|
16
|
-
id: Fr,
|
|
17
|
-
artifact: ContractArtifact | ContractArtifactWithHash,
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
if ('artifactHash' in artifact) {
|
|
20
|
-
this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
|
|
21
|
-
}
|
|
22
|
-
await super.addContractArtifact(id, artifact);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public override async getContractArtifact(
|
|
26
|
-
contractClassId: Fr,
|
|
27
|
-
): Promise<ContractArtifact | ContractArtifactWithHash | undefined> {
|
|
28
|
-
const artifact = await super.getContractArtifact(contractClassId);
|
|
29
|
-
if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
|
|
30
|
-
(artifact as ContractArtifactWithHash).artifactHash = Fr.fromBuffer(
|
|
31
|
-
this.#artifactHashes.get(contractClassId.toString())!,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return artifact;
|
|
35
|
-
}
|
|
36
|
-
}
|