@aztec/end-to-end 5.0.0-rc.2 → 5.0.1
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 +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +16 -4
- 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 +30 -11
- package/dest/fixtures/fixtures.d.ts +9 -6
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +11 -7
- 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 +34 -9
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +165 -160
- 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/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 +9 -1
- package/dest/p2p/p2p_network.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.js +26 -1
- 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 +158 -47
- package/dest/shared/wait_for_l1_to_l2_message.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 +74 -26
- 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 +9 -6
- 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 +121 -45
- 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 +374 -0
- package/dest/single-node/single_node_test_context.d.ts.map +1 -0
- package/dest/single-node/single_node_test_context.js +847 -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 +13 -7
- 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 +40 -40
- 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 +17 -4
- package/src/composed/ha/ha_full_setup.ts +466 -0
- package/src/fixtures/e2e_prover_test.ts +36 -20
- package/src/fixtures/fixtures.ts +11 -7
- package/src/fixtures/ha_setup.ts +7 -3
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +204 -162
- package/src/fixtures/standard_contracts_genesis.ts +28 -0
- package/src/fixtures/timing.ts +97 -0
- package/src/fixtures/wait_helpers.ts +333 -0
- package/src/forward-compatibility/wallet_service.ts +2 -2
- 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 +26 -0
- 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 +152 -48
- package/src/shared/wait_for_l1_to_l2_message.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 +100 -38
- package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
- package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +11 -7
- package/src/{e2e_fees → single-node/fees}/fees_test.ts +132 -47
- 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 +1058 -0
- package/src/spartan/setup_test_wallets.ts +19 -7
- 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 -59
- 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 -57
- 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 -100
- package/dest/e2e_p2p/shared.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.js +0 -257
- 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 -78
- 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 -391
- /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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
+
import { getPublishableStandardContracts } from '@aztec/standard-contracts';
|
|
4
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Computes the genesis nullifiers that pre-publish the standard contracts (AuthRegistry, PublicChecks,
|
|
8
|
+
* HandshakeRegistry) in e2e environments, mirroring the nullifiers their on-chain publish txs would emit. Per contract:
|
|
9
|
+
* - `siloNullifier(ContractClassRegistry, classId)` — the class-registration nullifier that `ContractClassRegistry.publish` pushes.
|
|
10
|
+
* - `siloNullifier(ContractInstanceRegistry, instanceAddress)` — the instance-deployment nullifier that
|
|
11
|
+
* `ContractInstanceRegistry.publish_for_public_execution` pushes, using the contract's real derived address (standard
|
|
12
|
+
* contracts are deployed at artifact-derived addresses, not magic protocol addresses).
|
|
13
|
+
*
|
|
14
|
+
* Seed these into the genesis nullifier tree (as the 5th `getGenesisValues` arg) alongside the archiver's
|
|
15
|
+
* `testPreloadStandardContracts` preload: the store preload makes the `ensure*Published` guards short-circuit, and these
|
|
16
|
+
* nullifiers make the AVM's deployment-nullifier check pass when the contracts are called. Every e2e node genesis that
|
|
17
|
+
* feeds an L1 `genesisArchiveRoot` must seed the same set, or the world-state root diverges from the deployed rollup.
|
|
18
|
+
*/
|
|
19
|
+
export async function getStandardContractGenesisNullifiers(): Promise<Fr[]> {
|
|
20
|
+
const classRegistry = ProtocolContractAddress.ContractClassRegistry;
|
|
21
|
+
const instanceRegistry = ProtocolContractAddress.ContractInstanceRegistry;
|
|
22
|
+
const nullifiers: Fr[] = [];
|
|
23
|
+
for (const { contractClass, address } of await getPublishableStandardContracts()) {
|
|
24
|
+
nullifiers.push(await siloNullifier(classRegistry, contractClass.id));
|
|
25
|
+
nullifiers.push(await siloNullifier(instanceRegistry, address.toField()));
|
|
26
|
+
}
|
|
27
|
+
return nullifiers;
|
|
28
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2e span instrumentation. Wrapping a shared test helper in {@link testSpan} / {@link testSpanSync}
|
|
3
|
+
* records how long it ran, attributed to the test (or suite) that was executing, so a full CI run can
|
|
4
|
+
* be aggregated into a ranked list of where the suite spends wall-clock (setup, protocol waits, client
|
|
5
|
+
* proving, warp scans, ...). See the A-1178 timing environment in `shared/timing_env.mjs`.
|
|
6
|
+
*
|
|
7
|
+
* Everything here is gated on the collector installed by that environment, which only exists when
|
|
8
|
+
* `TEST_TIMING_FILE` is set. When it is unset, {@link testSpan} calls `fn()` directly with no extra work
|
|
9
|
+
* and no clock reads — instrumentation is exactly zero-cost and cannot change a test's behavior or
|
|
10
|
+
* timing.
|
|
11
|
+
*/
|
|
12
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Async-context owner override. A span normally attributes itself to the running test
|
|
16
|
+
* (`collector.current`), but a background producer (e.g. the mempool feeder) runs interleaved with
|
|
17
|
+
* arbitrary tests, so its spans would smear across whichever test happened to be current when each
|
|
18
|
+
* round fired. Running such work inside {@link withTestSpanOwner} pins every span in that async call
|
|
19
|
+
* tree to a fixed owner instead — isolated by async context from concurrent test-body spans.
|
|
20
|
+
*/
|
|
21
|
+
const ownerOverride = new AsyncLocalStorage<string | null>();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs `fn` with every {@link testSpan} inside its async call tree attributed to `owner` instead of the
|
|
25
|
+
* currently running test. Use a non-test sentinel owner (e.g. `other:mempool-feeder`) to keep a
|
|
26
|
+
* background producer's spans out of the per-test view.
|
|
27
|
+
*/
|
|
28
|
+
export function withTestSpanOwner<T>(owner: string, fn: () => Promise<T>): Promise<T> {
|
|
29
|
+
return ownerOverride.run(owner, fn);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** One recorded span occurrence on the process-wide `performance.now()` clock. */
|
|
33
|
+
export type TimingSpan = {
|
|
34
|
+
/** Full name of the test running when the span started, or `null` if inside a beforeAll/afterAll hook. */
|
|
35
|
+
owner: string | null;
|
|
36
|
+
/** Stable `category:label` tag, aggregated across occurrences (e.g. `wait:checkpoint`, `setup:node`). */
|
|
37
|
+
name: string;
|
|
38
|
+
/** `performance.now()` at span start. */
|
|
39
|
+
start: number;
|
|
40
|
+
/** `performance.now()` at span end. */
|
|
41
|
+
end: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The collector shared by the timing environment on `globalThis.__e2eTimings`. `current` is the full
|
|
46
|
+
* name of the test currently running (`null` during beforeAll/afterAll); the environment sets it. The
|
|
47
|
+
* `spans` array accumulates every recorded span until the environment folds it into the per-test /
|
|
48
|
+
* per-suite JSONL line at flush.
|
|
49
|
+
*/
|
|
50
|
+
export type SpanCollector = {
|
|
51
|
+
/** Full name of the running test, or `null` during a beforeAll/afterAll hook. */
|
|
52
|
+
current: string | null;
|
|
53
|
+
/** All recorded spans, drained by the timing environment at flush time. */
|
|
54
|
+
spans: TimingSpan[];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function getCollector(): SpanCollector | undefined {
|
|
58
|
+
return (globalThis as { __e2eTimings?: SpanCollector }).__e2eTimings;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Times `fn` and records a span tagged `name`, attributed to the test (or suite) running when it
|
|
63
|
+
* started. The span is recorded even when `fn` throws. Pure passthrough: when no collector is
|
|
64
|
+
* installed (i.e. `TEST_TIMING_FILE` is unset) this calls `fn()` directly with zero overhead.
|
|
65
|
+
*
|
|
66
|
+
* Use stable `category:label` tags and prefer wrapping at the leaf wait/setup/tx level — labels are
|
|
67
|
+
* forever aggregation keys, and leaf-level tagging keeps spans additive. See `SPEEDUP_FOLLOWUPS` and
|
|
68
|
+
* the A-1179 design doc for the tag taxonomy.
|
|
69
|
+
*/
|
|
70
|
+
export async function testSpan<T>(name: string, fn: () => Promise<T>): Promise<T> {
|
|
71
|
+
const collector = getCollector();
|
|
72
|
+
if (!collector) {
|
|
73
|
+
return fn();
|
|
74
|
+
}
|
|
75
|
+
const owner = ownerOverride.getStore() ?? collector.current;
|
|
76
|
+
const start = performance.now();
|
|
77
|
+
try {
|
|
78
|
+
return await fn();
|
|
79
|
+
} finally {
|
|
80
|
+
collector.spans.push({ owner, name, start, end: performance.now() });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Synchronous variant of {@link testSpan} for non-async helpers. Same zero-cost guarantee when unset. */
|
|
85
|
+
export function testSpanSync<T>(name: string, fn: () => T): T {
|
|
86
|
+
const collector = getCollector();
|
|
87
|
+
if (!collector) {
|
|
88
|
+
return fn();
|
|
89
|
+
}
|
|
90
|
+
const owner = ownerOverride.getStore() ?? collector.current;
|
|
91
|
+
const start = performance.now();
|
|
92
|
+
try {
|
|
93
|
+
return fn();
|
|
94
|
+
} finally {
|
|
95
|
+
collector.spans.push({ owner, name, start, end: performance.now() });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
4
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/aztec.js/protocol';
|
|
5
|
+
import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
6
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
8
|
+
import type { Sequencer, SequencerEvents, SequencerState } from '@aztec/sequencer-client';
|
|
9
|
+
import type { L2BlockTag } from '@aztec/stdlib/block';
|
|
10
|
+
import type { AztecNode, CheckpointTag } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import type { L2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
12
|
+
import type { TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
13
|
+
|
|
14
|
+
import { testSpan } from './timing.js';
|
|
15
|
+
|
|
16
|
+
/** Options for the block-number polling helpers. */
|
|
17
|
+
export type WaitForBlockOpts = {
|
|
18
|
+
/** Which chain tip to read; defaults to 'proposed'. */
|
|
19
|
+
tag?: L2BlockTag;
|
|
20
|
+
/** How the node's block number must relate to `target`; defaults to `(actual, target) => actual >= target`. */
|
|
21
|
+
compare?: (actual: number, target: number) => boolean;
|
|
22
|
+
/** Seconds before the poll rejects; defaults to 60. */
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/** Seconds between polls; defaults to 0.25. */
|
|
25
|
+
interval?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Polls `node.getBlockNumber(tag)` until `opts.compare(actual, target)` holds (default `>=`). Replaces
|
|
30
|
+
* the ad-hoc `retryUntil(() => node.getBlockNumber(tag) <op> target)` polls scattered across the suite,
|
|
31
|
+
* where the node may sync forward or prune backward — the caller passes the comparator for whichever it
|
|
32
|
+
* expects.
|
|
33
|
+
* @returns The block number once the comparison holds.
|
|
34
|
+
*/
|
|
35
|
+
export function waitForBlockNumber(node: AztecNode, target: number, opts: WaitForBlockOpts = {}): Promise<BlockNumber> {
|
|
36
|
+
const tag = opts.tag ?? 'proposed';
|
|
37
|
+
const compare = opts.compare ?? ((actual, target) => actual >= target);
|
|
38
|
+
return testSpan(`wait:${tag}`, () =>
|
|
39
|
+
// Wrap the matched value: retryUntil treats any falsy return as "keep polling", so a legitimate
|
|
40
|
+
// match of block 0 (e.g. a freshly-pruned tip) would otherwise loop until timeout.
|
|
41
|
+
retryUntil(
|
|
42
|
+
async () => {
|
|
43
|
+
const blockNumber = await node.getBlockNumber(tag);
|
|
44
|
+
return compare(blockNumber, target) ? { blockNumber } : undefined;
|
|
45
|
+
},
|
|
46
|
+
`block ${tag} ${compare} ${target}`,
|
|
47
|
+
opts.timeout ?? 60,
|
|
48
|
+
opts.interval ?? 0.25,
|
|
49
|
+
).then(({ blockNumber }) => blockNumber),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Convenience for {@link waitForBlockNumber} on the proven tip. */
|
|
54
|
+
export function waitForProvenBlock(
|
|
55
|
+
node: AztecNode,
|
|
56
|
+
target: number,
|
|
57
|
+
opts: Omit<WaitForBlockOpts, 'tag'> = {},
|
|
58
|
+
): Promise<BlockNumber> {
|
|
59
|
+
return waitForBlockNumber(node, target, { ...opts, tag: 'proven' });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Compares the node's checkpoint number against the target; defaults to `>=`. */
|
|
63
|
+
export type CheckpointComparator = (actual: number, target: number) => boolean;
|
|
64
|
+
|
|
65
|
+
/** Options for {@link waitForNodeCheckpoint}. */
|
|
66
|
+
export type WaitForCheckpointOpts = {
|
|
67
|
+
/** Which checkpoint tip to read; defaults to 'checkpointed'. */
|
|
68
|
+
tag?: CheckpointTag;
|
|
69
|
+
/** How the node's checkpoint number must relate to `target`; defaults to `(actual, target) => actual >= target`. */
|
|
70
|
+
compare?: CheckpointComparator;
|
|
71
|
+
/** Seconds before the poll rejects; defaults to 30. */
|
|
72
|
+
timeout?: number;
|
|
73
|
+
/** Seconds between polls; defaults to 0.5. */
|
|
74
|
+
interval?: number;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Polls a single node's checkpoint number until `opts.compare(actual, target)` holds. Replaces the
|
|
79
|
+
* `retryUntil(() => node.getChainTips().then(tips => tips.<tag>.checkpoint.number <op> target))` polls
|
|
80
|
+
* duplicated across the reorg/proving tests, where the node may sync forward, prune backward, or land
|
|
81
|
+
* exactly on a value — the caller passes the comparator lambda for whichever it expects.
|
|
82
|
+
* @returns The node's checkpoint number once the comparison holds.
|
|
83
|
+
*/
|
|
84
|
+
export function waitForNodeCheckpoint(
|
|
85
|
+
node: AztecNode,
|
|
86
|
+
target: number,
|
|
87
|
+
opts: WaitForCheckpointOpts = {},
|
|
88
|
+
): Promise<CheckpointNumber> {
|
|
89
|
+
const tag = opts.tag ?? 'checkpointed';
|
|
90
|
+
const compare = opts.compare ?? ((actual, target) => actual >= target);
|
|
91
|
+
return testSpan(tag === 'proven' ? 'wait:proven-checkpoint' : 'wait:checkpoint', () =>
|
|
92
|
+
// Wrap the matched value: retryUntil treats any falsy return as "keep polling", so a legitimate
|
|
93
|
+
// match of checkpoint 0 (e.g. proven === 0 or checkpointed <= 1 after a prune) would otherwise
|
|
94
|
+
// loop until timeout instead of resolving.
|
|
95
|
+
retryUntil(
|
|
96
|
+
async () => {
|
|
97
|
+
const checkpointNumber = await node.getCheckpointNumber(tag);
|
|
98
|
+
return compare(checkpointNumber, target) ? { checkpointNumber } : undefined;
|
|
99
|
+
},
|
|
100
|
+
`node checkpoint ${tag} ${compare} ${target}`,
|
|
101
|
+
opts.timeout ?? 30,
|
|
102
|
+
opts.interval ?? 0.5,
|
|
103
|
+
).then(({ checkpointNumber }) => checkpointNumber),
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Convenience for {@link waitForNodeCheckpoint} on the proven tip. */
|
|
108
|
+
export function waitForNodeProvenCheckpoint(
|
|
109
|
+
node: AztecNode,
|
|
110
|
+
target: number,
|
|
111
|
+
opts: Omit<WaitForCheckpointOpts, 'tag'> = {},
|
|
112
|
+
): Promise<CheckpointNumber> {
|
|
113
|
+
return waitForNodeCheckpoint(node, target, { ...opts, tag: 'proven' });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Waits for all of `txHashes` to reach the desired status on `node`. The plural form of
|
|
118
|
+
* {@link waitForTx}; resolves with the receipts in input order.
|
|
119
|
+
*/
|
|
120
|
+
export function waitForTxs(node: AztecNode, txHashes: TxHash[], opts?: WaitOpts): Promise<TxReceipt[]> {
|
|
121
|
+
const optsWithInterval = { ...opts, interval: opts?.interval ?? 0.25 };
|
|
122
|
+
return testSpan('wait:tx-mined', () =>
|
|
123
|
+
Promise.all(txHashes.map(txHash => waitForTx(node, txHash, optsWithInterval))),
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Options for {@link waitForBlocksAtSlots}. */
|
|
128
|
+
export type WaitForBlocksAtSlotsOpts = {
|
|
129
|
+
/** Block number to start scanning from; defaults to the initial L2 block. */
|
|
130
|
+
from?: BlockNumber;
|
|
131
|
+
/** How many blocks to fetch per poll; defaults to 10. */
|
|
132
|
+
limit?: number;
|
|
133
|
+
/** Seconds before the poll rejects; defaults to 20. */
|
|
134
|
+
timeout?: number;
|
|
135
|
+
/** Seconds between polls; defaults to 0.25. */
|
|
136
|
+
interval?: number;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Polls `node.getBlocks` until every slot in `slots` is present among the fetched blocks' slot
|
|
141
|
+
* numbers. Replaces the hand-rolled `retryUntil` over `getBlocks(...).map(getSlot)` membership check.
|
|
142
|
+
*/
|
|
143
|
+
export async function waitForBlocksAtSlots(
|
|
144
|
+
node: AztecNode,
|
|
145
|
+
slots: SlotNumber[],
|
|
146
|
+
opts: WaitForBlocksAtSlotsOpts = {},
|
|
147
|
+
): Promise<void> {
|
|
148
|
+
const from = opts.from ?? INITIAL_L2_BLOCK_NUM;
|
|
149
|
+
const limit = opts.limit ?? 10;
|
|
150
|
+
await testSpan('wait:block', () =>
|
|
151
|
+
retryUntil(
|
|
152
|
+
async () => {
|
|
153
|
+
const blocks = await node.getBlocks(from, limit);
|
|
154
|
+
const foundSlots = blocks.map(block => block.header.getSlot());
|
|
155
|
+
return slots.every(slot => foundSlots.includes(slot)) || undefined;
|
|
156
|
+
},
|
|
157
|
+
`blocks at slots ${slots.join(', ')}`,
|
|
158
|
+
opts.timeout ?? 20,
|
|
159
|
+
opts.interval ?? 0.25,
|
|
160
|
+
),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Polls `node.getL2ToL1MembershipWitness(txHash, message)` until a witness is available, resolving
|
|
166
|
+
* with it. Wraps the `retryUntil` the cross-chain tests hand-roll while waiting for an L2-to-L1
|
|
167
|
+
* message's membership witness to become provable.
|
|
168
|
+
*/
|
|
169
|
+
export function waitForL2ToL1Witness(
|
|
170
|
+
node: AztecNode,
|
|
171
|
+
txHash: TxHash,
|
|
172
|
+
message: Fr,
|
|
173
|
+
opts: { timeout?: number; interval?: number } = {},
|
|
174
|
+
): Promise<L2ToL1MembershipWitness> {
|
|
175
|
+
return testSpan('wait:l2-to-l1-witness', () =>
|
|
176
|
+
retryUntil(
|
|
177
|
+
() => node.getL2ToL1MembershipWitness(txHash, message),
|
|
178
|
+
`L2-to-L1 membership witness for ${txHash.toString()}`,
|
|
179
|
+
opts.timeout ?? 30,
|
|
180
|
+
opts.interval ?? 0.25,
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Options for the tx-receipt polling helpers. */
|
|
186
|
+
export type WaitForTxReceiptOpts = {
|
|
187
|
+
/** Seconds before the poll rejects; defaults to 30. */
|
|
188
|
+
timeout?: number;
|
|
189
|
+
/** Seconds between polls; defaults to 0.25. */
|
|
190
|
+
interval?: number;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Polls `node.getTxReceipt(txHash)` until `predicate(receipt)` holds, resolving with the receipt.
|
|
195
|
+
* Wraps the `retryUntil` that the block-building reorg tests hand-roll while waiting for a tx to
|
|
196
|
+
* transition between statuses (pruned, re-included, ...).
|
|
197
|
+
* @returns The receipt once the predicate holds.
|
|
198
|
+
*/
|
|
199
|
+
export function waitForTxReceipt(
|
|
200
|
+
node: AztecNode,
|
|
201
|
+
txHash: TxHash,
|
|
202
|
+
predicate: (receipt: TxReceipt) => boolean,
|
|
203
|
+
opts: WaitForTxReceiptOpts = {},
|
|
204
|
+
): Promise<TxReceipt> {
|
|
205
|
+
return testSpan('wait:tx-mined', () =>
|
|
206
|
+
retryUntil(
|
|
207
|
+
async () => {
|
|
208
|
+
const receipt = await node.getTxReceipt(txHash);
|
|
209
|
+
return predicate(receipt) ? { receipt } : undefined;
|
|
210
|
+
},
|
|
211
|
+
`tx receipt for ${txHash.toString()}`,
|
|
212
|
+
opts.timeout ?? 30,
|
|
213
|
+
opts.interval ?? 0.25,
|
|
214
|
+
).then(({ receipt }) => receipt),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Polls until `node.getTxReceipt(txHash).status === status`. Thin wrapper over {@link waitForTxReceipt}. */
|
|
219
|
+
export function waitForTxStatus(
|
|
220
|
+
node: AztecNode,
|
|
221
|
+
txHash: TxHash,
|
|
222
|
+
status: TxStatus,
|
|
223
|
+
opts: WaitForTxReceiptOpts = {},
|
|
224
|
+
): Promise<TxReceipt> {
|
|
225
|
+
return waitForTxReceipt(node, txHash, receipt => receipt.status === status, opts);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Compares the node's pending-tx count against the target; defaults to `>=`. */
|
|
229
|
+
export type PendingTxCountComparator = (actual: number, target: number) => boolean;
|
|
230
|
+
|
|
231
|
+
/** Options for {@link waitForPendingTxCount}. */
|
|
232
|
+
export type WaitForPendingTxCountOpts = {
|
|
233
|
+
/** How the node's pending-tx count must relate to `target`; defaults to `(actual, target) => actual >= target`. */
|
|
234
|
+
compare?: PendingTxCountComparator;
|
|
235
|
+
/** Seconds before the poll rejects; defaults to 30. */
|
|
236
|
+
timeout?: number;
|
|
237
|
+
/** Seconds between polls; defaults to 0.25. */
|
|
238
|
+
interval?: number;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Polls `node.getPendingTxCount()` until `opts.compare(actual, target)` holds (default `>=`).
|
|
243
|
+
* Replaces the hand-rolled mempool-size poll in the slashing tests.
|
|
244
|
+
* @returns The pending-tx count once the comparison holds.
|
|
245
|
+
*/
|
|
246
|
+
export function waitForPendingTxCount(
|
|
247
|
+
node: AztecNode,
|
|
248
|
+
target: number,
|
|
249
|
+
opts: WaitForPendingTxCountOpts = {},
|
|
250
|
+
): Promise<number> {
|
|
251
|
+
const compare = opts.compare ?? ((actual, target) => actual >= target);
|
|
252
|
+
return testSpan('wait:pending-tx', () =>
|
|
253
|
+
// Wrap the matched value: retryUntil treats any falsy return as "keep polling", so a legitimate
|
|
254
|
+
// match of 0 pending txs would otherwise loop until timeout instead of resolving.
|
|
255
|
+
retryUntil(
|
|
256
|
+
async () => {
|
|
257
|
+
const count = await node.getPendingTxCount();
|
|
258
|
+
return compare(count, target) ? { count } : undefined;
|
|
259
|
+
},
|
|
260
|
+
`pending tx count ${compare} ${target}`,
|
|
261
|
+
opts.timeout ?? 30,
|
|
262
|
+
opts.interval ?? 0.25,
|
|
263
|
+
).then(({ count }) => count),
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** Options for {@link waitForSequencerState}. */
|
|
268
|
+
export type WaitForSequencerStateOpts = {
|
|
269
|
+
/** Milliseconds before the wait rejects; defaults to 30000. */
|
|
270
|
+
timeout?: number;
|
|
271
|
+
/**
|
|
272
|
+
* Action to run after subscribing to the sequencer but before awaiting the transition. Subscribing
|
|
273
|
+
* first guarantees the state change the action triggers is not missed between the action and the
|
|
274
|
+
* listener attaching.
|
|
275
|
+
*/
|
|
276
|
+
after?: () => unknown;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Resolves once `sequencer` reaches `state`. Subscribes to the `state-changed` event first, then (if
|
|
281
|
+
* `opts.after` is given) runs the action, then resolves immediately if the sequencer is already at
|
|
282
|
+
* `state`, otherwise waits for the transition. The listener is cleaned up on both resolve and timeout.
|
|
283
|
+
* Replaces the hand-rolled `state-changed` on/off subscriptions duplicated across the fee, cross-chain,
|
|
284
|
+
* and keystore-reload tests.
|
|
285
|
+
*/
|
|
286
|
+
export function waitForSequencerState(
|
|
287
|
+
sequencer: Sequencer,
|
|
288
|
+
state: SequencerState,
|
|
289
|
+
opts: WaitForSequencerStateOpts = {},
|
|
290
|
+
): Promise<void> {
|
|
291
|
+
return testSpan('wait:sequencer-state', () => waitForSequencerStateInner(sequencer, state, opts));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async function waitForSequencerStateInner(
|
|
295
|
+
sequencer: Sequencer,
|
|
296
|
+
state: SequencerState,
|
|
297
|
+
opts: WaitForSequencerStateOpts,
|
|
298
|
+
): Promise<void> {
|
|
299
|
+
const timeout = opts.timeout ?? 30000;
|
|
300
|
+
const { promise, resolve, reject } = promiseWithResolvers<void>();
|
|
301
|
+
|
|
302
|
+
let settled = false;
|
|
303
|
+
const handler = (args: Parameters<SequencerEvents['state-changed']>[0]) => {
|
|
304
|
+
if (args.newState === state) {
|
|
305
|
+
finish(resolve);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const timer = setTimeout(
|
|
309
|
+
() => finish(() => reject(new Error(`Timeout waiting for sequencer ${state} state`))),
|
|
310
|
+
timeout,
|
|
311
|
+
);
|
|
312
|
+
function finish(complete: () => void) {
|
|
313
|
+
if (settled) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
settled = true;
|
|
317
|
+
clearTimeout(timer);
|
|
318
|
+
sequencer.off('state-changed', handler);
|
|
319
|
+
complete();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
sequencer.on('state-changed', handler);
|
|
323
|
+
try {
|
|
324
|
+
await opts.after?.();
|
|
325
|
+
if (sequencer.status().state === state) {
|
|
326
|
+
finish(resolve);
|
|
327
|
+
}
|
|
328
|
+
await promise;
|
|
329
|
+
} catch (err) {
|
|
330
|
+
finish(() => {});
|
|
331
|
+
throw err;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -33,9 +33,9 @@ async function main() {
|
|
|
33
33
|
const extraAccountSalt = Fr.ZERO;
|
|
34
34
|
const extraAccountSigningKey = GrumpkinScalar.random();
|
|
35
35
|
const extraAccountAddress = await getSchnorrAccountContractAddress(
|
|
36
|
-
extraAccountSecret,
|
|
37
|
-
extraAccountSalt,
|
|
38
36
|
extraAccountSigningKey,
|
|
37
|
+
extraAccountSalt,
|
|
38
|
+
extraAccountSecret,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
logger.info('Starting wallet service...', { l1RpcUrls });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# `infra` e2e test category
|
|
2
|
+
|
|
3
|
+
Infrastructure tests cover deployment, network targeting, and ops scenarios that are not about a
|
|
4
|
+
single protocol behavior. A test belongs here when its primary concern is network targeting or
|
|
5
|
+
operational smoke-testing rather than correctness of a specific consensus, block-building, or
|
|
6
|
+
proving behavior.
|
|
7
|
+
|
|
8
|
+
## Tests
|
|
9
|
+
|
|
10
|
+
| File | Contents |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `public_testnet_transfer.test.ts` | Deploy and transfer on a public L1 network (Sepolia) or local Anvil, parameterized by `L1_CHAIN_ID`. With no `L1_CHAIN_ID` set the test targets local Anvil and runs in CI; with Sepolia credentials (`SEQ_PUBLISHER_PRIVATE_KEY`, `ETHEREUM_HOSTS`, `L1_CHAIN_ID=11155111`) it runs against the live public testnet. |
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# `multi-node` e2e test category
|
|
2
|
+
|
|
3
|
+
Multi-node tests run N validator nodes sharing an in-memory `MockGossipSubNetwork` bus (no real
|
|
4
|
+
libp2p). This is the category for any multi-node test whose subject — proposals, attestations,
|
|
5
|
+
checkpointing, pruning/recovery, offense detection — is faithfully reproduced by the mock-gossip bus.
|
|
6
|
+
Tests that need *real networking* (peer discovery / discv5, the req/resp protocol, gossip mesh
|
|
7
|
+
formation, peer auth/scoring, transport behavior) belong in the `p2p` category instead.
|
|
8
|
+
|
|
9
|
+
## Base class
|
|
10
|
+
|
|
11
|
+
`MultiNodeTestContext` (`multi_node_test_context.ts`) extends `SingleNodeTestContext` (in
|
|
12
|
+
`../single-node/`) with the N-validator topology:
|
|
13
|
+
|
|
14
|
+
- `createValidatorNode` / `createValidatorNodeAt(index)` spawn nodes on the mock-gossip bus; passing
|
|
15
|
+
the same index to two calls (with different coinbases) models an equivocating proposer that shares
|
|
16
|
+
a key across two nodes. Validators with no spawned node stay registered-but-offline.
|
|
17
|
+
- The per-validator registration accessors (`validatorAt` / `addressAt` / `privateKeyAt`) for the
|
|
18
|
+
validators registered at genesis via `initialValidators`.
|
|
19
|
+
- `getSlashingContracts()` for the rollup / slasher / slashing-proposer L1 contracts.
|
|
20
|
+
- The committee convergence helpers `waitForAllNodes*` and `findSlotsWithProposers`.
|
|
21
|
+
|
|
22
|
+
The environment (in-process anvil + L1 deploy), the prover lifecycle, and the proving / reorg waiters
|
|
23
|
+
all live on the parent and are inherited.
|
|
24
|
+
|
|
25
|
+
## Shared presets and helpers
|
|
26
|
+
|
|
27
|
+
These are exported from `multi_node_test_context.ts` and spread into a `setup(...)` call rather than
|
|
28
|
+
copy-pasted:
|
|
29
|
+
|
|
30
|
+
- `buildMockGossipValidators(n)` — the deterministic validator set (keys from
|
|
31
|
+
`getPrivateKeyFromIndex(i + 3)`), passed as `initialValidators`.
|
|
32
|
+
- `MOCK_GOSSIP_MULTI_VALIDATOR_OPTS` — a tight committee on the mock bus with no prover
|
|
33
|
+
(`{ mockGossipSubNetwork, skipInitialSequencer, startProverNode: false, aztecProofSubmissionEpochs:
|
|
34
|
+
NO_REORG_SUBMISSION_EPOCHS, numberOfAccounts: 0 }`, the constant re-exported from `../single-node/setup.ts`).
|
|
35
|
+
Tests that want a prover leave `startProverNode` explicit.
|
|
36
|
+
- `SLASHER_ENABLED_MULTI_VALIDATOR_OPTS` — the same committee with the slasher turned on, used by the
|
|
37
|
+
offense-detection tests.
|
|
38
|
+
- `defaultSlashingPenalties(unit?)` / `withOnlyOffense(offense, unit?)` — build the per-offense
|
|
39
|
+
`slash*Penalty` knobs; `withOnlyOffense` zeroes all but the named offense to isolate one offense.
|
|
40
|
+
- `setupHaPairs(test, validators, { baseOpts, coinbases })` — stands up two HA pairs (nodes 0/1 share
|
|
41
|
+
keys pk1+pk2, nodes 2/3 share pk3+pk4), each pair on a shared slashing-protection DB with distinct
|
|
42
|
+
per-node coinbases. Used by the `high-availability/` tests.
|
|
43
|
+
|
|
44
|
+
## Organizing principle
|
|
45
|
+
|
|
46
|
+
The top level groups tests by node topology and setup model; the second level names the primary
|
|
47
|
+
behavior under test, not the shared setup or a flag. Multiple-blocks-per-slot and proposer pipelining
|
|
48
|
+
are default traits of block production here, not separate categories. Each file has a single top-level
|
|
49
|
+
`describe` named to match its path, and a co-located `setup.ts` holds shared setup. A `.parallel`
|
|
50
|
+
suffix marks files with more than one top-level `it`; CI splits each `it` into its own job.
|
|
51
|
+
|
|
52
|
+
## Subfolders
|
|
53
|
+
|
|
54
|
+
| Folder | Base / preset | Contents |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `block-production/` | `MultiNodeTestContext` + wide-slot / block-production timing (`setup.ts`) | Happy-path committee block production with multiple blocks per slot and pipelining as the default cadence: `simple`, `high_tps`, `first_slot` (blocks on the first two slots of an epoch), `deploy_and_call_ordering` (a contract deployed and called in separate blocks of one slot), `cross_chain_messages.parallel` (multi-block slots carrying L2→L1 and L1→L2 messages), `proposed_chain.parallel` (txs anchored to proposed blocks; non-validators re-execute and sync multi-block slots), `proof_boundary.parallel` (the proof-submission deadline vs. the pipelining boundary slot, across five proof-landing scenarios), `redistribution.parallel` (checkpoint budget redistributed so a late tx burst fits across the last blocks), `blob_promotion` (a promotion-disabled node fetches blobs while peers skip them, and a high-block-count checkpoint still proves), `multi_validator_node.parallel` (one physical node hosting 5 validator keys builds blocks and collects quorum attestations; after withdrawing 2 validators, signing is filtered to the active committee only). |
|
|
57
|
+
| `recovery/` | `MultiNodeTestContext` + wide-slot / block-production timing | The chain detects a bad/withheld/conflicting proposal and recovers: `proposal_failure_recovery.parallel` (all nodes prune and recover when a proposer fails to publish to L1), `pipeline_prune` (an uncheckpointed-blocks prune under pipelined MBPS, then recovery to a multi-block checkpoint), `equivocation_recovery` (an L1-confirmed checkpoint overrides a gossip-only equivocating proposal, the chain heals, and observers record the offense). |
|
|
58
|
+
| `invalid-attestations/` | `MultiNodeTestContext` (slasher on) | Invalid checkpoints are detected, invalidated on L1, and the chain progresses: `invalidate_block.parallel`, a six-validator suite injecting insufficient/fake/high-s/unrecoverable/shuffled attestations and withheld blobs. |
|
|
59
|
+
| `high-availability/` | `MultiNodeTestContext` + `setupHaPairs` | HA-pair sync and handoff between nodes that share validator keys: `ha_sync` (a peer that did not build a block syncs to the proposed chain tip over P2P), `ha_checkpoint_handoff` (a peer records and takes over a pipelined checkpoint when its partner proposes the previous slot). |
|
|
60
|
+
| `slashing/` | `MultiNodeTestContext` + `SLASHER_ENABLED_MULTI_VALIDATOR_OPTS` (`setup.ts`) | Offense detection and the sentinel that drives it. Equivocation — both duplicate-proposal and duplicate-attestation — (`equivocation_offenses`), broadcast of an invalid block or checkpoint proposal (`broadcasted_invalid_block_proposal_slash`, `broadcasted_invalid_checkpoint_proposal_slash.parallel`), attesting to an invalid checkpoint (`attested_invalid_proposal.parallel`), data withholding (`data_withholding_slash`), inactivity (`inactivity_slash`, `inactivity_slash_with_consecutive_epochs`, sharing the `InactivityTest` fixture in `inactivity_setup.ts`), the slasher veto path (`slash_veto_demo`), and sentinel observability (`validators_sentinel.parallel`, `multiple_validators_sentinel.parallel`, `sentinel_status_slash.parallel`). `setup.ts` holds the two timing profiles (`baseSlashingOpts`, `SENTINEL_TIMING`), the shared offense lookup (`findSlashOffense`), and the slashing waiters (`awaitCommitteeExists`, `awaitOffenseDetected`, `advanceToEpochBeforeProposer`, `findUpcomingProposerSlot`, `awaitCommitteeKicked`, `awaitProposalExecution`). |
|
|
61
|
+
| `governance/` | `MultiNodeTestContext` + `MOCK_GOSSIP_MULTI_VALIDATOR_OPTS` + `GOVERNANCE_TIMING` (`setup.ts`) | A validator committee drives an L1 governance upgrade. `upgrade_governance_proposer` (the committee signals a new governance-proposer payload, reaches quorum, and the proposal executes) and `add_rollup` (a new rollup version is registered and the nodes migrate to it, exercising L1↔L2 bridging on both rollups). |
|
|
62
|
+
|
|
63
|
+
## Helper surface
|
|
64
|
+
|
|
65
|
+
Prefer these named waiters over hand-rolled `retryUntil` / raw `.on` / `sleep` polling in test bodies.
|
|
66
|
+
|
|
67
|
+
On `SingleNodeTestContext` (inherited):
|
|
68
|
+
|
|
69
|
+
- `waitUntilEpochStarts(epoch)` / `waitUntilNextEpochStarts()` — epoch-boundary waiters.
|
|
70
|
+
- `waitUntilCheckpointNumber(n)` / `waitUntilProvenCheckpointNumber(n)` — checkpoint waiters.
|
|
71
|
+
- `waitUntilLastSlotOfProofSubmissionWindow(epoch)` — proof-window timing.
|
|
72
|
+
- `waitForNodeToSync(blockNumber, type)` — single-node sync wait.
|
|
73
|
+
- `watchSequencerEvents(sequencers, …)` accumulates state-changes and fail-events across sequencers;
|
|
74
|
+
`assertNoFailuresFromSequencers(failEvents)` asserts none fired.
|
|
75
|
+
- `waitForSequencerEvent(sequencer, event, match?, opts)` — one-shot wait for a matching event, with
|
|
76
|
+
timeout and listener cleanup.
|
|
77
|
+
- `assertMultipleBlocksPerSlot(n)` — asserts some checkpoint has at least `n` blocks (MBPS).
|
|
78
|
+
|
|
79
|
+
Added by `MultiNodeTestContext`:
|
|
80
|
+
|
|
81
|
+
- `waitForAllNodes(predicate, opts)` and the conveniences
|
|
82
|
+
`waitForAllNodesToReachProvenCheckpoint(target, opts)` and
|
|
83
|
+
`waitForAllNodesToReachBlockAtSlot(slot, tag, match?, opts)` — multi-node convergence.
|
|
84
|
+
- `findSlotsWithProposers(count, predicate, opts)` — finds N consecutive slots whose proposers
|
|
85
|
+
satisfy `predicate`, warping the L1 clock forward and retrying on `EpochNotStable`.
|
|
86
|
+
|
|
87
|
+
On `ChainMonitor` (`@aztec/ethereum/test`):
|
|
88
|
+
|
|
89
|
+
- `waitUntilCheckpoint(n)` / `waitUntilCheckpointProven(n)`, `waitUntilL2Slot(slot)`,
|
|
90
|
+
`waitUntilL1Block` / `waitUntilL1Timestamp`.
|
|
91
|
+
|
|
92
|
+
Node-only / wallet-only waits (no context dependency) live in `../fixtures/wait_helpers.ts`:
|
|
93
|
+
|
|
94
|
+
- `waitForBlockNumber(node, target, { tag })` / `waitForProvenBlock(node, target)`.
|
|
95
|
+
- `waitForNodeCheckpoint(node, target, opts)` / `waitForNodeProvenCheckpoint(node, target)`.
|
|
96
|
+
- `waitForTxs(node, txHashes, opts)` — the plural form of `waitForTx`.
|