@aztec/end-to-end 0.0.0-test.0 → 0.0.1-commit.0208eb9

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 (247) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +62 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +281 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -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 +321 -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 +16 -41
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +41 -72
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
  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 +114 -102
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
  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 +104 -104
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +26 -27
  25. package/dest/e2e_epochs/epochs_test.d.ts +71 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +260 -54
  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 +61 -0
  31. package/dest/e2e_fees/fees_test.d.ts +38 -23
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +162 -183
  34. package/dest/e2e_l1_publisher/write_json.d.ts +11 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +56 -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 +15 -15
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
  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 +281 -27
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +237 -175
  49. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  50. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  51. package/dest/e2e_p2p/reqresp/utils.js +153 -0
  52. package/dest/e2e_p2p/shared.d.ts +44 -8
  53. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  54. package/dest/e2e_p2p/shared.js +165 -27
  55. package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
  56. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  57. package/dest/e2e_token_contract/token_contract_test.js +96 -74
  58. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  59. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  60. package/dest/fixtures/e2e_prover_test.js +278 -0
  61. package/dest/fixtures/fixtures.d.ts +6 -8
  62. package/dest/fixtures/fixtures.d.ts.map +1 -1
  63. package/dest/fixtures/fixtures.js +5 -5
  64. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  65. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_acvm_config.js +3 -15
  67. package/dest/fixtures/get_bb_config.d.ts +2 -2
  68. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  69. package/dest/fixtures/get_bb_config.js +10 -17
  70. package/dest/fixtures/ha_setup.d.ts +71 -0
  71. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  72. package/dest/fixtures/ha_setup.js +114 -0
  73. package/dest/fixtures/index.d.ts +2 -1
  74. package/dest/fixtures/index.d.ts.map +1 -1
  75. package/dest/fixtures/index.js +1 -0
  76. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  77. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  78. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  79. package/dest/fixtures/logging.d.ts +1 -1
  80. package/dest/fixtures/setup.d.ts +218 -0
  81. package/dest/fixtures/setup.d.ts.map +1 -0
  82. package/dest/fixtures/setup.js +695 -0
  83. package/dest/fixtures/setup_p2p_test.d.ts +15 -15
  84. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  85. package/dest/fixtures/setup_p2p_test.js +96 -31
  86. package/dest/fixtures/token_utils.d.ts +10 -4
  87. package/dest/fixtures/token_utils.d.ts.map +1 -1
  88. package/dest/fixtures/token_utils.js +31 -12
  89. package/dest/fixtures/utils.d.ts +5 -153
  90. package/dest/fixtures/utils.d.ts.map +1 -1
  91. package/dest/fixtures/utils.js +4 -552
  92. package/dest/fixtures/web3signer.d.ts +5 -0
  93. package/dest/fixtures/web3signer.d.ts.map +1 -0
  94. package/dest/fixtures/web3signer.js +53 -0
  95. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  96. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  97. package/dest/fixtures/with_telemetry_utils.js +2 -2
  98. package/dest/index.d.ts +1 -1
  99. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  100. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  101. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  102. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  103. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  104. package/dest/quality_of_service/prometheus_client.js +67 -0
  105. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  106. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  107. package/dest/shared/cross_chain_test_harness.js +105 -51
  108. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  109. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  110. package/dest/shared/gas_portal_test_harness.js +51 -30
  111. package/dest/shared/index.d.ts +2 -2
  112. package/dest/shared/index.d.ts.map +1 -1
  113. package/dest/shared/jest_setup.d.ts +1 -1
  114. package/dest/shared/jest_setup.js +1 -1
  115. package/dest/shared/submit-transactions.d.ts +6 -4
  116. package/dest/shared/submit-transactions.d.ts.map +1 -1
  117. package/dest/shared/submit-transactions.js +15 -16
  118. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  119. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  120. package/dest/shared/uniswap_l1_l2.js +176 -126
  121. package/dest/simulators/index.d.ts +1 -1
  122. package/dest/simulators/lending_simulator.d.ts +7 -7
  123. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  124. package/dest/simulators/lending_simulator.js +17 -18
  125. package/dest/simulators/token_simulator.d.ts +6 -3
  126. package/dest/simulators/token_simulator.d.ts.map +1 -1
  127. package/dest/simulators/token_simulator.js +16 -13
  128. package/dest/spartan/setup_test_wallets.d.ts +27 -11
  129. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  130. package/dest/spartan/setup_test_wallets.js +233 -62
  131. package/dest/spartan/tx_metrics.d.ts +88 -0
  132. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  133. package/dest/spartan/tx_metrics.js +422 -0
  134. package/dest/spartan/utils/bot.d.ts +27 -0
  135. package/dest/spartan/utils/bot.d.ts.map +1 -0
  136. package/dest/spartan/utils/bot.js +141 -0
  137. package/dest/spartan/utils/chaos.d.ts +79 -0
  138. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  139. package/dest/spartan/utils/chaos.js +142 -0
  140. package/dest/spartan/utils/clients.d.ts +39 -0
  141. package/dest/spartan/utils/clients.d.ts.map +1 -0
  142. package/dest/spartan/utils/clients.js +90 -0
  143. package/dest/spartan/utils/config.d.ts +39 -0
  144. package/dest/spartan/utils/config.d.ts.map +1 -0
  145. package/dest/spartan/utils/config.js +21 -0
  146. package/dest/spartan/utils/health.d.ts +63 -0
  147. package/dest/spartan/utils/health.d.ts.map +1 -0
  148. package/dest/spartan/utils/health.js +202 -0
  149. package/dest/spartan/utils/helm.d.ts +15 -0
  150. package/dest/spartan/utils/helm.d.ts.map +1 -0
  151. package/dest/spartan/utils/helm.js +47 -0
  152. package/dest/spartan/utils/index.d.ts +9 -0
  153. package/dest/spartan/utils/index.d.ts.map +1 -0
  154. package/dest/spartan/utils/index.js +18 -0
  155. package/dest/spartan/utils/k8s.d.ts +126 -0
  156. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  157. package/dest/spartan/utils/k8s.js +375 -0
  158. package/dest/spartan/utils/nodes.d.ts +41 -0
  159. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  160. package/dest/spartan/utils/nodes.js +461 -0
  161. package/dest/spartan/utils/scripts.d.ts +30 -0
  162. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  163. package/dest/spartan/utils/scripts.js +81 -0
  164. package/dest/spartan/utils.d.ts +2 -415
  165. package/dest/spartan/utils.d.ts.map +1 -1
  166. package/dest/spartan/utils.js +1 -445
  167. package/package.json +69 -58
  168. package/src/bench/client_flows/benchmark.ts +363 -0
  169. package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
  170. package/src/bench/client_flows/config.ts +61 -0
  171. package/src/bench/client_flows/data_extractor.ts +89 -0
  172. package/src/bench/utils.ts +41 -85
  173. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
  174. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
  175. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  176. package/src/e2e_epochs/epochs_test.ts +341 -81
  177. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  178. package/src/e2e_fees/fees_test.ts +220 -258
  179. package/src/e2e_l1_publisher/write_json.ts +77 -0
  180. package/src/e2e_multi_validator/utils.ts +258 -0
  181. package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
  182. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  183. package/src/e2e_p2p/p2p_network.ts +341 -234
  184. package/src/e2e_p2p/reqresp/utils.ts +207 -0
  185. package/src/e2e_p2p/shared.ts +260 -39
  186. package/src/e2e_token_contract/token_contract_test.ts +115 -126
  187. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  188. package/src/fixtures/e2e_prover_test.ts +336 -0
  189. package/src/fixtures/fixtures.ts +5 -7
  190. package/src/fixtures/get_acvm_config.ts +4 -12
  191. package/src/fixtures/get_bb_config.ts +18 -13
  192. package/src/fixtures/ha_setup.ts +184 -0
  193. package/src/fixtures/index.ts +1 -0
  194. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  195. package/src/fixtures/setup.ts +1017 -0
  196. package/src/fixtures/setup_p2p_test.ts +133 -50
  197. package/src/fixtures/token_utils.ts +33 -15
  198. package/src/fixtures/utils.ts +27 -820
  199. package/src/fixtures/web3signer.ts +63 -0
  200. package/src/fixtures/with_telemetry_utils.ts +2 -2
  201. package/src/guides/up_quick_start.sh +7 -15
  202. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  203. package/src/quality_of_service/prometheus_client.ts +113 -0
  204. package/src/shared/cross_chain_test_harness.ts +103 -91
  205. package/src/shared/gas_portal_test_harness.ts +59 -50
  206. package/src/shared/index.ts +1 -1
  207. package/src/shared/jest_setup.ts +1 -1
  208. package/src/shared/submit-transactions.ts +18 -20
  209. package/src/shared/uniswap_l1_l2.ts +197 -221
  210. package/src/simulators/lending_simulator.ts +16 -17
  211. package/src/simulators/token_simulator.ts +21 -13
  212. package/src/spartan/DEVELOP.md +128 -0
  213. package/src/spartan/setup_test_wallets.ts +308 -95
  214. package/src/spartan/tx_metrics.ts +376 -0
  215. package/src/spartan/utils/bot.ts +185 -0
  216. package/src/spartan/utils/chaos.ts +253 -0
  217. package/src/spartan/utils/clients.ts +100 -0
  218. package/src/spartan/utils/config.ts +27 -0
  219. package/src/spartan/utils/health.ts +255 -0
  220. package/src/spartan/utils/helm.ts +84 -0
  221. package/src/spartan/utils/index.ts +64 -0
  222. package/src/spartan/utils/k8s.ts +527 -0
  223. package/src/spartan/utils/nodes.ts +538 -0
  224. package/src/spartan/utils/scripts.ts +99 -0
  225. package/src/spartan/utils.ts +1 -582
  226. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  227. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  228. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  229. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  230. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  231. package/dest/fixtures/setup_l1_contracts.js +0 -17
  232. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  233. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  234. package/dest/fixtures/snapshot_manager.js +0 -479
  235. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  236. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  237. package/dest/sample-dapp/connect.js +0 -12
  238. package/dest/sample-dapp/contracts.js +0 -10
  239. package/dest/sample-dapp/deploy.js +0 -35
  240. package/dest/sample-dapp/index.js +0 -98
  241. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  242. package/src/fixtures/setup_l1_contracts.ts +0 -27
  243. package/src/fixtures/snapshot_manager.ts +0 -617
  244. package/src/sample-dapp/connect.mjs +0 -16
  245. package/src/sample-dapp/contracts.mjs +0 -14
  246. package/src/sample-dapp/deploy.mjs +0 -40
  247. package/src/sample-dapp/index.mjs +0 -128
@@ -0,0 +1,336 @@
1
+ import type { InitialAccountData } from '@aztec/accounts/testing';
2
+ import { type Archiver, createArchiver } from '@aztec/archiver';
3
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
4
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
5
+ import type { AztecNode } from '@aztec/aztec.js/node';
6
+ import { CheatCodes } from '@aztec/aztec/testing';
7
+ import {
8
+ BBCircuitVerifier,
9
+ type ClientProtocolCircuitVerifier,
10
+ QueuedIVCVerifier,
11
+ TestCircuitVerifier,
12
+ } from '@aztec/bb-prover';
13
+ import { BackendType, Barretenberg } from '@aztec/bb.js';
14
+ import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
15
+ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
16
+ import { Buffer32 } from '@aztec/foundation/buffer';
17
+ import { SecretValue } from '@aztec/foundation/config';
18
+ import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
19
+ import { TokenContract } from '@aztec/noir-contracts.js/Token';
20
+ import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
21
+ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
22
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
23
+ import { TestWallet } from '@aztec/test-wallet/server';
24
+ import { getGenesisValues } from '@aztec/world-state/testing';
25
+
26
+ import { type Hex, getContract } from 'viem';
27
+ import { privateKeyToAddress } from 'viem/accounts';
28
+
29
+ import { TokenSimulator } from '../simulators/token_simulator.js';
30
+ import { getACVMConfig } from './get_acvm_config.js';
31
+ import { getBBConfig } from './get_bb_config.js';
32
+ import {
33
+ type EndToEndContext,
34
+ deployAccounts,
35
+ getPrivateKeyFromIndex,
36
+ getSponsoredFPCAddress,
37
+ publicDeployAccounts,
38
+ setup,
39
+ setupPXEAndGetWallet,
40
+ teardown,
41
+ } from './setup.js';
42
+
43
+ type ProvenSetup = {
44
+ wallet: TestWallet;
45
+ teardown: () => Promise<void>;
46
+ };
47
+
48
+ /**
49
+ * Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
50
+ * However, we then setup a second PXE with a full prover instance.
51
+ * We configure this instance with all of the accounts and contracts.
52
+ * We then prove and verify transactions created via this full prover PXE.
53
+ */
54
+
55
+ export class FullProverTest {
56
+ static TOKEN_NAME = 'USDC';
57
+ static TOKEN_SYMBOL = 'USD';
58
+ static TOKEN_DECIMALS = 18n;
59
+ logger: Logger;
60
+ wallet!: TestWallet;
61
+ provenWallet!: TestWallet;
62
+ accounts: AztecAddress[] = [];
63
+ deployedAccounts!: InitialAccountData[];
64
+ fakeProofsAsset!: TokenContract;
65
+ fakeProofsAssetInstance!: ContractInstanceWithAddress;
66
+ tokenSim!: TokenSimulator;
67
+ aztecNode!: AztecNode;
68
+ aztecNodeAdmin!: AztecNodeAdmin;
69
+ cheatCodes!: CheatCodes;
70
+ private provenComponents: ProvenSetup[] = [];
71
+ private bbConfigCleanup?: () => Promise<void>;
72
+ private acvmConfigCleanup?: () => Promise<void>;
73
+ circuitProofVerifier?: ClientProtocolCircuitVerifier;
74
+ provenAsset!: TokenContract;
75
+ context!: EndToEndContext;
76
+ private proverNode!: ProverNode;
77
+ private simulatedProverNode!: ProverNode;
78
+ public l1Contracts!: DeployAztecL1ContractsReturnType;
79
+ public proverAddress!: EthAddress;
80
+ private minNumberOfTxsPerBlock: number;
81
+ private coinbase: EthAddress;
82
+ private realProofs: boolean;
83
+
84
+ constructor(testName: string, minNumberOfTxsPerBlock: number, coinbase: EthAddress, realProofs = true) {
85
+ this.logger = createLogger(`e2e:full_prover_test:${testName}`);
86
+ this.minNumberOfTxsPerBlock = minNumberOfTxsPerBlock;
87
+ this.coinbase = coinbase;
88
+ this.realProofs = realProofs;
89
+ }
90
+
91
+ /**
92
+ * Applies base setup: deploys 2 accounts and token contract.
93
+ */
94
+ private async applyBaseSetup() {
95
+ this.logger.info('Applying base setup: deploying accounts');
96
+ const { deployedAccounts } = await deployAccounts(
97
+ 2,
98
+ this.logger,
99
+ )({
100
+ wallet: this.context.wallet,
101
+ initialFundedAccounts: this.context.initialFundedAccounts,
102
+ });
103
+ this.deployedAccounts = deployedAccounts;
104
+ this.accounts = deployedAccounts.map(a => a.address);
105
+ this.wallet = this.context.wallet;
106
+
107
+ this.logger.info('Applying base setup: publicly deploying accounts');
108
+ await publicDeployAccounts(this.wallet, this.accounts.slice(0, 2));
109
+
110
+ this.logger.info('Applying base setup: deploying token contract');
111
+ const { contract: asset, instance } = await TokenContract.deploy(
112
+ this.wallet,
113
+ this.accounts[0],
114
+ FullProverTest.TOKEN_NAME,
115
+ FullProverTest.TOKEN_SYMBOL,
116
+ FullProverTest.TOKEN_DECIMALS,
117
+ ).send({ from: this.accounts[0], wait: { returnReceipt: true } });
118
+ this.logger.verbose(`Token deployed to ${asset.address}`);
119
+
120
+ this.fakeProofsAsset = asset;
121
+ this.fakeProofsAssetInstance = instance;
122
+ this.logger.verbose(`Token contract address: ${this.fakeProofsAsset.address}`);
123
+
124
+ this.tokenSim = new TokenSimulator(this.fakeProofsAsset, this.wallet, this.accounts[0], this.logger, this.accounts);
125
+
126
+ expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0] })).toBe(
127
+ this.accounts[0].toBigInt(),
128
+ );
129
+ }
130
+
131
+ async setup() {
132
+ this.logger.info('Setting up subsystems from fresh');
133
+ this.context = await setup(0, {
134
+ startProverNode: true,
135
+ coinbase: this.coinbase,
136
+ fundSponsoredFPC: true,
137
+ skipAccountDeployment: true,
138
+ l1ContractsArgs: { realVerifier: this.realProofs },
139
+ });
140
+
141
+ await this.applyBaseSetup();
142
+ await this.applyMint();
143
+
144
+ this.logger.info(`Enabling proving`, { realProofs: this.realProofs });
145
+
146
+ // We don't wish to mark as proven automatically, so we set the flag to false
147
+ this.context.watcher!.setIsMarkingAsProven(false);
148
+
149
+ this.simulatedProverNode = this.context.proverNode!;
150
+ ({
151
+ aztecNode: this.aztecNode,
152
+ deployL1ContractsValues: this.l1Contracts,
153
+ cheatCodes: this.cheatCodes,
154
+ } = this.context);
155
+ this.aztecNodeAdmin = this.context.aztecNodeService!;
156
+
157
+ const config = this.context.aztecNodeConfig;
158
+ const blobClient = await createBlobClientWithFileStores(config, this.logger);
159
+
160
+ // Configure a full prover PXE
161
+ let acvmConfig: Awaited<ReturnType<typeof getACVMConfig>> | undefined;
162
+ let bbConfig: Awaited<ReturnType<typeof getBBConfig>> | undefined;
163
+ if (this.realProofs) {
164
+ [acvmConfig, bbConfig] = await Promise.all([getACVMConfig(this.logger), getBBConfig(this.logger)]);
165
+ if (!acvmConfig || !bbConfig) {
166
+ throw new Error('Missing ACVM or BB config');
167
+ }
168
+
169
+ this.acvmConfigCleanup = acvmConfig.cleanup;
170
+ this.bbConfigCleanup = bbConfig.cleanup;
171
+
172
+ await Barretenberg.initSingleton({ backend: BackendType.NativeUnixSocket });
173
+
174
+ const verifier = await BBCircuitVerifier.new(bbConfig);
175
+ this.circuitProofVerifier = new QueuedIVCVerifier(bbConfig, verifier);
176
+
177
+ this.logger.debug(`Configuring the node for real proofs...`);
178
+ await this.aztecNodeAdmin.setConfig({
179
+ realProofs: true,
180
+ minTxsPerBlock: this.minNumberOfTxsPerBlock,
181
+ });
182
+ } else {
183
+ this.logger.debug(`Configuring the node min txs per block ${this.minNumberOfTxsPerBlock}...`);
184
+ this.circuitProofVerifier = new TestCircuitVerifier();
185
+ await this.aztecNodeAdmin.setConfig({
186
+ minTxsPerBlock: this.minNumberOfTxsPerBlock,
187
+ });
188
+ }
189
+
190
+ this.logger.verbose(`Move to a clean epoch`);
191
+ await this.context.cheatCodes.rollup.advanceToNextEpoch();
192
+
193
+ this.logger.verbose(`Marking current block as proven`);
194
+ await this.context.cheatCodes.rollup.markAsProven();
195
+
196
+ this.logger.verbose(`Main setup completed, initializing full prover PXE, Node, and Prover Node`);
197
+ const { wallet: provenWallet, teardown: provenTeardown } = await setupPXEAndGetWallet(
198
+ this.aztecNode,
199
+ { proverEnabled: this.realProofs },
200
+ undefined,
201
+ 'pxe-proven',
202
+ );
203
+ this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`);
204
+ await provenWallet.registerContract(this.fakeProofsAssetInstance, TokenContract.artifact);
205
+
206
+ for (let i = 0; i < 2; i++) {
207
+ await provenWallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt);
208
+ await this.wallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt);
209
+ }
210
+
211
+ const asset = TokenContract.at(this.fakeProofsAsset.address, provenWallet);
212
+ this.provenComponents.push({
213
+ wallet: provenWallet,
214
+ teardown: provenTeardown,
215
+ });
216
+ this.provenAsset = asset;
217
+ this.provenWallet = provenWallet;
218
+ this.logger.info(`Full prover PXE started`);
219
+
220
+ // Shutdown the current, simulated prover node
221
+ this.logger.verbose('Shutting down simulated prover node');
222
+ await this.simulatedProverNode.stop();
223
+
224
+ // Creating temp store and archiver for fully proven prover node
225
+ this.logger.verbose('Starting archiver for new prover node');
226
+ const archiver = await createArchiver(
227
+ { ...this.context.aztecNodeConfig, dataDirectory: undefined },
228
+ { blobClient, dateProvider: this.context.dateProvider! },
229
+ { blockUntilSync: true },
230
+ );
231
+
232
+ // The simulated prover node (now shutdown) used private key index 2
233
+ const proverNodePrivateKey = getPrivateKeyFromIndex(2);
234
+ const proverNodeSenderAddress = privateKeyToAddress(new Buffer32(proverNodePrivateKey!).toString());
235
+ this.proverAddress = EthAddress.fromString(proverNodeSenderAddress);
236
+
237
+ this.logger.verbose(`Funding prover node at ${proverNodeSenderAddress}`);
238
+ await this.mintFeeJuice(proverNodeSenderAddress);
239
+
240
+ this.logger.verbose('Starting prover node');
241
+ const proverConfig: ProverNodeConfig = {
242
+ ...this.context.aztecNodeConfig,
243
+ txCollectionNodeRpcUrls: [],
244
+ dataDirectory: undefined,
245
+ proverId: this.proverAddress,
246
+ realProofs: this.realProofs,
247
+ proverAgentCount: 2,
248
+ publisherPrivateKeys: [new SecretValue(`0x${proverNodePrivateKey!.toString('hex')}` as const)],
249
+ proverNodeMaxPendingJobs: 100,
250
+ proverNodeMaxParallelBlocksPerEpoch: 32,
251
+ proverNodePollingIntervalMs: 100,
252
+ txGatheringIntervalMs: 1000,
253
+ txGatheringBatchSize: 10,
254
+ txGatheringMaxParallelRequestsPerNode: 100,
255
+ txGatheringTimeoutMs: 24_000,
256
+ proverNodeFailedEpochStore: undefined,
257
+ proverNodeEpochProvingDelayMs: undefined,
258
+ };
259
+ const sponsoredFPCAddress = await getSponsoredFPCAddress();
260
+ const { prefilledPublicData } = await getGenesisValues(
261
+ this.context.initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
262
+ );
263
+ this.proverNode = await createProverNode(
264
+ proverConfig,
265
+ {
266
+ aztecNodeTxProvider: this.aztecNode,
267
+ archiver: archiver as Archiver,
268
+ },
269
+ { prefilledPublicData },
270
+ );
271
+ await this.proverNode.start();
272
+
273
+ this.logger.warn(`Proofs are now enabled`, { realProofs: this.realProofs });
274
+ return this;
275
+ }
276
+
277
+ private async mintFeeJuice(recipient: Hex) {
278
+ const handlerAddress = this.context.deployL1ContractsValues.l1ContractAddresses.feeAssetHandlerAddress!;
279
+ this.logger.verbose(`Minting fee juice to ${recipient} using handler at ${handlerAddress}`);
280
+ const client = this.context.deployL1ContractsValues.l1Client;
281
+ const handler = getContract({ abi: FeeAssetHandlerAbi, address: handlerAddress.toString(), client });
282
+ const hash = await handler.write.mint([recipient]);
283
+ await this.context.deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash });
284
+ }
285
+
286
+ async teardown() {
287
+ // Cleanup related to the full prover PXEs
288
+ for (let i = 0; i < this.provenComponents.length; i++) {
289
+ await this.provenComponents[i].teardown();
290
+ }
291
+
292
+ // clean up the full prover node
293
+ await this.proverNode.stop();
294
+
295
+ await Barretenberg.destroySingleton();
296
+ await this.bbConfigCleanup?.();
297
+ await this.acvmConfigCleanup?.();
298
+
299
+ await teardown(this.context);
300
+ }
301
+
302
+ private async applyMint() {
303
+ this.logger.info('Applying mint setup');
304
+ const { fakeProofsAsset: asset, accounts } = this;
305
+ const privateAmount = 10000n;
306
+ const publicAmount = 10000n;
307
+
308
+ this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
309
+ await asset.methods.mint_to_public(accounts[0], privateAmount + publicAmount).send({ from: accounts[0] });
310
+
311
+ this.logger.verbose(`Transferring ${privateAmount} to private...`);
312
+ await asset.methods.transfer_to_private(accounts[0], privateAmount).send({ from: accounts[0] });
313
+
314
+ this.logger.info(`Minting complete`);
315
+
316
+ const {
317
+ fakeProofsAsset,
318
+ accounts: [address],
319
+ tokenSim,
320
+ } = this;
321
+ tokenSim.mintPublic(address, publicAmount);
322
+
323
+ const publicBalance = await fakeProofsAsset.methods.balance_of_public(address).simulate({ from: address });
324
+ this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
325
+ expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
326
+
327
+ tokenSim.mintPrivate(address, publicAmount);
328
+ const privateBalance = await fakeProofsAsset.methods.balance_of_private(address).simulate({ from: address });
329
+ this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
330
+ expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
331
+
332
+ const totalSupply = await fakeProofsAsset.methods.total_supply().simulate({ from: address });
333
+ this.logger.verbose(`Total supply: ${totalSupply}`);
334
+ expect(totalSupply).toEqual(tokenSim.totalSupply);
335
+ }
336
+ }
@@ -8,21 +8,19 @@ export const shouldCollectMetrics = () => {
8
8
  };
9
9
 
10
10
  export const TEST_PEER_CHECK_INTERVAL_MS = 1000;
11
+ export const TEST_MAX_PENDING_TX_POOL_COUNT = 10_000; // Number of max pending TXs ~ 1.56GB
11
12
 
12
13
  export const MNEMONIC = 'test test test test test test test test test test test junk';
13
14
  export const privateKey = Buffer.from('ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', 'hex');
14
15
  export const privateKey2 = Buffer.from('59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d', 'hex');
15
16
 
16
17
  /// Common errors
17
- export const U128_UNDERFLOW_ERROR = "Assertion failed: attempt to subtract with overflow 'self - other'";
18
- export const U128_OVERFLOW_ERROR = "Assertion failed: attempt to add with overflow 'self + other'";
18
+ export const U128_UNDERFLOW_ERROR = 'Assertion failed: attempt to subtract with overflow';
19
+ export const U128_OVERFLOW_ERROR = 'Assertion failed: attempt to add with overflow';
19
20
  export const BITSIZE_TOO_BIG_ERROR = "Assertion failed: call to assert_max_bit_size 'self.__assert_max_bit_size'";
20
21
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): Make these a fixed error after transition.
21
- export const DUPLICATE_NULLIFIER_ERROR = /dropped|duplicate nullifier|reverted|Nullifier collision/;
22
+ export const DUPLICATE_NULLIFIER_ERROR = /dropped|nullifier|reverted/i;
22
23
  export const NO_L1_TO_L2_MSG_ERROR =
23
24
  /No non-nullified L1 to L2 message found for message hash|Tried to consume nonexistent L1-to-L2 message/;
24
- export const STATIC_CALL_STATE_MODIFICATION_ERROR =
25
- /Static call cannot update the state, emit L2->L1 messages or generate logs.*/;
25
+ export const STATIC_CALL_STATE_MODIFICATION_ERROR = /Static call cannot update the state.*/;
26
26
  export const STATIC_CONTEXT_ASSERTION_ERROR = /Assertion failed: Function .* can only be called statically.*/;
27
-
28
- export const DEFAULT_BLOB_SINK_PORT = '5052';
@@ -1,6 +1,7 @@
1
- import type { Logger } from '@aztec/aztec.js';
1
+ import type { Logger } from '@aztec/aztec.js/log';
2
2
  import { parseBooleanEnv } from '@aztec/foundation/config';
3
- import { randomBytes } from '@aztec/foundation/crypto';
3
+ import { randomBytes } from '@aztec/foundation/crypto/random';
4
+ import { tryRmDir } from '@aztec/foundation/fs';
4
5
 
5
6
  import { promises as fs } from 'fs';
6
7
 
@@ -36,16 +37,7 @@ export async function getACVMConfig(logger: Logger): Promise<
36
37
 
37
38
  const directoryToCleanup = ACVM_WORKING_DIRECTORY ? undefined : tempWorkingDirectory;
38
39
 
39
- const cleanup = async () => {
40
- if (directoryToCleanup) {
41
- try {
42
- logger.info(`Cleaning up ACVM temp directory ${directoryToCleanup}`);
43
- await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
44
- } catch (err) {
45
- logger.warn(`Failed to delete ACVM temp directory at ${directoryToCleanup}: ${err}`);
46
- }
47
- }
48
- };
40
+ const cleanup = () => tryRmDir(directoryToCleanup, logger);
49
41
 
50
42
  return {
51
43
  acvmWorkingDirectory,
@@ -1,9 +1,11 @@
1
- import { type Logger, fileURLToPath } from '@aztec/aztec.js';
1
+ import type { Logger } from '@aztec/aztec.js/log';
2
2
  import type { BBConfig } from '@aztec/bb-prover';
3
+ import { tryRmDir } from '@aztec/foundation/fs';
3
4
 
4
5
  import fs from 'node:fs/promises';
5
6
  import { tmpdir } from 'node:os';
6
7
  import path from 'path';
8
+ import { fileURLToPath } from 'url';
7
9
 
8
10
  const {
9
11
  BB_RELEASE_DIR = 'barretenberg/cpp/build/bin',
@@ -11,6 +13,8 @@ const {
11
13
  BB_SKIP_CLEANUP = '',
12
14
  TEMP_DIR = tmpdir(),
13
15
  BB_WORKING_DIRECTORY = '',
16
+ BB_NUM_IVC_VERIFIERS = '1',
17
+ BB_IVC_CONCURRENCY = '1',
14
18
  } = process.env;
15
19
 
16
20
  export const getBBConfig = async (
@@ -19,7 +23,7 @@ export const getBBConfig = async (
19
23
  try {
20
24
  const bbBinaryPath =
21
25
  BB_BINARY_PATH ??
22
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb');
26
+ path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb-avm');
23
27
  await fs.access(bbBinaryPath, fs.constants.R_OK);
24
28
 
25
29
  let bbWorkingDirectory: string;
@@ -35,18 +39,19 @@ export const getBBConfig = async (
35
39
  await fs.mkdir(bbWorkingDirectory, { recursive: true });
36
40
 
37
41
  const bbSkipCleanup = ['1', 'true'].includes(BB_SKIP_CLEANUP);
38
-
39
- const cleanup = async () => {
40
- if (directoryToCleanup && !bbSkipCleanup) {
41
- try {
42
- await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
43
- } catch (err) {
44
- logger.warn(`Failed to delete bb working directory at ${directoryToCleanup}: ${err}`);
45
- }
46
- }
42
+ const cleanup = bbSkipCleanup ? () => Promise.resolve() : () => tryRmDir(directoryToCleanup);
43
+
44
+ const numIvcVerifiers = Number(BB_NUM_IVC_VERIFIERS);
45
+ const ivcConcurrency = Number(BB_IVC_CONCURRENCY);
46
+
47
+ return {
48
+ bbSkipCleanup,
49
+ bbBinaryPath,
50
+ bbWorkingDirectory,
51
+ cleanup,
52
+ numConcurrentIVCVerifiers: numIvcVerifiers,
53
+ bbIVCConcurrency: ivcConcurrency,
47
54
  };
48
-
49
- return { bbSkipCleanup, bbBinaryPath, bbWorkingDirectory, cleanup };
50
55
  } catch (err) {
51
56
  logger.error(`Native BB not available, error: ${err}`);
52
57
  return undefined;
@@ -0,0 +1,184 @@
1
+ import { EthAddress } from '@aztec/aztec.js/addresses';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import type { Logger } from '@aztec/aztec.js/log';
4
+ import { SecretValue } from '@aztec/foundation/config';
5
+
6
+ import { Pool } from 'pg';
7
+ import { privateKeyToAccount } from 'viem/accounts';
8
+
9
+ /**
10
+ * Configuration for HA database connection
11
+ */
12
+ export interface HADatabaseConfig {
13
+ /** PostgreSQL connection URL */
14
+ databaseUrl: string;
15
+ /** Node ID for HA coordination */
16
+ nodeId: string;
17
+ /** Enable HA signing */
18
+ haSigningEnabled: boolean;
19
+ /** Polling interval in ms */
20
+ pollingIntervalMs: number;
21
+ /** Signing timeout in ms */
22
+ signingTimeoutMs: number;
23
+ /** Max stuck duties age in ms */
24
+ maxStuckDutiesAgeMs: number;
25
+ }
26
+
27
+ /**
28
+ * Get database configuration from environment variables
29
+ */
30
+ export function createHADatabaseConfig(nodeId: string): HADatabaseConfig {
31
+ const databaseUrl = process.env.DATABASE_URL || 'postgresql://aztec:aztec@localhost:5432/aztec_ha_test';
32
+
33
+ return {
34
+ databaseUrl,
35
+ nodeId,
36
+ haSigningEnabled: true,
37
+ pollingIntervalMs: 100,
38
+ signingTimeoutMs: 3000,
39
+ maxStuckDutiesAgeMs: 72000,
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Setup PostgreSQL database connection pool for HA tests
45
+ *
46
+ * Note: Database migrations should be run separately before starting tests,
47
+ * either via docker-compose entrypoint or manually with: aztec migrate-ha-db up
48
+ */
49
+ export function setupHADatabase(databaseUrl: string, logger?: Logger): Pool {
50
+ try {
51
+ // Create connection pool for test usage
52
+ // Migrations are already run by docker-compose entrypoint before tests start
53
+ const pool = new Pool({ connectionString: databaseUrl });
54
+
55
+ logger?.info('Connected to HA database (migrations should already be applied)');
56
+
57
+ return pool;
58
+ } catch (error) {
59
+ logger?.error(`Failed to connect to HA database: ${error}`);
60
+ throw error;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Clean up HA database - drop all tables
66
+ * Use this between tests to ensure clean state
67
+ */
68
+ export async function cleanupHADatabase(pool: Pool, logger?: Logger): Promise<void> {
69
+ try {
70
+ // Drop all HA tables
71
+ await pool.query('DROP TABLE IF EXISTS validator_duties CASCADE');
72
+ await pool.query('DROP TABLE IF EXISTS slashing_protection CASCADE');
73
+ await pool.query('DROP TABLE IF EXISTS schema_version CASCADE');
74
+
75
+ logger?.info('HA database cleaned up successfully');
76
+ } catch (error) {
77
+ logger?.error(`Failed to cleanup HA database: ${error}`);
78
+ throw error;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Query validator duties from the database
84
+ */
85
+ export async function getValidatorDuties(
86
+ pool: Pool,
87
+ slot: bigint,
88
+ dutyType?: 'ATTESTATION' | 'BLOCK_PROPOSAL' | 'GOVERNANCE_VOTE' | 'SLASHING_VOTE',
89
+ ): Promise<
90
+ Array<{
91
+ slot: string;
92
+ dutyType: string;
93
+ validatorAddress: string;
94
+ nodeId: string;
95
+ startedAt: Date;
96
+ completedAt: Date | undefined;
97
+ }>
98
+ > {
99
+ const query = dutyType
100
+ ? 'SELECT slot, duty_type, validator_address, node_id, started_at, completed_at FROM validator_duties WHERE slot = $1 AND duty_type = $2 ORDER BY started_at'
101
+ : 'SELECT slot, duty_type, validator_address, node_id, started_at, completed_at FROM validator_duties WHERE slot = $1 ORDER BY started_at';
102
+
103
+ const params = dutyType ? [slot.toString(), dutyType] : [slot.toString()];
104
+
105
+ const result = await pool.query<{
106
+ slot: string;
107
+ duty_type: string;
108
+ validator_address: string;
109
+ node_id: string;
110
+ started_at: Date;
111
+ completed_at: Date | undefined;
112
+ }>(query, params);
113
+
114
+ return result.rows.map(row => ({
115
+ slot: row.slot,
116
+ dutyType: row.duty_type,
117
+ validatorAddress: row.validator_address,
118
+ nodeId: row.node_id,
119
+ startedAt: row.started_at,
120
+ completedAt: row.completed_at,
121
+ }));
122
+ }
123
+
124
+ /**
125
+ * Convert private keys to Ethereum addresses
126
+ */
127
+ export function getAddressesFromPrivateKeys(privateKeys: `0x${string}`[]): string[] {
128
+ return privateKeys.map(pk => {
129
+ const account = privateKeyToAccount(pk);
130
+ return account.address;
131
+ });
132
+ }
133
+
134
+ /**
135
+ * Create initial validators from private keys for L1 contract deployment
136
+ */
137
+ export function createInitialValidatorsFromPrivateKeys(attesterPrivateKeys: `0x${string}`[]): Array<{
138
+ attester: EthAddress;
139
+ withdrawer: EthAddress;
140
+ privateKey: `0x${string}`;
141
+ bn254SecretKey: SecretValue<bigint>;
142
+ }> {
143
+ return attesterPrivateKeys.map(pk => {
144
+ const account = privateKeyToAccount(pk);
145
+ return {
146
+ attester: EthAddress.fromString(account.address),
147
+ withdrawer: EthAddress.fromString(account.address),
148
+ privateKey: pk,
149
+ bn254SecretKey: new SecretValue(Fr.random().toBigInt()),
150
+ };
151
+ });
152
+ }
153
+
154
+ /**
155
+ * Verify no duplicate attestations per validator (HA coordination check)
156
+ * Groups duties by validator address and verifies each validator attested exactly once
157
+ */
158
+ export function verifyNoDuplicateAttestations(
159
+ attestationDuties: Array<{
160
+ validatorAddress: string;
161
+ nodeId: string;
162
+ completedAt: Date | undefined;
163
+ }>,
164
+ logger?: Logger,
165
+ ): Map<string, typeof attestationDuties> {
166
+ const dutiesByValidator = new Map<string, typeof attestationDuties>();
167
+ for (const duty of attestationDuties) {
168
+ const existing = dutiesByValidator.get(duty.validatorAddress) || [];
169
+ existing.push(duty);
170
+ dutiesByValidator.set(duty.validatorAddress, existing);
171
+ }
172
+
173
+ for (const [validatorAddress, validatorDuties] of dutiesByValidator.entries()) {
174
+ if (validatorDuties.length !== 1) {
175
+ throw new Error(`Validator ${validatorAddress} attested ${validatorDuties.length} times (expected exactly once)`);
176
+ }
177
+ if (!validatorDuties[0].completedAt) {
178
+ throw new Error(`Validator ${validatorAddress} attestation duty not completed`);
179
+ }
180
+ logger?.info(`Validator ${validatorAddress} attested once via node ${validatorDuties[0].nodeId}`);
181
+ }
182
+
183
+ return dutiesByValidator;
184
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './fixtures.js';
2
+ export * from './ha_setup.js';
2
3
  export * from './logging.js';
3
4
  export * from './utils.js';
4
5
  export * from './token_utils.js';