@aztec/end-to-end 1.2.0 → 2.0.0-nightly.20250813

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 (119) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/benchmark.js +4 -2
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +33 -15
  7. package/dest/bench/utils.d.ts.map +1 -1
  8. package/dest/bench/utils.js +7 -4
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -3
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +59 -24
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +3 -2
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +13 -10
  15. package/dest/e2e_deploy_contract/deploy_test.d.ts +1 -1
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  17. package/dest/e2e_deploy_contract/deploy_test.js +7 -6
  18. package/dest/e2e_epochs/epochs_test.d.ts +16 -2
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +65 -7
  21. package/dest/e2e_fees/bridging_race.notest.js +3 -1
  22. package/dest/e2e_fees/fees_test.d.ts +5 -4
  23. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  24. package/dest/e2e_fees/fees_test.js +44 -59
  25. package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
  26. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  27. package/dest/e2e_nested_contract/nested_contract_test.js +17 -12
  28. package/dest/e2e_p2p/p2p_network.d.ts +7 -4
  29. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  30. package/dest/e2e_p2p/p2p_network.js +43 -22
  31. package/dest/e2e_p2p/shared.d.ts +3 -3
  32. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  33. package/dest/e2e_p2p/shared.js +16 -12
  34. package/dest/e2e_token_contract/token_contract_test.d.ts +8 -4
  35. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  36. package/dest/e2e_token_contract/token_contract_test.js +48 -23
  37. package/dest/fixtures/e2e_prover_test.d.ts +1 -1
  38. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  39. package/dest/fixtures/e2e_prover_test.js +27 -10
  40. package/dest/fixtures/setup_p2p_test.d.ts +4 -1
  41. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  42. package/dest/fixtures/setup_p2p_test.js +39 -8
  43. package/dest/fixtures/snapshot_manager.d.ts +3 -1
  44. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  45. package/dest/fixtures/snapshot_manager.js +20 -17
  46. package/dest/fixtures/token_utils.d.ts +3 -3
  47. package/dest/fixtures/token_utils.d.ts.map +1 -1
  48. package/dest/fixtures/token_utils.js +14 -10
  49. package/dest/fixtures/utils.d.ts +23 -8
  50. package/dest/fixtures/utils.d.ts.map +1 -1
  51. package/dest/fixtures/utils.js +88 -56
  52. package/dest/integration_l1_publisher/write_json.d.ts +8 -0
  53. package/dest/integration_l1_publisher/write_json.d.ts.map +1 -0
  54. package/dest/integration_l1_publisher/write_json.js +57 -0
  55. package/dest/sample-dapp/connect.d.mts +2 -0
  56. package/dest/sample-dapp/connect.d.mts.map +1 -0
  57. package/dest/sample-dapp/connect.js +1 -1
  58. package/dest/sample-dapp/contracts.d.mts +3 -0
  59. package/dest/sample-dapp/contracts.d.mts.map +1 -0
  60. package/dest/sample-dapp/contracts.js +1 -1
  61. package/dest/sample-dapp/deploy.d.mts +3 -0
  62. package/dest/sample-dapp/deploy.d.mts.map +1 -0
  63. package/dest/sample-dapp/deploy.js +4 -1
  64. package/dest/sample-dapp/index.d.mts +2 -0
  65. package/dest/sample-dapp/index.d.mts.map +1 -0
  66. package/dest/sample-dapp/index.js +18 -8
  67. package/dest/shared/cross_chain_test_harness.d.ts +6 -3
  68. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  69. package/dest/shared/cross_chain_test_harness.js +50 -20
  70. package/dest/shared/gas_portal_test_harness.d.ts +3 -3
  71. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  72. package/dest/shared/gas_portal_test_harness.js +21 -6
  73. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  74. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  75. package/dest/shared/uniswap_l1_l2.js +45 -22
  76. package/dest/simulators/lending_simulator.d.ts +1 -1
  77. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  78. package/dest/simulators/lending_simulator.js +6 -2
  79. package/dest/simulators/token_simulator.d.ts +2 -1
  80. package/dest/simulators/token_simulator.d.ts.map +1 -1
  81. package/dest/simulators/token_simulator.js +12 -4
  82. package/dest/spartan/setup_test_wallets.d.ts +7 -0
  83. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  84. package/dest/spartan/setup_test_wallets.js +96 -11
  85. package/dest/spartan/utils.d.ts +23 -3
  86. package/dest/spartan/utils.d.ts.map +1 -1
  87. package/dest/spartan/utils.js +9 -6
  88. package/package.json +36 -36
  89. package/src/bench/client_flows/benchmark.ts +8 -3
  90. package/src/bench/client_flows/client_flows_benchmark.ts +23 -14
  91. package/src/bench/utils.ts +5 -4
  92. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +47 -26
  93. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +14 -9
  94. package/src/e2e_deploy_contract/deploy_test.ts +7 -7
  95. package/src/e2e_epochs/epochs_test.ts +97 -25
  96. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  97. package/src/e2e_fees/fees_test.ts +55 -82
  98. package/src/e2e_nested_contract/nested_contract_test.ts +16 -11
  99. package/src/e2e_p2p/p2p_network.ts +51 -26
  100. package/src/e2e_p2p/shared.ts +14 -12
  101. package/src/e2e_token_contract/token_contract_test.ts +38 -36
  102. package/src/fixtures/e2e_prover_test.ts +17 -10
  103. package/src/fixtures/setup_p2p_test.ts +51 -9
  104. package/src/fixtures/snapshot_manager.ts +24 -17
  105. package/src/fixtures/token_utils.ts +14 -9
  106. package/src/fixtures/utils.ts +116 -57
  107. package/src/guides/up_quick_start.sh +1 -1
  108. package/src/integration_l1_publisher/write_json.ts +74 -0
  109. package/src/sample-dapp/connect.mjs +1 -1
  110. package/src/sample-dapp/contracts.mjs +1 -1
  111. package/src/sample-dapp/deploy.mjs +3 -3
  112. package/src/sample-dapp/index.mjs +11 -8
  113. package/src/shared/cross_chain_test_harness.ts +31 -18
  114. package/src/shared/gas_portal_test_harness.ts +17 -7
  115. package/src/shared/uniswap_l1_l2.ts +28 -24
  116. package/src/simulators/lending_simulator.ts +3 -3
  117. package/src/simulators/token_simulator.ts +12 -3
  118. package/src/spartan/setup_test_wallets.ts +130 -19
  119. package/src/spartan/utils.ts +10 -3
@@ -1,5 +1,5 @@
1
1
  import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import { type AccountWallet, type AztecNode, type CompleteAddress, type Logger, createLogger } from '@aztec/aztec.js';
2
+ import { type AccountWallet, AztecAddress, type AztecNode, type Logger, createLogger } from '@aztec/aztec.js';
3
3
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
4
  import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
5
5
 
@@ -23,13 +23,18 @@ export class TokenContractTest {
23
23
  static TOKEN_DECIMALS = 18n;
24
24
  private snapshotManager: ISnapshotManager;
25
25
  logger: Logger;
26
- wallets: AccountWallet[] = [];
27
- accounts: CompleteAddress[] = [];
28
26
  asset!: TokenContract;
29
27
  tokenSim!: TokenSimulator;
30
- badAccount!: InvalidAccountContract;
31
28
  node!: AztecNode;
32
29
 
30
+ badAccount!: InvalidAccountContract;
31
+ admin!: AccountWallet;
32
+ adminAddress!: AztecAddress;
33
+ account1!: AccountWallet;
34
+ account1Address!: AztecAddress;
35
+ account2!: AccountWallet;
36
+ account2Address!: AztecAddress;
37
+
33
38
  constructor(testName: string) {
34
39
  this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
35
40
  this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
@@ -51,8 +56,9 @@ export class TokenContractTest {
51
56
  deployAccounts(3, this.logger),
52
57
  async ({ deployedAccounts }, { pxe, aztecNode }) => {
53
58
  this.node = aztecNode;
54
- this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
55
- this.accounts = this.wallets.map(w => w.getCompleteAddress());
59
+ const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
60
+ [this.admin, this.account1, this.account2] = wallets;
61
+ [this.adminAddress, this.account1Address, this.account2Address] = wallets.map(w => w.getAddress());
56
62
  },
57
63
  );
58
64
 
@@ -62,42 +68,42 @@ export class TokenContractTest {
62
68
  // Create the token contract state.
63
69
  // Move this account thing to addAccounts above?
64
70
  this.logger.verbose(`Public deploy accounts...`);
65
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
71
+ await publicDeployAccounts(this.admin, [this.adminAddress, this.account1Address]);
66
72
 
67
73
  this.logger.verbose(`Deploying TokenContract...`);
68
74
  const asset = await TokenContract.deploy(
69
- this.wallets[0],
70
- this.accounts[0],
75
+ this.admin,
76
+ this.adminAddress,
71
77
  TokenContractTest.TOKEN_NAME,
72
78
  TokenContractTest.TOKEN_SYMBOL,
73
79
  TokenContractTest.TOKEN_DECIMALS,
74
80
  )
75
- .send()
81
+ .send({ from: this.adminAddress })
76
82
  .deployed();
77
83
  this.logger.verbose(`Token deployed to ${asset.address}`);
78
84
 
79
85
  this.logger.verbose(`Deploying bad account...`);
80
- this.badAccount = await InvalidAccountContract.deploy(this.wallets[0]).send().deployed();
86
+ this.badAccount = await InvalidAccountContract.deploy(this.admin).send({ from: this.adminAddress }).deployed();
81
87
  this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
82
88
 
83
89
  return { tokenContractAddress: asset.address, badAccountAddress: this.badAccount.address };
84
90
  },
85
91
  async ({ tokenContractAddress, badAccountAddress }) => {
86
92
  // Restore the token contract state.
87
- this.asset = await TokenContract.at(tokenContractAddress, this.wallets[0]);
93
+ this.asset = await TokenContract.at(tokenContractAddress, this.admin);
88
94
  this.logger.verbose(`Token contract address: ${this.asset.address}`);
89
95
 
90
- this.tokenSim = new TokenSimulator(
91
- this.asset,
92
- this.wallets[0],
93
- this.logger,
94
- this.accounts.map(a => a.address),
95
- );
96
+ this.tokenSim = new TokenSimulator(this.asset, this.admin, this.adminAddress, this.logger, [
97
+ this.adminAddress,
98
+ this.account1Address,
99
+ ]);
96
100
 
97
- this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallets[0]);
101
+ this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.admin);
98
102
  this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
99
103
 
100
- expect(await this.asset.methods.get_admin().simulate()).toBe(this.accounts[0].address.toBigInt());
104
+ expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
105
+ this.adminAddress.toBigInt(),
106
+ );
101
107
  },
102
108
  );
103
109
 
@@ -125,36 +131,32 @@ export class TokenContractTest {
125
131
  await this.snapshotManager.snapshot(
126
132
  'mint',
127
133
  async () => {
128
- const { asset, wallets } = this;
134
+ const { asset, admin, adminAddress } = this;
129
135
  const amount = 10000n;
130
136
 
131
137
  this.logger.verbose(`Minting ${amount} publicly...`);
132
- await asset.methods.mint_to_public(wallets[0].getAddress(), amount).send().wait();
138
+ await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress }).wait();
133
139
 
134
140
  this.logger.verbose(`Minting ${amount} privately...`);
135
- await mintTokensToPrivate(asset, wallets[0], wallets[0].getAddress(), amount);
141
+ await mintTokensToPrivate(asset, adminAddress, admin, adminAddress, amount);
136
142
  this.logger.verbose(`Minting complete.`);
137
143
 
138
144
  return { amount };
139
145
  },
140
146
  async ({ amount }) => {
141
- const {
142
- asset,
143
- accounts: [{ address }],
144
- tokenSim,
145
- } = this;
146
- tokenSim.mintPublic(address, amount);
147
-
148
- const publicBalance = await asset.methods.balance_of_public(address).simulate();
147
+ const { asset, adminAddress, tokenSim } = this;
148
+ tokenSim.mintPublic(adminAddress, amount);
149
+
150
+ const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({ from: adminAddress });
149
151
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
150
- expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
152
+ expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
151
153
 
152
- tokenSim.mintPrivate(address, amount);
153
- const privateBalance = await asset.methods.balance_of_private(address).simulate();
154
+ tokenSim.mintPrivate(adminAddress, amount);
155
+ const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({ from: adminAddress });
154
156
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
155
- expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
157
+ expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
156
158
 
157
- const totalSupply = await asset.methods.total_supply().simulate();
159
+ const totalSupply = await asset.methods.total_supply().simulate({ from: adminAddress });
158
160
  this.logger.verbose(`Total supply: ${totalSupply}`);
159
161
  expect(totalSupply).toEqual(tokenSim.totalSupply);
160
162
 
@@ -14,7 +14,7 @@ import {
14
14
  type PXE,
15
15
  createLogger,
16
16
  } from '@aztec/aztec.js';
17
- import { CheatCodes } from '@aztec/aztec.js/testing';
17
+ import { CheatCodes } from '@aztec/aztec/testing';
18
18
  import {
19
19
  BBCircuitVerifier,
20
20
  type ClientProtocolCircuitVerifier,
@@ -141,7 +141,7 @@ export class FullProverTest {
141
141
  FullProverTest.TOKEN_SYMBOL,
142
142
  FullProverTest.TOKEN_DECIMALS,
143
143
  )
144
- .send()
144
+ .send({ from: this.wallets[0].getAddress() })
145
145
  .deployed();
146
146
  this.logger.verbose(`Token deployed to ${asset.address}`);
147
147
 
@@ -155,11 +155,14 @@ export class FullProverTest {
155
155
  this.tokenSim = new TokenSimulator(
156
156
  this.fakeProofsAsset,
157
157
  this.wallets[0],
158
+ this.wallets[0].getAddress(),
158
159
  this.logger,
159
160
  this.accounts.map(a => a.address),
160
161
  );
161
162
 
162
- expect(await this.fakeProofsAsset.methods.get_admin().simulate()).toBe(this.accounts[0].address.toBigInt());
163
+ expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0].address })).toBe(
164
+ this.accounts[0].address.toBigInt(),
165
+ );
163
166
  },
164
167
  );
165
168
  }
@@ -276,7 +279,7 @@ export class FullProverTest {
276
279
  this.logger.verbose('Starting archiver for new prover node');
277
280
  const archiver = await createArchiver(
278
281
  { ...this.context.aztecNodeConfig, dataDirectory: undefined },
279
- blobSinkClient,
282
+ { blobSinkClient },
280
283
  { blockUntilSync: true },
281
284
  );
282
285
 
@@ -291,7 +294,7 @@ export class FullProverTest {
291
294
  this.logger.verbose('Starting prover node');
292
295
  const proverConfig: ProverNodeConfig = {
293
296
  ...this.context.aztecNodeConfig,
294
- proverCoordinationNodeUrls: [],
297
+ txCollectionNodeRpcUrls: [],
295
298
  dataDirectory: undefined,
296
299
  proverId: this.proverAddress.toField(),
297
300
  realProofs: this.realProofs,
@@ -303,6 +306,7 @@ export class FullProverTest {
303
306
  txGatheringIntervalMs: 1000,
304
307
  txGatheringBatchSize: 10,
305
308
  txGatheringMaxParallelRequestsPerNode: 100,
309
+ txGatheringTimeoutMs: 24_000,
306
310
  proverNodeFailedEpochStore: undefined,
307
311
  };
308
312
  const sponsoredFPCAddress = await getSponsoredFPCAddress();
@@ -364,11 +368,14 @@ export class FullProverTest {
364
368
  this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
365
369
  await asset.methods
366
370
  .mint_to_public(accounts[0].address, privateAmount + publicAmount)
367
- .send()
371
+ .send({ from: accounts[0].address })
368
372
  .wait();
369
373
 
370
374
  this.logger.verbose(`Transferring ${privateAmount} to private...`);
371
- await asset.methods.transfer_to_private(accounts[0].address, privateAmount).send().wait();
375
+ await asset.methods
376
+ .transfer_to_private(accounts[0].address, privateAmount)
377
+ .send({ from: accounts[0].address })
378
+ .wait();
372
379
 
373
380
  this.logger.verbose(`Minting complete.`);
374
381
 
@@ -382,16 +389,16 @@ export class FullProverTest {
382
389
  } = this;
383
390
  tokenSim.mintPublic(address, amount);
384
391
 
385
- const publicBalance = await asset.methods.balance_of_public(address).simulate();
392
+ const publicBalance = await asset.methods.balance_of_public(address).simulate({ from: address });
386
393
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
387
394
  expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
388
395
 
389
396
  tokenSim.mintPrivate(address, amount);
390
- const privateBalance = await asset.methods.balance_of_private(address).simulate();
397
+ const privateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
391
398
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
392
399
  expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
393
400
 
394
- const totalSupply = await asset.methods.total_supply().simulate();
401
+ const totalSupply = await asset.methods.total_supply().simulate({ from: address });
395
402
  this.logger.verbose(`Total supply: ${totalSupply}`);
396
403
  expect(totalSupply).toEqual(tokenSim.totalSupply);
397
404
 
@@ -5,7 +5,9 @@ import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
5
5
  import type { SentTx } from '@aztec/aztec.js';
6
6
  import { SecretValue } from '@aztec/foundation/config';
7
7
  import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
8
+ import { bufferToHex } from '@aztec/foundation/string';
8
9
  import type { DateProvider } from '@aztec/foundation/timer';
10
+ import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
9
11
  import type { PXEService } from '@aztec/pxe/server';
10
12
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
11
13
 
@@ -13,12 +15,14 @@ import getPort from 'get-port';
13
15
  import { AsyncLocalStorage } from 'node:async_hooks';
14
16
 
15
17
  import { TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
16
- import { getPrivateKeyFromIndex } from './utils.js';
18
+ import { createAndSyncProverNode, getPrivateKeyFromIndex } from './utils.js';
17
19
  import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
18
20
 
19
21
  // Setup snapshots will create a node with index 0, and run extra bootstrap with
20
22
  // index 1, so all of our loops here need to start from 2 to avoid running validators with the same key
21
23
  export const ATTESTER_PRIVATE_KEYS_START_INDEX = 2;
24
+ // We use slasher keys after the first 10 anvil keys, note that this requires anvil to be started with more than the default 10 accounts
25
+ export const SLASHER_PRIVATE_KEYS_START_INDEX = 12;
22
26
 
23
27
  export interface NodeContext {
24
28
  node: AztecNodeService;
@@ -44,6 +48,7 @@ export async function createNodes(
44
48
  prefilledPublicData?: PublicDataTreeLeaf[],
45
49
  dataDirectory?: string,
46
50
  metricsPort?: number,
51
+ indexOffset = 0,
47
52
  ): Promise<AztecNodeService[]> {
48
53
  const nodePromises: Promise<AztecNodeService>[] = [];
49
54
  const loggerIdStorage = new AsyncLocalStorage<string>();
@@ -52,16 +57,17 @@ export async function createNodes(
52
57
  addLogNameHandler(logNameHandler);
53
58
 
54
59
  for (let i = 0; i < numNodes; i++) {
60
+ const index = indexOffset + i;
55
61
  // We run on ports from the bootnode upwards
56
- const port = bootNodePort + i + 1;
62
+ const port = bootNodePort + 1 + index;
57
63
 
58
- const dataDir = dataDirectory ? `${dataDirectory}-${i}` : undefined;
64
+ const dataDir = dataDirectory ? `${dataDirectory}-${index}` : undefined;
59
65
  const nodePromise = createNode(
60
66
  config,
61
67
  dateProvider,
62
68
  port,
63
69
  bootstrapNodeEnr,
64
- i,
70
+ index,
65
71
  prefilledPublicData,
66
72
  dataDir,
67
73
  metricsPort,
@@ -71,9 +77,9 @@ export async function createNodes(
71
77
  }
72
78
  const nodes = await Promise.all(nodePromises);
73
79
 
74
- // Sanity check that we have a sequencer
80
+ // Sanity check that we have a sequencer if required
75
81
  const seqClient = nodes[0].getSequencer();
76
- if (!seqClient) {
82
+ if (!seqClient && config.disableValidator === false) {
77
83
  throw new Error('Sequencer not found');
78
84
  }
79
85
 
@@ -101,6 +107,42 @@ export async function createNode(
101
107
  return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
102
108
  }
103
109
 
110
+ export async function createProverNode(
111
+ config: AztecNodeConfig,
112
+ tcpPort: number,
113
+ bootstrapNode: string | undefined,
114
+ addressIndex: number,
115
+ proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
116
+ prefilledPublicData?: PublicDataTreeLeaf[],
117
+ dataDirectory?: string,
118
+ metricsPort?: number,
119
+ loggerIdStorage?: AsyncLocalStorage<string>,
120
+ ) {
121
+ const createProverNode = async () => {
122
+ const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
123
+ const telemetry = getEndToEndTestTelemetryClient(metricsPort);
124
+
125
+ const proverConfig: Partial<ProverNodeConfig> = {
126
+ p2pIp: `127.0.0.1`,
127
+ p2pPort: tcpPort ?? (await getPort()),
128
+ p2pEnabled: true,
129
+ peerCheckIntervalMS: TEST_PEER_CHECK_INTERVAL_MS,
130
+ blockCheckIntervalMS: 1000,
131
+ bootstrapNodes: bootstrapNode ? [bootstrapNode] : [],
132
+ };
133
+ const aztecNodeRpcTxProvider = undefined;
134
+ return await createAndSyncProverNode(
135
+ bufferToHex(proverNodePrivateKey),
136
+ config,
137
+ { ...proverConfig, dataDirectory },
138
+ aztecNodeRpcTxProvider,
139
+ prefilledPublicData,
140
+ { ...proverNodeDeps, telemetry },
141
+ );
142
+ };
143
+ return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
144
+ }
145
+
104
146
  export async function createValidatorConfig(
105
147
  config: AztecNodeConfig,
106
148
  bootstrapNodeEnr?: string,
@@ -110,12 +152,12 @@ export async function createValidatorConfig(
110
152
  ) {
111
153
  port = port ?? (await getPort());
112
154
 
113
- const attesterPrivateKey: `0x${string}` = `0x${getPrivateKeyFromIndex(
114
- ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex,
115
- )!.toString('hex')}`;
155
+ const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
156
+ const slasherPrivateKey = bufferToHex(getPrivateKeyFromIndex(SLASHER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
116
157
 
117
158
  config.validatorPrivateKeys = new SecretValue([attesterPrivateKey]);
118
159
  config.publisherPrivateKey = new SecretValue(attesterPrivateKey);
160
+ config.slasherPrivateKey = new SecretValue(slasherPrivateKey);
119
161
 
120
162
  const nodeConfig: AztecNodeConfig = {
121
163
  ...config,
@@ -14,16 +14,17 @@ import {
14
14
  getContractClassFromArtifact,
15
15
  waitForProven,
16
16
  } from '@aztec/aztec.js';
17
- import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
18
- import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec.js/testing';
17
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
18
+ import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
19
  import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
20
20
  import {
21
21
  type DeployL1ContractsArgs,
22
22
  type DeployL1ContractsReturnType,
23
+ FeeAssetArtifact,
24
+ RollupContract,
23
25
  createExtendedL1Client,
24
26
  deployMulticall3,
25
27
  getL1ContractsConfigEnvVars,
26
- l1Artifacts,
27
28
  } from '@aztec/ethereum';
28
29
  import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
29
30
  import { asyncMap } from '@aztec/foundation/async-map';
@@ -35,6 +36,7 @@ import { resolver, reviver } from '@aztec/foundation/serialize';
35
36
  import { TestDateProvider } from '@aztec/foundation/timer';
36
37
  import type { ProverNode } from '@aztec/prover-node';
37
38
  import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
39
+ import type { SequencerClient } from '@aztec/sequencer-client';
38
40
  import { tryStop } from '@aztec/stdlib/interfaces/server';
39
41
  import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
40
42
  import { getGenesisValues } from '@aztec/world-state/testing';
@@ -74,6 +76,7 @@ export type SubsystemsContext = {
74
76
  proverNode?: ProverNode;
75
77
  watcher: AnvilTestWatcher;
76
78
  cheatCodes: CheatCodes;
79
+ sequencer: SequencerClient;
77
80
  dateProvider: TestDateProvider;
78
81
  blobSink: BlobSinkServer;
79
82
  initialFundedAccounts: InitialAccountData[];
@@ -348,7 +351,7 @@ async function setupFromFresh(
348
351
  const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
349
352
 
350
353
  if (opts.l1StartTime) {
351
- await ethCheatCodes.warp(opts.l1StartTime);
354
+ await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
352
355
  }
353
356
 
354
357
  const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
@@ -376,22 +379,24 @@ async function setupFromFresh(
376
379
  if (opts.fundRewardDistributor) {
377
380
  // Mints block rewards for 10000 blocks to the rewardDistributor contract
378
381
 
379
- const rewardDistributor = getContract({
380
- address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
381
- abi: l1Artifacts.rewardDistributor.contractAbi,
382
- client: deployL1ContractsValues.l1Client,
383
- });
382
+ const rollup = new RollupContract(
383
+ deployL1ContractsValues.l1Client,
384
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
385
+ );
384
386
 
385
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
387
+ const blockReward = await rollup.getBlockReward();
386
388
  const mintAmount = 10_000n * (blockReward as bigint);
387
389
 
388
390
  const feeJuice = getContract({
389
391
  address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
390
- abi: l1Artifacts.feeAsset.contractAbi,
392
+ abi: FeeAssetArtifact.contractAbi,
391
393
  client: deployL1ContractsValues.l1Client,
392
394
  });
393
395
 
394
- const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
396
+ const rewardDistributorMintTxHash = await feeJuice.write.mint(
397
+ [deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(), mintAmount],
398
+ {} as any,
399
+ );
395
400
  await deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
396
401
  logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
397
402
  }
@@ -443,11 +448,11 @@ async function setupFromFresh(
443
448
 
444
449
  let proverNode: ProverNode | undefined = undefined;
445
450
  if (opts.startProverNode) {
446
- logger.verbose('Creating and syncing a simulated prover node...');
451
+ logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
447
452
  proverNode = await createAndSyncProverNode(
448
453
  `0x${proverNodePrivateKey!.toString('hex')}`,
449
454
  aztecNodeConfig,
450
- { dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')) },
455
+ { dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')), p2pEnabled: false },
451
456
  aztecNode,
452
457
  prefilledPublicData,
453
458
  );
@@ -472,6 +477,7 @@ async function setupFromFresh(
472
477
  anvil,
473
478
  aztecNode,
474
479
  pxe,
480
+ sequencer: aztecNode.getSequencer()!,
475
481
  acvmConfig,
476
482
  bbConfig,
477
483
  deployL1ContractsValues,
@@ -590,6 +596,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
590
596
  anvil,
591
597
  aztecNode,
592
598
  pxe,
599
+ sequencer: aztecNode.getSequencer()!,
593
600
  acvmConfig,
594
601
  bbConfig,
595
602
  proverNode,
@@ -653,13 +660,13 @@ export async function publicDeployAccounts(
653
660
  const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
654
661
 
655
662
  const calls: ContractFunctionInteraction[] = await Promise.all([
656
- ...(!alreadyRegistered ? [registerContractClass(sender, SchnorrAccountContractArtifact)] : []),
657
- ...instances.map(instance => deployInstance(sender, instance!)),
663
+ ...(!alreadyRegistered ? [publishContractClass(sender, SchnorrAccountContractArtifact)] : []),
664
+ ...instances.map(instance => publishInstance(sender, instance!)),
658
665
  ]);
659
666
 
660
667
  const batch = new BatchCall(sender, calls);
661
668
 
662
- const txReceipt = await batch.send().wait();
669
+ const txReceipt = await batch.send({ from: accountAddressesToDeploy[0] }).wait();
663
670
  if (waitUntilProven) {
664
671
  if (!pxeOrNode) {
665
672
  throw new Error('Need to provide a PXE or AztecNode to wait for proven.');
@@ -3,15 +3,20 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
3
3
 
4
4
  // docs:start:token_utils
5
5
 
6
- export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigint, logger: Logger) {
6
+ export async function deployToken(
7
+ adminWallet: Wallet,
8
+ deployerAddress: AztecAddress,
9
+ initialAdminBalance: bigint,
10
+ logger: Logger,
11
+ ) {
7
12
  logger.info(`Deploying Token contract...`);
8
- const contract = await TokenContract.deploy(adminWallet, adminWallet.getAddress(), 'TokenName', 'TokenSymbol', 18)
9
- .send()
13
+ const contract = await TokenContract.deploy(adminWallet, deployerAddress, 'TokenName', 'TokenSymbol', 18)
14
+ .send({ from: deployerAddress })
10
15
  .deployed();
11
16
 
12
17
  if (initialAdminBalance > 0n) {
13
18
  // Minter is minting to herself so contract as minter is the same as contract as recipient
14
- await mintTokensToPrivate(contract, adminWallet, adminWallet.getAddress(), initialAdminBalance);
19
+ await mintTokensToPrivate(contract, deployerAddress, adminWallet, deployerAddress, initialAdminBalance);
15
20
  }
16
21
 
17
22
  logger.info('L2 contract deployed');
@@ -21,13 +26,13 @@ export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigi
21
26
 
22
27
  export async function mintTokensToPrivate(
23
28
  token: TokenContract,
29
+ minter: AztecAddress,
24
30
  minterWallet: Wallet,
25
31
  recipient: AztecAddress,
26
32
  amount: bigint,
27
33
  ) {
28
34
  const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
29
- const from = minterWallet.getAddress(); // we are setting from to minter here because we need a sender to calculate the tag
30
- await tokenAsMinter.methods.mint_to_private(from, recipient, amount).send().wait();
35
+ await tokenAsMinter.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
31
36
  }
32
37
  // docs:end:token_utils
33
38
 
@@ -47,6 +52,7 @@ export async function expectTokenBalance(
47
52
 
48
53
  export async function mintNotes(
49
54
  sender: Wallet,
55
+ minter: AztecAddress,
50
56
  recipient: AztecAddress,
51
57
  asset: TokenContract,
52
58
  noteAmounts: bigint[],
@@ -56,9 +62,8 @@ export async function mintNotes(
56
62
  const notesPerIteration = 4;
57
63
  for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
58
64
  const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
59
- const from = sender.getAddress(); // we are setting from to sender here because we need a sender to calculate the tag
60
- const actions = toMint.map(amt => asset.methods.mint_to_private(from, recipient, amt));
61
- await new BatchCall(sender, actions).send().wait();
65
+ const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
66
+ await new BatchCall(sender, actions).send({ from: minter }).wait();
62
67
  }
63
68
 
64
69
  return noteAmounts.reduce((prev, curr) => prev + curr, 0n);