@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.1142ef1

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 (186) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +61 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +336 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +79 -0
  13. package/dest/bench/utils.d.ts +14 -40
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +37 -70
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +29 -28
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +79 -82
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +13 -19
  25. package/dest/e2e_epochs/epochs_test.d.ts +65 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +233 -49
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +63 -0
  31. package/dest/e2e_fees/fees_test.d.ts +27 -12
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +107 -110
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +55 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +10 -7
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +276 -23
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +188 -133
  49. package/dest/e2e_p2p/shared.d.ts +43 -7
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +164 -19
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +50 -26
  55. package/dest/fixtures/e2e_prover_test.d.ts +61 -0
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +108 -113
  58. package/dest/fixtures/fixtures.d.ts +6 -8
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +5 -5
  61. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +3 -15
  64. package/dest/fixtures/get_bb_config.d.ts +2 -2
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/index.d.ts +1 -1
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  69. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  70. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  71. package/dest/fixtures/logging.d.ts +1 -1
  72. package/dest/fixtures/setup_p2p_test.d.ts +15 -14
  73. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  74. package/dest/fixtures/setup_p2p_test.js +82 -22
  75. package/dest/fixtures/snapshot_manager.d.ts +20 -14
  76. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  77. package/dest/fixtures/snapshot_manager.js +147 -138
  78. package/dest/fixtures/token_utils.d.ts +10 -4
  79. package/dest/fixtures/token_utils.d.ts.map +1 -1
  80. package/dest/fixtures/token_utils.js +28 -12
  81. package/dest/fixtures/utils.d.ts +92 -54
  82. package/dest/fixtures/utils.d.ts.map +1 -1
  83. package/dest/fixtures/utils.js +452 -389
  84. package/dest/fixtures/web3signer.d.ts +5 -0
  85. package/dest/fixtures/web3signer.d.ts.map +1 -0
  86. package/dest/fixtures/web3signer.js +53 -0
  87. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  88. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  89. package/dest/fixtures/with_telemetry_utils.js +2 -2
  90. package/dest/index.d.ts +1 -1
  91. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  92. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  93. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  94. package/dest/shared/cross_chain_test_harness.d.ts +42 -35
  95. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  96. package/dest/shared/cross_chain_test_harness.js +106 -52
  97. package/dest/shared/gas_portal_test_harness.d.ts +29 -31
  98. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  99. package/dest/shared/gas_portal_test_harness.js +51 -30
  100. package/dest/shared/index.d.ts +2 -2
  101. package/dest/shared/index.d.ts.map +1 -1
  102. package/dest/shared/jest_setup.d.ts +1 -1
  103. package/dest/shared/jest_setup.js +1 -1
  104. package/dest/shared/submit-transactions.d.ts +6 -4
  105. package/dest/shared/submit-transactions.d.ts.map +1 -1
  106. package/dest/shared/submit-transactions.js +8 -7
  107. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  108. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  109. package/dest/shared/uniswap_l1_l2.js +170 -120
  110. package/dest/simulators/index.d.ts +1 -1
  111. package/dest/simulators/lending_simulator.d.ts +7 -11
  112. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  113. package/dest/simulators/lending_simulator.js +16 -17
  114. package/dest/simulators/token_simulator.d.ts +6 -3
  115. package/dest/simulators/token_simulator.d.ts.map +1 -1
  116. package/dest/simulators/token_simulator.js +16 -13
  117. package/dest/spartan/setup_test_wallets.d.ts +27 -11
  118. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  119. package/dest/spartan/setup_test_wallets.js +202 -58
  120. package/dest/spartan/tx_metrics.d.ts +39 -0
  121. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  122. package/dest/spartan/tx_metrics.js +95 -0
  123. package/dest/spartan/utils.d.ts +151 -313
  124. package/dest/spartan/utils.d.ts.map +1 -1
  125. package/dest/spartan/utils.js +598 -151
  126. package/package.json +65 -58
  127. package/src/bench/client_flows/benchmark.ts +341 -0
  128. package/src/bench/client_flows/client_flows_benchmark.ts +450 -0
  129. package/src/bench/client_flows/config.ts +61 -0
  130. package/src/bench/client_flows/data_extractor.ts +89 -0
  131. package/src/bench/utils.ts +35 -81
  132. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
  133. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +103 -122
  134. package/src/e2e_deploy_contract/deploy_test.ts +24 -39
  135. package/src/e2e_epochs/epochs_test.ts +299 -65
  136. package/src/e2e_fees/bridging_race.notest.ts +80 -0
  137. package/src/e2e_fees/fees_test.ts +150 -142
  138. package/src/e2e_l1_publisher/write_json.ts +74 -0
  139. package/src/e2e_multi_validator/utils.ts +258 -0
  140. package/src/e2e_nested_contract/nested_contract_test.ts +29 -19
  141. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  142. package/src/e2e_p2p/p2p_network.ts +274 -171
  143. package/src/e2e_p2p/shared.ts +252 -29
  144. package/src/e2e_token_contract/token_contract_test.ts +43 -39
  145. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  146. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +112 -160
  147. package/src/fixtures/fixtures.ts +5 -7
  148. package/src/fixtures/get_acvm_config.ts +4 -12
  149. package/src/fixtures/get_bb_config.ts +18 -13
  150. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  151. package/src/fixtures/setup_p2p_test.ts +127 -39
  152. package/src/fixtures/snapshot_manager.ts +189 -160
  153. package/src/fixtures/token_utils.ts +32 -15
  154. package/src/fixtures/utils.ts +556 -475
  155. package/src/fixtures/web3signer.ts +63 -0
  156. package/src/fixtures/with_telemetry_utils.ts +2 -2
  157. package/src/guides/up_quick_start.sh +7 -15
  158. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  159. package/src/shared/cross_chain_test_harness.ts +113 -87
  160. package/src/shared/gas_portal_test_harness.ts +59 -50
  161. package/src/shared/index.ts +1 -1
  162. package/src/shared/jest_setup.ts +1 -1
  163. package/src/shared/submit-transactions.ts +12 -8
  164. package/src/shared/uniswap_l1_l2.ts +194 -211
  165. package/src/simulators/lending_simulator.ts +15 -16
  166. package/src/simulators/token_simulator.ts +21 -13
  167. package/src/spartan/DEVELOP.md +128 -0
  168. package/src/spartan/setup_test_wallets.ts +258 -93
  169. package/src/spartan/tx_metrics.ts +130 -0
  170. package/src/spartan/utils.ts +722 -146
  171. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  172. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  173. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  174. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  175. package/dest/fixtures/setup_l1_contracts.js +0 -17
  176. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  177. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  178. package/dest/sample-dapp/connect.js +0 -12
  179. package/dest/sample-dapp/contracts.js +0 -10
  180. package/dest/sample-dapp/deploy.js +0 -35
  181. package/dest/sample-dapp/index.js +0 -98
  182. package/src/fixtures/setup_l1_contracts.ts +0 -27
  183. package/src/sample-dapp/connect.mjs +0 -16
  184. package/src/sample-dapp/contracts.mjs +0 -14
  185. package/src/sample-dapp/deploy.mjs +0 -40
  186. package/src/sample-dapp/index.mjs +0 -128
@@ -1,50 +1,61 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { type InitialAccountData, deployFundedSchnorrAccounts, generateSchnorrAccounts } from '@aztec/accounts/testing';
2
+ import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
5
+ import { getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
6
+ import { BatchCall, type ContractFunctionInteraction, waitForProven } from '@aztec/aztec.js/contracts';
7
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
+ import type { Logger } from '@aztec/aztec.js/log';
9
+ import type { AztecNode } from '@aztec/aztec.js/node';
10
+ import type { Wallet } from '@aztec/aztec.js/wallet';
11
+ import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
12
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
13
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
14
+ import { deployMulticall3 } from '@aztec/ethereum/contracts';
4
15
  import {
5
- AnvilTestWatcher,
6
- type AztecAddress,
7
- BatchCall,
8
- type Capsule,
9
- CheatCodes,
10
- type CompleteAddress,
11
- type ContractFunctionInteraction,
12
- type DeployL1ContractsReturnType,
13
- type FunctionCall,
14
- type Logger,
15
- type PXE,
16
- type Wallet,
17
- getContractClassFromArtifact,
18
- } from '@aztec/aztec.js';
19
- import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
20
- import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
21
- import { type DeployL1ContractsArgs, createL1Clients, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum';
16
+ type DeployAztecL1ContractsArgs,
17
+ type DeployAztecL1ContractsReturnType,
18
+ deployAztecL1Contracts,
19
+ } from '@aztec/ethereum/deploy-aztec-l1-contracts';
22
20
  import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
23
21
  import { asyncMap } from '@aztec/foundation/async-map';
24
- import { randomBytes } from '@aztec/foundation/crypto';
22
+ import { SecretValue } from '@aztec/foundation/config';
23
+ import { randomBytes } from '@aztec/foundation/crypto/random';
24
+ import { tryRmDir } from '@aztec/foundation/fs';
25
25
  import { createLogger } from '@aztec/foundation/log';
26
26
  import { resolver, reviver } from '@aztec/foundation/serialize';
27
27
  import { TestDateProvider } from '@aztec/foundation/timer';
28
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
29
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
28
30
  import type { ProverNode } from '@aztec/prover-node';
29
- import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
31
+ import { getPXEConfig } from '@aztec/pxe/server';
32
+ import type { SequencerClient } from '@aztec/sequencer-client';
33
+ import { tryStop } from '@aztec/stdlib/interfaces/server';
30
34
  import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
35
+ import { TestWallet } from '@aztec/test-wallet/server';
31
36
  import { getGenesisValues } from '@aztec/world-state/testing';
32
37
 
33
38
  import type { Anvil } from '@viem/anvil';
34
39
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
35
40
  import { copySync, removeSync } from 'fs-extra/esm';
36
41
  import fs from 'fs/promises';
37
- import getPort from 'get-port';
38
42
  import { tmpdir } from 'os';
39
43
  import path, { join } from 'path';
40
- import { type Hex, getContract } from 'viem';
44
+ import type { Hex } from 'viem';
41
45
  import { mnemonicToAccount } from 'viem/accounts';
46
+ import { foundry } from 'viem/chains';
42
47
 
43
- import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
48
+ import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
44
49
  import { getACVMConfig } from './get_acvm_config.js';
45
50
  import { getBBConfig } from './get_bb_config.js';
46
- import { setupL1Contracts } from './setup_l1_contracts.js';
47
- import { type SetupOptions, createAndSyncProverNode, getLogger, getPrivateKeyFromIndex } from './utils.js';
51
+ import {
52
+ type SetupOptions,
53
+ createAndSyncProverNode,
54
+ getLogger,
55
+ getPrivateKeyFromIndex,
56
+ getSponsoredFPCAddress,
57
+ setupSharedBlobStorage,
58
+ } from './utils.js';
48
59
  import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
49
60
 
50
61
  export type SubsystemsContext = {
@@ -53,13 +64,13 @@ export type SubsystemsContext = {
53
64
  bbConfig: any;
54
65
  aztecNode: AztecNodeService;
55
66
  aztecNodeConfig: AztecNodeConfig;
56
- pxe: PXEService;
57
- deployL1ContractsValues: DeployL1ContractsReturnType;
67
+ wallet: TestWallet;
68
+ deployL1ContractsValues: DeployAztecL1ContractsReturnType;
58
69
  proverNode?: ProverNode;
59
70
  watcher: AnvilTestWatcher;
60
71
  cheatCodes: CheatCodes;
72
+ sequencer: SequencerClient;
61
73
  dateProvider: TestDateProvider;
62
- blobSink: BlobSinkServer;
63
74
  initialFundedAccounts: InitialAccountData[];
64
75
  directoryToCleanup?: string;
65
76
  };
@@ -75,7 +86,7 @@ export function createSnapshotManager(
75
86
  testName: string,
76
87
  dataPath?: string,
77
88
  config: Partial<SetupOptions> = {},
78
- deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
89
+ deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
79
90
  initialValidators: [],
80
91
  },
81
92
  ) {
@@ -104,7 +115,7 @@ class MockSnapshotManager implements ISnapshotManager {
104
115
  constructor(
105
116
  testName: string,
106
117
  private config: Partial<AztecNodeConfig> = {},
107
- private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {},
118
+ private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {},
108
119
  ) {
109
120
  this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
110
121
  this.logger.warn(`No data path given, will not persist any snapshots.`);
@@ -152,7 +163,7 @@ class SnapshotManager implements ISnapshotManager {
152
163
  testName: string,
153
164
  private dataPath: string,
154
165
  private config: Partial<SetupOptions> = {},
155
- private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {},
166
+ private deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {},
156
167
  ) {
157
168
  this.livePath = join(this.dataPath, 'live', testName);
158
169
  this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
@@ -188,7 +199,7 @@ class SnapshotManager implements ISnapshotManager {
188
199
  await restore(snapshotData, context);
189
200
 
190
201
  // Save the snapshot data.
191
- const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
202
+ const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
192
203
  const anvilStateFile = `${this.livePath}/anvil.dat`;
193
204
  await ethCheatCodes.dumpChainState(anvilStateFile);
194
205
  writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
@@ -253,24 +264,18 @@ async function teardown(context: SubsystemsContext | undefined) {
253
264
  if (!context) {
254
265
  return;
255
266
  }
267
+ const logger = getLogger();
256
268
  try {
257
- getLogger().info('Tearing down subsystems');
258
- await context.proverNode?.stop();
259
- await context.aztecNode.stop();
269
+ logger.info('Tearing down subsystems');
270
+ await tryStop(context.proverNode);
271
+ await tryStop(context.aztecNode);
260
272
  await context.acvmConfig?.cleanup();
261
273
  await context.bbConfig?.cleanup();
262
- await context.anvil.stop();
263
- await context.watcher.stop();
264
- await context.blobSink.stop();
265
- if (context.directoryToCleanup) {
266
- try {
267
- await fs.rm(context.directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
268
- } catch (err) {
269
- getLogger().warn(`Failed to delete tmp directory ${context.directoryToCleanup}: ${err}`);
270
- }
271
- }
274
+ await tryStop(context.anvil);
275
+ await tryStop(context.watcher);
276
+ await tryRmDir(context.directoryToCleanup, logger);
272
277
  } catch (err) {
273
- getLogger().error('Error during teardown', err);
278
+ logger.error('Error during teardown', err);
274
279
  }
275
280
  }
276
281
 
@@ -283,18 +288,30 @@ async function setupFromFresh(
283
288
  statePath: string | undefined,
284
289
  logger: Logger,
285
290
  { numberOfInitialFundedAccounts = 10, ...opts }: SetupOptions = {},
286
- deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
291
+ deployL1ContractsArgs: Partial<DeployAztecL1ContractsArgs> = {
287
292
  initialValidators: [],
288
293
  },
289
294
  ): Promise<SubsystemsContext> {
290
295
  logger.verbose(`Initializing state...`);
291
296
 
292
- const blobSinkPort = await getPort();
297
+ // Default to no slashing
298
+ opts.slasherFlavor ??= 'none';
299
+ deployL1ContractsArgs.slasherFlavor ??= opts.slasherFlavor;
293
300
 
294
301
  // Fetch the AztecNode config.
295
302
  // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
296
303
  const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
297
304
  aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
305
+ aztecNodeConfig.maxPendingTxCount = opts.maxPendingTxCount ?? TEST_MAX_PENDING_TX_POOL_COUNT;
306
+ // Only enable proving if specifically requested.
307
+ aztecNodeConfig.realProofs = !!opts.realProofs;
308
+ // Only enforce the time table if requested
309
+ aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
310
+ // Only set the target committee size if it is explicitly set
311
+ aztecNodeConfig.aztecTargetCommitteeSize = opts.aztecTargetCommitteeSize ?? 0;
312
+ aztecNodeConfig.listenAddress = '127.0.0.1';
313
+
314
+ deployL1ContractsArgs.aztecTargetCommitteeSize ??= aztecNodeConfig.aztecTargetCommitteeSize;
298
315
 
299
316
  // Create a temp directory for all ephemeral state and cleanup afterwards
300
317
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
@@ -304,86 +321,77 @@ async function setupFromFresh(
304
321
  } else {
305
322
  aztecNodeConfig.dataDirectory = statePath;
306
323
  }
307
- aztecNodeConfig.blobSinkUrl = `http://localhost:${blobSinkPort}`;
308
-
309
- // Setup blob sink service
310
- const blobSink = await createBlobSinkServer({
311
- port: blobSinkPort,
312
- dataStoreConfig: {
313
- dataDirectory: aztecNodeConfig.dataDirectory,
314
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
315
- },
316
- });
317
- await blobSink.start();
318
324
 
319
- // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
320
- logger.verbose('Starting anvil...');
321
- const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
322
- const anvil = res.anvil;
323
- aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
325
+ await setupSharedBlobStorage(aztecNodeConfig);
324
326
 
325
- // Deploy our L1 contracts.
326
- logger.verbose('Deploying L1 contracts...');
327
- const hdAccount = mnemonicToAccount(MNEMONIC, { accountIndex: 0 });
327
+ const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
328
328
  const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
329
329
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
330
+ const publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` satisfies `0x${string}`;
331
+
332
+ const l1Client = createExtendedL1Client([aztecNodeConfig.l1RpcUrls[0]], hdAccount, foundry);
330
333
 
331
334
  const validatorPrivKey = getPrivateKeyFromIndex(0);
332
335
  const proverNodePrivateKey = getPrivateKeyFromIndex(0);
333
336
 
334
- aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
335
- aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey!.toString('hex')}`;
337
+ aztecNodeConfig.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
338
+ aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
339
+ aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
340
+
341
+ logger.info(`Setting up environment with config`, aztecNodeConfig);
336
342
 
337
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
343
+ // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
344
+ logger.verbose('Starting anvil...');
345
+ const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
346
+ const anvil = res.anvil;
347
+ aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
348
+
349
+ const dateProvider = new TestDateProvider();
350
+ const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
338
351
 
352
+ // Deploy our L1 contracts.
353
+ logger.verbose('Deploying Aztec L1 contracts...');
339
354
  if (opts.l1StartTime) {
340
- await ethCheatCodes.warp(opts.l1StartTime);
355
+ await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
341
356
  }
342
357
 
343
358
  const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
344
- const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(
345
- initialFundedAccounts.map(a => a.address),
359
+ const sponsoredFPCAddress = await getSponsoredFPCAddress();
360
+ const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
361
+ initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
346
362
  opts.initialAccountFeeJuice,
347
363
  );
348
364
 
349
- const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrls[0], hdAccount, logger, {
365
+ const vkTreeRoot = getVKTreeRoot();
366
+ await deployMulticall3(l1Client, logger);
367
+
368
+ // Define args, defaulted to our environment variables.
369
+ const args: DeployAztecL1ContractsArgs = {
350
370
  ...getL1ContractsConfigEnvVars(),
351
- genesisArchiveRoot,
352
- genesisBlockHash,
353
- salt: opts.salt,
354
371
  ...deployL1ContractsArgs,
372
+ vkTreeRoot,
373
+ genesisArchiveRoot,
374
+ protocolContractsHash,
355
375
  initialValidators: opts.initialValidators,
356
- });
357
- aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
358
- aztecNodeConfig.l1PublishRetryIntervalMS = 100;
359
-
360
- if (opts.fundRewardDistributor) {
361
- // Mints block rewards for 10000 blocks to the rewardDistributor contract
362
-
363
- const rewardDistributor = getContract({
364
- address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
365
- abi: l1Artifacts.rewardDistributor.contractAbi,
366
- client: deployL1ContractsValues.publicClient,
367
- });
368
-
369
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
370
- const mintAmount = 10_000n * (blockReward as bigint);
376
+ feeJuicePortalInitialBalance: fundingNeeded,
377
+ realVerifier: false,
378
+ };
371
379
 
372
- const feeJuice = getContract({
373
- address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
374
- abi: l1Artifacts.feeAsset.contractAbi,
375
- client: deployL1ContractsValues.walletClient,
376
- });
380
+ const deployL1ContractsValues = await deployAztecL1Contracts(
381
+ aztecNodeConfig.l1RpcUrls[0],
382
+ publisherPrivKeyHex,
383
+ foundry.id,
384
+ args,
385
+ );
377
386
 
378
- const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
379
- await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
380
- logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
381
- }
387
+ aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
388
+ aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
382
389
 
383
390
  const watcher = new AnvilTestWatcher(
384
- new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
391
+ new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
385
392
  deployL1ContractsValues.l1ContractAddresses.rollupAddress,
386
- deployL1ContractsValues.publicClient,
393
+ deployL1ContractsValues.l1Client,
394
+ dateProvider,
387
395
  );
388
396
  await watcher.start();
389
397
 
@@ -399,10 +407,9 @@ async function setupFromFresh(
399
407
  aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
400
408
  }
401
409
 
402
- const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
410
+ const telemetry = await getEndToEndTestTelemetryClient(opts.metricsPort);
403
411
 
404
- logger.verbose('Creating and synching an aztec node...');
405
- const dateProvider = new TestDateProvider();
412
+ logger.info('Creating and synching an aztec node...');
406
413
  const aztecNode = await AztecNodeService.createAndSync(
407
414
  aztecNodeConfig,
408
415
  { telemetry, dateProvider },
@@ -411,22 +418,27 @@ async function setupFromFresh(
411
418
 
412
419
  let proverNode: ProverNode | undefined = undefined;
413
420
  if (opts.startProverNode) {
414
- logger.verbose('Creating and syncing a simulated prover node...');
421
+ logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
415
422
  proverNode = await createAndSyncProverNode(
416
423
  `0x${proverNodePrivateKey!.toString('hex')}`,
417
424
  aztecNodeConfig,
425
+ {
426
+ ...aztecNodeConfig.proverNodeConfig,
427
+ dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
428
+ p2pEnabled: false,
429
+ },
418
430
  aztecNode,
419
- path.join(directoryToCleanup, randomBytes(8).toString('hex')),
420
431
  prefilledPublicData,
421
432
  );
422
433
  }
423
434
 
424
435
  logger.verbose('Creating pxe...');
425
- const pxeConfig = getPXEServiceConfig();
436
+ const pxeConfig = getPXEConfig();
426
437
  pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
427
- const pxe = await createPXEService(aztecNode, pxeConfig);
428
-
429
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
438
+ // Only enable proving if specifically requested.
439
+ pxeConfig.proverEnabled = !!opts.realProofs;
440
+ const wallet = await TestWallet.create(aztecNode, pxeConfig);
441
+ const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
430
442
 
431
443
  if (statePath) {
432
444
  writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
@@ -437,7 +449,8 @@ async function setupFromFresh(
437
449
  aztecNodeConfig,
438
450
  anvil,
439
451
  aztecNode,
440
- pxe,
452
+ wallet,
453
+ sequencer: aztecNode.getSequencer()!,
441
454
  acvmConfig,
442
455
  bbConfig,
443
456
  deployL1ContractsValues,
@@ -445,7 +458,6 @@ async function setupFromFresh(
445
458
  watcher,
446
459
  cheatCodes,
447
460
  dateProvider,
448
- blobSink,
449
461
  initialFundedAccounts,
450
462
  directoryToCleanup,
451
463
  };
@@ -460,36 +472,28 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
460
472
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
461
473
  await fs.mkdir(directoryToCleanup, { recursive: true });
462
474
 
463
- // Run the blob sink on a random port
464
- const blobSinkPort = await getPort();
465
-
466
475
  // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
467
476
  const aztecNodeConfig: AztecNodeConfig & SetupOptions = JSON.parse(
468
477
  readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'),
469
478
  reviver,
470
479
  );
471
480
  aztecNodeConfig.dataDirectory = statePath;
472
- aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
481
+ aztecNodeConfig.listenAddress = '127.0.0.1';
482
+
483
+ await setupSharedBlobStorage(aztecNodeConfig);
473
484
 
474
485
  const initialFundedAccounts: InitialAccountData[] =
475
486
  JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
476
487
  const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map(a => a.address));
477
488
 
478
- const blobSink = await createBlobSinkServer({
479
- port: blobSinkPort,
480
- dataStoreConfig: {
481
- dataDirectory: statePath,
482
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
483
- },
484
- });
485
- await blobSink.start();
486
-
487
489
  // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
488
490
  const { anvil, rpcUrl } = await startAnvil();
489
491
  aztecNodeConfig.l1RpcUrls = [rpcUrl];
490
492
  // Load anvil state.
491
493
  const anvilStateFile = `${statePath}/anvil.dat`;
492
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
494
+
495
+ const dateProvider = new TestDateProvider();
496
+ const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
493
497
  await ethCheatCodes.loadChainState(anvilStateFile);
494
498
 
495
499
  // TODO: Encapsulate this in a NativeAcvm impl.
@@ -506,18 +510,19 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
506
510
  }
507
511
 
508
512
  logger.verbose('Creating ETH clients...');
509
- const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
513
+ const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
510
514
 
511
515
  const watcher = new AnvilTestWatcher(
512
- new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
516
+ ethCheatCodes,
513
517
  aztecNodeConfig.l1Contracts.rollupAddress,
514
- publicClient,
518
+ l1Client,
519
+ dateProvider,
515
520
  );
516
521
  await watcher.start();
517
522
 
523
+ const telemetry = await initTelemetryClient(getTelemetryConfig());
524
+
518
525
  logger.verbose('Creating aztec node...');
519
- const telemetry = initTelemetryClient(getTelemetryConfig());
520
- const dateProvider = new TestDateProvider();
521
526
  const aztecNode = await AztecNodeService.createAndSync(
522
527
  aztecNodeConfig,
523
528
  { telemetry, dateProvider },
@@ -532,36 +537,39 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
532
537
  proverNode = await createAndSyncProverNode(
533
538
  proverNodePrivateKeyHex,
534
539
  aztecNodeConfig,
540
+ {
541
+ ...aztecNodeConfig.proverNodeConfig,
542
+ dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
543
+ p2pEnabled: false,
544
+ },
535
545
  aztecNode,
536
- path.join(directoryToCleanup, randomBytes(8).toString('hex')),
537
546
  prefilledPublicData,
538
547
  );
539
548
  }
540
549
 
541
550
  logger.verbose('Creating pxe...');
542
- const pxeConfig = getPXEServiceConfig();
551
+ const pxeConfig = getPXEConfig();
543
552
  pxeConfig.dataDirectory = statePath;
544
- const pxe = await createPXEService(aztecNode, pxeConfig);
545
-
546
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
553
+ const wallet = await TestWallet.create(aztecNode, pxeConfig);
554
+ const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
547
555
 
548
556
  return {
549
557
  aztecNodeConfig,
550
558
  anvil,
551
559
  aztecNode,
552
- pxe,
560
+ wallet,
561
+ sequencer: aztecNode.getSequencer()!,
553
562
  acvmConfig,
554
563
  bbConfig,
555
564
  proverNode,
556
565
  deployL1ContractsValues: {
557
- walletClient,
558
- publicClient,
566
+ l1Client,
559
567
  l1ContractAddresses: aztecNodeConfig.l1Contracts,
568
+ rollupVersion: aztecNodeConfig.rollupVersion,
560
569
  },
561
570
  watcher,
562
571
  cheatCodes,
563
572
  dateProvider,
564
- blobSink,
565
573
  initialFundedAccounts,
566
574
  directoryToCleanup,
567
575
  };
@@ -572,15 +580,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
572
580
  * The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
573
581
  */
574
582
  export const deployAccounts =
575
- (numberOfAccounts: number, logger: Logger, waitUntilProven = false) =>
576
- async ({ pxe, initialFundedAccounts }: { pxe: PXE; initialFundedAccounts: InitialAccountData[] }) => {
583
+ (numberOfAccounts: number, logger: Logger) =>
584
+ async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
577
585
  if (initialFundedAccounts.length < numberOfAccounts) {
578
586
  throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
579
587
  }
580
588
 
581
589
  logger.verbose('Deploying accounts funded with fee juice...');
582
590
  const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
583
- await deployFundedSchnorrAccounts(pxe, deployedAccounts, { proven: waitUntilProven });
591
+ // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
592
+ for (let i = 0; i < deployedAccounts.length; i++) {
593
+ const accountManager = await wallet.createSchnorrAccount(
594
+ deployedAccounts[i].secret,
595
+ deployedAccounts[i].salt,
596
+ deployedAccounts[i].signingKey,
597
+ );
598
+ const deployMethod = await accountManager.getDeployMethod();
599
+ await deployMethod
600
+ .send({
601
+ from: AztecAddress.ZERO,
602
+ skipClassPublication: i !== 0, // Publish the contract class at most once.
603
+ })
604
+ .wait();
605
+ }
584
606
 
585
607
  return { deployedAccounts };
586
608
  };
@@ -590,28 +612,35 @@ export const deployAccounts =
590
612
  * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
591
613
  * @param sender - Wallet to send the deployment tx.
592
614
  * @param accountsToDeploy - Which accounts to publicly deploy.
615
+ * @param waitUntilProven - Whether to wait for the tx to be proven.
616
+ * @param node - AztecNode used to wait for proven tx.
593
617
  */
594
618
  export async function publicDeployAccounts(
595
- sender: Wallet,
596
- accountsToDeploy: (CompleteAddress | AztecAddress)[],
619
+ wallet: Wallet,
620
+ accountsToDeploy: AztecAddress[],
597
621
  waitUntilProven = false,
622
+ node?: AztecNode,
598
623
  ) {
599
- const accountAddressesToDeploy = accountsToDeploy.map(a => ('address' in a ? a.address : a));
600
- const instances = (
601
- await Promise.all(accountAddressesToDeploy.map(account => sender.getContractMetadata(account)))
602
- ).map(metadata => metadata.contractInstance);
624
+ const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
625
+ metadata => metadata.contractInstance,
626
+ );
603
627
 
604
628
  const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
605
- const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
629
+ const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
606
630
 
607
- const fns: ContractFunctionInteraction[] = await Promise.all([
608
- ...(!alreadyRegistered ? [registerContractClass(sender, SchnorrAccountContractArtifact)] : []),
609
- ...instances.map(instance => deployInstance(sender, instance!)),
631
+ const calls: ContractFunctionInteraction[] = await Promise.all([
632
+ ...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
633
+ ...instances.map(instance => publishInstance(wallet, instance!)),
610
634
  ]);
611
- const calls: FunctionCall[] = await Promise.all(fns.map(fn => fn.request()));
612
- const capsules: Capsule[] = fns.map(fn => fn.getCapsules()).flat();
613
635
 
614
- const batch = new BatchCall(sender, calls);
615
- batch.addCapsules(capsules);
616
- await batch.send().wait({ proven: waitUntilProven });
636
+ const batch = new BatchCall(wallet, calls);
637
+
638
+ const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
639
+ if (waitUntilProven) {
640
+ if (!node) {
641
+ throw new Error('Need to provide an AztecNode to wait for proven.');
642
+ } else {
643
+ await waitForProven(node, txReceipt);
644
+ }
645
+ }
617
646
  }