@aztec/end-to-end 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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/bench/client_flows/benchmark.d.ts +15 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +17 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +13 -9
- package/dest/bench/utils.d.ts +1 -1
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +2 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +13 -4
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +15 -4
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +39 -7
- package/dest/e2e_deploy_contract/deploy_test.d.ts +3 -3
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +2 -1
- package/dest/e2e_epochs/epochs_test.d.ts +8 -2
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +30 -7
- package/dest/e2e_fees/fees_test.d.ts +5 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +29 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +2 -1
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +1 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts +1 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.js +28 -12
- package/dest/e2e_p2p/shared.d.ts +19 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +33 -13
- package/dest/e2e_token_contract/token_contract_test.d.ts +3 -3
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +4 -2
- package/dest/fixtures/e2e_prover_test.d.ts +3 -3
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +2 -1
- package/dest/fixtures/fixtures.d.ts +59 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +55 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +2 -4
- package/dest/fixtures/setup.d.ts +30 -4
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +117 -7
- package/dest/fixtures/setup_p2p_test.d.ts +5 -1
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/utils.d.ts +2 -2
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +1 -1
- package/dest/install_legacy_contracts.d.cts +10 -0
- package/dest/install_legacy_contracts.d.cts.map +1 -0
- package/dest/legacy-jest-resolver.d.cts +1 -1
- package/dest/legacy-jest-resolver.d.cts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +4 -2
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +9 -5
- package/dest/shared/gas_portal_test_harness.d.ts +8 -5
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +16 -7
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +50 -28
- package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
- package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
- package/dest/simulators/lending_simulator.d.ts +10 -3
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +23 -11
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +9 -3
- package/dest/spartan/tx_metrics.d.ts +18 -4
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +73 -20
- package/dest/spartan/utils/config.d.ts +9 -35
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +2 -2
- package/dest/test-wallet/test_wallet.d.ts +3 -2
- package/dest/test-wallet/test_wallet.d.ts.map +1 -1
- package/dest/test-wallet/test_wallet.js +49 -27
- package/dest/test-wallet/utils.d.ts +3 -3
- package/dest/test-wallet/utils.d.ts.map +1 -1
- package/dest/test-wallet/utils.js +2 -7
- package/dest/test-wallet/wallet_worker_script.js +7 -2
- package/dest/test-wallet/worker_wallet.d.ts +2 -1
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet.js +6 -2
- package/dest/test-wallet/worker_wallet_schema.d.ts +110 -229
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet_schema.js +14 -2
- package/package.json +45 -41
- package/src/bench/client_flows/benchmark.ts +19 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +32 -30
- package/src/bench/utils.ts +2 -1
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +21 -4
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +49 -11
- package/src/e2e_deploy_contract/deploy_test.ts +3 -2
- package/src/e2e_epochs/epochs_test.ts +32 -5
- package/src/e2e_fees/fees_test.ts +33 -2
- package/src/e2e_nested_contract/nested_contract_test.ts +3 -1
- package/src/e2e_p2p/inactivity_slash_test.ts +1 -0
- package/src/e2e_p2p/reqresp/utils.ts +29 -11
- package/src/e2e_p2p/shared.ts +31 -12
- package/src/e2e_token_contract/token_contract_test.ts +12 -2
- package/src/fixtures/e2e_prover_test.ts +3 -1
- package/src/fixtures/fixtures.ts +61 -0
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +2 -2
- package/src/fixtures/setup.ts +134 -10
- package/src/fixtures/setup_p2p_test.ts +4 -0
- package/src/fixtures/utils.ts +2 -0
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +25 -48
- package/src/shared/cross_chain_test_harness.ts +14 -4
- package/src/shared/gas_portal_test_harness.ts +20 -9
- package/src/shared/uniswap_l1_l2.ts +84 -36
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +27 -13
- package/src/spartan/setup_test_wallets.ts +6 -4
- package/src/spartan/tx_metrics.ts +81 -23
- package/src/spartan/utils/nodes.ts +2 -2
- package/src/test-wallet/test_wallet.ts +46 -23
- package/src/test-wallet/utils.ts +3 -7
- package/src/test-wallet/wallet_worker_script.ts +5 -2
- package/src/test-wallet/worker_wallet.ts +7 -3
- package/src/test-wallet/worker_wallet_schema.ts +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlockResponse } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
import type { TopicType } from '@aztec/stdlib/p2p';
|
|
5
5
|
import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
@@ -134,9 +134,12 @@ export class ProvingMetrics {
|
|
|
134
134
|
|
|
135
135
|
export type TxInclusionData = {
|
|
136
136
|
txHash: string;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
/** Wall-clock at client when the tx was submitted, in ms (Date.now()). */
|
|
138
|
+
sentAtMs: number;
|
|
139
|
+
/** Wall-clock at client when the block containing the tx first became visible, in ms (Date.now()). -1 if never observed. */
|
|
140
|
+
minedAtMs: number;
|
|
141
|
+
/** Reserved for future attestation-observed-at signal; -1 today. */
|
|
142
|
+
attestedAtMs: number;
|
|
140
143
|
blocknumber: number;
|
|
141
144
|
priorityFee: number;
|
|
142
145
|
totalFee: number;
|
|
@@ -147,7 +150,7 @@ export type TxInclusionData = {
|
|
|
147
150
|
export class TxInclusionMetrics {
|
|
148
151
|
private data = new Map<string, TxInclusionData>();
|
|
149
152
|
private groups = new Set<string>();
|
|
150
|
-
private blocks = new Map<number, Promise<
|
|
153
|
+
private blocks = new Map<number, Promise<BlockResponse<{ includeTransactions: true }> | undefined>>();
|
|
151
154
|
|
|
152
155
|
private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
|
|
153
156
|
|
|
@@ -174,9 +177,9 @@ export class TxInclusionMetrics {
|
|
|
174
177
|
|
|
175
178
|
this.data.set(txHash, {
|
|
176
179
|
txHash,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
sentAtMs: Date.now(),
|
|
181
|
+
minedAtMs: -1,
|
|
182
|
+
attestedAtMs: -1,
|
|
180
183
|
blocknumber: -1,
|
|
181
184
|
priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
|
|
182
185
|
totalFee: -1,
|
|
@@ -186,6 +189,28 @@ export class TxInclusionMetrics {
|
|
|
186
189
|
this.groups.add(group);
|
|
187
190
|
}
|
|
188
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Stamp mined-at metadata for any tracked tx contained in this block, using
|
|
194
|
+
* `observedAtMs` (caller-supplied wall-clock at the moment they first saw the
|
|
195
|
+
* block). Idempotent: existing minedAtMs is preserved so the first observer
|
|
196
|
+
* wins (typically the block-watcher; recordMinedTx is a fallback).
|
|
197
|
+
*/
|
|
198
|
+
observeBlockForMinedTxs(
|
|
199
|
+
blockNumber: number,
|
|
200
|
+
txHashes: ReadonlyArray<{ toString(): string }>,
|
|
201
|
+
observedAtMs: number,
|
|
202
|
+
): void {
|
|
203
|
+
txHashes.forEach((txHash, position) => {
|
|
204
|
+
const data = this.data.get(txHash.toString());
|
|
205
|
+
if (!data || data.minedAtMs !== -1) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
data.blocknumber = blockNumber;
|
|
209
|
+
data.minedAtMs = observedAtMs;
|
|
210
|
+
data.positionInBlock = position;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
189
214
|
async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
|
|
190
215
|
const { txHash, blockNumber } = txReceipt;
|
|
191
216
|
if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
|
|
@@ -197,26 +222,43 @@ export class TxInclusionMetrics {
|
|
|
197
222
|
return;
|
|
198
223
|
}
|
|
199
224
|
|
|
200
|
-
if (!this.blocks.has(blockNumber)) {
|
|
201
|
-
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const block = await this.blocks.get(blockNumber)!;
|
|
205
|
-
if (!block) {
|
|
206
|
-
this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
225
|
const data = this.data.get(txHash.toString());
|
|
210
226
|
if (!data) {
|
|
211
227
|
const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
|
|
212
228
|
this.logger?.warn(message, { txHash: txHash.toString(), blockNumber });
|
|
213
229
|
throw new Error(message);
|
|
214
230
|
}
|
|
215
|
-
data.blocknumber = blockNumber;
|
|
216
|
-
data.minedAt = Number(block.header.globalVariables.timestamp);
|
|
217
|
-
data.attestedAt = -1;
|
|
218
231
|
data.totalFee = Number(txReceipt.transactionFee ?? 0n);
|
|
219
|
-
|
|
232
|
+
|
|
233
|
+
// Fallback path for txs the block-watcher missed (e.g. observed only after
|
|
234
|
+
// the watcher stopped). Stamp with the block's L2 slot timestamp; this is
|
|
235
|
+
// earlier than the true client-observed time by attestation+propagation
|
|
236
|
+
// lag, but it's the only deterministic timestamp available post-hoc.
|
|
237
|
+
if (data.minedAtMs === -1) {
|
|
238
|
+
if (!this.blocks.has(blockNumber)) {
|
|
239
|
+
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber, { includeTransactions: true }));
|
|
240
|
+
}
|
|
241
|
+
const block = await this.blocks.get(blockNumber)!;
|
|
242
|
+
if (!block) {
|
|
243
|
+
this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
data.blocknumber = blockNumber;
|
|
247
|
+
data.minedAtMs = Number(block.header.globalVariables.timestamp) * 1000;
|
|
248
|
+
data.positionInBlock = block.body.txEffects.findIndex(txEffect => txEffect.txHash.equals(txHash));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Per-tx inclusion records for a group. Used to serialise out for downstream tooling. */
|
|
253
|
+
getInclusionRecords(group?: string): TxInclusionData[] {
|
|
254
|
+
const out: TxInclusionData[] = [];
|
|
255
|
+
for (const tx of this.data.values()) {
|
|
256
|
+
if (group !== undefined && tx.group !== group) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
out.push({ ...tx });
|
|
260
|
+
}
|
|
261
|
+
return out;
|
|
220
262
|
}
|
|
221
263
|
|
|
222
264
|
public inclusionTimeInSeconds(group: string): {
|
|
@@ -229,12 +271,28 @@ export class TxInclusionMetrics {
|
|
|
229
271
|
p99: number;
|
|
230
272
|
} {
|
|
231
273
|
const histogram = createHistogram({});
|
|
274
|
+
let nonPositive = 0;
|
|
232
275
|
for (const tx of this.data.values()) {
|
|
233
|
-
if (!tx.blocknumber || tx.group !== group || tx.
|
|
276
|
+
if (!tx.blocknumber || tx.group !== group || tx.minedAtMs === -1) {
|
|
234
277
|
continue;
|
|
235
278
|
}
|
|
236
279
|
|
|
237
|
-
|
|
280
|
+
// Both timestamps are client wall-clock (ms). A negative delta should be
|
|
281
|
+
// impossible since the watcher stamps minedAtMs strictly after sentAtMs,
|
|
282
|
+
// but the fallback path (recordMinedTx via L2 slot timestamp) can stamp
|
|
283
|
+
// earlier than sentAtMs. perf_hooks.createHistogram rejects <=0; skip
|
|
284
|
+
// those instead of crashing.
|
|
285
|
+
const deltaMs = tx.minedAtMs - tx.sentAtMs;
|
|
286
|
+
if (deltaMs <= 0) {
|
|
287
|
+
nonPositive++;
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
// Histogram is recorded in seconds (rounded) to match the existing
|
|
291
|
+
// toGithubActionBenchmarkJSON output unit; per-tx records carry the raw ms.
|
|
292
|
+
histogram.record(Math.max(1, Math.round(deltaMs / 1000)));
|
|
293
|
+
}
|
|
294
|
+
if (nonPositive > 0) {
|
|
295
|
+
this.logger?.debug(`Dropped ${nonPositive} tx inclusion samples with non-positive delta`, { group });
|
|
238
296
|
}
|
|
239
297
|
|
|
240
298
|
if (histogram.count === 0) {
|
|
@@ -71,7 +71,7 @@ export async function waitForProvenToAdvance(
|
|
|
71
71
|
// Get current proven block number
|
|
72
72
|
let initialProvenBlock: number;
|
|
73
73
|
try {
|
|
74
|
-
const tips = await node.
|
|
74
|
+
const tips = await node.getChainTips();
|
|
75
75
|
initialProvenBlock = Number(tips.proven.block.number);
|
|
76
76
|
log.info(`Current proven block: ${initialProvenBlock}. Waiting for it to increase...`);
|
|
77
77
|
} catch (err) {
|
|
@@ -82,7 +82,7 @@ export async function waitForProvenToAdvance(
|
|
|
82
82
|
await retryUntil(
|
|
83
83
|
async () => {
|
|
84
84
|
try {
|
|
85
|
-
const tips = await node.
|
|
85
|
+
const tips = await node.getChainTips();
|
|
86
86
|
const currentProvenBlock = Number(tips.proven.block.number);
|
|
87
87
|
const proposedBlock = Number(tips.proposed.number);
|
|
88
88
|
|
|
@@ -25,7 +25,7 @@ import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
|
|
|
25
25
|
import { PXE, type PXECreationOptions, createPXE } from '@aztec/pxe/server';
|
|
26
26
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
27
27
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
28
|
-
import {
|
|
28
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
29
29
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
30
30
|
import type { NoteDao } from '@aztec/stdlib/note';
|
|
31
31
|
import {
|
|
@@ -78,7 +78,9 @@ export class TestWallet extends BaseWallet {
|
|
|
78
78
|
...overridePXEConfig,
|
|
79
79
|
});
|
|
80
80
|
const pxe = await createPXE(nodeRef, pxeConfig, options);
|
|
81
|
-
|
|
81
|
+
const wallet = new TestWallet(pxe, nodeRef);
|
|
82
|
+
await wallet.initStubClasses();
|
|
83
|
+
return wallet;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
/**
|
|
@@ -112,6 +114,27 @@ export class TestWallet extends BaseWallet {
|
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
116
|
|
|
117
|
+
// Stub class ids, populated on wallet startup
|
|
118
|
+
// to avoid redundant work per simulation
|
|
119
|
+
private stubClassIds = new Map<AccountType, Fr>();
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
123
|
+
* stubClassIds. Called on wallet initialization.
|
|
124
|
+
*/
|
|
125
|
+
private async initStubClasses(): Promise<void> {
|
|
126
|
+
const { id: schnorrClassId } = await getContractClassFromArtifact(StubSchnorrAccountContractArtifact);
|
|
127
|
+
await this.pxe.registerContractClass(StubSchnorrAccountContractArtifact);
|
|
128
|
+
|
|
129
|
+
// ecdsa stubs share the same class id
|
|
130
|
+
const { id: ecdsaClassId } = await getContractClassFromArtifact(StubEcdsaAccountContractArtifact);
|
|
131
|
+
await this.pxe.registerContractClass(StubEcdsaAccountContractArtifact);
|
|
132
|
+
|
|
133
|
+
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
134
|
+
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
135
|
+
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
136
|
+
}
|
|
137
|
+
|
|
115
138
|
/**
|
|
116
139
|
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
117
140
|
*/
|
|
@@ -132,17 +155,16 @@ export class TestWallet extends BaseWallet {
|
|
|
132
155
|
);
|
|
133
156
|
}
|
|
134
157
|
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
158
|
+
const type = this.getTypeFor(address);
|
|
159
|
+
const stubClassId = this.stubClassIds.get(type);
|
|
160
|
+
if (!stubClassId) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
`Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
142
165
|
|
|
143
166
|
contracts[address.toString()] = {
|
|
144
|
-
instance:
|
|
145
|
-
artifact: stubArtifact,
|
|
167
|
+
instance: { ...contractInstance, currentContractClassId: stubClassId },
|
|
146
168
|
};
|
|
147
169
|
}
|
|
148
170
|
|
|
@@ -155,12 +177,6 @@ export class TestWallet extends BaseWallet {
|
|
|
155
177
|
return this.accounts.get(address.toString())?.type ?? 'schnorr';
|
|
156
178
|
}
|
|
157
179
|
|
|
158
|
-
private getStubArtifactFor(address: AztecAddress) {
|
|
159
|
-
return this.getTypeFor(address) === 'schnorr'
|
|
160
|
-
? StubSchnorrAccountContractArtifact
|
|
161
|
-
: StubEcdsaAccountContractArtifact;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
180
|
private getStubAccountFor(address: AztecAddress, completeAddress: CompleteAddress) {
|
|
165
181
|
return this.getTypeFor(address) === 'schnorr'
|
|
166
182
|
? createStubSchnorrAccount(completeAddress)
|
|
@@ -205,7 +221,7 @@ export class TestWallet extends BaseWallet {
|
|
|
205
221
|
const type = accountData?.type ?? 'schnorr';
|
|
206
222
|
const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
|
|
207
223
|
|
|
208
|
-
const accountManager = await AccountManager.create(this, secret, contract, salt);
|
|
224
|
+
const accountManager = await AccountManager.create(this, secret, contract, { salt });
|
|
209
225
|
|
|
210
226
|
const instance = accountManager.getInstance();
|
|
211
227
|
const artifact = await contract.getContractArtifact();
|
|
@@ -260,7 +276,7 @@ export class TestWallet extends BaseWallet {
|
|
|
260
276
|
executionPayload: ExecutionPayload,
|
|
261
277
|
opts: SimulateViaEntrypointOptions,
|
|
262
278
|
): Promise<TxSimulationResultWithAppOffset> {
|
|
263
|
-
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement } = opts;
|
|
279
|
+
const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
|
|
264
280
|
const scopes = this.scopesFrom(from, additionalScopes);
|
|
265
281
|
const skipKernels = this.simulationMode !== 'full';
|
|
266
282
|
const useOverride = this.simulationMode === 'kernelless-override';
|
|
@@ -271,11 +287,14 @@ export class TestWallet extends BaseWallet {
|
|
|
271
287
|
: executionPayload;
|
|
272
288
|
const chainInfo = await this.getChainInfo();
|
|
273
289
|
|
|
274
|
-
let overrides
|
|
290
|
+
let overrides = opts.overrides;
|
|
275
291
|
let txRequest: TxExecutionRequest;
|
|
276
292
|
if (useOverride) {
|
|
277
293
|
const accountOverrides = await this.buildAccountOverrides(scopes);
|
|
278
|
-
overrides = new SimulationOverrides(
|
|
294
|
+
overrides = new SimulationOverrides({
|
|
295
|
+
publicStorage: overrides?.publicStorage,
|
|
296
|
+
contracts: { ...overrides?.contracts, ...accountOverrides },
|
|
297
|
+
});
|
|
279
298
|
}
|
|
280
299
|
|
|
281
300
|
if (from === NO_FROM) {
|
|
@@ -310,6 +329,7 @@ export class TestWallet extends BaseWallet {
|
|
|
310
329
|
skipTxValidation,
|
|
311
330
|
overrides,
|
|
312
331
|
scopes,
|
|
332
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs),
|
|
313
333
|
});
|
|
314
334
|
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
315
335
|
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
@@ -322,7 +342,10 @@ export class TestWallet extends BaseWallet {
|
|
|
322
342
|
gasSettings: opts.fee?.gasSettings,
|
|
323
343
|
});
|
|
324
344
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
|
|
325
|
-
const txProvingResult = await this.pxe.proveTx(txRequest,
|
|
345
|
+
const txProvingResult = await this.pxe.proveTx(txRequest, {
|
|
346
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
347
|
+
senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs),
|
|
348
|
+
});
|
|
326
349
|
return new ProvenTx(
|
|
327
350
|
this.aztecNode,
|
|
328
351
|
await txProvingResult.toTx(),
|
|
@@ -344,7 +367,7 @@ export class TestWallet extends BaseWallet {
|
|
|
344
367
|
}
|
|
345
368
|
|
|
346
369
|
sync(): Promise<void> {
|
|
347
|
-
return this.pxe.
|
|
370
|
+
return this.pxe.sync();
|
|
348
371
|
}
|
|
349
372
|
|
|
350
373
|
stop(): Promise<void> {
|
package/src/test-wallet/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BatchCall,
|
|
2
3
|
ContractFunctionInteraction,
|
|
3
4
|
DeployMethod,
|
|
4
5
|
type DeployOptions,
|
|
@@ -62,15 +63,10 @@ export class ProvenTx extends Tx {
|
|
|
62
63
|
|
|
63
64
|
export async function proveInteraction(
|
|
64
65
|
wallet: TestWallet,
|
|
65
|
-
interaction: ContractFunctionInteraction | DeployMethod,
|
|
66
|
+
interaction: ContractFunctionInteraction | DeployMethod | BatchCall,
|
|
66
67
|
options: SendInteractionOptions | DeployOptions,
|
|
67
68
|
) {
|
|
68
|
-
|
|
69
|
-
if (interaction instanceof DeployMethod) {
|
|
70
|
-
execPayload = await interaction.request(interaction.convertDeployOptionsToRequestOptions(options));
|
|
71
|
-
} else {
|
|
72
|
-
execPayload = await interaction.request(options);
|
|
73
|
-
}
|
|
69
|
+
const execPayload = await interaction.request(options);
|
|
74
70
|
return wallet.proveTx(execPayload, toSendOptions(options));
|
|
75
71
|
}
|
|
76
72
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
2
2
|
import type { SendOptions } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { BackendType, BarretenbergSync } from '@aztec/bb.js';
|
|
3
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import type { ApiSchema, Fr } from '@aztec/foundation/schemas';
|
|
6
|
-
import { parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
|
|
7
|
+
import { getSchemaParameters, parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
|
|
7
8
|
import { NodeListener, TransportServer } from '@aztec/foundation/transport';
|
|
8
9
|
import { ExecutionPayload, Tx } from '@aztec/stdlib/tx';
|
|
9
10
|
|
|
@@ -19,6 +20,8 @@ try {
|
|
|
19
20
|
|
|
20
21
|
logger.info('Initializing worker wallet', { nodeUrl });
|
|
21
22
|
const node = createAztecNodeClient(nodeUrl);
|
|
23
|
+
// Worker sync bb use is limited to crypto and proof serialization helpers.
|
|
24
|
+
await BarretenbergSync.initSingleton({ backend: BackendType.Wasm });
|
|
22
25
|
const wallet = await TestWallet.create(node, pxeConfig);
|
|
23
26
|
logger.info('Worker wallet initialized');
|
|
24
27
|
|
|
@@ -46,7 +49,7 @@ try {
|
|
|
46
49
|
throw new Error(`Unknown method: ${msg.fn}`);
|
|
47
50
|
}
|
|
48
51
|
const jsonParams = JSON.parse(msg.args) as unknown[];
|
|
49
|
-
const args: any[] = await parseWithOptionals(jsonParams, schema[msg.fn]
|
|
52
|
+
const args: any[] = await parseWithOptionals(jsonParams, getSchemaParameters(schema[msg.fn]));
|
|
50
53
|
// we have to erase the fn type in order to be able to spread ...args
|
|
51
54
|
const handler: ((...args: any[]) => Promise<any>) | undefined =
|
|
52
55
|
msg.fn in customMethods ? customMethods[msg.fn as keyof typeof customMethods] : undefined;
|
|
@@ -22,7 +22,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
22
22
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
23
23
|
import { createLogger } from '@aztec/foundation/log';
|
|
24
24
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
25
|
-
import type
|
|
25
|
+
import { type ApiSchema, getSchemaReturnType } from '@aztec/foundation/schemas';
|
|
26
26
|
import { sleep } from '@aztec/foundation/sleep';
|
|
27
27
|
import { NodeConnector, TransportClient } from '@aztec/foundation/transport';
|
|
28
28
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
@@ -71,7 +71,7 @@ export class WorkerWallet implements Wallet {
|
|
|
71
71
|
env: {
|
|
72
72
|
...parentEnv,
|
|
73
73
|
...(process.stderr.isTTY || process.env.FORCE_COLOR ? { FORCE_COLOR: '1' } : {}),
|
|
74
|
-
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? '
|
|
74
|
+
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'info',
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -124,7 +124,7 @@ export class WorkerWallet implements Wallet {
|
|
|
124
124
|
private async call(fn: string, ...args: any[]): Promise<any> {
|
|
125
125
|
const resultJson = await this.callRaw(fn, ...args);
|
|
126
126
|
const methodSchema = (WorkerWalletSchema as ApiSchema)[fn];
|
|
127
|
-
return methodSchema
|
|
127
|
+
return getSchemaReturnType(methodSchema).parseAsync(JSON.parse(resultJson));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
getChainInfo(): Promise<ChainInfo> {
|
|
@@ -166,6 +166,10 @@ export class WorkerWallet implements Wallet {
|
|
|
166
166
|
return this.call('registerContract', instance, artifact, secretKey);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
170
|
+
return this.call('registerContractClass', artifact);
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset> {
|
|
170
174
|
return this.call('simulateTx', exec, opts);
|
|
171
175
|
}
|
|
@@ -8,6 +8,6 @@ import { z } from 'zod';
|
|
|
8
8
|
/** Schema for the WorkerWallet API — extends WalletSchema with proveTx and registerAccount. */
|
|
9
9
|
export const WorkerWalletSchema = {
|
|
10
10
|
...WalletSchema,
|
|
11
|
-
proveTx: z.function(
|
|
12
|
-
registerAccount: z.function(
|
|
11
|
+
proveTx: z.function({ input: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]), output: Tx.schema }),
|
|
12
|
+
registerAccount: z.function({ input: z.tuple([schemas.Fr, schemas.Fr]), output: AztecAddress.schema }),
|
|
13
13
|
};
|