@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
@@ -1,479 +0,0 @@
1
- import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { deployFundedSchnorrAccounts, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import { AnvilTestWatcher, BatchCall, CheatCodes, getContractClassFromArtifact } from '@aztec/aztec.js';
5
- import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
6
- import { createBlobSinkServer } from '@aztec/blob-sink/server';
7
- import { createL1Clients, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum';
8
- import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
9
- import { asyncMap } from '@aztec/foundation/async-map';
10
- import { randomBytes } from '@aztec/foundation/crypto';
11
- import { createLogger } from '@aztec/foundation/log';
12
- import { resolver, reviver } from '@aztec/foundation/serialize';
13
- import { TestDateProvider } from '@aztec/foundation/timer';
14
- import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
15
- import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
16
- import { getGenesisValues } from '@aztec/world-state/testing';
17
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
18
- import { copySync, removeSync } from 'fs-extra/esm';
19
- import fs from 'fs/promises';
20
- import getPort from 'get-port';
21
- import { tmpdir } from 'os';
22
- import path, { join } from 'path';
23
- import { getContract } from 'viem';
24
- import { mnemonicToAccount } from 'viem/accounts';
25
- import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
26
- import { getACVMConfig } from './get_acvm_config.js';
27
- import { getBBConfig } from './get_bb_config.js';
28
- import { setupL1Contracts } from './setup_l1_contracts.js';
29
- import { createAndSyncProverNode, getLogger, getPrivateKeyFromIndex } from './utils.js';
30
- import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
31
- export function createSnapshotManager(testName, dataPath, config = {}, deployL1ContractsArgs = {
32
- initialValidators: []
33
- }) {
34
- return dataPath ? new SnapshotManager(testName, dataPath, config, deployL1ContractsArgs) : new MockSnapshotManager(testName, config, deployL1ContractsArgs);
35
- }
36
- /** Snapshot manager that does not perform snapshotting, it just applies transition and restoration functions as it receives them. */ class MockSnapshotManager {
37
- config;
38
- deployL1ContractsArgs;
39
- context;
40
- logger;
41
- constructor(testName, config = {}, deployL1ContractsArgs = {}){
42
- this.config = config;
43
- this.deployL1ContractsArgs = deployL1ContractsArgs;
44
- this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
45
- this.logger.warn(`No data path given, will not persist any snapshots.`);
46
- }
47
- async snapshot(name, apply, restore = ()=>Promise.resolve()) {
48
- // We are running in disabled mode. Just apply the state.
49
- const context = await this.setup();
50
- this.logger.verbose(`Applying state transition for ${name}...`);
51
- const snapshotData = await apply(context);
52
- this.logger.verbose(`State transition for ${name} complete.`);
53
- // Execute the restoration function.
54
- await restore(snapshotData, context);
55
- return;
56
- }
57
- async setup() {
58
- if (!this.context) {
59
- this.context = await setupFromFresh(undefined, this.logger, this.config, this.deployL1ContractsArgs);
60
- }
61
- return this.context;
62
- }
63
- async teardown() {
64
- await teardown(this.context);
65
- this.context = undefined;
66
- }
67
- }
68
- /**
69
- * Snapshot engine for local e2e tests. Read more:
70
- * https://github.com/AztecProtocol/aztec-packages/pull/5526
71
- */ class SnapshotManager {
72
- dataPath;
73
- config;
74
- deployL1ContractsArgs;
75
- snapshotStack;
76
- context;
77
- livePath;
78
- logger;
79
- constructor(testName, dataPath, config = {}, deployL1ContractsArgs = {}){
80
- this.dataPath = dataPath;
81
- this.config = config;
82
- this.deployL1ContractsArgs = deployL1ContractsArgs;
83
- this.snapshotStack = [];
84
- this.livePath = join(this.dataPath, 'live', testName);
85
- this.logger = createLogger(`e2e:snapshot_manager:${testName}`);
86
- }
87
- async snapshot(name, apply, restore = ()=>Promise.resolve()) {
88
- const snapshotPath = join(this.dataPath, 'snapshots', ...this.snapshotStack.map((e)=>e.name), name, 'snapshot');
89
- if (existsSync(snapshotPath)) {
90
- // Snapshot exists. Record entry on stack but do nothing else as we're probably still descending the tree.
91
- // It's the tests responsibility to call setup() before a test to ensure subsystems get created.
92
- this.logger.verbose(`Snapshot exists at ${snapshotPath}. Continuing...`);
93
- this.snapshotStack.push({
94
- name,
95
- apply,
96
- restore,
97
- snapshotPath
98
- });
99
- return;
100
- }
101
- // Snapshot didn't exist at snapshotPath, and by definition none of the child snapshots can exist.
102
- // If we have no subsystem context yet, create it from the top of the snapshot stack (if it exists).
103
- const context = await this.setup();
104
- this.snapshotStack.push({
105
- name,
106
- apply,
107
- restore,
108
- snapshotPath
109
- });
110
- // Apply current state transition.
111
- this.logger.verbose(`Applying state transition for ${name}...`);
112
- const snapshotData = await apply(context);
113
- this.logger.verbose(`State transition for ${name} complete.`);
114
- // Execute the restoration function.
115
- await restore(snapshotData, context);
116
- // Save the snapshot data.
117
- const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
118
- const anvilStateFile = `${this.livePath}/anvil.dat`;
119
- await ethCheatCodes.dumpChainState(anvilStateFile);
120
- writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
121
- // Copy everything to snapshot path.
122
- // We want it to be atomic, in case multiple processes are racing to create the snapshot.
123
- this.logger.verbose(`Saving snapshot to ${snapshotPath}...`);
124
- if (mkdirSync(snapshotPath, {
125
- recursive: true
126
- })) {
127
- copySync(this.livePath, snapshotPath);
128
- this.logger.verbose(`Snapshot copied to ${snapshotPath}.`);
129
- } else {
130
- this.logger.verbose(`Snapshot already exists at ${snapshotPath}. Discarding our version.`);
131
- await this.teardown();
132
- }
133
- }
134
- /**
135
- * Creates and returns the subsystem context based on the current snapshot stack.
136
- * If the subsystem context already exists, just return it.
137
- * If you want to be sure to get a clean snapshot, be sure to call teardown() before calling setup().
138
- */ async setup() {
139
- // We have no subsystem context yet.
140
- // If one exists on the snapshot stack, create one from that snapshot.
141
- // Otherwise create a fresh one.
142
- if (!this.context) {
143
- removeSync(this.livePath);
144
- mkdirSync(this.livePath, {
145
- recursive: true
146
- });
147
- const previousSnapshotPath = this.snapshotStack[this.snapshotStack.length - 1]?.snapshotPath;
148
- if (previousSnapshotPath) {
149
- this.logger.verbose(`Copying snapshot from ${previousSnapshotPath} to ${this.livePath}...`);
150
- copySync(previousSnapshotPath, this.livePath);
151
- this.context = await setupFromState(this.livePath, this.logger);
152
- // Execute each of the previous snapshots restoration functions in turn.
153
- await asyncMap(this.snapshotStack, async (e)=>{
154
- const snapshotData = JSON.parse(readFileSync(`${e.snapshotPath}/${e.name}.json`, 'utf-8'), reviver);
155
- this.logger.verbose(`Executing restoration function for ${e.name}...`);
156
- await e.restore(snapshotData, this.context);
157
- this.logger.verbose(`Restoration of ${e.name} complete.`);
158
- });
159
- } else {
160
- this.context = await setupFromFresh(this.livePath, this.logger, this.config, this.deployL1ContractsArgs);
161
- }
162
- }
163
- return this.context;
164
- }
165
- /**
166
- * Destroys the current subsystem context.
167
- */ async teardown() {
168
- await teardown(this.context);
169
- this.context = undefined;
170
- removeSync(this.livePath);
171
- }
172
- }
173
- /**
174
- * Destroys the current subsystem context.
175
- */ async function teardown(context) {
176
- if (!context) {
177
- return;
178
- }
179
- try {
180
- getLogger().info('Tearing down subsystems');
181
- await context.proverNode?.stop();
182
- await context.aztecNode.stop();
183
- await context.acvmConfig?.cleanup();
184
- await context.bbConfig?.cleanup();
185
- await context.anvil.stop();
186
- await context.watcher.stop();
187
- await context.blobSink.stop();
188
- if (context.directoryToCleanup) {
189
- try {
190
- await fs.rm(context.directoryToCleanup, {
191
- recursive: true,
192
- force: true,
193
- maxRetries: 3
194
- });
195
- } catch (err) {
196
- getLogger().warn(`Failed to delete tmp directory ${context.directoryToCleanup}: ${err}`);
197
- }
198
- }
199
- } catch (err) {
200
- getLogger().error('Error during teardown', err);
201
- }
202
- }
203
- /**
204
- * Initializes a fresh set of subsystems.
205
- * If given a statePath, the state will be written to the path.
206
- * If there is no statePath, in-memory and temporary state locations will be used.
207
- */ async function setupFromFresh(statePath, logger, { numberOfInitialFundedAccounts = 10, ...opts } = {}, deployL1ContractsArgs = {
208
- initialValidators: []
209
- }) {
210
- logger.verbose(`Initializing state...`);
211
- const blobSinkPort = await getPort();
212
- // Fetch the AztecNode config.
213
- // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
214
- const aztecNodeConfig = {
215
- ...getConfigEnvVars(),
216
- ...opts
217
- };
218
- aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
219
- // Create a temp directory for all ephemeral state and cleanup afterwards
220
- const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
221
- await fs.mkdir(directoryToCleanup, {
222
- recursive: true
223
- });
224
- if (statePath === undefined) {
225
- aztecNodeConfig.dataDirectory = directoryToCleanup;
226
- } else {
227
- aztecNodeConfig.dataDirectory = statePath;
228
- }
229
- aztecNodeConfig.blobSinkUrl = `http://localhost:${blobSinkPort}`;
230
- // Setup blob sink service
231
- const blobSink = await createBlobSinkServer({
232
- port: blobSinkPort,
233
- dataStoreConfig: {
234
- dataDirectory: aztecNodeConfig.dataDirectory,
235
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB
236
- }
237
- });
238
- await blobSink.start();
239
- // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
240
- logger.verbose('Starting anvil...');
241
- const res = await startAnvil({
242
- l1BlockTime: opts.ethereumSlotDuration
243
- });
244
- const anvil = res.anvil;
245
- aztecNodeConfig.l1RpcUrls = [
246
- res.rpcUrl
247
- ];
248
- // Deploy our L1 contracts.
249
- logger.verbose('Deploying L1 contracts...');
250
- const hdAccount = mnemonicToAccount(MNEMONIC, {
251
- accountIndex: 0
252
- });
253
- const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
254
- const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
255
- const validatorPrivKey = getPrivateKeyFromIndex(0);
256
- const proverNodePrivateKey = getPrivateKeyFromIndex(0);
257
- aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey.toString('hex')}`;
258
- aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey.toString('hex')}`;
259
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
260
- if (opts.l1StartTime) {
261
- await ethCheatCodes.warp(opts.l1StartTime);
262
- }
263
- const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
264
- const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address), opts.initialAccountFeeJuice);
265
- const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrls[0], hdAccount, logger, {
266
- ...getL1ContractsConfigEnvVars(),
267
- genesisArchiveRoot,
268
- genesisBlockHash,
269
- salt: opts.salt,
270
- ...deployL1ContractsArgs,
271
- initialValidators: opts.initialValidators
272
- });
273
- aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
274
- aztecNodeConfig.l1PublishRetryIntervalMS = 100;
275
- if (opts.fundRewardDistributor) {
276
- // Mints block rewards for 10000 blocks to the rewardDistributor contract
277
- const rewardDistributor = getContract({
278
- address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
279
- abi: l1Artifacts.rewardDistributor.contractAbi,
280
- client: deployL1ContractsValues.publicClient
281
- });
282
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
283
- const mintAmount = 10_000n * blockReward;
284
- const feeJuice = getContract({
285
- address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
286
- abi: l1Artifacts.feeAsset.contractAbi,
287
- client: deployL1ContractsValues.walletClient
288
- });
289
- const rewardDistributorMintTxHash = await feeJuice.write.mint([
290
- rewardDistributor.address,
291
- mintAmount
292
- ], {});
293
- await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
294
- hash: rewardDistributorMintTxHash
295
- });
296
- logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
297
- }
298
- const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls), deployL1ContractsValues.l1ContractAddresses.rollupAddress, deployL1ContractsValues.publicClient);
299
- await watcher.start();
300
- const acvmConfig = await getACVMConfig(logger);
301
- if (acvmConfig) {
302
- aztecNodeConfig.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
303
- aztecNodeConfig.acvmBinaryPath = acvmConfig.acvmBinaryPath;
304
- }
305
- const bbConfig = await getBBConfig(logger);
306
- if (bbConfig) {
307
- aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
308
- aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
309
- }
310
- const telemetry = getEndToEndTestTelemetryClient(opts.metricsPort);
311
- logger.verbose('Creating and synching an aztec node...');
312
- const dateProvider = new TestDateProvider();
313
- const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
314
- telemetry,
315
- dateProvider
316
- }, {
317
- prefilledPublicData
318
- });
319
- let proverNode = undefined;
320
- if (opts.startProverNode) {
321
- logger.verbose('Creating and syncing a simulated prover node...');
322
- proverNode = await createAndSyncProverNode(`0x${proverNodePrivateKey.toString('hex')}`, aztecNodeConfig, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')), prefilledPublicData);
323
- }
324
- logger.verbose('Creating pxe...');
325
- const pxeConfig = getPXEServiceConfig();
326
- pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
327
- const pxe = await createPXEService(aztecNode, pxeConfig);
328
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
329
- if (statePath) {
330
- writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
331
- writeFileSync(`${statePath}/accounts.json`, JSON.stringify(initialFundedAccounts, resolver));
332
- }
333
- return {
334
- aztecNodeConfig,
335
- anvil,
336
- aztecNode,
337
- pxe,
338
- acvmConfig,
339
- bbConfig,
340
- deployL1ContractsValues,
341
- proverNode,
342
- watcher,
343
- cheatCodes,
344
- dateProvider,
345
- blobSink,
346
- initialFundedAccounts,
347
- directoryToCleanup
348
- };
349
- }
350
- /**
351
- * Given a statePath, setup the system starting from that state.
352
- */ async function setupFromState(statePath, logger) {
353
- logger.verbose(`Initializing with saved state at ${statePath}...`);
354
- const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
355
- await fs.mkdir(directoryToCleanup, {
356
- recursive: true
357
- });
358
- // Run the blob sink on a random port
359
- const blobSinkPort = await getPort();
360
- // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing.
361
- const aztecNodeConfig = JSON.parse(readFileSync(`${statePath}/aztec_node_config.json`, 'utf-8'), reviver);
362
- aztecNodeConfig.dataDirectory = statePath;
363
- aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
364
- const initialFundedAccounts = JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
365
- const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts.map((a)=>a.address));
366
- const blobSink = await createBlobSinkServer({
367
- port: blobSinkPort,
368
- dataStoreConfig: {
369
- dataDirectory: statePath,
370
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB
371
- }
372
- });
373
- await blobSink.start();
374
- // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
375
- const { anvil, rpcUrl } = await startAnvil();
376
- aztecNodeConfig.l1RpcUrls = [
377
- rpcUrl
378
- ];
379
- // Load anvil state.
380
- const anvilStateFile = `${statePath}/anvil.dat`;
381
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
382
- await ethCheatCodes.loadChainState(anvilStateFile);
383
- // TODO: Encapsulate this in a NativeAcvm impl.
384
- const acvmConfig = await getACVMConfig(logger);
385
- if (acvmConfig) {
386
- aztecNodeConfig.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
387
- aztecNodeConfig.acvmBinaryPath = acvmConfig.acvmBinaryPath;
388
- }
389
- const bbConfig = await getBBConfig(logger);
390
- if (bbConfig) {
391
- aztecNodeConfig.bbBinaryPath = bbConfig.bbBinaryPath;
392
- aztecNodeConfig.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
393
- }
394
- logger.verbose('Creating ETH clients...');
395
- const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
396
- const watcher = new AnvilTestWatcher(new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls), aztecNodeConfig.l1Contracts.rollupAddress, publicClient);
397
- await watcher.start();
398
- logger.verbose('Creating aztec node...');
399
- const telemetry = initTelemetryClient(getTelemetryConfig());
400
- const dateProvider = new TestDateProvider();
401
- const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, {
402
- telemetry,
403
- dateProvider
404
- }, {
405
- prefilledPublicData
406
- });
407
- let proverNode = undefined;
408
- if (aztecNodeConfig.startProverNode) {
409
- logger.verbose('Creating and syncing a simulated prover node...');
410
- const proverNodePrivateKey = getPrivateKeyFromIndex(2);
411
- const proverNodePrivateKeyHex = `0x${proverNodePrivateKey.toString('hex')}`;
412
- proverNode = await createAndSyncProverNode(proverNodePrivateKeyHex, aztecNodeConfig, aztecNode, path.join(directoryToCleanup, randomBytes(8).toString('hex')), prefilledPublicData);
413
- }
414
- logger.verbose('Creating pxe...');
415
- const pxeConfig = getPXEServiceConfig();
416
- pxeConfig.dataDirectory = statePath;
417
- const pxe = await createPXEService(aztecNode, pxeConfig);
418
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
419
- return {
420
- aztecNodeConfig,
421
- anvil,
422
- aztecNode,
423
- pxe,
424
- acvmConfig,
425
- bbConfig,
426
- proverNode,
427
- deployL1ContractsValues: {
428
- walletClient,
429
- publicClient,
430
- l1ContractAddresses: aztecNodeConfig.l1Contracts
431
- },
432
- watcher,
433
- cheatCodes,
434
- dateProvider,
435
- blobSink,
436
- initialFundedAccounts,
437
- directoryToCleanup
438
- };
439
- }
440
- /**
441
- * Snapshot 'apply' helper function to add accounts.
442
- * The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
443
- */ export const deployAccounts = (numberOfAccounts, logger, waitUntilProven = false)=>async ({ pxe, initialFundedAccounts })=>{
444
- if (initialFundedAccounts.length < numberOfAccounts) {
445
- throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
446
- }
447
- logger.verbose('Deploying accounts funded with fee juice...');
448
- const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
449
- await deployFundedSchnorrAccounts(pxe, deployedAccounts, {
450
- proven: waitUntilProven
451
- });
452
- return {
453
- deployedAccounts
454
- };
455
- };
456
- /**
457
- * Registers the contract class used for test accounts and publicly deploys the instances requested.
458
- * Use this when you need to make a public call to an account contract, such as for requesting a public authwit.
459
- * @param sender - Wallet to send the deployment tx.
460
- * @param accountsToDeploy - Which accounts to publicly deploy.
461
- */ export async function publicDeployAccounts(sender, accountsToDeploy, waitUntilProven = false) {
462
- const accountAddressesToDeploy = accountsToDeploy.map((a)=>'address' in a ? a.address : a);
463
- const instances = (await Promise.all(accountAddressesToDeploy.map((account)=>sender.getContractMetadata(account)))).map((metadata)=>metadata.contractInstance);
464
- const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
465
- const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
466
- const fns = await Promise.all([
467
- ...!alreadyRegistered ? [
468
- registerContractClass(sender, SchnorrAccountContractArtifact)
469
- ] : [],
470
- ...instances.map((instance)=>deployInstance(sender, instance))
471
- ]);
472
- const calls = await Promise.all(fns.map((fn)=>fn.request()));
473
- const capsules = fns.map((fn)=>fn.getCapsules()).flat();
474
- const batch = new BatchCall(sender, calls);
475
- batch.addCapsules(capsules);
476
- await batch.send().wait({
477
- proven: waitUntilProven
478
- });
479
- }
@@ -1,41 +0,0 @@
1
- import type { Logger } from '@aztec/aztec.js';
2
- export interface AlertConfig {
3
- alert: string;
4
- expr: string;
5
- start?: number;
6
- end?: number;
7
- step?: number;
8
- for: string;
9
- labels: Record<string, string>;
10
- annotations: Record<string, string>;
11
- }
12
- export interface AlertCheckerConfig {
13
- grafanaEndpoint: string;
14
- grafanaCredentials: string;
15
- }
16
- export declare class AlertChecker {
17
- private config;
18
- private logger;
19
- constructor(logger: Logger, config?: Partial<AlertCheckerConfig>);
20
- /**
21
- * Load the alerts config from a file path.
22
- * @param filePath - The absolute path to the alerts file.
23
- */
24
- private loadAlertsConfig;
25
- private queryGrafana;
26
- private checkAlerts;
27
- /**
28
- * Run the alert check based on the alerts defined in an array.
29
- * @param alerts - The alerts to check.
30
- */
31
- runAlertCheck(alerts: AlertConfig[]): Promise<void>;
32
- /**
33
- * Run the alert check based on the alerts defined in a yaml file.
34
- * @param filePath - The absolute path to the alerts file.
35
- */
36
- runAlertCheckFromFilePath(filePath: string): Promise<void>;
37
- }
38
- export declare class AlertTriggeredError extends Error {
39
- name: string;
40
- }
41
- //# sourceMappingURL=alert_checker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alert_checker.d.ts","sourceRoot":"","sources":["../../src/quality_of_service/alert_checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAK9C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAQD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,kBAAkB,CAAM;IAKpE;;;OAGG;IACH,OAAO,CAAC,gBAAgB;YAMV,YAAY;YAqCZ,WAAW;IAqBzB;;;OAGG;IACU,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhE;;;OAGG;IACU,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIxE;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IACnC,IAAI,SAAyB;CACvC"}
@@ -1,12 +0,0 @@
1
- // docs:start:all
2
- import { createPXEClient } from '@aztec/aztec.js';
3
- const { PXE_URL = 'http://localhost:8080' } = process.env;
4
- async function main() {
5
- const pxe = await createPXEClient(PXE_URL);
6
- const { l1ChainId } = await pxe.getNodeInfo();
7
- console.log(`Connected to chain ${l1ChainId}`);
8
- }
9
- main().catch((err)=>{
10
- console.error(`Error in app: ${err}`);
11
- process.exit(1);
12
- }); // docs:end:all
@@ -1,10 +0,0 @@
1
- // docs:start:imports
2
- import { AztecAddress } from '@aztec/aztec.js';
3
- import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
- import { readFileSync } from 'fs';
5
- // docs:end:imports
6
- // docs:start:get-tokens
7
- export async function getToken(wallet) {
8
- const addresses = JSON.parse(readFileSync('addresses.json'));
9
- return TokenContract.at(AztecAddress.fromString(addresses.token), wallet);
10
- } // docs:end:get-tokens
@@ -1,35 +0,0 @@
1
- // docs:start:deploy-imports
2
- import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
3
- import { Contract, createPXEClient, waitForPXE } from '@aztec/aztec.js';
4
- // docs:end:deploy-imports
5
- import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
6
- import { writeFileSync } from 'fs';
7
- import { fileURLToPath } from 'url';
8
- // docs:start:dapp-deploy
9
- const { PXE_URL = 'http://localhost:8080' } = process.env;
10
- async function main() {
11
- const pxe = createPXEClient(PXE_URL);
12
- await waitForPXE(pxe);
13
- const [ownerWallet] = await getInitialTestAccountsWallets(pxe);
14
- const ownerAddress = ownerWallet.getAddress();
15
- const token = await Contract.deploy(ownerWallet, TokenContractArtifact, [
16
- ownerAddress,
17
- 'TokenName',
18
- 'TKN',
19
- 18
20
- ]).send().deployed();
21
- console.log(`Token deployed at ${token.address.toString()}`);
22
- const addresses = {
23
- token: token.address.toString()
24
- };
25
- writeFileSync('addresses.json', JSON.stringify(addresses, null, 2));
26
- }
27
- // docs:end:dapp-deploy
28
- // Execute main only if run directly
29
- if (process.argv[1].replace(/\/index\.m?js$/, '') === fileURLToPath(import.meta.url).replace(/\/index\.m?js$/, '')) {
30
- main().catch((err)=>{
31
- console.error(`Error in deployment script: ${err}`);
32
- process.exit(1);
33
- });
34
- }
35
- export { main as deploy };