@aztec/end-to-end 5.0.0-rc.1 → 5.0.0

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 (257) hide show
  1. package/README.md +215 -27
  2. package/dest/automine/automine_test_context.d.ts +85 -0
  3. package/dest/automine/automine_test_context.d.ts.map +1 -0
  4. package/dest/automine/automine_test_context.js +98 -0
  5. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
  6. package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  7. package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
  8. package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
  9. package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
  10. package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
  11. package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
  12. package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
  13. package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
  14. package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
  15. package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
  16. package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
  17. package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +17 -24
  18. package/dest/automine/token/token_contract_test.d.ts +40 -0
  19. package/dest/automine/token/token_contract_test.d.ts.map +1 -0
  20. package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +22 -28
  21. package/dest/automine/token/token_test_helpers.d.ts +73 -0
  22. package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
  23. package/dest/automine/token/token_test_helpers.js +97 -0
  24. package/dest/bench/client_flows/benchmark.d.ts +1 -1
  25. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  26. package/dest/bench/client_flows/benchmark.js +3 -1
  27. package/dest/bench/client_flows/client_flows_benchmark.d.ts +4 -4
  28. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  29. package/dest/bench/client_flows/client_flows_benchmark.js +25 -10
  30. package/dest/bench/utils.d.ts +1 -1
  31. package/dest/composed/ha/ha_full_setup.d.ts +77 -0
  32. package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
  33. package/dest/composed/ha/ha_full_setup.js +383 -0
  34. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
  35. package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
  36. package/dest/fixtures/e2e_prover_test.d.ts +10 -7
  37. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  38. package/dest/fixtures/e2e_prover_test.js +33 -14
  39. package/dest/fixtures/fixtures.d.ts +8 -5
  40. package/dest/fixtures/fixtures.d.ts.map +1 -1
  41. package/dest/fixtures/fixtures.js +12 -4
  42. package/dest/fixtures/ha_setup.d.ts +3 -3
  43. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  44. package/dest/fixtures/ha_setup.js +4 -1
  45. package/dest/fixtures/index.d.ts +2 -1
  46. package/dest/fixtures/index.d.ts.map +1 -1
  47. package/dest/fixtures/index.js +1 -0
  48. package/dest/fixtures/setup.d.ts +35 -9
  49. package/dest/fixtures/setup.d.ts.map +1 -1
  50. package/dest/fixtures/setup.js +175 -142
  51. package/dest/fixtures/setup_p2p_test.d.ts +1 -1
  52. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  53. package/dest/fixtures/setup_p2p_test.js +3 -3
  54. package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
  55. package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
  56. package/dest/fixtures/standard_contracts_genesis.js +25 -0
  57. package/dest/fixtures/timing.d.ts +42 -0
  58. package/dest/fixtures/timing.d.ts.map +1 -0
  59. package/dest/fixtures/timing.js +72 -0
  60. package/dest/fixtures/token_utils.d.ts +22 -4
  61. package/dest/fixtures/token_utils.d.ts.map +1 -1
  62. package/dest/fixtures/token_utils.js +21 -1
  63. package/dest/fixtures/wait_helpers.d.ts +135 -0
  64. package/dest/fixtures/wait_helpers.d.ts.map +1 -0
  65. package/dest/fixtures/wait_helpers.js +154 -0
  66. package/dest/forward-compatibility/wallet_service.js +1 -1
  67. package/dest/multi-node/block-production/setup.d.ts +97 -0
  68. package/dest/multi-node/block-production/setup.d.ts.map +1 -0
  69. package/dest/multi-node/block-production/setup.js +158 -0
  70. package/dest/multi-node/governance/setup.d.ts +67 -0
  71. package/dest/multi-node/governance/setup.d.ts.map +1 -0
  72. package/dest/multi-node/governance/setup.js +126 -0
  73. package/dest/multi-node/multi_node_test_context.d.ts +212 -0
  74. package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
  75. package/dest/multi-node/multi_node_test_context.js +347 -0
  76. package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
  77. package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
  78. package/dest/multi-node/slashing/inactivity_setup.js +111 -0
  79. package/dest/multi-node/slashing/setup.d.ts +167 -0
  80. package/dest/multi-node/slashing/setup.d.ts.map +1 -0
  81. package/dest/multi-node/slashing/setup.js +275 -0
  82. package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +10 -2
  83. package/dest/p2p/p2p_network.d.ts.map +1 -0
  84. package/dest/{e2e_p2p → p2p}/p2p_network.js +36 -9
  85. package/dest/p2p/reqresp/utils.d.ts +19 -0
  86. package/dest/p2p/reqresp/utils.d.ts.map +1 -0
  87. package/dest/{e2e_p2p → p2p}/reqresp/utils.js +4 -15
  88. package/dest/p2p/shared.d.ts +72 -0
  89. package/dest/p2p/shared.d.ts.map +1 -0
  90. package/dest/p2p/shared.js +212 -0
  91. package/dest/shared/cross_chain_test_harness.d.ts +3 -3
  92. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  93. package/dest/shared/cross_chain_test_harness.js +24 -16
  94. package/dest/shared/gas_portal_test_harness.d.ts +1 -1
  95. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  96. package/dest/shared/gas_portal_test_harness.js +8 -5
  97. package/dest/shared/submit-transactions.d.ts +1 -1
  98. package/dest/shared/submit-transactions.d.ts.map +1 -1
  99. package/dest/shared/submit-transactions.js +12 -5
  100. package/dest/shared/timing_env.d.js +5 -0
  101. package/dest/shared/timing_env.js +365 -0
  102. package/dest/shared/wait_for_l1_to_l2_message.js +1 -1
  103. package/dest/simulators/lending_simulator.js +1 -1
  104. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
  105. package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
  106. package/dest/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.js +77 -27
  107. package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
  108. package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
  109. package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
  110. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
  111. package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
  112. package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
  113. package/dest/single-node/fees/fees_test.d.ts +95 -0
  114. package/dest/single-node/fees/fees_test.d.ts.map +1 -0
  115. package/dest/{e2e_fees → single-node/fees}/fees_test.js +124 -46
  116. package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
  117. package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
  118. package/dest/single-node/l1-reorgs/setup.js +57 -0
  119. package/dest/single-node/partial-proofs/setup.d.ts +5 -0
  120. package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
  121. package/dest/single-node/partial-proofs/setup.js +5 -0
  122. package/dest/single-node/proving/setup.d.ts +5 -0
  123. package/dest/single-node/proving/setup.d.ts.map +1 -0
  124. package/dest/single-node/proving/setup.js +5 -0
  125. package/dest/single-node/recovery/setup.d.ts +5 -0
  126. package/dest/single-node/recovery/setup.d.ts.map +1 -0
  127. package/dest/single-node/recovery/setup.js +5 -0
  128. package/dest/single-node/setup.d.ts +49 -0
  129. package/dest/single-node/setup.d.ts.map +1 -0
  130. package/dest/single-node/setup.js +56 -0
  131. package/dest/single-node/single_node_test_context.d.ts +373 -0
  132. package/dest/single-node/single_node_test_context.d.ts.map +1 -0
  133. package/dest/single-node/single_node_test_context.js +845 -0
  134. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  135. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  136. package/dest/spartan/setup_test_wallets.js +18 -8
  137. package/dest/spartan/tx_metrics.d.ts +10 -1
  138. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  139. package/dest/spartan/tx_metrics.js +32 -0
  140. package/dest/test-wallet/test_wallet.d.ts +23 -4
  141. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  142. package/dest/test-wallet/test_wallet.js +20 -4
  143. package/dest/test-wallet/utils.d.ts +36 -1
  144. package/dest/test-wallet/utils.d.ts.map +1 -1
  145. package/dest/test-wallet/utils.js +64 -4
  146. package/dest/test-wallet/wallet_worker_script.js +5 -2
  147. package/dest/test-wallet/worker_wallet.d.ts +5 -5
  148. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  149. package/dest/test-wallet/worker_wallet.js +2 -2
  150. package/dest/test-wallet/worker_wallet_schema.js +2 -1
  151. package/package.json +41 -41
  152. package/src/automine/README.md +60 -0
  153. package/src/automine/automine_test_context.ts +153 -0
  154. package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
  155. package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
  156. package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +19 -39
  157. package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +24 -43
  158. package/src/automine/token/token_test_helpers.ts +138 -0
  159. package/src/bench/client_flows/benchmark.ts +3 -1
  160. package/src/bench/client_flows/client_flows_benchmark.ts +39 -12
  161. package/src/composed/ha/ha_full_setup.ts +466 -0
  162. package/src/fixtures/e2e_prover_test.ts +40 -23
  163. package/src/fixtures/fixtures.ts +14 -4
  164. package/src/fixtures/ha_setup.ts +7 -3
  165. package/src/fixtures/index.ts +1 -0
  166. package/src/fixtures/setup.ts +217 -146
  167. package/src/fixtures/setup_p2p_test.ts +3 -3
  168. package/src/fixtures/standard_contracts_genesis.ts +28 -0
  169. package/src/fixtures/timing.ts +97 -0
  170. package/src/fixtures/token_utils.ts +39 -4
  171. package/src/fixtures/wait_helpers.ts +333 -0
  172. package/src/forward-compatibility/wallet_service.ts +2 -2
  173. package/src/guides/up_quick_start.sh +5 -0
  174. package/src/infra/README.md +12 -0
  175. package/src/multi-node/README.md +96 -0
  176. package/src/multi-node/block-production/setup.ts +272 -0
  177. package/src/multi-node/governance/setup.ts +172 -0
  178. package/src/multi-node/multi_node_test_context.ts +447 -0
  179. package/src/multi-node/slashing/inactivity_setup.ts +139 -0
  180. package/src/multi-node/slashing/setup.ts +433 -0
  181. package/src/p2p/README.md +78 -0
  182. package/src/{e2e_p2p → p2p}/p2p_network.ts +36 -7
  183. package/src/{e2e_p2p → p2p}/reqresp/utils.ts +5 -14
  184. package/src/p2p/shared.ts +329 -0
  185. package/src/shared/cross_chain_test_harness.ts +22 -13
  186. package/src/shared/gas_portal_test_harness.ts +13 -5
  187. package/src/shared/submit-transactions.ts +13 -5
  188. package/src/shared/timing_env.d.mts +39 -0
  189. package/src/shared/timing_env.mjs +363 -0
  190. package/src/shared/wait_for_l1_to_l2_message.ts +1 -1
  191. package/src/simulators/lending_simulator.ts +1 -1
  192. package/src/single-node/README.md +66 -0
  193. package/src/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.ts +110 -39
  194. package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
  195. package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
  196. package/src/{e2e_fees → single-node/fees}/fees_test.ts +141 -48
  197. package/src/single-node/l1-reorgs/setup.ts +93 -0
  198. package/src/single-node/partial-proofs/setup.ts +8 -0
  199. package/src/single-node/proving/setup.ts +15 -0
  200. package/src/single-node/recovery/setup.ts +8 -0
  201. package/src/single-node/setup.ts +63 -0
  202. package/src/single-node/single_node_test_context.ts +1054 -0
  203. package/src/spartan/setup_test_wallets.ts +23 -8
  204. package/src/spartan/tx_metrics.ts +26 -0
  205. package/src/test-wallet/test_wallet.ts +28 -6
  206. package/src/test-wallet/utils.ts +102 -5
  207. package/src/test-wallet/wallet_worker_script.ts +6 -3
  208. package/src/test-wallet/worker_wallet.ts +5 -9
  209. package/src/test-wallet/worker_wallet_schema.ts +1 -1
  210. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -56
  211. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
  212. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -58
  213. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
  214. package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -36
  215. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
  216. package/dest/e2e_deploy_contract/deploy_test.js +0 -42
  217. package/dest/e2e_epochs/epochs_test.d.ts +0 -137
  218. package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
  219. package/dest/e2e_epochs/epochs_test.js +0 -485
  220. package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
  221. package/dest/e2e_fees/fees_test.d.ts +0 -89
  222. package/dest/e2e_fees/fees_test.d.ts.map +0 -1
  223. package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
  224. package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
  225. package/dest/e2e_l1_publisher/write_json.js +0 -56
  226. package/dest/e2e_multi_validator/utils.d.ts +0 -12
  227. package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
  228. package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -22
  229. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
  230. package/dest/e2e_nested_contract/nested_contract_test.js +0 -40
  231. package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
  232. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
  233. package/dest/e2e_p2p/inactivity_slash_test.js +0 -138
  234. package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
  235. package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
  236. package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
  237. package/dest/e2e_p2p/shared.d.ts +0 -75
  238. package/dest/e2e_p2p/shared.d.ts.map +0 -1
  239. package/dest/e2e_p2p/shared.js +0 -217
  240. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
  241. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
  242. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
  243. package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
  244. package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
  245. package/src/e2e_deploy_contract/deploy_test.ts +0 -73
  246. package/src/e2e_epochs/epochs_test.ts +0 -596
  247. package/src/e2e_l1_publisher/write_json.ts +0 -77
  248. package/src/e2e_nested_contract/nested_contract_test.ts +0 -51
  249. package/src/e2e_p2p/inactivity_slash_test.ts +0 -181
  250. package/src/e2e_p2p/shared.ts +0 -332
  251. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
  252. /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
  253. /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
  254. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
  255. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
  256. /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
  257. /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
@@ -1,51 +0,0 @@
1
- import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
- import type { AztecNode } from '@aztec/aztec.js/node';
4
- import type { Wallet } from '@aztec/aztec.js/wallet';
5
- import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
6
- import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
7
-
8
- import { type EndToEndContext, type SetupOptions, setup, teardown as teardownSubsystems } from '../fixtures/setup.js';
9
-
10
- export class NestedContractTest {
11
- context!: EndToEndContext;
12
- logger: Logger;
13
- wallet!: Wallet;
14
- defaultAccountAddress!: AztecAddress;
15
- aztecNode!: AztecNode;
16
-
17
- parentContract!: ParentContract;
18
- childContract!: ChildContract;
19
-
20
- constructor(
21
- testName: string,
22
- private numberOfAccounts = 1,
23
- ) {
24
- this.logger = createLogger(`e2e:e2e_nested_contract:${testName}`);
25
- }
26
-
27
- async setup(opts: Partial<SetupOptions> = {}) {
28
- this.logger.info('Setting up fresh subsystems');
29
- this.context = await setup(this.numberOfAccounts, {
30
- ...opts,
31
- fundSponsoredFPC: true,
32
- });
33
- this.wallet = this.context.wallet;
34
- this.defaultAccountAddress = this.context.accounts[0];
35
- this.aztecNode = this.context.aztecNodeService;
36
- }
37
-
38
- async teardown() {
39
- await teardownSubsystems(this.context);
40
- }
41
-
42
- async applyManual() {
43
- this.logger.info('Deploying parent and child contracts');
44
- ({ contract: this.parentContract } = await ParentContract.deploy(this.wallet).send({
45
- from: this.defaultAccountAddress,
46
- }));
47
- ({ contract: this.childContract } = await ChildContract.deploy(this.wallet).send({
48
- from: this.defaultAccountAddress,
49
- }));
50
- }
51
- }
@@ -1,181 +0,0 @@
1
- import type { AztecNodeService } from '@aztec/aztec-node';
2
- import { EthAddress } from '@aztec/aztec.js/addresses';
3
- import { RollupContract } from '@aztec/ethereum/contracts';
4
- import { EpochNumber } from '@aztec/foundation/branded-types';
5
-
6
- import fs from 'fs';
7
- import 'jest-extended';
8
- import os from 'os';
9
- import path from 'path';
10
-
11
- import { createNodes } from '../fixtures/setup_p2p_test.js';
12
- import { P2PNetworkTest } from './p2p_network.js';
13
-
14
- const NUM_NODES = 6;
15
- const NUM_VALIDATORS = NUM_NODES;
16
- const COMMITTEE_SIZE = NUM_VALIDATORS;
17
- const SLASHING_QUORUM = 3;
18
- const EPOCH_DURATION = 2;
19
- const SLASHING_ROUND_SIZE_IN_EPOCHS = 2;
20
- const BOOT_NODE_UDP_PORT = 4500;
21
- const ETHEREUM_SLOT_DURATION = process.env.CI ? 8 : 4;
22
- const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
23
- const SLASHING_UNIT = BigInt(1e18);
24
- const SLASHING_AMOUNT = SLASHING_UNIT * 3n;
25
-
26
- // How many epochs it may take to set everything up, so we dont slash during this period
27
- const SETUP_EPOCH_DURATION = 8;
28
-
29
- export class P2PInactivityTest {
30
- public nodes!: AztecNodeService[];
31
- public activeNodes!: AztecNodeService[];
32
- public inactiveNodes!: AztecNodeService[];
33
-
34
- public rollup!: RollupContract;
35
- public offlineValidators!: EthAddress[];
36
-
37
- private dataDir: string;
38
- private inactiveNodeCount: number;
39
- private keepInitialNode: boolean;
40
-
41
- constructor(
42
- public readonly test: P2PNetworkTest,
43
- opts: { inactiveNodeCount: number; keepInitialNode?: boolean },
44
- ) {
45
- this.dataDir = fs.mkdtempSync(path.join(os.tmpdir(), test.testName));
46
- this.inactiveNodeCount = opts.inactiveNodeCount;
47
- this.keepInitialNode = opts.keepInitialNode ?? false;
48
- }
49
-
50
- static async create(
51
- testName: string,
52
- opts: { slashInactivityConsecutiveEpochThreshold: number; inactiveNodeCount: number; keepInitialNode?: boolean },
53
- ) {
54
- const test = await P2PNetworkTest.create({
55
- testName,
56
- numberOfNodes: 0,
57
- numberOfValidators: NUM_VALIDATORS,
58
- basePort: BOOT_NODE_UDP_PORT,
59
- startProverNode: true,
60
- initialConfig: {
61
- inboxLag: 2,
62
- anvilSlotsInAnEpoch: 4,
63
- proverNodeConfig: { proverNodeEpochProvingDelayMs: AZTEC_SLOT_DURATION * 1000 },
64
- proverBrokerMaxEpochsToKeepResultsFor: 20,
65
- aztecTargetCommitteeSize: COMMITTEE_SIZE,
66
- aztecSlotDuration: AZTEC_SLOT_DURATION,
67
- ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
68
- aztecProofSubmissionEpochs: 1024, // effectively do not reorg
69
- listenAddress: '127.0.0.1',
70
- minTxsPerBlock: 0,
71
- aztecEpochDuration: EPOCH_DURATION,
72
- sentinelEnabled: true,
73
- slashingQuorum: SLASHING_QUORUM,
74
- slashingRoundSizeInEpochs: SLASHING_ROUND_SIZE_IN_EPOCHS,
75
- slashInactivityTargetPercentage: 0.8,
76
- slashGracePeriodL2Slots: SETUP_EPOCH_DURATION * EPOCH_DURATION, // do not slash during setup
77
- slashAmountSmall: SLASHING_UNIT,
78
- slashAmountMedium: SLASHING_UNIT * 2n,
79
- slashAmountLarge: SLASHING_UNIT * 3n,
80
- ...opts,
81
- },
82
- });
83
- return new P2PInactivityTest(test, opts);
84
- }
85
-
86
- public async setup() {
87
- await this.test.setup();
88
- await this.test.applyBaseSetup();
89
-
90
- // Set slashing penalties for inactivity
91
- const { rollup } = await this.test.getContracts();
92
- const [activationThreshold, ejectionThreshold, localEjectionThreshold] = await Promise.all([
93
- rollup.getActivationThreshold(),
94
- rollup.getEjectionThreshold(),
95
- rollup.getLocalEjectionThreshold(),
96
- ]);
97
- const biggestEjection = ejectionThreshold > localEjectionThreshold ? ejectionThreshold : localEjectionThreshold;
98
- expect(activationThreshold - SLASHING_AMOUNT).toBeLessThan(biggestEjection);
99
- this.test.ctx.aztecNodeConfig.slashInactivityPenalty = SLASHING_AMOUNT;
100
- this.rollup = rollup;
101
-
102
- if (!this.keepInitialNode) {
103
- await this.test.ctx.aztecNodeService.stop();
104
- }
105
-
106
- // Create all active nodes
107
- this.activeNodes = await createNodes(
108
- this.test.ctx.aztecNodeConfig,
109
- this.test.ctx.dateProvider,
110
- this.test.bootstrapNodeEnr,
111
- NUM_NODES - this.inactiveNodeCount - Number(this.keepInitialNode),
112
- BOOT_NODE_UDP_PORT,
113
- this.test.genesis,
114
- this.dataDir,
115
- undefined,
116
- Number(this.keepInitialNode),
117
- );
118
-
119
- // And the ones with an initially disabled sequencer
120
- const inactiveConfig = { ...this.test.ctx.aztecNodeConfig, dontStartSequencer: true };
121
- this.inactiveNodes = await createNodes(
122
- inactiveConfig,
123
- this.test.ctx.dateProvider,
124
- this.test.bootstrapNodeEnr,
125
- this.inactiveNodeCount,
126
- BOOT_NODE_UDP_PORT,
127
- this.test.genesis,
128
- this.dataDir,
129
- undefined,
130
- NUM_NODES - this.inactiveNodeCount,
131
- );
132
-
133
- this.nodes = [
134
- ...(this.keepInitialNode ? [this.test.ctx.aztecNodeService] : []),
135
- ...this.activeNodes,
136
- ...this.inactiveNodes,
137
- ];
138
-
139
- if (this.nodes.length !== NUM_NODES) {
140
- throw new Error(`Expected ${NUM_NODES} nodes but got ${this.nodes.length}`);
141
- }
142
-
143
- this.offlineValidators = this.test.validators
144
- .slice(this.test.validators.length - this.inactiveNodeCount)
145
- .map(a => a.attester);
146
-
147
- this.test.logger.warn(`Setup complete. Offline validators are ${this.offlineValidators.join(', ')}.`, {
148
- validators: this.test.validators,
149
- offlineValidators: this.offlineValidators,
150
- });
151
-
152
- // Wait for P2P mesh to be fully formed before starting slashing period
153
- // This prevents race conditions where validators propose blocks before the network is ready
154
- await this.test.waitForP2PMeshConnectivity(this.nodes, NUM_NODES);
155
-
156
- this.test.logger.warn(`Advancing to epoch ${SETUP_EPOCH_DURATION - 1} (slashing will start after it is completed)`);
157
- await this.test.ctx.cheatCodes.rollup.advanceToEpoch(EpochNumber(SETUP_EPOCH_DURATION - 1));
158
-
159
- return this;
160
- }
161
-
162
- public async teardown() {
163
- await this.test.stopNodes(this.nodes);
164
- await this.test.teardown();
165
- for (let i = 0; i < NUM_NODES; i++) {
166
- fs.rmSync(`${this.dataDir}-${i}`, { recursive: true, force: true, maxRetries: 3 });
167
- }
168
- }
169
-
170
- public get ctx() {
171
- return this.test.ctx;
172
- }
173
-
174
- public get logger() {
175
- return this.test.logger;
176
- }
177
-
178
- public get slashingAmount() {
179
- return SLASHING_AMOUNT;
180
- }
181
- }
@@ -1,332 +0,0 @@
1
- import type { InitialAccountData } from '@aztec/accounts/testing';
2
- import type { AztecNodeService } from '@aztec/aztec-node';
3
- import { AztecAddress } from '@aztec/aztec.js/addresses';
4
- import { NO_WAIT, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
5
- import { Fr } from '@aztec/aztec.js/fields';
6
- import type { Logger } from '@aztec/aztec.js/log';
7
- import { TxHash } from '@aztec/aztec.js/tx';
8
- import type { RollupCheatCodes } from '@aztec/aztec/testing';
9
- import type { EpochCacheInterface } from '@aztec/epoch-cache';
10
- import type { RollupContract, SlashingProposerContract } from '@aztec/ethereum/contracts';
11
- import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
12
- import { timesAsync, unique } from '@aztec/foundation/collection';
13
- import { EthAddress } from '@aztec/foundation/eth-address';
14
- import { retryUntil } from '@aztec/foundation/retry';
15
- import { pluralize } from '@aztec/foundation/string';
16
- import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
17
- import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
18
- import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
19
- import { getRoundForOffense } from '@aztec/slasher';
20
- import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
21
-
22
- import { SchnorrHardcodedKeyAccountContract } from '../fixtures/schnorr_hardcoded_account_contract.js';
23
- import { submitTxsTo } from '../shared/submit-transactions.js';
24
- import { TestWallet } from '../test-wallet/test_wallet.js';
25
- import { type ProvenTx, proveInteraction } from '../test-wallet/utils.js';
26
-
27
- // submits a set of transactions to the provided Private eXecution Environment (PXE)
28
- export const submitComplexTxsTo = async (
29
- logger: Logger,
30
- from: AztecAddress,
31
- spamContract: SpamContract,
32
- numTxs: number,
33
- opts: { callPublic?: boolean } = {},
34
- ) => {
35
- const txs: TxHash[] = [];
36
-
37
- const seed = 1234n;
38
- const spamCount = 15;
39
- for (let i = 0; i < numTxs; i++) {
40
- const method = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic);
41
- const { txHash } = await method.send({ from, wait: NO_WAIT });
42
- logger.info(`Tx sent with hash ${txHash.toString()}`);
43
- txs.push(txHash);
44
- }
45
- return txs;
46
- };
47
-
48
- // creates a wallet and submit a given number of transactions through it.
49
- export const submitTransactions = async (
50
- logger: Logger,
51
- node: AztecNodeService,
52
- numTxs: number,
53
- fundedAccount: InitialAccountData,
54
- ): Promise<TxHash[]> => {
55
- const rpcConfig = getRpcConfig();
56
- rpcConfig.proverEnabled = false;
57
- const wallet = await TestWallet.create(
58
- node,
59
- // Use checkpointed chain tip to avoid anchoring on provisional blocks that the archiver can prune
60
- // when their slot ends without a checkpoint landing on L1.
61
- { ...getPXEConfig(), proverEnabled: false, syncChainTip: 'checkpointed' },
62
- { loggerActorLabel: 'pxe-tx' },
63
- );
64
- const contract = new SchnorrHardcodedKeyAccountContract();
65
- const fundedAccountManager = await wallet.createAccount({
66
- secret: fundedAccount.secret,
67
- salt: fundedAccount.salt,
68
- contract,
69
- });
70
- return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
71
- };
72
-
73
- export async function prepareTransactions(
74
- logger: Logger,
75
- node: AztecNodeService,
76
- numTxs: number,
77
- fundedAccount: InitialAccountData,
78
- ): Promise<ProvenTx[]> {
79
- const rpcConfig = getRpcConfig();
80
- rpcConfig.proverEnabled = false;
81
-
82
- const wallet = await TestWallet.create(
83
- node,
84
- { ...getPXEConfig(), proverEnabled: false, syncChainTip: 'checkpointed' },
85
- { loggerActorLabel: 'pxe-tx' },
86
- );
87
- const accountContract = new SchnorrHardcodedKeyAccountContract();
88
- const fundedAccountManager = await wallet.createAccount({
89
- secret: fundedAccount.secret,
90
- salt: fundedAccount.salt,
91
- contract: accountContract,
92
- });
93
-
94
- const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
95
- salt: Fr.random(),
96
- });
97
- await wallet.registerContract(testContractInstance, TestContractArtifact);
98
- const contract = TestContract.at(testContractInstance.address, wallet);
99
-
100
- return timesAsync(numTxs, async () => {
101
- const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
102
- from: fundedAccountManager.address,
103
- });
104
- logger.info(`Tx prepared with hash ${tx.getTxHash()}`);
105
- return tx;
106
- });
107
- }
108
-
109
- export function awaitProposalExecution(
110
- slashingProposer: SlashingProposerContract,
111
- timeoutSeconds: number,
112
- logger: Logger,
113
- ): Promise<bigint> {
114
- return new Promise<bigint>((resolve, reject) => {
115
- const timeout = setTimeout(() => {
116
- logger.warn(`Timed out waiting for proposal execution`);
117
- reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
118
- }, timeoutSeconds * 1000);
119
-
120
- const unwatch = slashingProposer.listenToRoundExecuted(args => {
121
- logger.warn(`Slash from round ${args.round} executed`);
122
- clearTimeout(timeout);
123
- unwatch();
124
- resolve(args.round);
125
- });
126
- });
127
- }
128
-
129
- export async function awaitCommitteeExists({
130
- rollup,
131
- logger,
132
- }: {
133
- rollup: RollupContract;
134
- logger: Logger;
135
- }): Promise<readonly `0x${string}`[]> {
136
- logger.info(`Waiting for committee to be set`);
137
- let committee: EthAddress[] | undefined;
138
- await retryUntil(
139
- async () => {
140
- committee = await rollup.getCurrentEpochCommittee();
141
- return committee && committee.length > 0;
142
- },
143
- 'non-empty committee',
144
- 60,
145
- );
146
- logger.warn(`Committee has been formed`, { committee: committee!.map(c => c.toString()) });
147
- return committee!.map(c => c.toString() as `0x${string}`);
148
- }
149
-
150
- /**
151
- * Advance epochs until we find one where the target proposer is selected for a slot at least
152
- * `warmupSlots` into the epoch, then stop one epoch before it. This leaves time for the caller to
153
- * start sequencers before warping to the target epoch, avoiding the race where the target epoch
154
- * passes before sequencers are ready.
155
- *
156
- * The first `warmupSlots` slots of the epoch are skipped on purpose. Callers warp to one slot
157
- * before the target epoch and, under proposer pipelining, the proposer begins building one slot
158
- * before its proposal slot. If the proposer were in the first slot of the epoch, that build would
159
- * begin at the exact instant of the warp, leaving the freshly-started sequencer no warm-up margin;
160
- * it then serializes its (often AVM-heavy) proposal past the slot boundary and honest receivers
161
- * reject it as late. Picking a slot at least `warmupSlots` into the epoch guarantees that many full
162
- * slots of wall-clock between the warp and the start of the proposer's build.
163
- *
164
- * Returns the target epoch and the concrete target slot so the caller can warp to it after starting
165
- * sequencers.
166
- */
167
- export async function advanceToEpochBeforeProposer({
168
- epochCache,
169
- cheatCodes,
170
- targetProposer,
171
- logger,
172
- maxAttempts = 20,
173
- warmupSlots = 1,
174
- }: {
175
- epochCache: EpochCacheInterface;
176
- cheatCodes: RollupCheatCodes;
177
- targetProposer: EthAddress;
178
- logger: Logger;
179
- maxAttempts?: number;
180
- warmupSlots?: number;
181
- }): Promise<{ targetEpoch: EpochNumber; targetSlot: SlotNumber }> {
182
- const { epochDuration } = await cheatCodes.getConfig();
183
-
184
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
185
- const currentEpoch = await cheatCodes.getEpoch();
186
- // Check the NEXT epoch's slots so we stay one epoch before the target,
187
- // giving the caller time to start sequencers before the target epoch arrives.
188
- const nextEpoch = Number(currentEpoch) + 1;
189
- const epochStartSlot = nextEpoch * Number(epochDuration);
190
- // Skip the first `warmupSlots` slots so the caller keeps a warm-up margin after warping to one
191
- // slot before the epoch (see the doc comment above).
192
- const startSlot = epochStartSlot + warmupSlots;
193
- const endSlot = epochStartSlot + Number(epochDuration);
194
-
195
- logger.info(
196
- `Checking next epoch ${nextEpoch} (slots ${startSlot}-${endSlot - 1}) for proposer ${targetProposer} (current epoch: ${currentEpoch})`,
197
- );
198
-
199
- for (let s = startSlot; s < endSlot; s++) {
200
- const proposer = await epochCache.getProposerAttesterAddressInSlot(SlotNumber(s));
201
- if (proposer && proposer.equals(targetProposer)) {
202
- logger.warn(
203
- `Found target proposer ${targetProposer} in slot ${s} of epoch ${nextEpoch}. Staying at epoch ${currentEpoch} to allow sequencer startup.`,
204
- );
205
- return { targetEpoch: EpochNumber(nextEpoch), targetSlot: SlotNumber(s) };
206
- }
207
- }
208
-
209
- logger.info(`Target proposer not found in epoch ${nextEpoch}, advancing to next epoch`);
210
- await cheatCodes.advanceToNextEpoch();
211
- }
212
-
213
- throw new Error(`Target proposer ${targetProposer} not found in any slot after ${maxAttempts} epoch attempts`);
214
- }
215
-
216
- export async function awaitOffenseDetected({
217
- logger,
218
- nodeAdmin,
219
- slashingRoundSize,
220
- epochDuration,
221
- waitUntilOffenseCount,
222
- timeoutSeconds = 120,
223
- }: {
224
- nodeAdmin: AztecNodeAdmin;
225
- logger: Logger;
226
- slashingRoundSize: number;
227
- epochDuration: number;
228
- waitUntilOffenseCount?: number;
229
- timeoutSeconds?: number;
230
- }) {
231
- const targetOffenseCount = waitUntilOffenseCount ?? 1;
232
- logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
233
- const offenses = await retryUntil(
234
- async () => {
235
- const offenses = await nodeAdmin.getSlashOffenses('all');
236
- if (offenses.length >= targetOffenseCount) {
237
- return offenses;
238
- }
239
- },
240
- 'non-empty offenses',
241
- timeoutSeconds,
242
- );
243
- logger.info(
244
- `Hit ${offenses.length} offenses on rounds ${unique(offenses.map(o => getRoundForOffense(o, { slashingRoundSize, epochDuration })))}`,
245
- { offenses },
246
- );
247
- return offenses;
248
- }
249
-
250
- /**
251
- * Await the committee to be slashed out of the validator set.
252
- * Currently assumes that the committee is the same size as the validator set.
253
- */
254
- export async function awaitCommitteeKicked({
255
- rollup,
256
- cheatCodes,
257
- committee,
258
- slashingProposer,
259
- slashingRoundSize,
260
- aztecSlotDuration,
261
- aztecEpochDuration,
262
- logger,
263
- offenseEpoch,
264
- }: {
265
- rollup: RollupContract;
266
- cheatCodes: RollupCheatCodes;
267
- committee: readonly `0x${string}`[];
268
- slashingProposer: SlashingProposerContract | undefined;
269
- slashingRoundSize: number;
270
- aztecSlotDuration: number;
271
- aztecEpochDuration: number;
272
- logger: Logger;
273
- offenseEpoch: number;
274
- }) {
275
- if (!slashingProposer) {
276
- throw new Error('No slashing proposer configured. Cannot test slashing.');
277
- }
278
-
279
- await cheatCodes.debugRollup();
280
-
281
- // Use the slash offset to ensure we are in the right epoch for tally
282
- const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
283
- const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
284
- const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
285
- const firstEpochInOffenseRound = offenseEpoch - (offenseEpoch % slashingRoundSizeInEpochs);
286
- const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
287
- logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
288
- await cheatCodes.advanceToEpoch(EpochNumber(targetEpoch), { offset: -aztecSlotDuration / 2 });
289
-
290
- const attestersPre = await rollup.getAttesters();
291
- expect(attestersPre.length).toBe(committee.length);
292
-
293
- for (const attester of attestersPre) {
294
- const attesterInfo = await rollup.getAttesterView(attester);
295
- expect(attesterInfo.status).toEqual(1); // Validating
296
- }
297
-
298
- // Allow up to four round-lengths so that under proposer pipelining, where individual rounds
299
- // sometimes fail to gather quorum because parts of the committee miss votes due to chain-state
300
- // races, we still see a later round execute the slash.
301
- const timeout = slashingRoundSize * 4 * aztecSlotDuration + 30;
302
- logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
303
- await awaitProposalExecution(slashingProposer, timeout, logger);
304
-
305
- // The attesters should still form the committee but they should be reduced to the "living" status
306
- await cheatCodes.debugRollup();
307
- const committeePostSlashing = await rollup.getCurrentEpochCommittee();
308
- expect(committeePostSlashing?.length).toBe(attestersPre.length);
309
-
310
- const attestersPostSlashing = await rollup.getAttesters();
311
- expect(attestersPostSlashing.length).toBe(0);
312
-
313
- for (const attester of attestersPre) {
314
- const attesterInfo = await rollup.getAttesterView(attester);
315
- expect(attesterInfo.status).toEqual(2); // Living
316
- }
317
-
318
- logger.info(`Advancing to check current committee`);
319
- await cheatCodes.debugRollup();
320
- await cheatCodes.advanceToEpoch(
321
- EpochNumber((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochsForValidatorSet()) + 1),
322
- );
323
- await cheatCodes.debugRollup();
324
-
325
- const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
326
- // The committee should be undefined, since the validator set is empty
327
- // and the tests currently using this helper always set a target committee size.
328
- expect(committeeNextEpoch).toBeUndefined();
329
-
330
- const attestersNextEpoch = await rollup.getAttesters();
331
- expect(attestersNextEpoch.length).toBe(0);
332
- }