@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.0b941701

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 (236) 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 +65 -22
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +236 -49
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +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 +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +62 -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/shared.d.ts +44 -8
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +165 -27
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +96 -74
  55. package/dest/fixtures/e2e_prover_test.d.ts +55 -0
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/fixtures/e2e_prover_test.js +278 -0
  58. package/dest/fixtures/fixtures.d.ts +6 -8
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +5 -5
  61. package/dest/fixtures/get_acvm_config.d.ts +2 -2
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +3 -15
  64. package/dest/fixtures/get_bb_config.d.ts +2 -2
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/index.d.ts +1 -1
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
  69. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  70. package/dest/fixtures/l1_to_l2_messaging.js +45 -19
  71. package/dest/fixtures/logging.d.ts +1 -1
  72. package/dest/fixtures/setup.d.ts +218 -0
  73. package/dest/fixtures/setup.d.ts.map +1 -0
  74. package/dest/fixtures/setup.js +690 -0
  75. package/dest/fixtures/setup_p2p_test.d.ts +15 -14
  76. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  77. package/dest/fixtures/setup_p2p_test.js +82 -22
  78. package/dest/fixtures/token_utils.d.ts +10 -4
  79. package/dest/fixtures/token_utils.d.ts.map +1 -1
  80. package/dest/fixtures/token_utils.js +31 -12
  81. package/dest/fixtures/utils.d.ts +5 -153
  82. package/dest/fixtures/utils.d.ts.map +1 -1
  83. package/dest/fixtures/utils.js +4 -552
  84. package/dest/fixtures/web3signer.d.ts +5 -0
  85. package/dest/fixtures/web3signer.d.ts.map +1 -0
  86. package/dest/fixtures/web3signer.js +53 -0
  87. package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
  88. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
  89. package/dest/fixtures/with_telemetry_utils.js +2 -2
  90. package/dest/index.d.ts +1 -1
  91. package/dest/quality_of_service/grafana_client.d.ts +41 -0
  92. package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
  93. package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
  94. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  95. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  96. package/dest/quality_of_service/prometheus_client.js +67 -0
  97. package/dest/shared/cross_chain_test_harness.d.ts +44 -27
  98. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  99. package/dest/shared/cross_chain_test_harness.js +105 -51
  100. package/dest/shared/gas_portal_test_harness.d.ts +33 -25
  101. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  102. package/dest/shared/gas_portal_test_harness.js +51 -30
  103. package/dest/shared/index.d.ts +2 -2
  104. package/dest/shared/index.d.ts.map +1 -1
  105. package/dest/shared/jest_setup.d.ts +1 -1
  106. package/dest/shared/jest_setup.js +1 -1
  107. package/dest/shared/submit-transactions.d.ts +6 -4
  108. package/dest/shared/submit-transactions.d.ts.map +1 -1
  109. package/dest/shared/submit-transactions.js +15 -16
  110. package/dest/shared/uniswap_l1_l2.d.ts +3 -25
  111. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  112. package/dest/shared/uniswap_l1_l2.js +176 -126
  113. package/dest/simulators/index.d.ts +1 -1
  114. package/dest/simulators/lending_simulator.d.ts +7 -7
  115. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  116. package/dest/simulators/lending_simulator.js +17 -18
  117. package/dest/simulators/token_simulator.d.ts +6 -3
  118. package/dest/simulators/token_simulator.d.ts.map +1 -1
  119. package/dest/simulators/token_simulator.js +16 -13
  120. package/dest/spartan/setup_test_wallets.d.ts +27 -11
  121. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  122. package/dest/spartan/setup_test_wallets.js +233 -62
  123. package/dest/spartan/tx_metrics.d.ts +54 -0
  124. package/dest/spartan/tx_metrics.d.ts.map +1 -0
  125. package/dest/spartan/tx_metrics.js +272 -0
  126. package/dest/spartan/utils/bot.d.ts +27 -0
  127. package/dest/spartan/utils/bot.d.ts.map +1 -0
  128. package/dest/spartan/utils/bot.js +141 -0
  129. package/dest/spartan/utils/chaos.d.ts +79 -0
  130. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  131. package/dest/spartan/utils/chaos.js +142 -0
  132. package/dest/spartan/utils/clients.d.ts +39 -0
  133. package/dest/spartan/utils/clients.d.ts.map +1 -0
  134. package/dest/spartan/utils/clients.js +90 -0
  135. package/dest/spartan/utils/config.d.ts +36 -0
  136. package/dest/spartan/utils/config.d.ts.map +1 -0
  137. package/dest/spartan/utils/config.js +20 -0
  138. package/dest/spartan/utils/health.d.ts +63 -0
  139. package/dest/spartan/utils/health.d.ts.map +1 -0
  140. package/dest/spartan/utils/health.js +202 -0
  141. package/dest/spartan/utils/helm.d.ts +15 -0
  142. package/dest/spartan/utils/helm.d.ts.map +1 -0
  143. package/dest/spartan/utils/helm.js +47 -0
  144. package/dest/spartan/utils/index.d.ts +9 -0
  145. package/dest/spartan/utils/index.d.ts.map +1 -0
  146. package/dest/spartan/utils/index.js +18 -0
  147. package/dest/spartan/utils/k8s.d.ts +98 -0
  148. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  149. package/dest/spartan/utils/k8s.js +257 -0
  150. package/dest/spartan/utils/nodes.d.ts +31 -0
  151. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  152. package/dest/spartan/utils/nodes.js +290 -0
  153. package/dest/spartan/utils/scripts.d.ts +16 -0
  154. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  155. package/dest/spartan/utils/scripts.js +66 -0
  156. package/dest/spartan/utils.d.ts +2 -415
  157. package/dest/spartan/utils.d.ts.map +1 -1
  158. package/dest/spartan/utils.js +1 -445
  159. package/package.json +66 -58
  160. package/src/bench/client_flows/benchmark.ts +363 -0
  161. package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
  162. package/src/bench/client_flows/config.ts +61 -0
  163. package/src/bench/client_flows/data_extractor.ts +89 -0
  164. package/src/bench/utils.ts +41 -85
  165. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
  166. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
  167. package/src/e2e_deploy_contract/deploy_test.ts +40 -48
  168. package/src/e2e_epochs/epochs_test.ts +315 -76
  169. package/src/e2e_fees/bridging_race.notest.ts +74 -0
  170. package/src/e2e_fees/fees_test.ts +220 -258
  171. package/src/e2e_l1_publisher/write_json.ts +82 -0
  172. package/src/e2e_multi_validator/utils.ts +258 -0
  173. package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
  174. package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
  175. package/src/e2e_p2p/p2p_network.ts +341 -234
  176. package/src/e2e_p2p/shared.ts +253 -40
  177. package/src/e2e_token_contract/token_contract_test.ts +115 -126
  178. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  179. package/src/fixtures/e2e_prover_test.ts +336 -0
  180. package/src/fixtures/fixtures.ts +5 -7
  181. package/src/fixtures/get_acvm_config.ts +4 -12
  182. package/src/fixtures/get_bb_config.ts +18 -13
  183. package/src/fixtures/l1_to_l2_messaging.ts +56 -24
  184. package/src/fixtures/setup.ts +1017 -0
  185. package/src/fixtures/setup_p2p_test.ts +127 -39
  186. package/src/fixtures/token_utils.ts +33 -15
  187. package/src/fixtures/utils.ts +27 -820
  188. package/src/fixtures/web3signer.ts +63 -0
  189. package/src/fixtures/with_telemetry_utils.ts +2 -2
  190. package/src/guides/up_quick_start.sh +7 -15
  191. package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
  192. package/src/quality_of_service/prometheus_client.ts +113 -0
  193. package/src/shared/cross_chain_test_harness.ts +103 -91
  194. package/src/shared/gas_portal_test_harness.ts +59 -50
  195. package/src/shared/index.ts +1 -1
  196. package/src/shared/jest_setup.ts +1 -1
  197. package/src/shared/submit-transactions.ts +18 -20
  198. package/src/shared/uniswap_l1_l2.ts +197 -221
  199. package/src/simulators/lending_simulator.ts +16 -17
  200. package/src/simulators/token_simulator.ts +21 -13
  201. package/src/spartan/DEVELOP.md +128 -0
  202. package/src/spartan/setup_test_wallets.ts +308 -95
  203. package/src/spartan/tx_metrics.ts +250 -0
  204. package/src/spartan/utils/bot.ts +185 -0
  205. package/src/spartan/utils/chaos.ts +253 -0
  206. package/src/spartan/utils/clients.ts +100 -0
  207. package/src/spartan/utils/config.ts +26 -0
  208. package/src/spartan/utils/health.ts +255 -0
  209. package/src/spartan/utils/helm.ts +84 -0
  210. package/src/spartan/utils/index.ts +62 -0
  211. package/src/spartan/utils/k8s.ts +375 -0
  212. package/src/spartan/utils/nodes.ts +323 -0
  213. package/src/spartan/utils/scripts.ts +63 -0
  214. package/src/spartan/utils.ts +1 -582
  215. package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
  216. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  217. package/dest/e2e_prover/e2e_prover_test.js +0 -291
  218. package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
  219. package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
  220. package/dest/fixtures/setup_l1_contracts.js +0 -17
  221. package/dest/fixtures/snapshot_manager.d.ts +0 -87
  222. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  223. package/dest/fixtures/snapshot_manager.js +0 -479
  224. package/dest/quality_of_service/alert_checker.d.ts +0 -41
  225. package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
  226. package/dest/sample-dapp/connect.js +0 -12
  227. package/dest/sample-dapp/contracts.js +0 -10
  228. package/dest/sample-dapp/deploy.js +0 -35
  229. package/dest/sample-dapp/index.js +0 -98
  230. package/src/e2e_prover/e2e_prover_test.ts +0 -418
  231. package/src/fixtures/setup_l1_contracts.ts +0 -27
  232. package/src/fixtures/snapshot_manager.ts +0 -617
  233. package/src/sample-dapp/connect.mjs +0 -16
  234. package/src/sample-dapp/contracts.mjs +0 -14
  235. package/src/sample-dapp/deploy.mjs +0 -40
  236. 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
+ true,
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;
@@ -1,50 +1,82 @@
1
- import type { L1ContractAddresses, ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { RollupContract } from '@aztec/ethereum/contracts';
2
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
3
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { tryJsonStringify } from '@aztec/foundation/json-rpc';
3
6
  import { InboxAbi } from '@aztec/l1-artifacts';
4
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
8
 
6
- import { expect } from '@jest/globals';
7
9
  import { decodeEventLog, getContract } from 'viem';
8
10
 
11
+ import { getLogger } from './utils.js';
12
+
9
13
  export async function sendL1ToL2Message(
10
14
  message: { recipient: AztecAddress; content: Fr; secretHash: Fr },
11
15
  ctx: {
12
- walletClient: ViemWalletClient;
13
- publicClient: ViemPublicClient;
14
- l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress'>;
16
+ l1Client: ExtendedViemWalletClient;
17
+ l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress' | 'rollupAddress'>;
15
18
  },
16
19
  ) {
20
+ const logger = getLogger();
17
21
  const inbox = getContract({
18
22
  address: ctx.l1ContractAddresses.inboxAddress.toString(),
19
23
  abi: InboxAbi,
20
- client: ctx.walletClient,
24
+ client: ctx.l1Client,
21
25
  });
22
26
 
23
27
  const { recipient, content, secretHash } = message;
24
- const version = 1;
28
+
29
+ const version = await new RollupContract(ctx.l1Client, ctx.l1ContractAddresses.rollupAddress.toString()).getVersion();
25
30
 
26
31
  // We inject the message to Inbox
27
- const txHash = await inbox.write.sendL2Message([
28
- { actor: recipient.toString(), version: BigInt(version) },
29
- content.toString(),
30
- secretHash.toString(),
31
- ]);
32
+ const txHash = await inbox.write.sendL2Message(
33
+ [{ actor: recipient.toString(), version: BigInt(version) }, content.toString(), secretHash.toString()],
34
+ {
35
+ gas: 1_000_000n,
36
+ },
37
+ );
38
+ logger.info(`L1 to L2 message sent in tx ${txHash}`);
32
39
 
33
40
  // We check that the message was correctly injected by checking the emitted event
34
- const txReceipt = await ctx.publicClient.waitForTransactionReceipt({ hash: txHash });
41
+ const txReceipt = await ctx.l1Client.waitForTransactionReceipt({ hash: txHash });
35
42
 
36
- // Exactly 1 event should be emitted in the transaction
37
- expect(txReceipt.logs.length).toBe(1);
43
+ if (txReceipt.status !== 'success') {
44
+ throw new Error(`L1 to L2 message failed to be sent in tx ${txHash}. Status: ${txReceipt.status}`);
45
+ }
38
46
 
39
- // We decode the event and get leaf out of it
40
- const messageSentLog = txReceipt.logs[0];
41
- const topics = decodeEventLog({
42
- abi: InboxAbi,
43
- data: messageSentLog.data,
44
- topics: messageSentLog.topics,
45
- });
47
+ logger.info(`L1 to L2 message receipt retrieved for tx ${txReceipt.transactionHash}`, txReceipt);
48
+
49
+ if (txReceipt.transactionHash !== txHash) {
50
+ throw new Error(`Receipt transaction hash mismatch: ${txReceipt.transactionHash} !== ${txHash}`);
51
+ }
52
+
53
+ // Filter for MessageSent events from the Inbox contract by trying to decode each log
54
+ const messageSentLogs = txReceipt.logs
55
+ .filter(log => log.address.toLowerCase() === ctx.l1ContractAddresses.inboxAddress.toString().toLowerCase())
56
+ .map(log => {
57
+ try {
58
+ const decoded = decodeEventLog({
59
+ abi: InboxAbi,
60
+ data: log.data,
61
+ topics: log.topics,
62
+ });
63
+ return { log, decoded };
64
+ } catch {
65
+ return null; // Not a decodable event from this ABI
66
+ }
67
+ })
68
+ .filter((item): item is { log: any; decoded: any } => item !== null && item.decoded.eventName === 'MessageSent');
69
+
70
+ if (messageSentLogs.length !== 1) {
71
+ throw new Error(
72
+ `Wrong number of MessageSent logs found in ${txHash} transaction (got ${messageSentLogs.length} expected 1)\n${tryJsonStringify(messageSentLogs.map(item => item.log))}`,
73
+ );
74
+ }
75
+
76
+ // We already have the decoded event
77
+ const topics = messageSentLogs[0].decoded;
46
78
  const receivedMsgHash = topics.args.hash;
47
79
  const receivedGlobalLeafIndex = topics.args.index;
48
80
 
49
- return [Fr.fromHexString(receivedMsgHash), new Fr(receivedGlobalLeafIndex)];
81
+ return { msgHash: Fr.fromHexString(receivedMsgHash), globalLeafIndex: new Fr(receivedGlobalLeafIndex), txReceipt };
50
82
  }