@aztec/end-to-end 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2

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.
Files changed (120) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +18 -10
  4. package/dest/bench/utils.d.ts +1 -1
  5. package/dest/bench/utils.d.ts.map +1 -1
  6. package/dest/bench/utils.js +6 -3
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +14 -14
  10. package/dest/e2e_epochs/epochs_test.d.ts +3 -1
  11. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  12. package/dest/e2e_epochs/epochs_test.js +5 -2
  13. package/dest/e2e_fees/fees_test.d.ts +1 -1
  14. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  15. package/dest/e2e_fees/fees_test.js +13 -6
  16. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  17. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  19. package/dest/e2e_p2p/p2p_network.d.ts +4 -3
  20. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  21. package/dest/e2e_p2p/p2p_network.js +19 -16
  22. package/dest/e2e_p2p/reqresp/utils.d.ts +1 -1
  23. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  24. package/dest/e2e_p2p/reqresp/utils.js +15 -2
  25. package/dest/e2e_p2p/shared.d.ts +21 -1
  26. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  27. package/dest/e2e_p2p/shared.js +33 -2
  28. package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
  29. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  30. package/dest/e2e_token_contract/token_contract_test.js +11 -11
  31. package/dest/fixtures/authwit_proxy.d.ts +3 -3
  32. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  33. package/dest/fixtures/e2e_prover_test.d.ts +4 -3
  34. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  35. package/dest/fixtures/e2e_prover_test.js +9 -11
  36. package/dest/fixtures/elu_monitor.d.ts +21 -0
  37. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  38. package/dest/fixtures/elu_monitor.js +102 -0
  39. package/dest/fixtures/get_bb_config.d.ts +1 -1
  40. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  41. package/dest/fixtures/get_bb_config.js +5 -5
  42. package/dest/fixtures/setup.d.ts +8 -4
  43. package/dest/fixtures/setup.d.ts.map +1 -1
  44. package/dest/fixtures/setup.js +16 -12
  45. package/dest/fixtures/token_utils.d.ts +2 -2
  46. package/dest/fixtures/token_utils.d.ts.map +1 -1
  47. package/dest/fixtures/token_utils.js +5 -4
  48. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  49. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  50. package/dest/shared/cross_chain_test_harness.js +13 -13
  51. package/dest/shared/gas_portal_test_harness.js +2 -2
  52. package/dest/shared/jest_setup.js +41 -1
  53. package/dest/shared/submit-transactions.js +1 -1
  54. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  55. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  56. package/dest/shared/uniswap_l1_l2.js +14 -17
  57. package/dest/simulators/lending_simulator.d.ts +1 -1
  58. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  59. package/dest/simulators/lending_simulator.js +4 -4
  60. package/dest/simulators/token_simulator.d.ts +1 -1
  61. package/dest/simulators/token_simulator.d.ts.map +1 -1
  62. package/dest/simulators/token_simulator.js +2 -2
  63. package/dest/spartan/setup_test_wallets.d.ts +4 -2
  64. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  65. package/dest/spartan/setup_test_wallets.js +79 -15
  66. package/dest/spartan/tx_metrics.js +1 -1
  67. package/dest/spartan/utils/config.d.ts +7 -1
  68. package/dest/spartan/utils/config.d.ts.map +1 -1
  69. package/dest/spartan/utils/config.js +3 -1
  70. package/dest/spartan/utils/index.d.ts +3 -1
  71. package/dest/spartan/utils/index.d.ts.map +1 -1
  72. package/dest/spartan/utils/index.js +4 -0
  73. package/dest/spartan/utils/nodes.d.ts +4 -5
  74. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  75. package/dest/spartan/utils/nodes.js +9 -9
  76. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  77. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  78. package/dest/spartan/utils/pod_logs.js +74 -0
  79. package/dest/test-wallet/test_wallet.d.ts +10 -17
  80. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  81. package/dest/test-wallet/test_wallet.js +48 -49
  82. package/dest/test-wallet/wallet_worker_script.js +41 -33
  83. package/dest/test-wallet/worker_wallet.d.ts +1 -1
  84. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  85. package/dest/test-wallet/worker_wallet.js +51 -3
  86. package/dest/test-wallet/worker_wallet_schema.d.ts +7 -4
  87. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  88. package/package.json +42 -44
  89. package/src/bench/client_flows/client_flows_benchmark.ts +40 -31
  90. package/src/bench/utils.ts +7 -2
  91. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +18 -14
  92. package/src/e2e_epochs/epochs_test.ts +14 -2
  93. package/src/e2e_fees/fees_test.ts +13 -6
  94. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  95. package/src/e2e_p2p/p2p_network.ts +25 -21
  96. package/src/e2e_p2p/reqresp/utils.ts +23 -2
  97. package/src/e2e_p2p/shared.ts +55 -2
  98. package/src/e2e_token_contract/token_contract_test.ts +16 -8
  99. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  100. package/src/fixtures/e2e_prover_test.ts +16 -16
  101. package/src/fixtures/elu_monitor.ts +126 -0
  102. package/src/fixtures/get_bb_config.ts +7 -6
  103. package/src/fixtures/setup.ts +25 -15
  104. package/src/fixtures/token_utils.ts +6 -3
  105. package/src/shared/cross_chain_test_harness.ts +13 -9
  106. package/src/shared/gas_portal_test_harness.ts +1 -1
  107. package/src/shared/jest_setup.ts +51 -1
  108. package/src/shared/submit-transactions.ts +1 -1
  109. package/src/shared/uniswap_l1_l2.ts +35 -28
  110. package/src/simulators/lending_simulator.ts +8 -4
  111. package/src/simulators/token_simulator.ts +6 -2
  112. package/src/spartan/setup_test_wallets.ts +107 -18
  113. package/src/spartan/tx_metrics.ts +1 -1
  114. package/src/spartan/utils/config.ts +2 -0
  115. package/src/spartan/utils/index.ts +6 -0
  116. package/src/spartan/utils/nodes.ts +15 -10
  117. package/src/spartan/utils/pod_logs.ts +99 -0
  118. package/src/test-wallet/test_wallet.ts +61 -66
  119. package/src/test-wallet/wallet_worker_script.ts +47 -30
  120. package/src/test-wallet/worker_wallet.ts +51 -3
@@ -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 type { ApiSchema } from '@aztec/foundation/schemas';
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 { nodeUrl, pxeConfig } = workerData as { nodeUrl: string; pxeConfig?: Record<string, unknown> };
15
+ const logger = createLogger('e2e:test-wallet:worker');
13
16
 
14
- const node = createAztecNodeClient(nodeUrl);
15
- const wallet = await TestWallet.create(node, pxeConfig);
17
+ try {
18
+ const { nodeUrl, pxeConfig } = workerData as { nodeUrl: string; pxeConfig?: Record<string, unknown> };
16
19
 
17
- /** Handlers for methods that need custom implementation (not direct wallet passthrough). */
18
- const handlers: Record<string, (...args: any[]) => Promise<any>> = {
19
- proveTx: async (exec, opts) => {
20
- const provenTx = await wallet.proveTx(exec, opts);
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 schema = WorkerWalletSchema as ApiSchema;
32
- const listener = new NodeListener();
33
- const server = new TransportServer<{ fn: string; args: string }>(listener, async msg => {
34
- if (!schemaHasMethod(schema, msg.fn)) {
35
- throw new Error(`Unknown method: ${msg.fn}`);
36
- }
37
- const jsonParams = JSON.parse(msg.args) as unknown[];
38
- const args = await parseWithOptionals(jsonParams, schema[msg.fn].parameters());
39
- const handler = handlers[msg.fn];
40
- const result = handler ? await handler(...args) : await (wallet as any)[msg.fn](...args);
41
- return jsonStringify(result);
42
- });
43
- server.start();
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
+ }
@@ -19,7 +19,10 @@ import type {
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';
@@ -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
- const worker = new Worker(new URL('./wallet_worker_script.js', import.meta.url), {
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
- // Warmup / readiness check — blocks until the worker has finished creating the TestWallet.
66
- await wallet.getChainInfo();
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