@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.
- package/README.md +215 -27
- package/dest/automine/automine_test_context.d.ts +85 -0
- package/dest/automine/automine_test_context.d.ts.map +1 -0
- package/dest/automine/automine_test_context.js +98 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
- package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
- package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +17 -24
- package/dest/automine/token/token_contract_test.d.ts +40 -0
- package/dest/automine/token/token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +22 -28
- package/dest/automine/token/token_test_helpers.d.ts +73 -0
- package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
- package/dest/automine/token/token_test_helpers.js +97 -0
- package/dest/bench/client_flows/benchmark.d.ts +1 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +3 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +4 -4
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +25 -10
- package/dest/bench/utils.d.ts +1 -1
- package/dest/composed/ha/ha_full_setup.d.ts +77 -0
- package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
- package/dest/composed/ha/ha_full_setup.js +383 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.d.ts +10 -7
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +33 -14
- package/dest/fixtures/fixtures.d.ts +8 -5
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +12 -4
- package/dest/fixtures/ha_setup.d.ts +3 -3
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +4 -1
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +35 -9
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +175 -142
- package/dest/fixtures/setup_p2p_test.d.ts +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +3 -3
- package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
- package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
- package/dest/fixtures/standard_contracts_genesis.js +25 -0
- package/dest/fixtures/timing.d.ts +42 -0
- package/dest/fixtures/timing.d.ts.map +1 -0
- package/dest/fixtures/timing.js +72 -0
- package/dest/fixtures/token_utils.d.ts +22 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +21 -1
- package/dest/fixtures/wait_helpers.d.ts +135 -0
- package/dest/fixtures/wait_helpers.d.ts.map +1 -0
- package/dest/fixtures/wait_helpers.js +154 -0
- package/dest/forward-compatibility/wallet_service.js +1 -1
- package/dest/multi-node/block-production/setup.d.ts +97 -0
- package/dest/multi-node/block-production/setup.d.ts.map +1 -0
- package/dest/multi-node/block-production/setup.js +158 -0
- package/dest/multi-node/governance/setup.d.ts +67 -0
- package/dest/multi-node/governance/setup.d.ts.map +1 -0
- package/dest/multi-node/governance/setup.js +126 -0
- package/dest/multi-node/multi_node_test_context.d.ts +212 -0
- package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
- package/dest/multi-node/multi_node_test_context.js +347 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/inactivity_setup.js +111 -0
- package/dest/multi-node/slashing/setup.d.ts +167 -0
- package/dest/multi-node/slashing/setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/setup.js +275 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +10 -2
- package/dest/p2p/p2p_network.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.js +36 -9
- package/dest/p2p/reqresp/utils.d.ts +19 -0
- package/dest/p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/reqresp/utils.js +4 -15
- package/dest/p2p/shared.d.ts +72 -0
- package/dest/p2p/shared.d.ts.map +1 -0
- package/dest/p2p/shared.js +212 -0
- package/dest/shared/cross_chain_test_harness.d.ts +3 -3
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +24 -16
- package/dest/shared/gas_portal_test_harness.d.ts +1 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +8 -5
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +12 -5
- package/dest/shared/timing_env.d.js +5 -0
- package/dest/shared/timing_env.js +365 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +1 -1
- package/dest/simulators/lending_simulator.js +1 -1
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.js +77 -27
- package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
- package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
- package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
- package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +17 -4
- package/dest/single-node/fees/fees_test.d.ts +95 -0
- package/dest/single-node/fees/fees_test.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/fees_test.js +124 -46
- package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
- package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
- package/dest/single-node/l1-reorgs/setup.js +57 -0
- package/dest/single-node/partial-proofs/setup.d.ts +5 -0
- package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
- package/dest/single-node/partial-proofs/setup.js +5 -0
- package/dest/single-node/proving/setup.d.ts +5 -0
- package/dest/single-node/proving/setup.d.ts.map +1 -0
- package/dest/single-node/proving/setup.js +5 -0
- package/dest/single-node/recovery/setup.d.ts +5 -0
- package/dest/single-node/recovery/setup.d.ts.map +1 -0
- package/dest/single-node/recovery/setup.js +5 -0
- package/dest/single-node/setup.d.ts +49 -0
- package/dest/single-node/setup.d.ts.map +1 -0
- package/dest/single-node/setup.js +56 -0
- package/dest/single-node/single_node_test_context.d.ts +373 -0
- package/dest/single-node/single_node_test_context.d.ts.map +1 -0
- package/dest/single-node/single_node_test_context.js +845 -0
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +18 -8
- package/dest/spartan/tx_metrics.d.ts +10 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +32 -0
- package/dest/test-wallet/test_wallet.d.ts +23 -4
- package/dest/test-wallet/test_wallet.d.ts.map +1 -1
- package/dest/test-wallet/test_wallet.js +20 -4
- package/dest/test-wallet/utils.d.ts +36 -1
- package/dest/test-wallet/utils.d.ts.map +1 -1
- package/dest/test-wallet/utils.js +64 -4
- package/dest/test-wallet/wallet_worker_script.js +5 -2
- package/dest/test-wallet/worker_wallet.d.ts +5 -5
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet.js +2 -2
- package/dest/test-wallet/worker_wallet_schema.js +2 -1
- package/package.json +41 -41
- package/src/automine/README.md +60 -0
- package/src/automine/automine_test_context.ts +153 -0
- package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
- package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
- package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +19 -39
- package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +24 -43
- package/src/automine/token/token_test_helpers.ts +138 -0
- package/src/bench/client_flows/benchmark.ts +3 -1
- package/src/bench/client_flows/client_flows_benchmark.ts +39 -12
- package/src/composed/ha/ha_full_setup.ts +466 -0
- package/src/fixtures/e2e_prover_test.ts +40 -23
- package/src/fixtures/fixtures.ts +14 -4
- package/src/fixtures/ha_setup.ts +7 -3
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +217 -146
- package/src/fixtures/setup_p2p_test.ts +3 -3
- package/src/fixtures/standard_contracts_genesis.ts +28 -0
- package/src/fixtures/timing.ts +97 -0
- package/src/fixtures/token_utils.ts +39 -4
- package/src/fixtures/wait_helpers.ts +333 -0
- package/src/forward-compatibility/wallet_service.ts +2 -2
- package/src/guides/up_quick_start.sh +5 -0
- package/src/infra/README.md +12 -0
- package/src/multi-node/README.md +96 -0
- package/src/multi-node/block-production/setup.ts +272 -0
- package/src/multi-node/governance/setup.ts +172 -0
- package/src/multi-node/multi_node_test_context.ts +447 -0
- package/src/multi-node/slashing/inactivity_setup.ts +139 -0
- package/src/multi-node/slashing/setup.ts +433 -0
- package/src/p2p/README.md +78 -0
- package/src/{e2e_p2p → p2p}/p2p_network.ts +36 -7
- package/src/{e2e_p2p → p2p}/reqresp/utils.ts +5 -14
- package/src/p2p/shared.ts +329 -0
- package/src/shared/cross_chain_test_harness.ts +22 -13
- package/src/shared/gas_portal_test_harness.ts +13 -5
- package/src/shared/submit-transactions.ts +13 -5
- package/src/shared/timing_env.d.mts +39 -0
- package/src/shared/timing_env.mjs +363 -0
- package/src/shared/wait_for_l1_to_l2_message.ts +1 -1
- package/src/simulators/lending_simulator.ts +1 -1
- package/src/single-node/README.md +66 -0
- package/src/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.ts +110 -39
- package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
- package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +19 -5
- package/src/{e2e_fees → single-node/fees}/fees_test.ts +141 -48
- package/src/single-node/l1-reorgs/setup.ts +93 -0
- package/src/single-node/partial-proofs/setup.ts +8 -0
- package/src/single-node/proving/setup.ts +15 -0
- package/src/single-node/recovery/setup.ts +8 -0
- package/src/single-node/setup.ts +63 -0
- package/src/single-node/single_node_test_context.ts +1054 -0
- package/src/spartan/setup_test_wallets.ts +23 -8
- package/src/spartan/tx_metrics.ts +26 -0
- package/src/test-wallet/test_wallet.ts +28 -6
- package/src/test-wallet/utils.ts +102 -5
- package/src/test-wallet/wallet_worker_script.ts +6 -3
- package/src/test-wallet/worker_wallet.ts +5 -9
- package/src/test-wallet/worker_wallet_schema.ts +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -56
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -58
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -36
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.js +0 -42
- package/dest/e2e_epochs/epochs_test.d.ts +0 -137
- package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
- package/dest/e2e_epochs/epochs_test.js +0 -485
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
- package/dest/e2e_fees/fees_test.d.ts +0 -89
- package/dest/e2e_fees/fees_test.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
- package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.js +0 -56
- package/dest/e2e_multi_validator/utils.d.ts +0 -12
- package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -22
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +0 -40
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +0 -138
- package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.d.ts +0 -75
- package/dest/e2e_p2p/shared.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.js +0 -217
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
- package/src/e2e_deploy_contract/deploy_test.ts +0 -73
- package/src/e2e_epochs/epochs_test.ts +0 -596
- package/src/e2e_l1_publisher/write_json.ts +0 -77
- package/src/e2e_nested_contract/nested_contract_test.ts +0 -51
- package/src/e2e_p2p/inactivity_slash_test.ts +0 -181
- package/src/e2e_p2p/shared.ts +0 -332
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
- /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
- /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
|
@@ -13,6 +13,7 @@ import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
|
|
|
13
13
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
14
14
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
15
15
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
16
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
16
17
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
18
|
import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
18
19
|
import { TestERC20Bytecode } from '@aztec/l1-artifacts/TestERC20Bytecode';
|
|
@@ -20,15 +21,20 @@ import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
|
20
21
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
21
22
|
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
22
23
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
23
|
-
import {
|
|
24
|
+
import { TestTokenContract as BananaCoin, TestTokenContract } from '@aztec/noir-test-contracts.js/TestToken';
|
|
24
25
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
25
26
|
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
26
27
|
import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
|
|
27
28
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
28
29
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
29
|
-
import {
|
|
30
|
+
import { AppTaggingSecretKind } from '@aztec/stdlib/logs';
|
|
30
31
|
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
AUTOMINE_E2E_OPTS,
|
|
34
|
+
L1_DIRECT_WRITE_ACCOUNT_INDEX,
|
|
35
|
+
MNEMONIC,
|
|
36
|
+
getPaddedMaxFeesPerGas,
|
|
37
|
+
} from '../../fixtures/fixtures.js';
|
|
32
38
|
import { type EndToEndContext, type SetupOptions, setup, teardown } from '../../fixtures/setup.js';
|
|
33
39
|
import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
|
|
34
40
|
import { setupSponsoredFPC } from '../../fixtures/utils.js';
|
|
@@ -71,13 +77,13 @@ export class ClientFlowsBenchmark {
|
|
|
71
77
|
public bananaFPC!: FPCContract;
|
|
72
78
|
public bananaFPCInstance!: ContractInstanceWithAddress;
|
|
73
79
|
// Random asset we want to trade
|
|
74
|
-
public candyBarCoin!:
|
|
80
|
+
public candyBarCoin!: TestTokenContract;
|
|
75
81
|
public candyBarCoinInstance!: ContractInstanceWithAddress;
|
|
76
82
|
// AMM contract
|
|
77
83
|
public amm!: AMMContract;
|
|
78
84
|
public ammInstance!: ContractInstanceWithAddress;
|
|
79
85
|
// Liquidity token for AMM
|
|
80
|
-
public liquidityToken!:
|
|
86
|
+
public liquidityToken!: TestTokenContract;
|
|
81
87
|
public liquidityTokenInstance!: ContractInstanceWithAddress;
|
|
82
88
|
// Sponsored FPC contract
|
|
83
89
|
public sponsoredFPC!: SponsoredFPCContract;
|
|
@@ -134,7 +140,8 @@ export class ClientFlowsBenchmark {
|
|
|
134
140
|
async setup() {
|
|
135
141
|
this.logger.info('Setting up subsystems from fresh');
|
|
136
142
|
// Token allowlist entries are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
|
|
137
|
-
|
|
143
|
+
// BananaCoin is the codegen'd TestToken here, so the allowlist must key on its class, not canonical Token's.
|
|
144
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions(BananaCoin.artifact);
|
|
138
145
|
this.context = await setup(2, {
|
|
139
146
|
...this.setupOptions,
|
|
140
147
|
fundSponsoredFPC: true,
|
|
@@ -185,7 +192,7 @@ export class ClientFlowsBenchmark {
|
|
|
185
192
|
|
|
186
193
|
let benchysPrivateSigningKey;
|
|
187
194
|
if (type === 'schnorr') {
|
|
188
|
-
benchysPrivateSigningKey =
|
|
195
|
+
benchysPrivateSigningKey = GrumpkinScalar.random();
|
|
189
196
|
return wallet.createSchnorrAccount(benchysSecret, salt, benchysPrivateSigningKey);
|
|
190
197
|
} else if (type === 'ecdsar1') {
|
|
191
198
|
benchysPrivateSigningKey = randomBytes(32);
|
|
@@ -225,6 +232,19 @@ export class ClientFlowsBenchmark {
|
|
|
225
232
|
loggers: {
|
|
226
233
|
prover: this.proxyLogger.createLogger('pxe:bb:wasm:bundle:proxied'),
|
|
227
234
|
},
|
|
235
|
+
// The benchmark measures steady-state app cost, not first-send discovery cost. Reproduce the pre-handshake-default
|
|
236
|
+
// behavior of unconstrained delivery: derive the tagging secret from the (sender, recipient) key pair via ECDH
|
|
237
|
+
// instead of taking the current default (a non-interactive handshake, which injects two extra private app
|
|
238
|
+
// executions and a nullifier per cold chain). Constrained delivery is unaffected: the Noir circuit rejects
|
|
239
|
+
// address-derived for constrained, so the hook falls through to a handshake there.
|
|
240
|
+
hooks: {
|
|
241
|
+
resolveTaggingSecretStrategy: ({ deliveryMode }) =>
|
|
242
|
+
Promise.resolve(
|
|
243
|
+
deliveryMode === AppTaggingSecretKind.UNCONSTRAINED
|
|
244
|
+
? { type: 'address-derived' }
|
|
245
|
+
: { type: 'non-interactive-handshake' },
|
|
246
|
+
),
|
|
247
|
+
},
|
|
228
248
|
});
|
|
229
249
|
}
|
|
230
250
|
|
|
@@ -235,7 +255,15 @@ export class ClientFlowsBenchmark {
|
|
|
235
255
|
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
236
256
|
aztecNode: this.context.aztecNodeService,
|
|
237
257
|
aztecNodeAdmin: this.context.aztecNodeService,
|
|
238
|
-
|
|
258
|
+
// Bridge from a dedicated L1 account so its direct writes don't race the sequencer publisher's
|
|
259
|
+
// txs on the deployer account (see L1_DIRECT_WRITE_ACCOUNT_INDEX).
|
|
260
|
+
l1Client: createExtendedL1Client(
|
|
261
|
+
this.context.config.l1RpcUrls,
|
|
262
|
+
MNEMONIC,
|
|
263
|
+
undefined,
|
|
264
|
+
undefined,
|
|
265
|
+
L1_DIRECT_WRITE_ACCOUNT_INDEX,
|
|
266
|
+
),
|
|
239
267
|
wallet: this.adminWallet,
|
|
240
268
|
logger: this.logger,
|
|
241
269
|
});
|
|
@@ -259,7 +287,7 @@ export class ClientFlowsBenchmark {
|
|
|
259
287
|
|
|
260
288
|
async applyDeployCandyBarToken() {
|
|
261
289
|
this.logger.info('Applying candy bar token deployment');
|
|
262
|
-
const { contract: candyBarCoin, instance: candyBarCoinInstance } = await
|
|
290
|
+
const { contract: candyBarCoin, instance: candyBarCoinInstance } = await TestTokenContract.deploy(
|
|
263
291
|
this.adminWallet,
|
|
264
292
|
this.adminAddress,
|
|
265
293
|
'CBC',
|
|
@@ -329,7 +357,6 @@ export class ClientFlowsBenchmark {
|
|
|
329
357
|
|
|
330
358
|
public async createAndFundBenchmarkingAccountOnUserWallet(accountType: AccountType) {
|
|
331
359
|
const benchysAccountManager = await this.createBenchmarkingAccountManager(this.adminWallet, accountType);
|
|
332
|
-
const benchysAccount = await benchysAccountManager.getAccount();
|
|
333
360
|
const benchysAddress = benchysAccountManager.address;
|
|
334
361
|
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(benchysAddress);
|
|
335
362
|
const behchysDeployMethod = await benchysAccountManager.getDeployMethod();
|
|
@@ -339,7 +366,7 @@ export class ClientFlowsBenchmark {
|
|
|
339
366
|
});
|
|
340
367
|
// Register benchy on the user's Wallet, where we're going to be interacting from
|
|
341
368
|
const accountManager = await this.userWallet.createAccount({
|
|
342
|
-
secret:
|
|
369
|
+
secret: benchysAccountManager.getSecretKey(),
|
|
343
370
|
salt: new Fr(benchysAccountManager.getInstance().salt),
|
|
344
371
|
contract: benchysAccountManager.getAccountContract(),
|
|
345
372
|
});
|
|
@@ -348,7 +375,7 @@ export class ClientFlowsBenchmark {
|
|
|
348
375
|
|
|
349
376
|
public async applyDeployAmm() {
|
|
350
377
|
this.logger.info('Applying AMM deployment');
|
|
351
|
-
const { contract: liquidityToken, instance: liquidityTokenInstance } = await
|
|
378
|
+
const { contract: liquidityToken, instance: liquidityTokenInstance } = await TestTokenContract.deploy(
|
|
352
379
|
this.adminWallet,
|
|
353
380
|
this.adminAddress,
|
|
354
381
|
'LPT',
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared setup for the docker-compose HA full suite.
|
|
3
|
+
*
|
|
4
|
+
* Stands up the complete HA cluster used by `e2e_ha_full.parallel.test.ts` and
|
|
5
|
+
* `e2e_ha_distribute_work.test.ts`: a bootstrap RPC/P2P node plus NODE_COUNT in-proc
|
|
6
|
+
* `AztecNodeService` HA peers that share one PostgreSQL slashing-protection DB and a Web3Signer keystore.
|
|
7
|
+
* Requires the docker-compose HA suite (run_test.sh ha): live Postgres (DATABASE_URL) and Web3Signer
|
|
8
|
+
* sidecar.
|
|
9
|
+
*
|
|
10
|
+
* The suite is split across two files because the "distribute work" test kills nodes as it runs, leaving
|
|
11
|
+
* the cluster unusable; giving it its own file (its own cluster) removes the previous "must run last"
|
|
12
|
+
* ordering contract without changing what any test asserts.
|
|
13
|
+
*/
|
|
14
|
+
import { type AztecNodeConfig, AztecNodeService, createAztecNodeService } from '@aztec/aztec-node';
|
|
15
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
16
|
+
import { NO_WAIT, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
17
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
18
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
19
|
+
import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
|
|
20
|
+
import { GovernanceProposerContract } from '@aztec/ethereum/contracts';
|
|
21
|
+
import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
22
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
23
|
+
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
24
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
25
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
26
|
+
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
|
|
27
|
+
import { TopicType } from '@aztec/stdlib/p2p';
|
|
28
|
+
import { TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
29
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
30
|
+
|
|
31
|
+
import getPort, { portNumbers } from 'get-port';
|
|
32
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
33
|
+
import { tmpdir } from 'node:os';
|
|
34
|
+
import { join } from 'node:path';
|
|
35
|
+
import { Pool } from 'pg';
|
|
36
|
+
|
|
37
|
+
import { PIPELINING_SETUP_OPTS } from '../../fixtures/fixtures.js';
|
|
38
|
+
import {
|
|
39
|
+
type HADatabaseConfig,
|
|
40
|
+
cleanupHADatabase,
|
|
41
|
+
createHADatabaseConfig,
|
|
42
|
+
createInitialValidatorsFromPrivateKeys,
|
|
43
|
+
getAddressesFromPrivateKeys,
|
|
44
|
+
setupHADatabase,
|
|
45
|
+
} from '../../fixtures/ha_setup.js';
|
|
46
|
+
import { getPrivateKeyFromIndex, setup } from '../../fixtures/utils.js';
|
|
47
|
+
import {
|
|
48
|
+
createWeb3SignerKeystore,
|
|
49
|
+
getWeb3SignerTestKeystoreDir,
|
|
50
|
+
getWeb3SignerUrl,
|
|
51
|
+
refreshWeb3Signer,
|
|
52
|
+
} from '../../fixtures/web3signer.js';
|
|
53
|
+
import type { TestWallet } from '../../test-wallet/test_wallet.js';
|
|
54
|
+
import { proveInteraction } from '../../test-wallet/utils.js';
|
|
55
|
+
|
|
56
|
+
export const NODE_COUNT = 5;
|
|
57
|
+
export const VALIDATOR_COUNT = 4;
|
|
58
|
+
export const COMMITTEE_SIZE = 4;
|
|
59
|
+
|
|
60
|
+
// Allocate p2p listen ports from above the OS ephemeral range (Linux default tops out at 60999) so they
|
|
61
|
+
// never collide with an ephemeral socket the OS may already have handed out -- e.g. the in-process prover
|
|
62
|
+
// node (which listens on p2pPort 0) or any outbound connection. The previous fixed 4040x ports sat inside
|
|
63
|
+
// the ephemeral range, so an ephemeral socket occasionally held a node's port at bind time, surfacing as
|
|
64
|
+
// libp2p ERR_NO_VALID_ADDRESSES and aborting beforeAll. get-port also locks each returned port briefly, so
|
|
65
|
+
// concurrent calls within this process never hand back the same one.
|
|
66
|
+
const getFreeP2PPort = () => getPort({ port: portNumbers(61000, 65535) });
|
|
67
|
+
|
|
68
|
+
export async function registerTestContract(wallet: TestWallet): Promise<TestContract> {
|
|
69
|
+
const instance = await getContractInstanceFromInstantiationParams(TestContract.artifact, {
|
|
70
|
+
constructorArgs: [],
|
|
71
|
+
constructorArtifact: undefined,
|
|
72
|
+
salt: Fr.ZERO,
|
|
73
|
+
publicKeys: undefined,
|
|
74
|
+
deployer: undefined,
|
|
75
|
+
});
|
|
76
|
+
await wallet.registerContract(instance, TestContract.artifact);
|
|
77
|
+
return TestContract.at(instance.address, wallet);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function submitTriggerTx(
|
|
81
|
+
wallet: TestWallet,
|
|
82
|
+
testContract: TestContract,
|
|
83
|
+
from: AztecAddress,
|
|
84
|
+
): Promise<TxHash> {
|
|
85
|
+
const tx = await proveInteraction(wallet, testContract.methods.emit_nullifier(Fr.random()), { from });
|
|
86
|
+
return await tx.send({ wait: NO_WAIT });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function waitForTriggerTx(node: AztecNode, txHash: TxHash): Promise<TxReceipt> {
|
|
90
|
+
const receipt = await waitForTx(node, txHash, { waitForStatus: TxStatus.CHECKPOINTED });
|
|
91
|
+
if (!receipt.blockNumber) {
|
|
92
|
+
throw new Error('Trigger tx was checkpointed without a block number');
|
|
93
|
+
}
|
|
94
|
+
return receipt;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Owns the full HA cluster lifecycle and the shared helpers the two HA test files drive it with. Each
|
|
99
|
+
* test file constructs one instance and calls {@link setup} in `beforeAll` / {@link teardown} in
|
|
100
|
+
* `afterAll`; state fields are populated by {@link setup} and read directly by the tests.
|
|
101
|
+
*/
|
|
102
|
+
export class HaFullTestContext {
|
|
103
|
+
logger!: Logger;
|
|
104
|
+
wallet!: TestWallet;
|
|
105
|
+
ownerAddress!: AztecAddress;
|
|
106
|
+
testContract!: TestContract;
|
|
107
|
+
aztecNode!: AztecNode;
|
|
108
|
+
config!: AztecNodeConfig;
|
|
109
|
+
accounts!: AztecAddress[];
|
|
110
|
+
dateProvider!: TestDateProvider;
|
|
111
|
+
genesis: GenesisData | undefined;
|
|
112
|
+
|
|
113
|
+
haNodePools!: Pool[]; // Database pools for HA nodes (for cleanup)
|
|
114
|
+
haNodeServices!: AztecNodeService[]; // All N HA peer nodes
|
|
115
|
+
haKeystoreDirs!: string[];
|
|
116
|
+
mainPool!: Pool;
|
|
117
|
+
databaseConfig!: HADatabaseConfig;
|
|
118
|
+
attesterPrivateKeys!: `0x${string}`[];
|
|
119
|
+
attesterAddresses!: string[];
|
|
120
|
+
publisherPrivateKeys!: `0x${string}`[];
|
|
121
|
+
publisherAddresses!: string[];
|
|
122
|
+
web3SignerUrl!: string;
|
|
123
|
+
deployL1ContractsValues!: DeployAztecL1ContractsReturnType;
|
|
124
|
+
governanceProposer!: GovernanceProposerContract;
|
|
125
|
+
/** Per-node initial keystore JSON (all 4 attesters, node's own publisher) for restore after reload test */
|
|
126
|
+
initialKeystoreJsons!: string[];
|
|
127
|
+
|
|
128
|
+
private teardownBootstrap: () => Promise<void> = async () => {};
|
|
129
|
+
private haSequencersStarted = false;
|
|
130
|
+
private readonly stoppedHANodeIndexes = new Set<number>();
|
|
131
|
+
|
|
132
|
+
getSignatureContext = () => ({
|
|
133
|
+
chainId: this.config.l1ChainId,
|
|
134
|
+
rollupAddress: this.deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
startHASequencers = async () => {
|
|
138
|
+
if (this.haSequencersStarted) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
await Promise.all(
|
|
143
|
+
this.haNodeServices.map(async (service, i) => {
|
|
144
|
+
this.logger.info(`Starting HA peer node ${i} sequencer`);
|
|
145
|
+
await service.getSequencer()?.start();
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
this.haSequencersStarted = true;
|
|
149
|
+
this.logger.info('All HA peer sequencers started');
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
sendTriggerTx = async (): Promise<TxReceipt> => {
|
|
153
|
+
await this.startHASequencers();
|
|
154
|
+
const txHash = await submitTriggerTx(this.wallet, this.testContract, this.ownerAddress);
|
|
155
|
+
return await waitForTriggerTx(this.aztecNode, txHash);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
stopHANode = async (nodeIndex: number) => {
|
|
159
|
+
if (this.stoppedHANodeIndexes.has(nodeIndex)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.logger.info(`Stopping HA peer node ${nodeIndex}`);
|
|
164
|
+
await this.haNodeServices[nodeIndex].stop();
|
|
165
|
+
this.stoppedHANodeIndexes.add(nodeIndex);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
async setup(): Promise<void> {
|
|
169
|
+
// Check required environment variables
|
|
170
|
+
if (!process.env.DATABASE_URL) {
|
|
171
|
+
throw new Error('DATABASE_URL environment variable must be set for HA tests');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
this.web3SignerUrl = getWeb3SignerUrl();
|
|
175
|
+
if (!this.web3SignerUrl) {
|
|
176
|
+
throw new Error('WEB3_SIGNER_URL environment variable must be set for HA tests');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Setup database configuration
|
|
180
|
+
this.databaseConfig = createHADatabaseConfig('ha-full-test');
|
|
181
|
+
|
|
182
|
+
// Connect to database (migrations already run by docker-compose entrypoint)
|
|
183
|
+
this.mainPool = setupHADatabase(this.databaseConfig.databaseUrl.getValue()!);
|
|
184
|
+
|
|
185
|
+
this.attesterPrivateKeys = Array.from(
|
|
186
|
+
{ length: VALIDATOR_COUNT },
|
|
187
|
+
(_, i) => `0x${getPrivateKeyFromIndex(i)!.toString('hex')}` as `0x${string}`,
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
this.publisherPrivateKeys = Array.from(
|
|
191
|
+
{ length: NODE_COUNT },
|
|
192
|
+
(_, i) => `0x${getPrivateKeyFromIndex(i + VALIDATOR_COUNT)!.toString('hex')}` as `0x${string}`,
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const web3SignerDir = getWeb3SignerTestKeystoreDir();
|
|
196
|
+
const allKeys = [...this.attesterPrivateKeys, ...this.publisherPrivateKeys];
|
|
197
|
+
for (const key of allKeys) {
|
|
198
|
+
await createWeb3SignerKeystore(web3SignerDir, key);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.attesterAddresses = getAddressesFromPrivateKeys(this.attesterPrivateKeys);
|
|
202
|
+
|
|
203
|
+
this.publisherAddresses = getAddressesFromPrivateKeys(this.publisherPrivateKeys);
|
|
204
|
+
|
|
205
|
+
// Refresh Web3Signer to load all the keys (attesters + publishers)
|
|
206
|
+
await refreshWeb3Signer(this.web3SignerUrl, ...this.attesterAddresses, ...this.publisherAddresses);
|
|
207
|
+
|
|
208
|
+
// Create database pools for HA nodes
|
|
209
|
+
this.haNodePools = Array.from({ length: NODE_COUNT }, () => {
|
|
210
|
+
const pool = new Pool({ connectionString: this.databaseConfig.databaseUrl.getValue()! });
|
|
211
|
+
// pg-pool re-emits idle-client errors on the pool; with no listener the emit throws - in production this
|
|
212
|
+
// crashes the validator process.
|
|
213
|
+
pool.on('error', (err: Error) => this.logger?.warn(`HA node pool error: ${err.message}`));
|
|
214
|
+
return pool;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const initialValidators = createInitialValidatorsFromPrivateKeys(this.attesterPrivateKeys);
|
|
218
|
+
|
|
219
|
+
const bootstrapP2PPort = await getFreeP2PPort();
|
|
220
|
+
|
|
221
|
+
({
|
|
222
|
+
teardown: this.teardownBootstrap,
|
|
223
|
+
logger: this.logger,
|
|
224
|
+
wallet: this.wallet,
|
|
225
|
+
aztecNode: this.aztecNode,
|
|
226
|
+
config: this.config,
|
|
227
|
+
accounts: this.accounts,
|
|
228
|
+
dateProvider: this.dateProvider,
|
|
229
|
+
deployL1ContractsValues: this.deployL1ContractsValues,
|
|
230
|
+
genesis: this.genesis,
|
|
231
|
+
} = await setup(
|
|
232
|
+
// A single default initializerless account, created/funded/registered by setup with no on-chain
|
|
233
|
+
// deploy tx -- the bootstrap node can't build blocks (disableValidator), so the owner must be usable
|
|
234
|
+
// without one.
|
|
235
|
+
1,
|
|
236
|
+
{
|
|
237
|
+
...PIPELINING_SETUP_OPTS,
|
|
238
|
+
automineL1Setup: true,
|
|
239
|
+
initialValidators,
|
|
240
|
+
sequencerPublisherPrivateKeys: [new SecretValue(this.publisherPrivateKeys[0])],
|
|
241
|
+
aztecTargetCommitteeSize: COMMITTEE_SIZE,
|
|
242
|
+
// The full HA docker/Web3Signer stack can still be joining and syncing after the shared
|
|
243
|
+
// 12s pipelining preset's 2.5s start window has closed. Keep real sequencing, but give
|
|
244
|
+
// HA validators enough time to pass the enforced build-start gate in CI.
|
|
245
|
+
aztecSlotDuration: 16,
|
|
246
|
+
// This suite validates HA coordination on tx-bearing checkpoints. Requiring one tx avoids a startup empty
|
|
247
|
+
// checkpoint from occupying the shared HA publisher while the trigger tx is still being prepared.
|
|
248
|
+
minTxsPerBlock: 1,
|
|
249
|
+
archiverPollingIntervalMS: 200,
|
|
250
|
+
sequencerPollingIntervalMS: 200,
|
|
251
|
+
worldStateBlockCheckIntervalMS: 200,
|
|
252
|
+
blockCheckIntervalMS: 200,
|
|
253
|
+
startProverNode: true,
|
|
254
|
+
// The bootstrap node is only an RPC/P2P anchor. HA validators are the first block producers in this suite.
|
|
255
|
+
disableValidator: true,
|
|
256
|
+
// Enable P2P for transaction gossip
|
|
257
|
+
p2pEnabled: true,
|
|
258
|
+
// Bind the bootstrap node above the ephemeral range too (see getFreeP2PPort), so it can't lose
|
|
259
|
+
// its port to an ephemeral socket and abort the whole suite before any HA node is created. Set
|
|
260
|
+
// the broadcast port explicitly to the same value: discv5 otherwise defaults p2pBroadcastPort to
|
|
261
|
+
// p2pPort by mutating this config object in place, and that mutated value would then leak into the
|
|
262
|
+
// HA nodes' configs below (built by spreading `config`), making them advertise the wrong port.
|
|
263
|
+
p2pPort: bootstrapP2PPort,
|
|
264
|
+
p2pBroadcastPort: bootstrapP2PPort,
|
|
265
|
+
// Enable slashing for testing governance + slashing vote coordination
|
|
266
|
+
slasherEnabled: true,
|
|
267
|
+
slashingRoundSizeInEpochs: 1, // 32 slots (1 epoch)
|
|
268
|
+
slashingQuorum: 17, // >50% of 32 slots for tally quorum,
|
|
269
|
+
},
|
|
270
|
+
{ syncChainTip: 'proven' },
|
|
271
|
+
));
|
|
272
|
+
|
|
273
|
+
this.ownerAddress = this.accounts[0];
|
|
274
|
+
this.testContract = await registerTestContract(this.wallet);
|
|
275
|
+
|
|
276
|
+
if (!this.dateProvider) {
|
|
277
|
+
throw new Error('dateProvider must be provided by setup for HA tests');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this.logger.info(
|
|
281
|
+
'Bootstrap node setup complete; funded initializerless account and test contract registered locally',
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
// Get bootstrap node's P2P ENR for HA nodes to connect to
|
|
285
|
+
const bootstrapNodeEnr = await this.aztecNode.getEncodedEnr();
|
|
286
|
+
if (!bootstrapNodeEnr) {
|
|
287
|
+
throw new Error('Failed to get bootstrap node ENR - P2P may not be enabled');
|
|
288
|
+
}
|
|
289
|
+
this.logger.info(`Bootstrap node ENR: ${bootstrapNodeEnr}`);
|
|
290
|
+
|
|
291
|
+
// L1 contract wrappers for querying votes
|
|
292
|
+
this.governanceProposer = new GovernanceProposerContract(
|
|
293
|
+
this.deployL1ContractsValues.l1Client,
|
|
294
|
+
this.deployL1ContractsValues.l1ContractAddresses.governanceProposerAddress.toString(),
|
|
295
|
+
);
|
|
296
|
+
this.logger.info('L1 contract wrappers initialized');
|
|
297
|
+
|
|
298
|
+
this.haNodeServices = [];
|
|
299
|
+
this.haKeystoreDirs = [];
|
|
300
|
+
this.logger.info(`Starting ${NODE_COUNT} HA peer nodes...`);
|
|
301
|
+
|
|
302
|
+
// Per-node keystore: all attesters but only this node's publisher to avoid nonce conflicts.
|
|
303
|
+
// When keyStoreDirectory is set the node loads validators/publishers from file only, so we omit them from config.
|
|
304
|
+
this.initialKeystoreJsons = [];
|
|
305
|
+
|
|
306
|
+
for (let i = 0; i < NODE_COUNT; i++) {
|
|
307
|
+
const nodeId = `${this.databaseConfig.nodeId}-${i + 1}`;
|
|
308
|
+
this.logger.info(`Starting HA peer node ${i} with nodeId: ${nodeId}`);
|
|
309
|
+
|
|
310
|
+
const keystoreContent = {
|
|
311
|
+
schemaVersion: 1,
|
|
312
|
+
validators: [
|
|
313
|
+
{
|
|
314
|
+
attester: this.attesterAddresses,
|
|
315
|
+
feeRecipient: AztecAddress.ZERO.toString(),
|
|
316
|
+
coinbase: EthAddress.fromString(this.attesterAddresses[0]).toChecksumString(),
|
|
317
|
+
remoteSigner: this.web3SignerUrl,
|
|
318
|
+
publisher: [this.publisherAddresses[i]],
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
};
|
|
322
|
+
const keystoreJson = JSON.stringify(keystoreContent, null, 2);
|
|
323
|
+
this.initialKeystoreJsons.push(keystoreJson);
|
|
324
|
+
|
|
325
|
+
const keystoreDir = await mkdtemp(join(tmpdir(), `ha-keystore-${i}-`));
|
|
326
|
+
this.haKeystoreDirs.push(keystoreDir);
|
|
327
|
+
await writeFile(join(keystoreDir, 'keystore.json'), keystoreJson);
|
|
328
|
+
|
|
329
|
+
const dataDirectory = this.config.dataDirectory ? `${this.config.dataDirectory}-${i}` : undefined;
|
|
330
|
+
|
|
331
|
+
const nodeP2PPort = await getFreeP2PPort();
|
|
332
|
+
const nodeConfig: AztecNodeConfig = {
|
|
333
|
+
...this.config,
|
|
334
|
+
nodeId,
|
|
335
|
+
keyStoreDirectory: keystoreDir,
|
|
336
|
+
// Ensure txs are included in proposals to test full signing path
|
|
337
|
+
publishTxsWithProposals: true,
|
|
338
|
+
dataDirectory,
|
|
339
|
+
databaseUrl: this.databaseConfig.databaseUrl,
|
|
340
|
+
pollingIntervalMs: this.databaseConfig.pollingIntervalMs,
|
|
341
|
+
peerSigningTimeoutMs: this.databaseConfig.peerSigningTimeoutMs,
|
|
342
|
+
maxStuckDutiesAgeMs: this.databaseConfig.maxStuckDutiesAgeMs,
|
|
343
|
+
haSigningEnabled: true,
|
|
344
|
+
disableValidator: false,
|
|
345
|
+
// Enable P2P for transaction and block gossip
|
|
346
|
+
p2pEnabled: true,
|
|
347
|
+
// Each HA node gets its own free port above the ephemeral range. Override the broadcast port too:
|
|
348
|
+
// `...config` carries the bootstrap node's broadcast port (discv5 sets it in place), which would
|
|
349
|
+
// otherwise make every HA node advertise the bootstrap's port instead of its own.
|
|
350
|
+
p2pPort: nodeP2PPort,
|
|
351
|
+
p2pBroadcastPort: nodeP2PPort,
|
|
352
|
+
// Connect to bootstrap node for tx gossip
|
|
353
|
+
bootstrapNodes: [bootstrapNodeEnr],
|
|
354
|
+
web3SignerUrl: this.web3SignerUrl,
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const nodeService = await withLoggerBindings({ actor: `HA-${i}` }, async () => {
|
|
358
|
+
return await createAztecNodeService(
|
|
359
|
+
nodeConfig,
|
|
360
|
+
{ dateProvider: this.dateProvider },
|
|
361
|
+
{ genesis: this.genesis, dontStartSequencer: true },
|
|
362
|
+
);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
this.haNodeServices.push(nodeService);
|
|
366
|
+
this.logger.info(`HA peer node ${i} started successfully`);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
this.logger.info(`All ${NODE_COUNT} HA peer nodes started and coordinating via PostgreSQL database`);
|
|
370
|
+
this.logger.info('Waiting for HA peer nodes to join the tx gossip mesh');
|
|
371
|
+
await retryUntil(
|
|
372
|
+
async () => {
|
|
373
|
+
const meshStates = await Promise.all(
|
|
374
|
+
this.haNodeServices.map(async (service, nodeIndex) => {
|
|
375
|
+
const p2p = service.getP2P();
|
|
376
|
+
const [peers, txMeshPeerCount] = await Promise.all([
|
|
377
|
+
p2p.getPeers(),
|
|
378
|
+
p2p.getGossipMeshPeerCount(TopicType.tx),
|
|
379
|
+
]);
|
|
380
|
+
|
|
381
|
+
return { nodeIndex, peerCount: peers.length, txMeshPeerCount };
|
|
382
|
+
}),
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
this.logger.debug('HA tx gossip mesh status', { meshStates });
|
|
386
|
+
return meshStates.every(({ peerCount, txMeshPeerCount }) => peerCount > 0 && txMeshPeerCount > 0)
|
|
387
|
+
? true
|
|
388
|
+
: undefined;
|
|
389
|
+
},
|
|
390
|
+
'HA tx gossip mesh readiness',
|
|
391
|
+
60,
|
|
392
|
+
1,
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
// The owner is an initializerless account, so it needs no deployment tx -- it was funded at genesis
|
|
396
|
+
// and registered during setup, and is ready to transact as soon as the HA nodes start building blocks.
|
|
397
|
+
this.logger.info(`Test account ready at ${this.ownerAddress}`);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async teardown(): Promise<void> {
|
|
401
|
+
// Stop all sequencers before tearing down the nodes: a sequencer stop awaits its in-flight
|
|
402
|
+
// iteration, which can spend tens of seconds finishing a vote or checkpoint publish on L1.
|
|
403
|
+
// Stops must be awaited fully — jest runs without forceExit, so a node abandoned mid-stop
|
|
404
|
+
// outlives the test environment and keeps the worker process alive until the CI job timeout.
|
|
405
|
+
// The dateProvider reset must wait until nodes are stopped: it rewinds the shared clock from
|
|
406
|
+
// chain time to wall time (minutes apart after the automine deploy burst), and any publisher
|
|
407
|
+
// deadline armed against the rewound clock would block shutdown until wall time catches up.
|
|
408
|
+
if (this.haNodeServices) {
|
|
409
|
+
await Promise.allSettled(
|
|
410
|
+
this.haNodeServices.map(async (service, i) => {
|
|
411
|
+
try {
|
|
412
|
+
await service.getSequencer()?.stop();
|
|
413
|
+
} catch (error) {
|
|
414
|
+
this.logger.error(`Failed to stop sequencer of HA peer node ${i}: ${error}`);
|
|
415
|
+
}
|
|
416
|
+
}),
|
|
417
|
+
);
|
|
418
|
+
await Promise.allSettled(
|
|
419
|
+
this.haNodeServices.map((_, i) =>
|
|
420
|
+
this.stopHANode(i).catch(error => {
|
|
421
|
+
this.logger.error(`Failed to stop HA peer node ${i}: ${error}`);
|
|
422
|
+
}),
|
|
423
|
+
),
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
this.dateProvider?.reset();
|
|
428
|
+
|
|
429
|
+
// Cleanup HA keystore temp directories
|
|
430
|
+
if (this.haKeystoreDirs) {
|
|
431
|
+
for (let i = 0; i < this.haKeystoreDirs.length; i++) {
|
|
432
|
+
try {
|
|
433
|
+
await rm(this.haKeystoreDirs[i], { recursive: true });
|
|
434
|
+
} catch (error) {
|
|
435
|
+
this.logger.error(`Failed to remove HA keystore dir ${i}: ${error}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Cleanup HA resources (database pools, etc.)
|
|
441
|
+
if (this.haNodePools) {
|
|
442
|
+
for (const pool of this.haNodePools) {
|
|
443
|
+
try {
|
|
444
|
+
await pool.end();
|
|
445
|
+
} catch (error) {
|
|
446
|
+
this.logger.error(`Failed to close HA node pool: ${error}`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
await cleanupHADatabase(this.mainPool, this.logger);
|
|
451
|
+
await this.mainPool.end();
|
|
452
|
+
|
|
453
|
+
// Cleanup bootstrap node and test infrastructure (this cleans up the shared data directory)
|
|
454
|
+
await this.teardownBootstrap();
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** Clean up database state between tests. */
|
|
458
|
+
async resetDutiesTable(): Promise<void> {
|
|
459
|
+
try {
|
|
460
|
+
await this.mainPool.query('DELETE FROM validator_duties');
|
|
461
|
+
} catch (error) {
|
|
462
|
+
// Ignore cleanup errors (table might not exist on first run failure)
|
|
463
|
+
this.logger?.warn(`Failed to clean up validator_duties: ${error}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|