@aztec/end-to-end 0.0.1-commit.24de95ac → 0.0.1-commit.3469e52

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 (167) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +21 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +21 -15
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +116 -121
  7. package/dest/bench/client_flows/config.d.ts +1 -1
  8. package/dest/bench/client_flows/data_extractor.d.ts +1 -1
  9. package/dest/bench/client_flows/data_extractor.js +7 -27
  10. package/dest/bench/utils.d.ts +5 -5
  11. package/dest/bench/utils.d.ts.map +1 -1
  12. package/dest/bench/utils.js +18 -11
  13. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +98 -113
  16. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -13
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +91 -70
  19. package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  21. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  22. package/dest/e2e_epochs/epochs_test.d.ts +11 -9
  23. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  24. package/dest/e2e_epochs/epochs_test.js +19 -16
  25. package/dest/e2e_fees/bridging_race.notest.d.ts +1 -1
  26. package/dest/e2e_fees/bridging_race.notest.js +4 -6
  27. package/dest/e2e_fees/fees_test.d.ts +20 -16
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +127 -139
  30. package/dest/e2e_l1_publisher/write_json.d.ts +3 -3
  31. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  32. package/dest/e2e_l1_publisher/write_json.js +23 -18
  33. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  34. package/dest/e2e_multi_validator/utils.js +1 -1
  35. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  36. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  37. package/dest/e2e_nested_contract/nested_contract_test.js +32 -39
  38. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  39. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  40. package/dest/e2e_p2p/inactivity_slash_test.js +7 -6
  41. package/dest/e2e_p2p/p2p_network.d.ts +225 -18
  42. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  43. package/dest/e2e_p2p/p2p_network.js +117 -110
  44. package/dest/e2e_p2p/shared.d.ts +6 -6
  45. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  46. package/dest/e2e_p2p/shared.js +6 -5
  47. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  48. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  49. package/dest/e2e_token_contract/token_contract_test.js +90 -92
  50. package/dest/fixtures/e2e_prover_test.d.ts +12 -18
  51. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  52. package/dest/fixtures/e2e_prover_test.js +98 -109
  53. package/dest/fixtures/fixtures.d.ts +2 -3
  54. package/dest/fixtures/fixtures.d.ts.map +1 -1
  55. package/dest/fixtures/fixtures.js +2 -3
  56. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  57. package/dest/fixtures/get_acvm_config.js +1 -1
  58. package/dest/fixtures/get_bb_config.d.ts +1 -1
  59. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  60. package/dest/fixtures/index.d.ts +1 -1
  61. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  62. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  63. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  64. package/dest/fixtures/logging.d.ts +1 -1
  65. package/dest/fixtures/setup.d.ts +216 -0
  66. package/dest/fixtures/setup.d.ts.map +1 -0
  67. package/dest/fixtures/setup.js +684 -0
  68. package/dest/fixtures/setup_p2p_test.d.ts +4 -4
  69. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  70. package/dest/fixtures/setup_p2p_test.js +18 -10
  71. package/dest/fixtures/token_utils.d.ts +5 -2
  72. package/dest/fixtures/token_utils.d.ts.map +1 -1
  73. package/dest/fixtures/token_utils.js +7 -4
  74. package/dest/fixtures/utils.d.ts +5 -192
  75. package/dest/fixtures/utils.d.ts.map +1 -1
  76. package/dest/fixtures/utils.js +4 -648
  77. package/dest/fixtures/web3signer.d.ts +1 -1
  78. package/dest/fixtures/web3signer.js +1 -1
  79. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  80. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  81. package/dest/fixtures/with_telemetry_utils.js +2 -2
  82. package/dest/index.d.ts +1 -1
  83. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  84. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  85. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  86. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  87. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  88. package/dest/quality_of_service/prometheus_client.js +67 -0
  89. package/dest/shared/cross_chain_test_harness.d.ts +5 -3
  90. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  91. package/dest/shared/cross_chain_test_harness.js +3 -3
  92. package/dest/shared/gas_portal_test_harness.d.ts +2 -2
  93. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  94. package/dest/shared/gas_portal_test_harness.js +1 -1
  95. package/dest/shared/index.d.ts +2 -2
  96. package/dest/shared/index.d.ts.map +1 -1
  97. package/dest/shared/jest_setup.d.ts +1 -1
  98. package/dest/shared/submit-transactions.d.ts +1 -1
  99. package/dest/shared/submit-transactions.d.ts.map +1 -1
  100. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  101. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  102. package/dest/shared/uniswap_l1_l2.js +43 -23
  103. package/dest/simulators/index.d.ts +1 -1
  104. package/dest/simulators/lending_simulator.d.ts +2 -2
  105. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  106. package/dest/simulators/lending_simulator.js +5 -3
  107. package/dest/simulators/token_simulator.d.ts +1 -1
  108. package/dest/simulators/token_simulator.d.ts.map +1 -1
  109. package/dest/spartan/setup_test_wallets.d.ts +8 -5
  110. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  111. package/dest/spartan/setup_test_wallets.js +45 -10
  112. package/dest/spartan/tx_metrics.d.ts +52 -0
  113. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  114. package/dest/spartan/tx_metrics.js +248 -0
  115. package/dest/spartan/utils.d.ts +66 -24
  116. package/dest/spartan/utils.d.ts.map +1 -1
  117. package/dest/spartan/utils.js +326 -133
  118. package/package.json +43 -40
  119. package/src/bench/client_flows/benchmark.ts +24 -2
  120. package/src/bench/client_flows/client_flows_benchmark.ts +157 -162
  121. package/src/bench/client_flows/data_extractor.ts +6 -28
  122. package/src/bench/utils.ts +22 -14
  123. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +107 -142
  124. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -124
  125. package/src/e2e_deploy_contract/deploy_test.ts +22 -15
  126. package/src/e2e_epochs/epochs_test.ts +39 -25
  127. package/src/e2e_fees/bridging_race.notest.ts +4 -7
  128. package/src/e2e_fees/fees_test.ts +180 -215
  129. package/src/e2e_l1_publisher/write_json.ts +26 -20
  130. package/src/e2e_multi_validator/utils.ts +1 -1
  131. package/src/e2e_nested_contract/nested_contract_test.ts +35 -55
  132. package/src/e2e_p2p/inactivity_slash_test.ts +10 -9
  133. package/src/e2e_p2p/p2p_network.ts +175 -180
  134. package/src/e2e_p2p/shared.ts +15 -7
  135. package/src/e2e_token_contract/token_contract_test.ts +105 -118
  136. package/src/fixtures/e2e_prover_test.ts +120 -153
  137. package/src/fixtures/fixtures.ts +2 -5
  138. package/src/fixtures/get_acvm_config.ts +1 -1
  139. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  140. package/src/fixtures/setup.ts +1010 -0
  141. package/src/fixtures/setup_p2p_test.ts +23 -9
  142. package/src/fixtures/token_utils.ts +4 -4
  143. package/src/fixtures/utils.ts +27 -947
  144. package/src/fixtures/web3signer.ts +1 -1
  145. package/src/fixtures/with_telemetry_utils.ts +2 -2
  146. package/src/guides/up_quick_start.sh +1 -1
  147. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  148. package/src/quality_of_service/prometheus_client.ts +113 -0
  149. package/src/shared/cross_chain_test_harness.ts +6 -9
  150. package/src/shared/gas_portal_test_harness.ts +2 -2
  151. package/src/shared/index.ts +1 -1
  152. package/src/shared/uniswap_l1_l2.ts +53 -67
  153. package/src/simulators/lending_simulator.ts +6 -4
  154. package/src/spartan/DEVELOP.md +7 -0
  155. package/src/spartan/setup_test_wallets.ts +56 -13
  156. package/src/spartan/tx_metrics.ts +231 -0
  157. package/src/spartan/utils.ts +379 -75
  158. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  159. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  160. package/dest/fixtures/setup_l1_contracts.js +0 -17
  161. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  162. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  163. package/dest/fixtures/snapshot_manager.js +0 -505
  164. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  165. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  166. package/src/fixtures/setup_l1_contracts.ts +0 -26
  167. package/src/fixtures/snapshot_manager.ts +0 -665
@@ -1,4 +1,4 @@
1
- import { randomBytes } from '@aztec/foundation/crypto';
1
+ import { randomBytes } from '@aztec/foundation/crypto/random';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import { sleep } from '@aztec/foundation/sleep';
4
4
  import { RemoteSigner } from '@aztec/node-keystore';
@@ -7,12 +7,12 @@ import {
7
7
  } from '@aztec/telemetry-client';
8
8
  import { OTelPinoStream } from '@aztec/telemetry-client/otel-pino-stream';
9
9
 
10
- export function getEndToEndTestTelemetryClient(metricsPort?: number): TelemetryClient {
10
+ export async function getEndToEndTestTelemetryClient(metricsPort?: number): Promise<TelemetryClient> {
11
11
  if (metricsPort) {
12
12
  const otelStream = new OTelPinoStream({ levels });
13
13
  registerLoggingStream(otelStream);
14
14
  }
15
- return initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
15
+ return await initTelemetryClient(getEndToEndTestTelemetryConfig(metricsPort));
16
16
  }
17
17
 
18
18
  /**
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # Run locally from end-to-end folder while running anvil and sandbox with:
2
+ # Run locally from end-to-end folder while running anvil and local network with:
3
3
  # PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh
4
4
  set -eux
5
5
 
@@ -25,7 +25,7 @@ const DEFAULT_CONFIG: AlertCheckerConfig = {
25
25
  grafanaCredentials: 'admin:admin',
26
26
  };
27
27
 
28
- export class AlertChecker {
28
+ export class GrafanaClient {
29
29
  private config: AlertCheckerConfig;
30
30
  private logger: Logger;
31
31
 
@@ -0,0 +1,113 @@
1
+ export type PromteheusClientOptions = {
2
+ server: URL;
3
+ };
4
+
5
+ export class PrometheusClient {
6
+ constructor(
7
+ private config: PromteheusClientOptions,
8
+ private httpClient: typeof fetch = fetch,
9
+ ) {}
10
+
11
+ public async querySingleValue(query: string, time = new Date()): Promise<number> {
12
+ const resp = await this.queryRaw(query, time);
13
+ if (resp.status === 'success') {
14
+ if (resp.data.resultType === 'vector') {
15
+ if (resp.data.result.length === 0) {
16
+ return 0;
17
+ }
18
+ const [_, value] = resp.data.result[0].value;
19
+ return parseFloat(value);
20
+ }
21
+ }
22
+
23
+ throw new TypeError('Unsupported response body', { cause: JSON.stringify(resp) });
24
+ }
25
+
26
+ public queryRaw(query: string, time = new Date()): Promise<PrometheusResponse> {
27
+ const searchParams = new URLSearchParams();
28
+ searchParams.set('query', query);
29
+ searchParams.set('time', String(Math.trunc(time.getTime() / 1000)));
30
+ searchParams.set('limit', '10');
31
+
32
+ return this.callPrometheus('query', searchParams);
33
+ }
34
+
35
+ public queryRangeRaw(
36
+ query: string,
37
+ step: PrometheusDuration,
38
+ start: Date,
39
+ end = new Date(),
40
+ ): Promise<PrometheusResponse> {
41
+ const searchParams = new URLSearchParams();
42
+ searchParams.set('query', query);
43
+ searchParams.set('step', step);
44
+ searchParams.set('start', String(Math.trunc(start.getTime() / 1000)));
45
+ searchParams.set('end', String(Math.trunc(end.getTime() / 1000)));
46
+ searchParams.set('limit', '10');
47
+
48
+ return this.callPrometheus('query_range', searchParams);
49
+ }
50
+
51
+ private async callPrometheus(api: string, searchParams: URLSearchParams): Promise<PrometheusResponse> {
52
+ const url = new URL('api/v1/' + api, this.config.server);
53
+ for (const [name, value] of searchParams) {
54
+ url.searchParams.append(name, value);
55
+ }
56
+
57
+ const resp = await this.httpClient(url, { method: 'GET' });
58
+ if (!resp.ok || resp.status !== 200) {
59
+ throw new Error('Invalid HTTP response from Prometheus', {
60
+ cause: {
61
+ url,
62
+ status: resp.status,
63
+ statusText: resp.statusText,
64
+ },
65
+ });
66
+ }
67
+
68
+ const body = await resp.json();
69
+ if ('status' in body && (body.status === 'error' || body.status === 'success')) {
70
+ return body;
71
+ }
72
+
73
+ throw new Error('Invalid response from Prometheus', {
74
+ cause: {
75
+ url,
76
+ body,
77
+ },
78
+ });
79
+ }
80
+ }
81
+
82
+ export type PrometheusDuration = `${number}s` | `${number}m` | `${number}h`;
83
+
84
+ export type PrometheusData =
85
+ | {
86
+ resultType: 'vector';
87
+ result: Array<{
88
+ metric: unknown;
89
+ value: [unixTimestamp: number, value: string];
90
+ }>;
91
+ }
92
+ | {
93
+ resultType: 'matrix';
94
+ result: Array<{
95
+ metric: unknown;
96
+ values: [unixTimestamp: number, value: string];
97
+ }>;
98
+ }
99
+ | {
100
+ resultType: 'scalar' | 'string';
101
+ result: unknown;
102
+ };
103
+
104
+ export type PrometheusResponse =
105
+ | {
106
+ status: 'error';
107
+ errorType: string;
108
+ error: string;
109
+ }
110
+ | {
111
+ status: 'success';
112
+ data: PrometheusData;
113
+ };
@@ -13,7 +13,10 @@ import type { AztecNode } from '@aztec/aztec.js/node';
13
13
  import type { SiblingPath } from '@aztec/aztec.js/trees';
14
14
  import type { TxReceipt } from '@aztec/aztec.js/tx';
15
15
  import type { Wallet } from '@aztec/aztec.js/wallet';
16
- import { type ExtendedViemWalletClient, type L1ContractAddresses, deployL1Contract } from '@aztec/ethereum';
16
+ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
17
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
18
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
19
+ import { EpochNumber } from '@aztec/foundation/branded-types';
17
20
  import { retryUntil } from '@aztec/foundation/retry';
18
21
  import type { FieldsOf } from '@aztec/foundation/types';
19
22
  import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
@@ -321,17 +324,11 @@ export class CrossChainTestHarness {
321
324
 
322
325
  withdrawFundsFromBridgeOnL1(
323
326
  amount: bigint,
324
- blockNumber: number | bigint,
327
+ epochNumber: EpochNumber,
325
328
  messageIndex: bigint,
326
329
  siblingPath: SiblingPath<number>,
327
330
  ) {
328
- return this.l1TokenPortalManager.withdrawFunds(
329
- amount,
330
- this.ethAccount,
331
- BigInt(blockNumber),
332
- messageIndex,
333
- siblingPath,
334
- );
331
+ return this.l1TokenPortalManager.withdrawFunds(amount, this.ethAccount, epochNumber, messageIndex, siblingPath);
335
332
  }
336
333
 
337
334
  async transferToPrivateOnL2(shieldAmount: bigint) {
@@ -4,7 +4,7 @@ import { Fr } from '@aztec/aztec.js/fields';
4
4
  import type { Logger } from '@aztec/aztec.js/log';
5
5
  import type { AztecNode } from '@aztec/aztec.js/node';
6
6
  import type { Wallet } from '@aztec/aztec.js/wallet';
7
- import type { ExtendedViemWalletClient } from '@aztec/ethereum';
7
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
8
8
  import { retryUntil } from '@aztec/foundation/retry';
9
9
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
10
10
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
@@ -43,7 +43,7 @@ export class FeeJuicePortalTestingHarnessFactory {
43
43
  throw new Error('Fee Juice portal not deployed on L1');
44
44
  }
45
45
 
46
- const gasL2 = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
46
+ const gasL2 = FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
47
47
 
48
48
  return new GasBridgingTestHarness(
49
49
  aztecNode,
@@ -1 +1 @@
1
- export { uniswapL1L2TestSuite, type UniswapSetupContext } from './uniswap_l1_l2.js';
1
+ export { uniswapL1L2TestSuite } from './uniswap_l1_l2.js';
@@ -1,18 +1,18 @@
1
1
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
2
2
  import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization';
3
+ import { waitForProven } from '@aztec/aztec.js/contracts';
3
4
  import { generateClaimSecret } from '@aztec/aztec.js/ethereum';
4
5
  import { Fr } from '@aztec/aztec.js/fields';
5
6
  import type { Logger } from '@aztec/aztec.js/log';
6
7
  import type { AztecNode } from '@aztec/aztec.js/node';
7
8
  import { CheatCodes } from '@aztec/aztec/testing';
8
- import {
9
- type DeployL1ContractsReturnType,
10
- type ExtendedViemWalletClient,
11
- RollupContract,
12
- deployL1Contract,
13
- extractEvent,
14
- } from '@aztec/ethereum';
15
- import { sha256ToField } from '@aztec/foundation/crypto';
9
+ import { RollupContract } from '@aztec/ethereum/contracts';
10
+ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
11
+ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
12
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
13
+ import { extractEvent } from '@aztec/ethereum/utils';
14
+ import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
15
+ import { sha256ToField } from '@aztec/foundation/crypto/sha256';
16
16
  import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
17
17
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
18
18
  import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
@@ -22,7 +22,7 @@ import type { TestWallet } from '@aztec/test-wallet/server';
22
22
  import { jest } from '@jest/globals';
23
23
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
24
24
 
25
- import { ensureAccountContractsPublished } from '../fixtures/utils.js';
25
+ import { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
26
26
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
27
27
 
28
28
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -34,28 +34,8 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
34
34
 
35
35
  const TIMEOUT = 360_000;
36
36
 
37
- /** Objects to be returned by the uniswap setup function */
38
- export type UniswapSetupContext = {
39
- /** Aztec Node instance */
40
- aztecNode: AztecNode;
41
- /** Logger instance named as the current test. */
42
- logger: Logger;
43
- /** The L1 wallet client, extended with public actions. */
44
- l1Client: ExtendedViemWalletClient;
45
- /** The wallet. */
46
- wallet: TestWallet;
47
- /** The owner address. */
48
- ownerAddress: AztecAddress;
49
- /** The sponsor wallet. */
50
- sponsorAddress: AztecAddress;
51
- /** */
52
- deployL1ContractsValues: DeployL1ContractsReturnType;
53
- /** Cheat codes instance. */
54
- cheatCodes: CheatCodes;
55
- };
56
-
57
37
  export const uniswapL1L2TestSuite = (
58
- setup: () => Promise<UniswapSetupContext>,
38
+ setup: () => Promise<EndToEndContext>,
59
39
  cleanup: () => Promise<void>,
60
40
  expectedForkBlockNumber = 17514288,
61
41
  ) => {
@@ -79,7 +59,7 @@ export const uniswapL1L2TestSuite = (
79
59
  let daiCrossChainHarness: CrossChainTestHarness;
80
60
  let wethCrossChainHarness: CrossChainTestHarness;
81
61
 
82
- let deployL1ContractsValues: DeployL1ContractsReturnType;
62
+ let deployL1ContractsValues: DeployAztecL1ContractsReturnType;
83
63
  let rollup: RollupContract;
84
64
  let uniswapPortal: GetContractReturnType<typeof UniswapPortalAbi, ExtendedViemWalletClient>;
85
65
  let uniswapPortalAddress: EthAddress;
@@ -92,8 +72,19 @@ export const uniswapL1L2TestSuite = (
92
72
  let cheatCodes: CheatCodes;
93
73
  let version: number;
94
74
  beforeAll(async () => {
95
- ({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } =
96
- await setup());
75
+ const t = await setup();
76
+ ({
77
+ aztecNode,
78
+ logger,
79
+ deployL1ContractsValues,
80
+ cheatCodes,
81
+ wallet,
82
+ accounts: [ownerAddress, sponsorAddress],
83
+ } = t);
84
+
85
+ l1Client = deployL1ContractsValues.l1Client;
86
+
87
+ t.watcher?.setIsMarkingAsProven(false);
97
88
 
98
89
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
99
90
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
@@ -261,24 +252,19 @@ export const uniswapL1L2TestSuite = (
261
252
  // ensure that uniswap contract didn't eat the funds.
262
253
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
263
254
 
264
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
265
- await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
255
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
256
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(l2UniswapInteractionReceipt.blockNumber!);
257
+ const epoch = await rollup.getEpochNumberForCheckpoint(checkpointNumber);
258
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
259
+ await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
266
260
 
267
261
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
268
262
  logger.info('Execute withdraw and swap on the uniswapPortal!');
269
263
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
270
264
  daiCrossChainHarness.tokenPortalAddress,
271
265
  );
272
- const swapResult = await computeL2ToL1MembershipWitness(
273
- aztecNode,
274
- l2UniswapInteractionReceipt.blockNumber!,
275
- swapPrivateLeaf,
276
- );
277
- const withdrawResult = await computeL2ToL1MembershipWitness(
278
- aztecNode,
279
- l2UniswapInteractionReceipt.blockNumber!,
280
- withdrawLeaf,
281
- );
266
+ const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
267
+ const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
282
268
 
283
269
  const swapPrivateL2MessageIndex = swapResult!.leafIndex;
284
270
  const swapPrivateSiblingPath = swapResult!.siblingPath;
@@ -287,7 +273,7 @@ export const uniswapL1L2TestSuite = (
287
273
  const withdrawSiblingPath = withdrawResult!.siblingPath;
288
274
 
289
275
  const withdrawMessageMetadata = {
290
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
276
+ _epoch: BigInt(epoch),
291
277
  _leafIndex: BigInt(withdrawL2MessageIndex),
292
278
  _path: withdrawSiblingPath
293
279
  .toBufferArray()
@@ -295,7 +281,7 @@ export const uniswapL1L2TestSuite = (
295
281
  };
296
282
 
297
283
  const swapPrivateMessageMetadata = {
298
- _l2BlockNumber: BigInt(l2UniswapInteractionReceipt.blockNumber!),
284
+ _epoch: BigInt(epoch),
299
285
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
300
286
  _path: swapPrivateSiblingPath
301
287
  .toBufferArray()
@@ -506,7 +492,7 @@ export const uniswapL1L2TestSuite = (
506
492
  // );
507
493
 
508
494
  // const withdrawMessageMetadata = {
509
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
495
+ // _epoch: epoch,
510
496
  // _leafIndex: BigInt(withdrawL2MessageIndex),
511
497
  // _path: withdrawSiblingPath
512
498
  // .toBufferArray()
@@ -514,7 +500,7 @@ export const uniswapL1L2TestSuite = (
514
500
  // };
515
501
 
516
502
  // const swapPrivateMessageMetadata = {
517
- // _l2BlockNumber: BigInt(uniswapL2Interaction.blockNumber!),
503
+ // _epoch: epoch,
518
504
  // _leafIndex: BigInt(swapPrivateL2MessageIndex),
519
505
  // _path: swapPrivateSiblingPath
520
506
  // .toBufferArray()
@@ -858,12 +844,11 @@ export const uniswapL1L2TestSuite = (
858
844
  chainId: new Fr(l1Client.chain.id),
859
845
  });
860
846
 
861
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber!, swapPrivateLeaf);
862
- const withdrawResult = await computeL2ToL1MembershipWitness(
863
- aztecNode,
864
- withdrawReceipt.blockNumber!,
865
- withdrawLeaf,
847
+ const epoch = await rollup.getEpochNumberForCheckpoint(
848
+ CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
866
849
  );
850
+ const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
851
+ const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
867
852
 
868
853
  const swapPrivateL2MessageIndex = swapResult!.leafIndex;
869
854
  const swapPrivateSiblingPath = swapResult!.siblingPath;
@@ -872,7 +857,7 @@ export const uniswapL1L2TestSuite = (
872
857
  const withdrawSiblingPath = withdrawResult!.siblingPath;
873
858
 
874
859
  const withdrawMessageMetadata = {
875
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
860
+ _epoch: BigInt(epoch),
876
861
  _leafIndex: BigInt(withdrawL2MessageIndex),
877
862
  _path: withdrawSiblingPath
878
863
  .toBufferArray()
@@ -880,7 +865,7 @@ export const uniswapL1L2TestSuite = (
880
865
  };
881
866
 
882
867
  const swapPrivateMessageMetadata = {
883
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
868
+ _epoch: BigInt(epoch),
884
869
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
885
870
  _path: swapPrivateSiblingPath
886
871
  .toBufferArray()
@@ -890,8 +875,9 @@ export const uniswapL1L2TestSuite = (
890
875
  // ensure that user's funds were burnt
891
876
  await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
892
877
 
893
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
894
- await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
878
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
879
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
880
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
895
881
 
896
882
  // On L1 call swap_public!
897
883
  logger.info('call swap_public on L1');
@@ -993,12 +979,11 @@ export const uniswapL1L2TestSuite = (
993
979
  chainId: new Fr(l1Client.chain.id),
994
980
  });
995
981
 
996
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, withdrawReceipt.blockNumber!, swapPublicLeaf);
997
- const withdrawResult = await computeL2ToL1MembershipWitness(
998
- aztecNode,
999
- withdrawReceipt.blockNumber!,
1000
- withdrawLeaf,
982
+ const epoch = await rollup.getEpochNumberForCheckpoint(
983
+ CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
1001
984
  );
985
+ const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
986
+ const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
1002
987
 
1003
988
  const swapPublicL2MessageIndex = swapResult!.leafIndex;
1004
989
  const swapPublicSiblingPath = swapResult!.siblingPath;
@@ -1007,7 +992,7 @@ export const uniswapL1L2TestSuite = (
1007
992
  const withdrawSiblingPath = withdrawResult!.siblingPath;
1008
993
 
1009
994
  const withdrawMessageMetadata = {
1010
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
995
+ _epoch: BigInt(epoch),
1011
996
  _leafIndex: BigInt(withdrawL2MessageIndex),
1012
997
  _path: withdrawSiblingPath
1013
998
  .toBufferArray()
@@ -1015,7 +1000,7 @@ export const uniswapL1L2TestSuite = (
1015
1000
  };
1016
1001
 
1017
1002
  const swapPublicMessageMetadata = {
1018
- _l2BlockNumber: BigInt(withdrawReceipt.blockNumber!),
1003
+ _epoch: BigInt(epoch),
1019
1004
  _leafIndex: BigInt(swapPublicL2MessageIndex),
1020
1005
  _path: swapPublicSiblingPath
1021
1006
  .toBufferArray()
@@ -1025,8 +1010,9 @@ export const uniswapL1L2TestSuite = (
1025
1010
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1026
1011
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1027
1012
 
1028
- // Since the outbox is only consumable when the block is proven, we need to set the block to be proven
1029
- await cheatCodes.rollup.markAsProven(await rollup.getBlockNumber());
1013
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
1014
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
1015
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1030
1016
 
1031
1017
  // Call swap_private on L1
1032
1018
  logger.info('Execute withdraw and swap on the uniswapPortal!');
@@ -2,8 +2,9 @@
2
2
  import { AztecAddress } from '@aztec/aztec.js/addresses';
3
3
  import { Fr } from '@aztec/aztec.js/fields';
4
4
  import { CheatCodes } from '@aztec/aztec/testing';
5
- import type { RollupContract } from '@aztec/ethereum';
6
- import { pedersenHash } from '@aztec/foundation/crypto';
5
+ import type { RollupContract } from '@aztec/ethereum/contracts';
6
+ import { SlotNumber } from '@aztec/foundation/branded-types';
7
+ import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
7
8
  import type { TestDateProvider } from '@aztec/foundation/timer';
8
9
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
9
10
 
@@ -103,7 +104,8 @@ export class LendingSimulator {
103
104
  }
104
105
 
105
106
  const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
106
- const ts = Number(await this.rollup.getTimestampForSlot(slot + BigInt(diff)));
107
+ const targetSlot = SlotNumber(slot + diff);
108
+ const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
107
109
  const timeDiff = ts - this.time;
108
110
  this.time = ts;
109
111
 
@@ -112,7 +114,7 @@ export class LendingSimulator {
112
114
  if (dateProvider) {
113
115
  dateProvider.setTime(this.time * 1000);
114
116
  }
115
- await this.cc.rollup.markAsProven(await this.rollup.getBlockNumber());
117
+ await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
116
118
  this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
117
119
  }
118
120
 
@@ -61,10 +61,17 @@ The export is important there. The `AZTEC_DOCKER_IMAGE` env var is used as both:
61
61
  - the containers for the aztec infrastructure (validators, provers, etc)
62
62
 
63
63
  # Deploy Metrics
64
+
64
65
  ```bash
65
66
  ./spartan/bootstrap.sh metrics-kind
66
67
  ```
67
68
 
69
+ # Install Chaos Mesh
70
+
71
+ ```bash
72
+ ./spartan/bootstrap.sh chaos-mesh
73
+ ```
74
+
68
75
  # Deploy stuff
69
76
 
70
77
  ```bash
@@ -6,12 +6,13 @@ import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.j
6
6
  import { Fr } from '@aztec/aztec.js/fields';
7
7
  import { type AztecNode, createAztecNodeClient } from '@aztec/aztec.js/node';
8
8
  import type { Wallet } from '@aztec/aztec.js/wallet';
9
- import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
9
+ import { createEthereumChain } from '@aztec/ethereum/chain';
10
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
10
11
  import type { Logger } from '@aztec/foundation/log';
11
12
  import { retryUntil } from '@aztec/foundation/retry';
12
13
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
13
14
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
14
- import { TestWallet, proveInteraction, registerInitialSandboxAccountsInWallet } from '@aztec/test-wallet/server';
15
+ import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
15
16
 
16
17
  import { getACVMConfig } from '../fixtures/get_acvm_config.js';
17
18
  import { getBBConfig } from '../fixtures/get_bb_config.js';
@@ -28,6 +29,11 @@ export interface TestAccounts {
28
29
  tokenAddress: AztecAddress;
29
30
  }
30
31
 
32
+ export type TestAccountsWithoutTokens = Omit<
33
+ TestAccounts,
34
+ 'tokenAddress' | 'tokenContract' | 'tokenName' | 'tokenAdminAddress'
35
+ >;
36
+
31
37
  const TOKEN_NAME = 'USDC';
32
38
  const TOKEN_SYMBOL = 'USD';
33
39
  const TOKEN_DECIMALS = 18n;
@@ -42,14 +48,14 @@ export async function setupTestAccountsWithTokens(
42
48
  const aztecNode = createAztecNodeClient(nodeUrl);
43
49
  const wallet = await TestWallet.create(aztecNode);
44
50
 
45
- const [recipientAccount, ...accounts] = (await registerInitialSandboxAccountsInWallet(wallet)).slice(
51
+ const [recipientAccount, ...accounts] = (await registerInitialLocalNetworkAccountsInWallet(wallet)).slice(
46
52
  0,
47
53
  ACCOUNT_COUNT + 1,
48
54
  );
49
55
 
50
56
  const tokenAdmin = accounts[0];
51
57
  const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
52
- const tokenContract = await TokenContract.at(tokenAddress, wallet);
58
+ const tokenContract = TokenContract.at(tokenAddress, wallet);
53
59
 
54
60
  return {
55
61
  aztecNode,
@@ -63,7 +69,7 @@ export async function setupTestAccountsWithTokens(
63
69
  };
64
70
  }
65
71
 
66
- export async function deploySponsoredTestAccounts(
72
+ export async function deploySponsoredTestAccountsWithTokens(
67
73
  wallet: TestWallet,
68
74
  aztecNode: AztecNode,
69
75
  mintAmount: bigint,
@@ -96,7 +102,7 @@ export async function deploySponsoredTestAccounts(
96
102
  new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
97
103
  logger,
98
104
  );
99
- const tokenContract = await TokenContract.at(tokenAddress, wallet);
105
+ const tokenContract = TokenContract.at(tokenAddress, wallet);
100
106
 
101
107
  return {
102
108
  aztecNode,
@@ -110,6 +116,37 @@ export async function deploySponsoredTestAccounts(
110
116
  };
111
117
  }
112
118
 
119
+ export async function deploySponsoredTestAccounts(
120
+ wallet: TestWallet,
121
+ aztecNode: AztecNode,
122
+ logger: Logger,
123
+ numberOfFundedWallets = 1,
124
+ ): Promise<TestAccountsWithoutTokens> {
125
+ const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
126
+ const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
127
+ const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
128
+
129
+ await registerSponsoredFPC(wallet);
130
+
131
+ const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
132
+ const recipientDeployMethod = await recipientAccount.getDeployMethod();
133
+ await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
134
+ await Promise.all(
135
+ fundedAccounts.map(async a => {
136
+ const deployMethod = await a.getDeployMethod();
137
+ await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
138
+ logger.info(`Account deployed at ${a.address}`);
139
+ }),
140
+ );
141
+
142
+ return {
143
+ aztecNode,
144
+ wallet,
145
+ accounts: fundedAccounts.map(acc => acc.address),
146
+ recipientAddress: recipientAccount.address,
147
+ };
148
+ }
149
+
113
150
  export async function deployTestAccountsWithTokens(
114
151
  nodeUrl: string,
115
152
  l1RpcUrls: string[],
@@ -152,7 +189,7 @@ export async function deployTestAccountsWithTokens(
152
189
  undefined,
153
190
  logger,
154
191
  );
155
- const tokenContract = await TokenContract.at(tokenAddress, wallet);
192
+ const tokenContract = TokenContract.at(tokenAddress, wallet);
156
193
 
157
194
  return {
158
195
  aztecNode,
@@ -228,9 +265,9 @@ async function deployTokenAndMint(
228
265
  logger.verbose(`Minting ${mintAmount} public assets to the ${accounts.length} accounts...`);
229
266
 
230
267
  await Promise.all(
231
- accounts.map(async acc =>
232
- (await TokenContract.at(tokenAddress, wallet)).methods
233
- .mint_to_public(acc, mintAmount)
268
+ accounts.map(acc =>
269
+ TokenContract.at(tokenAddress, wallet)
270
+ .methods.mint_to_public(acc, mintAmount)
234
271
  .send({ from: admin, fee: { paymentMethod } })
235
272
  .wait({ timeout: 600 }),
236
273
  ),
@@ -260,8 +297,8 @@ export async function performTransfers({
260
297
  // Default to sponsored fee payment if no fee method is provided
261
298
  const defaultFeePaymentMethod = feePaymentMethod || new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
262
299
  for (let i = 0; i < rounds; i++) {
263
- const txs = testAccounts.accounts.map(async acc => {
264
- const token = await TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
300
+ const txs = testAccounts.accounts.map(acc => {
301
+ const token = TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
265
302
  return proveInteraction(wallet, token.methods.transfer_in_public(acc, recipient, transferAmount, 0), {
266
303
  from: acc,
267
304
  fee: {
@@ -278,11 +315,17 @@ export async function performTransfers({
278
315
  }
279
316
  }
280
317
 
318
+ export type WalletWrapper = {
319
+ wallet: TestWallet;
320
+ aztecNode: AztecNode;
321
+ cleanup: () => Promise<void>;
322
+ };
323
+
281
324
  export async function createWalletAndAztecNodeClient(
282
325
  nodeUrl: string,
283
326
  proverEnabled: boolean,
284
327
  logger: Logger,
285
- ): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise<void> }> {
328
+ ): Promise<WalletWrapper> {
286
329
  const aztecNode = createAztecNodeClient(nodeUrl);
287
330
  const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
288
331
  const pxeConfig = {