@aztec/end-to-end 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2c85e299c

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 (187) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +19 -11
  4. package/dest/bench/client_flows/config.d.ts +2 -2
  5. package/dest/bench/client_flows/config.d.ts.map +1 -1
  6. package/dest/bench/client_flows/config.js +18 -0
  7. package/dest/bench/utils.d.ts +1 -1
  8. package/dest/bench/utils.d.ts.map +1 -1
  9. package/dest/bench/utils.js +6 -3
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  12. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +22 -12
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  15. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -2
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
  17. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  18. package/dest/e2e_epochs/epochs_test.d.ts +9 -7
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +68 -38
  21. package/dest/e2e_fees/fees_test.d.ts +2 -2
  22. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  23. package/dest/e2e_fees/fees_test.js +18 -11
  24. package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
  25. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  26. package/dest/e2e_l1_publisher/write_json.js +1 -7
  27. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  28. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  29. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  30. package/dest/e2e_p2p/p2p_network.d.ts +5 -4
  31. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  32. package/dest/e2e_p2p/p2p_network.js +24 -7
  33. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  34. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  35. package/dest/e2e_p2p/reqresp/utils.js +177 -0
  36. package/dest/e2e_p2p/shared.d.ts +16 -2
  37. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  38. package/dest/e2e_p2p/shared.js +32 -5
  39. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  40. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  41. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  42. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  43. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  44. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  45. package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
  46. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  47. package/dest/e2e_token_contract/token_contract_test.js +19 -9
  48. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  49. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  50. package/dest/fixtures/authwit_proxy.js +30 -0
  51. package/dest/fixtures/e2e_prover_test.d.ts +4 -4
  52. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  53. package/dest/fixtures/e2e_prover_test.js +34 -41
  54. package/dest/fixtures/elu_monitor.d.ts +21 -0
  55. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  56. package/dest/fixtures/elu_monitor.js +102 -0
  57. package/dest/fixtures/fixtures.d.ts +5 -1
  58. package/dest/fixtures/fixtures.d.ts.map +1 -1
  59. package/dest/fixtures/fixtures.js +6 -0
  60. package/dest/fixtures/ha_setup.d.ts +71 -0
  61. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  62. package/dest/fixtures/ha_setup.js +116 -0
  63. package/dest/fixtures/index.d.ts +2 -1
  64. package/dest/fixtures/index.d.ts.map +1 -1
  65. package/dest/fixtures/index.js +1 -0
  66. package/dest/fixtures/setup.d.ts +41 -25
  67. package/dest/fixtures/setup.d.ts.map +1 -1
  68. package/dest/fixtures/setup.js +81 -166
  69. package/dest/fixtures/setup_p2p_test.d.ts +16 -9
  70. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  71. package/dest/fixtures/setup_p2p_test.js +40 -29
  72. package/dest/fixtures/token_utils.d.ts +2 -2
  73. package/dest/fixtures/token_utils.d.ts.map +1 -1
  74. package/dest/fixtures/token_utils.js +5 -4
  75. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  76. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  77. package/dest/shared/cross_chain_test_harness.js +13 -13
  78. package/dest/shared/gas_portal_test_harness.js +2 -2
  79. package/dest/shared/index.d.ts +2 -1
  80. package/dest/shared/index.d.ts.map +1 -1
  81. package/dest/shared/index.js +1 -0
  82. package/dest/shared/jest_setup.js +41 -1
  83. package/dest/shared/mock_state_view.d.ts +86 -0
  84. package/dest/shared/mock_state_view.d.ts.map +1 -0
  85. package/dest/shared/mock_state_view.js +186 -0
  86. package/dest/shared/submit-transactions.d.ts +2 -2
  87. package/dest/shared/submit-transactions.d.ts.map +1 -1
  88. package/dest/shared/submit-transactions.js +1 -1
  89. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  90. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  91. package/dest/shared/uniswap_l1_l2.js +13 -11
  92. package/dest/simulators/lending_simulator.d.ts +1 -1
  93. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  94. package/dest/simulators/lending_simulator.js +2 -2
  95. package/dest/simulators/token_simulator.d.ts +1 -1
  96. package/dest/simulators/token_simulator.d.ts.map +1 -1
  97. package/dest/simulators/token_simulator.js +3 -24
  98. package/dest/spartan/setup_test_wallets.d.ts +9 -2
  99. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  100. package/dest/spartan/setup_test_wallets.js +35 -4
  101. package/dest/spartan/tx_metrics.js +1 -1
  102. package/dest/spartan/utils/bot.d.ts +3 -2
  103. package/dest/spartan/utils/bot.d.ts.map +1 -1
  104. package/dest/spartan/utils/bot.js +2 -1
  105. package/dest/spartan/utils/config.d.ts +7 -1
  106. package/dest/spartan/utils/config.d.ts.map +1 -1
  107. package/dest/spartan/utils/config.js +3 -1
  108. package/dest/spartan/utils/index.d.ts +5 -4
  109. package/dest/spartan/utils/index.d.ts.map +1 -1
  110. package/dest/spartan/utils/index.js +4 -2
  111. package/dest/spartan/utils/k8s.d.ts +31 -1
  112. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  113. package/dest/spartan/utils/k8s.js +124 -0
  114. package/dest/spartan/utils/nodes.d.ts +14 -5
  115. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  116. package/dest/spartan/utils/nodes.js +204 -33
  117. package/dest/spartan/utils/scripts.d.ts +18 -4
  118. package/dest/spartan/utils/scripts.d.ts.map +1 -1
  119. package/dest/spartan/utils/scripts.js +19 -4
  120. package/dest/test-wallet/test_wallet.d.ts +83 -0
  121. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  122. package/dest/test-wallet/test_wallet.js +214 -0
  123. package/dest/test-wallet/utils.d.ts +41 -0
  124. package/dest/test-wallet/utils.d.ts.map +1 -0
  125. package/dest/test-wallet/utils.js +71 -0
  126. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  127. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  128. package/dest/test-wallet/wallet_worker_script.js +48 -0
  129. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  130. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  131. package/dest/test-wallet/worker_wallet.js +151 -0
  132. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  133. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  134. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  135. package/package.json +46 -43
  136. package/src/bench/client_flows/client_flows_benchmark.ts +42 -38
  137. package/src/bench/client_flows/config.ts +9 -1
  138. package/src/bench/utils.ts +8 -3
  139. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +28 -15
  140. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
  141. package/src/e2e_deploy_contract/deploy_test.ts +3 -3
  142. package/src/e2e_epochs/epochs_test.ts +79 -68
  143. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  144. package/src/e2e_fees/fees_test.ts +20 -28
  145. package/src/e2e_l1_publisher/write_json.ts +1 -6
  146. package/src/e2e_nested_contract/nested_contract_test.ts +7 -5
  147. package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
  148. package/src/e2e_p2p/p2p_network.ts +36 -10
  149. package/src/e2e_p2p/reqresp/utils.ts +235 -0
  150. package/src/e2e_p2p/shared.ts +58 -5
  151. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  152. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  153. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  154. package/src/e2e_token_contract/token_contract_test.ts +26 -9
  155. package/src/fixtures/authwit_proxy.ts +50 -0
  156. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  157. package/src/fixtures/e2e_prover_test.ts +40 -44
  158. package/src/fixtures/elu_monitor.ts +126 -0
  159. package/src/fixtures/fixtures.ts +10 -0
  160. package/src/fixtures/ha_setup.ts +186 -0
  161. package/src/fixtures/index.ts +1 -0
  162. package/src/fixtures/setup.ts +106 -226
  163. package/src/fixtures/setup_p2p_test.ts +40 -44
  164. package/src/fixtures/token_utils.ts +6 -3
  165. package/src/guides/up_quick_start.sh +3 -3
  166. package/src/shared/cross_chain_test_harness.ts +13 -9
  167. package/src/shared/gas_portal_test_harness.ts +1 -1
  168. package/src/shared/index.ts +1 -0
  169. package/src/shared/jest_setup.ts +51 -1
  170. package/src/shared/mock_state_view.ts +188 -0
  171. package/src/shared/submit-transactions.ts +3 -2
  172. package/src/shared/uniswap_l1_l2.ts +15 -15
  173. package/src/simulators/lending_simulator.ts +4 -2
  174. package/src/simulators/token_simulator.ts +6 -30
  175. package/src/spartan/setup_test_wallets.ts +59 -12
  176. package/src/spartan/tx_metrics.ts +1 -1
  177. package/src/spartan/utils/bot.ts +4 -1
  178. package/src/spartan/utils/config.ts +2 -0
  179. package/src/spartan/utils/index.ts +7 -1
  180. package/src/spartan/utils/k8s.ts +160 -0
  181. package/src/spartan/utils/nodes.ts +251 -31
  182. package/src/spartan/utils/scripts.ts +43 -7
  183. package/src/test-wallet/test_wallet.ts +306 -0
  184. package/src/test-wallet/utils.ts +112 -0
  185. package/src/test-wallet/wallet_worker_script.ts +60 -0
  186. package/src/test-wallet/worker_wallet.ts +213 -0
  187. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -11,18 +11,18 @@ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-az
11
11
  import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
12
12
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
13
13
  import { extractEvent } from '@aztec/ethereum/utils';
14
- import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
14
+ import { EpochNumber } from '@aztec/foundation/branded-types';
15
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';
19
19
  import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
20
- import type { TestWallet } from '@aztec/test-wallet/server';
21
20
 
22
21
  import { jest } from '@jest/globals';
23
22
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
24
23
 
25
24
  import { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
25
+ import type { TestWallet } from '../test-wallet/test_wallet.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
@@ -84,7 +84,7 @@ export const uniswapL1L2TestSuite = (
84
84
 
85
85
  l1Client = deployL1ContractsValues.l1Client;
86
86
 
87
- t.watcher?.setIsMarkingAsProven(false);
87
+ t.watcher.setIsMarkingAsProven(false);
88
88
 
89
89
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
90
90
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
@@ -130,7 +130,9 @@ export const uniswapL1L2TestSuite = (
130
130
  client: l1Client,
131
131
  });
132
132
  // deploy l2 uniswap contract and attach to portal
133
- uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({ from: ownerAddress });
133
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
134
+ from: ownerAddress,
135
+ }));
134
136
 
135
137
  const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
136
138
 
@@ -195,7 +197,7 @@ export const uniswapL1L2TestSuite = (
195
197
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
196
198
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
197
199
 
198
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
200
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
199
201
  .swap_private(
200
202
  wethCrossChainHarness.l2Token.address,
201
203
  wethCrossChainHarness.l2Bridge.address,
@@ -250,8 +252,8 @@ export const uniswapL1L2TestSuite = (
250
252
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
251
253
 
252
254
  // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
253
- const checkpointNumber = CheckpointNumber.fromBlockNumber(l2UniswapInteractionReceipt.blockNumber!);
254
- const epoch = await rollup.getEpochNumberForCheckpoint(checkpointNumber);
255
+ const block = await aztecNode.getBlock(l2UniswapInteractionReceipt.blockNumber!);
256
+ const epoch = await rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
255
257
  await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
256
258
  await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
257
259
 
@@ -787,7 +789,7 @@ export const uniswapL1L2TestSuite = (
787
789
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
788
790
 
789
791
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
790
- const withdrawReceipt = await uniswapL2Contract.methods
792
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
791
793
  .swap_private(
792
794
  wethCrossChainHarness.l2Token.address,
793
795
  wethCrossChainHarness.l2Bridge.address,
@@ -838,9 +840,8 @@ export const uniswapL1L2TestSuite = (
838
840
  chainId: new Fr(l1Client.chain.id),
839
841
  });
840
842
 
841
- const epoch = await rollup.getEpochNumberForCheckpoint(
842
- CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
843
- );
843
+ const block = await aztecNode.getBlock(withdrawReceipt.blockNumber!);
844
+ const epoch = await rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
844
845
  const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
845
846
  const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
846
847
 
@@ -916,7 +917,7 @@ export const uniswapL1L2TestSuite = (
916
917
 
917
918
  // Call swap_public on L2
918
919
  const secretHashForDepositingSwappedDai = Fr.random();
919
- const withdrawReceipt = await uniswapL2Contract.methods
920
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
920
921
  .swap_public(
921
922
  ownerAddress,
922
923
  wethCrossChainHarness.l2Bridge.address,
@@ -972,9 +973,8 @@ export const uniswapL1L2TestSuite = (
972
973
  chainId: new Fr(l1Client.chain.id),
973
974
  });
974
975
 
975
- const epoch = await rollup.getEpochNumberForCheckpoint(
976
- CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
977
- );
976
+ const block = await aztecNode.getBlock(withdrawReceipt.blockNumber!);
977
+ const epoch = await rollup.getEpochNumberForCheckpoint(block!.checkpointNumber);
978
978
  const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
979
979
  const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
980
980
 
@@ -186,14 +186,16 @@ export class LendingSimulator {
186
186
 
187
187
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
188
188
 
189
- const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
189
+ const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
190
190
 
191
191
  const interestAccumulator = asset['interest_accumulator'];
192
192
  expect(interestAccumulator).toEqual(this.accumulator);
193
193
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
194
194
 
195
195
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
196
- const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
196
+ const { result: privatePos } = await this.lendingContract.methods
197
+ .get_position(key)
198
+ .simulate({ from: this.account.address });
197
199
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
198
200
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
199
201
  expect(privatePos['debt']).toEqual(
@@ -109,7 +109,9 @@ export class TokenSimulator {
109
109
  await Promise.all(
110
110
  chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
111
111
  )
112
- ).flat();
112
+ )
113
+ .flat()
114
+ .map(r => r.result);
113
115
  expect(results[0]).toEqual(this.totalSupply);
114
116
 
115
117
  // Check that all our balances match
@@ -119,39 +121,13 @@ export class TokenSimulator {
119
121
  }
120
122
 
121
123
  async checkPrivate() {
122
- // Private calls
123
- const defaultLookups = [];
124
- const nonDefaultLookups = [];
125
-
126
124
  for (const address of this.accounts) {
127
- if (this.lookupProvider.has(address.toString())) {
128
- nonDefaultLookups.push(address);
129
- } else {
130
- defaultLookups.push(address);
131
- }
132
- }
133
-
134
- const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
135
- const results = (
136
- await Promise.all(
137
- chunk(defaultCalls, 4).map(batch =>
138
- new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
139
- ),
140
- )
141
- ).flat();
142
- for (let i = 0; i < defaultLookups.length; i++) {
143
- expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
144
- }
145
-
146
- // We are just running individual calls for the non-default lookups
147
- // @todo We should also batch these
148
- for (const address of nonDefaultLookups) {
149
125
  const wallet = this.lookupProvider.get(address.toString());
150
126
  const asset = wallet ? this.token.withWallet(wallet) : this.token;
151
127
 
152
- const actualPrivateBalance = await asset.methods
153
- .balance_of_private({ address })
154
- .simulate({ from: this.defaultAddress });
128
+ const { result: actualPrivateBalance } = await asset.methods
129
+ .balance_of_private(address)
130
+ .simulate({ from: address });
155
131
  expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
156
132
  }
157
133
  }
@@ -13,11 +13,14 @@ import type { Logger } from '@aztec/foundation/log';
13
13
  import { retryUntil } from '@aztec/foundation/retry';
14
14
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
15
15
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
16
- import { TestWallet, proveInteraction, registerInitialLocalNetworkAccountsInWallet } from '@aztec/test-wallet/server';
16
+ import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
17
17
 
18
18
  import { getACVMConfig } from '../fixtures/get_acvm_config.js';
19
19
  import { getBBConfig } from '../fixtures/get_bb_config.js';
20
20
  import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
21
+ import { TestWallet } from '../test-wallet/test_wallet.js';
22
+ import { proveInteraction } from '../test-wallet/utils.js';
23
+ import { WorkerWallet } from '../test-wallet/worker_wallet.js';
21
24
 
22
25
  export interface TestAccounts {
23
26
  aztecNode: AztecNode;
@@ -85,11 +88,19 @@ export async function deploySponsoredTestAccountsWithTokens(
85
88
 
86
89
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
87
90
  const recipientDeployMethod = await recipientAccount.getDeployMethod();
88
- await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
91
+ await recipientDeployMethod.send({
92
+ from: AztecAddress.ZERO,
93
+ fee: { paymentMethod },
94
+ wait: { timeout: 2400 },
95
+ });
89
96
  await Promise.all(
90
97
  fundedAccounts.map(async a => {
91
98
  const deployMethod = await a.getDeployMethod();
92
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
99
+ await deployMethod.send({
100
+ from: AztecAddress.ZERO,
101
+ fee: { paymentMethod },
102
+ wait: { timeout: 2400 },
103
+ }); // increase timeout on purpose in order to account for two empty epochs
93
104
  logger.info(`Account deployed at ${a.address}`);
94
105
  }),
95
106
  );
@@ -127,7 +138,8 @@ async function deployAccountWithDiagnostics(
127
138
  const deployMethod = await account.getDeployMethod();
128
139
  let txHash;
129
140
  try {
130
- txHash = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT });
141
+ const deployResult = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT });
142
+ txHash = deployResult.txHash;
131
143
  await waitForTx(aztecNode, txHash, { timeout: 2400 });
132
144
  logger.info(`${accountLabel} deployed at ${account.address}`);
133
145
  } catch (error) {
@@ -263,7 +275,7 @@ async function bridgeL1FeeJuice(
263
275
  const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
264
276
 
265
277
  const isSynced = async () =>
266
- (await aztecNode.getL1ToL2MessageBlock(Fr.fromHexString(claim.messageHash))) !== undefined;
278
+ (await aztecNode.getL1ToL2MessageCheckpoint(Fr.fromHexString(claim.messageHash))) !== undefined;
267
279
  await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
268
280
 
269
281
  log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
@@ -295,13 +307,9 @@ async function deployTokenAndMint(
295
307
  logger: Logger,
296
308
  ) {
297
309
  logger.verbose(`Deploying TokenContract...`);
298
- const { contract: tokenContract } = await TokenContract.deploy(
299
- wallet,
300
- admin,
301
- TOKEN_NAME,
302
- TOKEN_SYMBOL,
303
- TOKEN_DECIMALS,
304
- ).send({
310
+ const {
311
+ receipt: { contract: tokenContract },
312
+ } = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS).send({
305
313
  from: admin,
306
314
  fee: {
307
315
  paymentMethod,
@@ -395,3 +403,42 @@ export async function createWalletAndAztecNodeClient(
395
403
  },
396
404
  };
397
405
  }
406
+
407
+ export type WorkerWalletWrapper = {
408
+ wallet: WorkerWallet;
409
+ aztecNode: AztecNode;
410
+ cleanup: () => Promise<void>;
411
+ };
412
+
413
+ export async function createWorkerWalletClient(
414
+ nodeUrl: string,
415
+ proverEnabled: boolean,
416
+ logger: Logger,
417
+ ): Promise<WorkerWalletWrapper> {
418
+ const aztecNode = createAztecNodeClient(nodeUrl);
419
+ const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
420
+
421
+ // Strip cleanup functions — they can't be structured-cloned for worker transfer
422
+ const { cleanup: bbCleanup, ...bbPaths } = bbConfig ?? {};
423
+ const { cleanup: acvmCleanup, ...acvmPaths } = acvmConfig ?? {};
424
+
425
+ const pxeConfig = {
426
+ dataDirectory: undefined,
427
+ dataStoreMapSizeKb: 1024 * 1024,
428
+ ...bbPaths,
429
+ ...acvmPaths,
430
+ proverEnabled,
431
+ };
432
+
433
+ const wallet = await WorkerWallet.create(nodeUrl, pxeConfig);
434
+
435
+ return {
436
+ wallet,
437
+ aztecNode,
438
+ async cleanup() {
439
+ await wallet.stop();
440
+ await bbCleanup?.();
441
+ await acvmCleanup?.();
442
+ },
443
+ };
444
+ }
@@ -296,7 +296,7 @@ export class TxInclusionMetrics {
296
296
  value: stats.mean,
297
297
  },
298
298
  {
299
- name: `${group}/median_inclusion`,
299
+ name: `${group}/p50_inclusion`,
300
300
  unit: 's',
301
301
  value: stats.median,
302
302
  },
@@ -34,7 +34,8 @@ export async function installTransferBot({
34
34
  logger: log,
35
35
  replicas = 1,
36
36
  txIntervalSeconds = 10,
37
- followChain = 'PENDING',
37
+ followChain = 'CHECKPOINTED',
38
+ pxeSyncChainTip = 'proposed',
38
39
  mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
39
40
  mnemonicStartIndex,
40
41
  botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
@@ -49,6 +50,7 @@ export async function installTransferBot({
49
50
  replicas?: number;
50
51
  txIntervalSeconds?: number;
51
52
  followChain?: string;
53
+ pxeSyncChainTip?: string;
52
54
  mnemonic?: string;
53
55
  mnemonicStartIndex?: number | string;
54
56
  botPrivateKey?: string;
@@ -67,6 +69,7 @@ export async function installTransferBot({
67
69
  'bot.replicaCount': replicas,
68
70
  'bot.txIntervalSeconds': txIntervalSeconds,
69
71
  'bot.followChain': followChain,
72
+ 'bot.pxeSyncChainTip': pxeSyncChainTip,
70
73
  'bot.botPrivateKey': botPrivateKey,
71
74
  'bot.nodeUrl': resolvedNodeUrl,
72
75
  'bot.mnemonic': mnemonic,
@@ -15,6 +15,8 @@ const testConfigSchema = z.object({
15
15
  AZTEC_EPOCH_DURATION: z.coerce.number().optional().default(32),
16
16
  AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
17
17
  AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
18
+ FUNDING_PRIVATE_KEY: z.string().optional(),
19
+ AZTEC_ADMIN_API_KEY: z.string().optional(),
18
20
  });
19
21
 
20
22
  export type TestConfig = z.infer<typeof testConfigSchema>;
@@ -5,7 +5,7 @@
5
5
  export { type TestConfig, setupEnvironment } from './config.js';
6
6
 
7
7
  // Scripts
8
- export { getGitProjectRoot, getAztecBin, runAztecBin, runProjectScript } from './scripts.js';
8
+ export { type ScriptResult, getGitProjectRoot, getAztecBin, runAztecBin, runProjectScript } from './scripts.js';
9
9
 
10
10
  // K8s operations
11
11
  export {
@@ -24,6 +24,8 @@ export {
24
24
  getServiceEndpoint,
25
25
  getRPCEndpoint,
26
26
  getEthereumEndpoint,
27
+ createResilientPrometheusConnection,
28
+ scaleProverAgents,
27
29
  } from './k8s.js';
28
30
 
29
31
  // Chaos Mesh
@@ -39,12 +41,16 @@ export {
39
41
  applyNetworkShaping,
40
42
  } from './chaos.js';
41
43
 
44
+ // Helm
45
+ export { hasDeployedHelmRelease } from './helm.js';
46
+
42
47
  // Bot management
43
48
  export { restartBot, installTransferBot, uninstallTransferBot } from './bot.js';
44
49
 
45
50
  // Node operations (sequencers, validators, pods)
46
51
  export {
47
52
  awaitCheckpointNumber,
53
+ waitForProvenToAdvance,
48
54
  getSequencers,
49
55
  updateSequencersConfig,
50
56
  getSequencersConfig,
@@ -1,4 +1,5 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
+ import type { Logger } from '@aztec/foundation/log';
2
3
  import { promiseWithResolvers } from '@aztec/foundation/promise';
3
4
  import { retryUntil } from '@aztec/foundation/retry';
4
5
 
@@ -6,6 +7,8 @@ import { type ChildProcess, exec, spawn } from 'child_process';
6
7
  import path from 'path';
7
8
  import { promisify } from 'util';
8
9
 
10
+ import { AlertTriggeredError, GrafanaClient } from '../../quality_of_service/grafana_client.js';
11
+
9
12
  const execAsync = promisify(exec);
10
13
 
11
14
  const logger = createLogger('e2e:k8s-utils');
@@ -370,6 +373,163 @@ export async function waitForResourcesByName({
370
373
  );
371
374
  }
372
375
 
376
+ /**
377
+ * Waits for all StatefulSets matching a label to have all their replicas ready.
378
+ *
379
+ * @param namespace - Kubernetes namespace
380
+ * @param label - Label selector for StatefulSets (e.g., "app.kubernetes.io/component=sequencer-node")
381
+ * @param timeoutSeconds - Maximum time to wait in seconds
382
+ * @param pollIntervalSeconds - How often to check status
383
+ */
384
+ export async function waitForStatefulSetsReady({
385
+ namespace,
386
+ label,
387
+ timeoutSeconds = 600,
388
+ pollIntervalSeconds = 5,
389
+ }: {
390
+ namespace: string;
391
+ label: string;
392
+ timeoutSeconds?: number;
393
+ pollIntervalSeconds?: number;
394
+ }): Promise<void> {
395
+ logger.info(`Waiting for StatefulSets with label ${label} to have all replicas ready (timeout: ${timeoutSeconds}s)`);
396
+
397
+ await retryUntil(
398
+ async () => {
399
+ // Get all StatefulSets matching the label
400
+ const getCmd = `kubectl get statefulset -l ${label} -n ${namespace} -o json`;
401
+ const { stdout } = await execAsync(getCmd);
402
+ const result = JSON.parse(stdout);
403
+
404
+ if (!result.items || result.items.length === 0) {
405
+ logger.verbose(`No StatefulSets found with label ${label}`);
406
+ return false;
407
+ }
408
+
409
+ // Check each StatefulSet
410
+ for (const sts of result.items) {
411
+ const name = sts.metadata.name;
412
+ const desired = sts.spec.replicas ?? 0;
413
+ const ready = sts.status.readyReplicas ?? 0;
414
+ const updated = sts.status.updatedReplicas ?? 0;
415
+
416
+ if (ready < desired || updated < desired) {
417
+ logger.verbose(`StatefulSet ${name}: ${ready}/${desired} ready, ${updated}/${desired} updated`);
418
+ return false;
419
+ }
420
+ }
421
+
422
+ logger.info(`All StatefulSets with label ${label} are ready`);
423
+ return true;
424
+ },
425
+ `StatefulSets with label ${label} to be ready`,
426
+ timeoutSeconds,
427
+ pollIntervalSeconds,
428
+ );
429
+ }
430
+
431
+ /**
432
+ * Creates a Prometheus connection that can re-establish port-forward on failure.
433
+ * Returns functions to connect and run alert checks that automatically reconnect if needed.
434
+ *
435
+ * @param namespace - K8s namespace to fall back to if metrics namespace doesn't have Prometheus
436
+ * @param endpoints - Array to track created endpoints for cleanup
437
+ * @param log - Logger instance
438
+ */
439
+ export function createResilientPrometheusConnection(
440
+ namespace: string,
441
+ endpoints: ServiceEndpoint[],
442
+ log: Logger,
443
+ ): {
444
+ connect: () => Promise<GrafanaClient>;
445
+ runAlertCheck: (alerts: Parameters<GrafanaClient['runAlertCheck']>[0]) => Promise<void>;
446
+ } {
447
+ let alertChecker: GrafanaClient | undefined;
448
+ let currentEndpoint: ServiceEndpoint | undefined;
449
+
450
+ const connect = async (): Promise<GrafanaClient> => {
451
+ // Kill existing connection if any
452
+ if (currentEndpoint?.process) {
453
+ currentEndpoint.process.kill();
454
+ }
455
+
456
+ // Try metrics namespace first, then network namespace
457
+ let promPort = 0;
458
+ let promUrl = '';
459
+ let promProc: ChildProcess | undefined;
460
+
461
+ try {
462
+ const metricsResult = await startPortForward({
463
+ resource: `svc/metrics-prometheus-server`,
464
+ namespace: 'metrics',
465
+ containerPort: 80,
466
+ });
467
+ promProc = metricsResult.process;
468
+ promPort = metricsResult.port;
469
+ promUrl = `http://127.0.0.1:${promPort}/api/v1`;
470
+ } catch {
471
+ // Metrics namespace might not have Prometheus, try network namespace
472
+ log.verbose('Metrics namespace Prometheus not available, trying network namespace');
473
+ }
474
+
475
+ if (promPort === 0) {
476
+ const nsResult = await startPortForward({
477
+ resource: `svc/prometheus-server`,
478
+ namespace,
479
+ containerPort: 80,
480
+ });
481
+ promProc = nsResult.process;
482
+ promPort = nsResult.port;
483
+ promUrl = `http://127.0.0.1:${promPort}/api/v1`;
484
+ }
485
+
486
+ if (!promProc || promPort === 0) {
487
+ throw new Error('Unable to port-forward to Prometheus');
488
+ }
489
+
490
+ currentEndpoint = { url: promUrl, process: promProc };
491
+ endpoints.push(currentEndpoint);
492
+ alertChecker = new GrafanaClient(log, { grafanaEndpoint: promUrl, grafanaCredentials: '' });
493
+ log.info(`Established Prometheus connection at ${promUrl}`);
494
+ return alertChecker;
495
+ };
496
+
497
+ const runAlertCheck = async (alerts: Parameters<GrafanaClient['runAlertCheck']>[0]): Promise<void> => {
498
+ if (!alertChecker) {
499
+ alertChecker = await connect();
500
+ }
501
+
502
+ try {
503
+ await alertChecker.runAlertCheck(alerts);
504
+ } catch (err) {
505
+ // If it's an AlertTriggeredError (expected behavior)
506
+ if (err instanceof AlertTriggeredError) {
507
+ throw err;
508
+ }
509
+
510
+ // Check if it's a connection error (port-forward died)
511
+ const errorStr = String(err);
512
+ if (errorStr.includes('fetch failed') || errorStr.includes('ECONNREFUSED') || errorStr.includes('ECONNRESET')) {
513
+ log.warn(`Prometheus connection lost, re-establishing port-forward...`);
514
+ alertChecker = await connect();
515
+ await alertChecker.runAlertCheck(alerts);
516
+ } else {
517
+ throw err;
518
+ }
519
+ }
520
+ };
521
+
522
+ return { connect, runAlertCheck };
523
+ }
524
+
525
+ /** Scales the prover-agent Deployment to the given number of replicas. */
526
+ export async function scaleProverAgents(namespace: string, replicas: number, log: Logger): Promise<void> {
527
+ const label = 'app.kubernetes.io/component=prover-agent';
528
+ const command = `kubectl scale deployment -l ${label} -n ${namespace} --replicas=${replicas} --timeout=2m`;
529
+ log.info(`Scaling prover agents to ${replicas}: ${command}`);
530
+ await execAsync(command);
531
+ }
532
+
373
533
  export function getChartDir(spartanDir: string, chartName: string) {
374
534
  return path.join(spartanDir.trim(), chartName);
375
535
  }