@aztec/end-to-end 0.0.1-commit.cf93bcc56 → 0.0.1-commit.d117d021b
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/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +16 -8
- package/dest/bench/utils.d.ts +1 -1
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +6 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
- 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 +14 -14
- package/dest/e2e_fees/fees_test.d.ts +1 -1
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +13 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
- package/dest/e2e_p2p/p2p_network.d.ts +4 -3
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +22 -5
- package/dest/e2e_p2p/shared.d.ts +15 -1
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +25 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +11 -11
- package/dest/fixtures/authwit_proxy.d.ts +3 -3
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +6 -6
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/setup.d.ts +3 -4
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +3 -3
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +5 -4
- package/dest/shared/cross_chain_test_harness.d.ts +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -13
- package/dest/shared/gas_portal_test_harness.js +2 -2
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/submit-transactions.js +1 -1
- 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 +5 -5
- package/dest/simulators/lending_simulator.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -2
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- 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 +4 -3
- package/dest/spartan/tx_metrics.js +1 -1
- package/dest/spartan/utils/config.d.ts +4 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +2 -1
- package/dest/spartan/utils/index.d.ts +2 -1
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +2 -0
- package/dest/spartan/utils/nodes.d.ts +4 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +9 -9
- package/dest/test-wallet/test_wallet.js +1 -1
- package/dest/test-wallet/wallet_worker_script.js +41 -33
- package/dest/test-wallet/worker_wallet.d.ts +4 -4
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet.js +53 -5
- package/dest/test-wallet/worker_wallet_schema.d.ts +6 -3
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
- package/package.json +43 -44
- package/src/bench/client_flows/client_flows_benchmark.ts +38 -30
- package/src/bench/utils.ts +7 -2
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +18 -14
- package/src/e2e_fees/fees_test.ts +13 -6
- package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
- package/src/e2e_p2p/p2p_network.ts +29 -3
- package/src/e2e_p2p/shared.ts +45 -2
- package/src/e2e_token_contract/token_contract_test.ts +16 -8
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +11 -5
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/setup.ts +8 -7
- package/src/fixtures/token_utils.ts +6 -3
- package/src/shared/cross_chain_test_harness.ts +13 -9
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/submit-transactions.ts +1 -1
- package/src/shared/uniswap_l1_l2.ts +6 -4
- package/src/simulators/lending_simulator.ts +4 -2
- package/src/simulators/token_simulator.ts +6 -2
- package/src/spartan/setup_test_wallets.ts +16 -11
- package/src/spartan/tx_metrics.ts +1 -1
- package/src/spartan/utils/config.ts +1 -0
- package/src/spartan/utils/index.ts +3 -0
- package/src/spartan/utils/nodes.ts +15 -10
- package/src/test-wallet/test_wallet.ts +1 -1
- package/src/test-wallet/wallet_worker_script.ts +47 -30
- package/src/test-wallet/worker_wallet.ts +55 -7
|
@@ -1,43 +1,60 @@
|
|
|
1
1
|
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
2
|
+
import type { SendOptions } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
-
import
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import type { ApiSchema, Fr } from '@aztec/foundation/schemas';
|
|
4
6
|
import { parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
|
|
5
7
|
import { NodeListener, TransportServer } from '@aztec/foundation/transport';
|
|
8
|
+
import { ExecutionPayload, Tx } from '@aztec/stdlib/tx';
|
|
6
9
|
|
|
7
10
|
import { workerData } from 'worker_threads';
|
|
8
11
|
|
|
9
12
|
import { TestWallet } from './test_wallet.js';
|
|
10
13
|
import { WorkerWalletSchema } from './worker_wallet_schema.js';
|
|
11
14
|
|
|
12
|
-
const
|
|
15
|
+
const logger = createLogger('e2e:test-wallet:worker');
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
const
|
|
17
|
+
try {
|
|
18
|
+
const { nodeUrl, pxeConfig } = workerData as { nodeUrl: string; pxeConfig?: Record<string, unknown> };
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// ProvenTx has non-serializable fields (node proxy, etc.) — extract only Tx-compatible fields
|
|
22
|
-
const { data, chonkProof, contractClassLogFields, publicFunctionCalldata } = provenTx;
|
|
23
|
-
return { data, chonkProof, contractClassLogFields, publicFunctionCalldata };
|
|
24
|
-
},
|
|
25
|
-
registerAccount: async (secret, salt) => {
|
|
26
|
-
const manager = await wallet.createSchnorrAccount(secret, salt);
|
|
27
|
-
return manager.address;
|
|
28
|
-
},
|
|
29
|
-
};
|
|
20
|
+
logger.info('Initializing worker wallet', { nodeUrl });
|
|
21
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
22
|
+
const wallet = await TestWallet.create(node, pxeConfig);
|
|
23
|
+
logger.info('Worker wallet initialized');
|
|
30
24
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
const customMethods = {
|
|
26
|
+
proveTx: async (exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>) => {
|
|
27
|
+
const provenTx = await wallet.proveTx(exec, opts);
|
|
28
|
+
return new Tx(
|
|
29
|
+
provenTx.getTxHash(),
|
|
30
|
+
provenTx.data,
|
|
31
|
+
provenTx.chonkProof,
|
|
32
|
+
provenTx.contractClassLogFields,
|
|
33
|
+
provenTx.publicFunctionCalldata,
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
registerAccount: async (secret: Fr, salt: Fr) => {
|
|
37
|
+
const manager = await wallet.createSchnorrAccount(secret, salt);
|
|
38
|
+
return manager.address;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const schema = WorkerWalletSchema as ApiSchema;
|
|
43
|
+
const listener = new NodeListener();
|
|
44
|
+
const server = new TransportServer<{ fn: string; args: string }>(listener, async msg => {
|
|
45
|
+
if (!schemaHasMethod(schema, msg.fn)) {
|
|
46
|
+
throw new Error(`Unknown method: ${msg.fn}`);
|
|
47
|
+
}
|
|
48
|
+
const jsonParams = JSON.parse(msg.args) as unknown[];
|
|
49
|
+
const args: any[] = await parseWithOptionals(jsonParams, schema[msg.fn].parameters());
|
|
50
|
+
// we have to erase the fn type in order to be able to spread ...args
|
|
51
|
+
const handler: ((...args: any[]) => Promise<any>) | undefined =
|
|
52
|
+
msg.fn in customMethods ? customMethods[msg.fn as keyof typeof customMethods] : undefined;
|
|
53
|
+
const result = handler ? await handler(...args) : await (wallet as any)[msg.fn](...args);
|
|
54
|
+
return jsonStringify(result);
|
|
55
|
+
});
|
|
56
|
+
server.start();
|
|
57
|
+
} catch (err: unknown) {
|
|
58
|
+
logger.error('Worker wallet initialization failed', { error: err instanceof Error ? err.stack : String(err) });
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
@@ -7,26 +7,29 @@ import type {
|
|
|
7
7
|
BatchedMethod,
|
|
8
8
|
ContractClassMetadata,
|
|
9
9
|
ContractMetadata,
|
|
10
|
+
ExecuteUtilityOptions,
|
|
10
11
|
PrivateEvent,
|
|
11
12
|
PrivateEventFilter,
|
|
12
13
|
ProfileOptions,
|
|
13
14
|
SendOptions,
|
|
14
15
|
SimulateOptions,
|
|
15
|
-
SimulateUtilityOptions,
|
|
16
16
|
Wallet,
|
|
17
17
|
WalletCapabilities,
|
|
18
18
|
} from '@aztec/aztec.js/wallet';
|
|
19
19
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
20
20
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
21
21
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
22
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
23
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
22
24
|
import type { ApiSchema } from '@aztec/foundation/schemas';
|
|
25
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
23
26
|
import { NodeConnector, TransportClient } from '@aztec/foundation/transport';
|
|
24
27
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
25
28
|
import type { ContractArtifact, EventMetadataDefinition, FunctionCall } from '@aztec/stdlib/abi';
|
|
26
29
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
27
30
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
28
31
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
29
|
-
import type { ExecutionPayload, TxProfileResult, TxSimulationResult,
|
|
32
|
+
import type { ExecutionPayload, TxProfileResult, TxSimulationResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
30
33
|
import { Tx } from '@aztec/stdlib/tx';
|
|
31
34
|
|
|
32
35
|
import { Worker } from 'worker_threads';
|
|
@@ -35,6 +38,10 @@ import { WorkerWalletSchema } from './worker_wallet_schema.js';
|
|
|
35
38
|
|
|
36
39
|
type WorkerMsg = { fn: string; args: string };
|
|
37
40
|
|
|
41
|
+
const log = createLogger('e2e:test-wallet:worker-wallet');
|
|
42
|
+
|
|
43
|
+
const WORKER_READY_TIMEOUT_MS = 120_000;
|
|
44
|
+
|
|
38
45
|
/**
|
|
39
46
|
* Wallet implementation that offloads all work to a worker thread.
|
|
40
47
|
* Implements the Wallet interface by proxying calls over a transport layer
|
|
@@ -53,8 +60,18 @@ export class WorkerWallet implements Wallet {
|
|
|
53
60
|
* @returns A WorkerWallet ready to use.
|
|
54
61
|
*/
|
|
55
62
|
static async create(nodeUrl: string, pxeConfig?: Partial<PXEConfig>): Promise<WorkerWallet> {
|
|
56
|
-
|
|
63
|
+
// replace stc/ with dest/ so the wallet works in Jest tests
|
|
64
|
+
const workerUrl = new URL('./wallet_worker_script.js', import.meta.url);
|
|
65
|
+
workerUrl.pathname = workerUrl.pathname.replace('/src/', '/dest/');
|
|
66
|
+
// remove JEST_WORKER_ID so the worker uses pino-pretty transport instead of Jest's raw output.
|
|
67
|
+
const { JEST_WORKER_ID: _, ...parentEnv } = process.env;
|
|
68
|
+
const worker = new Worker(workerUrl, {
|
|
57
69
|
workerData: { nodeUrl, pxeConfig },
|
|
70
|
+
env: {
|
|
71
|
+
...parentEnv,
|
|
72
|
+
...(process.stderr.isTTY || process.env.FORCE_COLOR ? { FORCE_COLOR: '1' } : {}),
|
|
73
|
+
LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'warn',
|
|
74
|
+
},
|
|
58
75
|
});
|
|
59
76
|
|
|
60
77
|
const connector = new NodeConnector(worker);
|
|
@@ -62,8 +79,39 @@ export class WorkerWallet implements Wallet {
|
|
|
62
79
|
await client.open();
|
|
63
80
|
|
|
64
81
|
const wallet = new WorkerWallet(worker, client);
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
|
|
83
|
+
const { promise: workerDied, reject: rejectWorkerDied } = promiseWithResolvers<void>();
|
|
84
|
+
// reject if the worker exits or errors before the warmup completes.
|
|
85
|
+
const onError = (err: Error): void => {
|
|
86
|
+
worker.off('exit', onExit!);
|
|
87
|
+
rejectWorkerDied(new Error(`Worker wallet thread error: ${err.message}`));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const onExit = (code: number): void => {
|
|
91
|
+
worker.off('error', onError!);
|
|
92
|
+
rejectWorkerDied(new Error(`Worker wallet thread exited with code ${code} before becoming ready`));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
worker.once('error', onError);
|
|
96
|
+
worker.once('exit', onExit);
|
|
97
|
+
|
|
98
|
+
const timeout = sleep(WORKER_READY_TIMEOUT_MS).then(() => {
|
|
99
|
+
throw new Error(`Worker wallet creation timed out after ${WORKER_READY_TIMEOUT_MS / 1000}s`);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
// wait for worker wallet to start
|
|
104
|
+
await Promise.race([wallet.getChainInfo(), workerDied, timeout]);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
log.error('Worker wallet creation failed, cleaning up', { error: String(err) });
|
|
107
|
+
client.close();
|
|
108
|
+
await worker.terminate();
|
|
109
|
+
throw err;
|
|
110
|
+
} finally {
|
|
111
|
+
worker.off('error', onError);
|
|
112
|
+
worker.off('exit', onExit);
|
|
113
|
+
}
|
|
114
|
+
|
|
67
115
|
return wallet;
|
|
68
116
|
}
|
|
69
117
|
|
|
@@ -121,8 +169,8 @@ export class WorkerWallet implements Wallet {
|
|
|
121
169
|
return this.call('simulateTx', exec, opts);
|
|
122
170
|
}
|
|
123
171
|
|
|
124
|
-
|
|
125
|
-
return this.call('
|
|
172
|
+
executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult> {
|
|
173
|
+
return this.call('executeUtility', call, opts);
|
|
126
174
|
}
|
|
127
175
|
|
|
128
176
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
|