@aztec/end-to-end 0.0.1-commit.d3ec352c → 0.0.1-commit.f295ac2

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 (141) 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 +14 -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 +110 -138
  7. package/dest/bench/client_flows/data_extractor.js +3 -1
  8. package/dest/bench/utils.d.ts +6 -6
  9. package/dest/bench/utils.d.ts.map +1 -1
  10. package/dest/bench/utils.js +18 -11
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -7
  12. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  13. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +98 -113
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -13
  15. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  16. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +91 -71
  17. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
  18. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  19. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  20. package/dest/e2e_epochs/epochs_test.d.ts +3 -2
  21. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  22. package/dest/e2e_epochs/epochs_test.js +13 -11
  23. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  24. package/dest/e2e_fees/fees_test.d.ts +18 -15
  25. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  26. package/dest/e2e_fees/fees_test.js +126 -141
  27. package/dest/e2e_l1_publisher/write_json.d.ts +3 -3
  28. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  29. package/dest/e2e_l1_publisher/write_json.js +19 -15
  30. package/dest/e2e_multi_validator/utils.js +1 -1
  31. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  32. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  33. package/dest/e2e_nested_contract/nested_contract_test.js +32 -40
  34. package/dest/e2e_p2p/inactivity_slash_test.d.ts +4 -4
  35. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  36. package/dest/e2e_p2p/inactivity_slash_test.js +6 -9
  37. package/dest/e2e_p2p/p2p_network.d.ts +13 -11
  38. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  39. package/dest/e2e_p2p/p2p_network.js +116 -111
  40. package/dest/e2e_p2p/shared.d.ts +2 -2
  41. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  42. package/dest/e2e_p2p/shared.js +4 -4
  43. package/dest/e2e_token_contract/token_contract_test.d.ts +16 -9
  44. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  45. package/dest/e2e_token_contract/token_contract_test.js +90 -92
  46. package/dest/fixtures/e2e_prover_test.d.ts +10 -18
  47. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  48. package/dest/fixtures/e2e_prover_test.js +88 -103
  49. package/dest/fixtures/fixtures.d.ts +2 -3
  50. package/dest/fixtures/fixtures.d.ts.map +1 -1
  51. package/dest/fixtures/fixtures.js +1 -2
  52. package/dest/fixtures/get_acvm_config.js +1 -1
  53. package/dest/fixtures/l1_to_l2_messaging.d.ts +4 -3
  54. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  55. package/dest/fixtures/l1_to_l2_messaging.js +2 -2
  56. package/dest/fixtures/setup.d.ts +216 -0
  57. package/dest/fixtures/setup.d.ts.map +1 -0
  58. package/dest/fixtures/setup.js +684 -0
  59. package/dest/fixtures/setup_p2p_test.js +3 -3
  60. package/dest/fixtures/utils.d.ts +5 -638
  61. package/dest/fixtures/utils.d.ts.map +1 -1
  62. package/dest/fixtures/utils.js +4 -647
  63. package/dest/fixtures/web3signer.js +1 -1
  64. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  65. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  66. package/dest/fixtures/with_telemetry_utils.js +2 -2
  67. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  68. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  69. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  70. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  71. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  72. package/dest/quality_of_service/prometheus_client.js +67 -0
  73. package/dest/shared/cross_chain_test_harness.d.ts +16 -4
  74. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  75. package/dest/shared/cross_chain_test_harness.js +3 -3
  76. package/dest/shared/gas_portal_test_harness.d.ts +12 -2
  77. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  78. package/dest/shared/index.d.ts +2 -2
  79. package/dest/shared/index.d.ts.map +1 -1
  80. package/dest/shared/uniswap_l1_l2.d.ts +3 -27
  81. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  82. package/dest/shared/uniswap_l1_l2.js +43 -23
  83. package/dest/simulators/lending_simulator.d.ts +6 -2
  84. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  85. package/dest/simulators/lending_simulator.js +1 -1
  86. package/dest/spartan/setup_test_wallets.d.ts +4 -3
  87. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  88. package/dest/spartan/setup_test_wallets.js +2 -1
  89. package/dest/spartan/tx_metrics.d.ts +42 -0
  90. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  91. package/dest/spartan/tx_metrics.js +118 -0
  92. package/dest/spartan/utils.d.ts +51 -12
  93. package/dest/spartan/utils.d.ts.map +1 -1
  94. package/dest/spartan/utils.js +262 -102
  95. package/package.json +40 -39
  96. package/src/bench/client_flows/benchmark.ts +24 -2
  97. package/src/bench/client_flows/client_flows_benchmark.ts +150 -200
  98. package/src/bench/client_flows/data_extractor.ts +1 -1
  99. package/src/bench/utils.ts +22 -14
  100. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +107 -142
  101. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +140 -125
  102. package/src/e2e_deploy_contract/deploy_test.ts +21 -14
  103. package/src/e2e_epochs/epochs_test.ts +26 -13
  104. package/src/e2e_fees/bridging_race.notest.ts +3 -6
  105. package/src/e2e_fees/fees_test.ts +177 -216
  106. package/src/e2e_l1_publisher/write_json.ts +22 -17
  107. package/src/e2e_multi_validator/utils.ts +1 -1
  108. package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
  109. package/src/e2e_p2p/inactivity_slash_test.ts +9 -12
  110. package/src/e2e_p2p/p2p_network.ts +174 -183
  111. package/src/e2e_p2p/shared.ts +11 -6
  112. package/src/e2e_token_contract/token_contract_test.ts +105 -118
  113. package/src/fixtures/e2e_prover_test.ts +112 -144
  114. package/src/fixtures/fixtures.ts +1 -3
  115. package/src/fixtures/get_acvm_config.ts +1 -1
  116. package/src/fixtures/l1_to_l2_messaging.ts +4 -2
  117. package/src/fixtures/setup.ts +1010 -0
  118. package/src/fixtures/setup_p2p_test.ts +3 -3
  119. package/src/fixtures/utils.ts +27 -966
  120. package/src/fixtures/web3signer.ts +1 -1
  121. package/src/fixtures/with_telemetry_utils.ts +2 -2
  122. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +1 -1
  123. package/src/quality_of_service/prometheus_client.ts +113 -0
  124. package/src/shared/cross_chain_test_harness.ts +6 -10
  125. package/src/shared/gas_portal_test_harness.ts +1 -1
  126. package/src/shared/index.ts +1 -1
  127. package/src/shared/uniswap_l1_l2.ts +53 -67
  128. package/src/simulators/lending_simulator.ts +2 -2
  129. package/src/spartan/setup_test_wallets.ts +9 -2
  130. package/src/spartan/tx_metrics.ts +153 -0
  131. package/src/spartan/utils.ts +308 -45
  132. package/dest/fixtures/setup_l1_contracts.d.ts +0 -477
  133. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  134. package/dest/fixtures/setup_l1_contracts.js +0 -17
  135. package/dest/fixtures/snapshot_manager.d.ts +0 -95
  136. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  137. package/dest/fixtures/snapshot_manager.js +0 -505
  138. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  139. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  140. package/src/fixtures/setup_l1_contracts.ts +0 -26
  141. 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
  /**
@@ -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,8 +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';
17
- import { BlockNumber } from '@aztec/foundation/branded-types';
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';
18
20
  import { retryUntil } from '@aztec/foundation/retry';
19
21
  import type { FieldsOf } from '@aztec/foundation/types';
20
22
  import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
@@ -322,17 +324,11 @@ export class CrossChainTestHarness {
322
324
 
323
325
  withdrawFundsFromBridgeOnL1(
324
326
  amount: bigint,
325
- blockNumber: BlockNumber,
327
+ epochNumber: EpochNumber,
326
328
  messageIndex: bigint,
327
329
  siblingPath: SiblingPath<number>,
328
330
  ) {
329
- return this.l1TokenPortalManager.withdrawFunds(
330
- amount,
331
- this.ethAccount,
332
- BigInt(blockNumber),
333
- messageIndex,
334
- siblingPath,
335
- );
331
+ return this.l1TokenPortalManager.withdrawFunds(amount, this.ethAccount, epochNumber, messageIndex, siblingPath);
336
332
  }
337
333
 
338
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';
@@ -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.getCheckpointNumber());
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
- _checkpointNumber: 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
- _checkpointNumber: 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
- // _checkpointNumber: 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
- // _checkpointNumber: 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
- _checkpointNumber: 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
- _checkpointNumber: 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.getCheckpointNumber());
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
- _checkpointNumber: 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
- _checkpointNumber: 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.getCheckpointNumber());
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,9 +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';
5
+ import type { RollupContract } from '@aztec/ethereum/contracts';
6
6
  import { SlotNumber } from '@aztec/foundation/branded-types';
7
- import { pedersenHash } from '@aztec/foundation/crypto';
7
+ import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
8
8
  import type { TestDateProvider } from '@aztec/foundation/timer';
9
9
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
10
10
 
@@ -6,7 +6,8 @@ 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';
@@ -314,11 +315,17 @@ export async function performTransfers({
314
315
  }
315
316
  }
316
317
 
318
+ export type WalletWrapper = {
319
+ wallet: TestWallet;
320
+ aztecNode: AztecNode;
321
+ cleanup: () => Promise<void>;
322
+ };
323
+
317
324
  export async function createWalletAndAztecNodeClient(
318
325
  nodeUrl: string,
319
326
  proverEnabled: boolean,
320
327
  logger: Logger,
321
- ): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise<void> }> {
328
+ ): Promise<WalletWrapper> {
322
329
  const aztecNode = createAztecNodeClient(nodeUrl);
323
330
  const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
324
331
  const pxeConfig = {
@@ -0,0 +1,153 @@
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import type { L2BlockNew } from '@aztec/stdlib/block';
3
+ import type { TopicType } from '@aztec/stdlib/p2p';
4
+ import { Tx, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
5
+
6
+ import { createHistogram } from 'perf_hooks';
7
+
8
+ export type TxInclusionData = {
9
+ txHash: string;
10
+ sentAt: number;
11
+ minedAt: number;
12
+ attestedAt: number;
13
+ blocknumber: number;
14
+ priorityFee: number;
15
+ totalFee: number;
16
+ positionInBlock: number;
17
+ group: string;
18
+ };
19
+
20
+ export class TxInclusionMetrics {
21
+ private data = new Map<string, TxInclusionData>();
22
+ private groups = new Set<string>();
23
+ private blocks = new Map<number, Promise<L2BlockNew | undefined>>();
24
+
25
+ private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
26
+
27
+ constructor(private aztecNode: AztecNode) {}
28
+
29
+ recordSentTx(tx: Tx, group: string): void {
30
+ const txHash = tx.getTxHash().toString();
31
+ const priorityFees = tx.getGasSettings().maxPriorityFeesPerGas;
32
+
33
+ this.data.set(txHash, {
34
+ txHash,
35
+ sentAt: Math.trunc(Date.now() / 1000),
36
+ minedAt: -1,
37
+ attestedAt: -1,
38
+ blocknumber: -1,
39
+ priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
40
+ totalFee: -1,
41
+ positionInBlock: -1,
42
+ group,
43
+ });
44
+ this.groups.add(group);
45
+ }
46
+
47
+ async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
48
+ const { status, txHash, blockNumber } = txReceipt;
49
+ if (status !== TxStatus.SUCCESS || !blockNumber) {
50
+ return;
51
+ }
52
+
53
+ if (!this.blocks.has(blockNumber)) {
54
+ this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber));
55
+ }
56
+
57
+ const block = await this.blocks.get(blockNumber)!;
58
+ if (!block) {
59
+ return;
60
+ }
61
+ const data = this.data.get(txHash.toString())!;
62
+ data.blocknumber = blockNumber;
63
+ data.minedAt = Number(block.header.globalVariables.timestamp);
64
+ data.attestedAt = -1;
65
+ data.totalFee = Number(txReceipt.transactionFee ?? 0n);
66
+ data.positionInBlock = block.body.txEffects.findIndex(txEffect => txEffect.txHash.equals(txHash));
67
+ }
68
+
69
+ public inclusionTimeInSeconds(group: string): {
70
+ count: number;
71
+ group: string;
72
+ min: number;
73
+ mean: number;
74
+ max: number;
75
+ median: number;
76
+ p99: number;
77
+ } {
78
+ const histogram = createHistogram({});
79
+ for (const tx of this.data.values()) {
80
+ if (!tx.blocknumber || tx.group !== group || tx.minedAt === -1) {
81
+ continue;
82
+ }
83
+
84
+ histogram.record(tx.minedAt - tx.sentAt);
85
+ }
86
+
87
+ if (histogram.count === 0) {
88
+ return {
89
+ group,
90
+ count: 0,
91
+ mean: 0,
92
+ max: 0,
93
+ median: 0,
94
+ min: 0,
95
+ p99: 0,
96
+ };
97
+ }
98
+
99
+ return {
100
+ group,
101
+ count: histogram.count,
102
+ mean: histogram.mean,
103
+ max: histogram.max,
104
+ median: histogram.percentile(50),
105
+ min: histogram.min,
106
+ p99: histogram.percentile(99),
107
+ };
108
+ }
109
+
110
+ public recordP2PGossipLatency(topicName: TopicType, p50: number, p95: number): void {
111
+ this.p2pGossipLatencyByTopic[topicName] = { p50, p95 };
112
+ }
113
+
114
+ toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> {
115
+ const data: Array<{ name: string; unit: string; value: number; range?: number; extra?: string }> = [];
116
+ for (const group of this.groups) {
117
+ const stats = this.inclusionTimeInSeconds(group);
118
+
119
+ data.push(
120
+ {
121
+ name: `${group}/avg_inclusion`,
122
+ unit: 's',
123
+ value: stats.mean,
124
+ },
125
+ {
126
+ name: `${group}/median_inclusion`,
127
+ unit: 's',
128
+ value: stats.median,
129
+ },
130
+ {
131
+ name: `${group}/p99_inclusion`,
132
+ unit: 's',
133
+ value: stats.p99,
134
+ },
135
+ );
136
+ }
137
+
138
+ for (const [topic, { p50, p95 }] of Object.entries(this.p2pGossipLatencyByTopic)) {
139
+ data.push({
140
+ name: `p2p_gossip_latency/${topic}/p50`,
141
+ unit: 'ms',
142
+ value: p50,
143
+ });
144
+ data.push({
145
+ name: `p2p_gossip_latency/${topic}/p95`,
146
+ unit: 'ms',
147
+ value: p95,
148
+ });
149
+ }
150
+
151
+ return data;
152
+ }
153
+ }