@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.0b941701
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bench/client_flows/benchmark.d.ts +62 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +281 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +79 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +321 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +79 -0
- package/dest/bench/utils.d.ts +16 -41
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +41 -72
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +26 -19
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +114 -102
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +32 -32
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +104 -104
- package/dest/e2e_deploy_contract/deploy_test.d.ts +19 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +26 -27
- package/dest/e2e_epochs/epochs_test.d.ts +65 -22
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +236 -49
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +61 -0
- package/dest/e2e_fees/fees_test.d.ts +38 -23
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +162 -183
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +62 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +15 -15
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +37 -41
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +136 -0
- package/dest/e2e_p2p/p2p_network.d.ts +281 -27
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +237 -175
- package/dest/e2e_p2p/shared.d.ts +44 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +165 -27
- package/dest/e2e_token_contract/token_contract_test.d.ts +27 -14
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +96 -74
- package/dest/fixtures/e2e_prover_test.d.ts +55 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.js +278 -0
- package/dest/fixtures/fixtures.d.ts +6 -8
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +5 -5
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +3 -15
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +11 -7
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +45 -19
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup.d.ts +218 -0
- package/dest/fixtures/setup.d.ts.map +1 -0
- package/dest/fixtures/setup.js +690 -0
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +82 -22
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +31 -12
- package/dest/fixtures/utils.d.ts +5 -153
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +4 -552
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +2 -2
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -1
- package/dest/fixtures/with_telemetry_utils.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/grafana_client.d.ts +41 -0
- package/dest/quality_of_service/grafana_client.d.ts.map +1 -0
- package/dest/quality_of_service/{alert_checker.js → grafana_client.js} +1 -1
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/shared/cross_chain_test_harness.d.ts +44 -27
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +105 -51
- package/dest/shared/gas_portal_test_harness.d.ts +33 -25
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +2 -2
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +15 -16
- package/dest/shared/uniswap_l1_l2.d.ts +3 -25
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +176 -126
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -7
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +17 -18
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +27 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +233 -62
- package/dest/spartan/tx_metrics.d.ts +54 -0
- package/dest/spartan/tx_metrics.d.ts.map +1 -0
- package/dest/spartan/tx_metrics.js +272 -0
- package/dest/spartan/utils/bot.d.ts +27 -0
- package/dest/spartan/utils/bot.d.ts.map +1 -0
- package/dest/spartan/utils/bot.js +141 -0
- package/dest/spartan/utils/chaos.d.ts +79 -0
- package/dest/spartan/utils/chaos.d.ts.map +1 -0
- package/dest/spartan/utils/chaos.js +142 -0
- package/dest/spartan/utils/clients.d.ts +39 -0
- package/dest/spartan/utils/clients.d.ts.map +1 -0
- package/dest/spartan/utils/clients.js +90 -0
- package/dest/spartan/utils/config.d.ts +36 -0
- package/dest/spartan/utils/config.d.ts.map +1 -0
- package/dest/spartan/utils/config.js +20 -0
- package/dest/spartan/utils/health.d.ts +63 -0
- package/dest/spartan/utils/health.d.ts.map +1 -0
- package/dest/spartan/utils/health.js +202 -0
- package/dest/spartan/utils/helm.d.ts +15 -0
- package/dest/spartan/utils/helm.d.ts.map +1 -0
- package/dest/spartan/utils/helm.js +47 -0
- package/dest/spartan/utils/index.d.ts +9 -0
- package/dest/spartan/utils/index.d.ts.map +1 -0
- package/dest/spartan/utils/index.js +18 -0
- package/dest/spartan/utils/k8s.d.ts +98 -0
- package/dest/spartan/utils/k8s.d.ts.map +1 -0
- package/dest/spartan/utils/k8s.js +257 -0
- package/dest/spartan/utils/nodes.d.ts +31 -0
- package/dest/spartan/utils/nodes.d.ts.map +1 -0
- package/dest/spartan/utils/nodes.js +290 -0
- package/dest/spartan/utils/scripts.d.ts +16 -0
- package/dest/spartan/utils/scripts.d.ts.map +1 -0
- package/dest/spartan/utils/scripts.js +66 -0
- package/dest/spartan/utils.d.ts +2 -415
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +1 -445
- package/package.json +66 -58
- package/src/bench/client_flows/benchmark.ts +363 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +384 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +41 -85
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +134 -169
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +156 -182
- package/src/e2e_deploy_contract/deploy_test.ts +40 -48
- package/src/e2e_epochs/epochs_test.ts +315 -76
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +220 -258
- package/src/e2e_l1_publisher/write_json.ts +82 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +46 -59
- package/src/e2e_p2p/inactivity_slash_test.ts +179 -0
- package/src/e2e_p2p/p2p_network.ts +341 -234
- package/src/e2e_p2p/shared.ts +253 -40
- package/src/e2e_token_contract/token_contract_test.ts +115 -126
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +336 -0
- package/src/fixtures/fixtures.ts +5 -7
- package/src/fixtures/get_acvm_config.ts +4 -12
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +56 -24
- package/src/fixtures/setup.ts +1017 -0
- package/src/fixtures/setup_p2p_test.ts +127 -39
- package/src/fixtures/token_utils.ts +33 -15
- package/src/fixtures/utils.ts +27 -820
- package/src/fixtures/web3signer.ts +63 -0
- package/src/fixtures/with_telemetry_utils.ts +2 -2
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/{alert_checker.ts → grafana_client.ts} +2 -2
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/shared/cross_chain_test_harness.ts +103 -91
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/index.ts +1 -1
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +18 -20
- package/src/shared/uniswap_l1_l2.ts +197 -221
- package/src/simulators/lending_simulator.ts +16 -17
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +128 -0
- package/src/spartan/setup_test_wallets.ts +308 -95
- package/src/spartan/tx_metrics.ts +250 -0
- package/src/spartan/utils/bot.ts +185 -0
- package/src/spartan/utils/chaos.ts +253 -0
- package/src/spartan/utils/clients.ts +100 -0
- package/src/spartan/utils/config.ts +26 -0
- package/src/spartan/utils/health.ts +255 -0
- package/src/spartan/utils/helm.ts +84 -0
- package/src/spartan/utils/index.ts +62 -0
- package/src/spartan/utils/k8s.ts +375 -0
- package/src/spartan/utils/nodes.ts +323 -0
- package/src/spartan/utils/scripts.ts +63 -0
- package/src/spartan/utils.ts +1 -582
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/e2e_prover/e2e_prover_test.js +0 -291
- package/dest/fixtures/setup_l1_contracts.d.ts +0 -6
- package/dest/fixtures/setup_l1_contracts.d.ts.map +0 -1
- package/dest/fixtures/setup_l1_contracts.js +0 -17
- package/dest/fixtures/snapshot_manager.d.ts +0 -87
- package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
- package/dest/fixtures/snapshot_manager.js +0 -479
- package/dest/quality_of_service/alert_checker.d.ts +0 -41
- package/dest/quality_of_service/alert_checker.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/e2e_prover/e2e_prover_test.ts +0 -418
- package/src/fixtures/setup_l1_contracts.ts +0 -27
- package/src/fixtures/snapshot_manager.ts +0 -617
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -1,20 +1,40 @@
|
|
|
1
|
-
import { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { getTimestampRangeForEpoch } from '@aztec/aztec.js/block';
|
|
3
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
6
|
+
import { MerkleTreeId } from '@aztec/aztec.js/trees';
|
|
7
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { EpochCache } from '@aztec/epoch-cache';
|
|
9
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
10
|
+
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
|
|
4
11
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
-
import { DelayedTxUtils, type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/test';
|
|
6
|
-
import {
|
|
12
|
+
import { ChainMonitor, DelayedTxUtils, type Delayer, waitUntilL1Timestamp, withDelayer } from '@aztec/ethereum/test';
|
|
13
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
14
|
+
import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
15
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
16
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
7
17
|
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
8
|
-
import {
|
|
18
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
19
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
20
|
+
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
21
|
+
import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
22
|
+
import { ProverNode, type ProverNodeConfig, ProverNodePublisher } from '@aztec/prover-node';
|
|
9
23
|
import type { TestProverNode } from '@aztec/prover-node/test';
|
|
10
|
-
import
|
|
24
|
+
import {
|
|
25
|
+
type SequencerClient,
|
|
26
|
+
type SequencerEvents,
|
|
27
|
+
type SequencerPublisher,
|
|
28
|
+
SequencerState,
|
|
29
|
+
} from '@aztec/sequencer-client';
|
|
11
30
|
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
12
|
-
import type
|
|
13
|
-
import type
|
|
14
|
-
import {
|
|
31
|
+
import { type BlockParameter, EthAddress } from '@aztec/stdlib/block';
|
|
32
|
+
import { type L1RollupConstants, getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
33
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
15
34
|
|
|
16
35
|
import { join } from 'path';
|
|
17
|
-
import type { Hex
|
|
36
|
+
import type { Hex } from 'viem';
|
|
37
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
18
38
|
|
|
19
39
|
import {
|
|
20
40
|
type EndToEndContext,
|
|
@@ -24,15 +44,20 @@ import {
|
|
|
24
44
|
setup,
|
|
25
45
|
} from '../fixtures/utils.js';
|
|
26
46
|
|
|
27
|
-
// This can be lowered to as much as 2s in non-CI
|
|
28
|
-
export const L1_BLOCK_TIME_IN_S = process.env.L1_BLOCK_TIME ? parseInt(process.env.L1_BLOCK_TIME) : 8;
|
|
29
|
-
export const EPOCH_DURATION_IN_L2_SLOTS = 4;
|
|
30
|
-
export const L2_SLOT_DURATION_IN_L1_SLOTS = 2;
|
|
31
47
|
export const WORLD_STATE_BLOCK_HISTORY = 2;
|
|
32
48
|
export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
|
|
33
49
|
export const ARCHIVER_POLL_INTERVAL = 50;
|
|
50
|
+
export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
|
|
51
|
+
|
|
52
|
+
export type EpochsTestOpts = Partial<SetupOptions> & { numberOfAccounts?: number };
|
|
34
53
|
|
|
35
|
-
export type
|
|
54
|
+
export type TrackedSequencerEvent = {
|
|
55
|
+
[K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
|
|
56
|
+
type: K;
|
|
57
|
+
sequencerIndex: number;
|
|
58
|
+
validator: EthAddress;
|
|
59
|
+
};
|
|
60
|
+
}[keyof SequencerEvents];
|
|
36
61
|
|
|
37
62
|
/**
|
|
38
63
|
* Tests building of epochs using fast block times and short epochs.
|
|
@@ -41,79 +66,127 @@ export type EpochsTestOpts = Partial<Pick<SetupOptions, 'startProverNode'>>;
|
|
|
41
66
|
*/
|
|
42
67
|
export class EpochsTestContext {
|
|
43
68
|
public context!: EndToEndContext;
|
|
44
|
-
public l1Client!:
|
|
69
|
+
public l1Client!: ExtendedViemWalletClient;
|
|
45
70
|
public rollup!: RollupContract;
|
|
46
71
|
public constants!: L1RollupConstants;
|
|
47
72
|
public logger!: Logger;
|
|
48
73
|
public monitor!: ChainMonitor;
|
|
74
|
+
public epochCache!: EpochCache;
|
|
49
75
|
public proverDelayer!: Delayer;
|
|
50
76
|
public sequencerDelayer!: Delayer;
|
|
51
77
|
|
|
52
78
|
public proverNodes: ProverNode[] = [];
|
|
53
79
|
public nodes: AztecNodeService[] = [];
|
|
54
80
|
|
|
81
|
+
public epochDuration!: number;
|
|
82
|
+
|
|
83
|
+
public L1_BLOCK_TIME_IN_S!: number;
|
|
84
|
+
public L2_SLOT_DURATION_IN_S!: number;
|
|
85
|
+
|
|
55
86
|
public static async setup(opts: EpochsTestOpts = {}) {
|
|
56
87
|
const test = new EpochsTestContext();
|
|
57
88
|
await test.setup(opts);
|
|
58
89
|
return test;
|
|
59
90
|
}
|
|
60
91
|
|
|
92
|
+
public static getSlotDurations(opts: EpochsTestOpts = {}) {
|
|
93
|
+
const envEthereumSlotDuration = process.env.L1_BLOCK_TIME
|
|
94
|
+
? parseInt(process.env.L1_BLOCK_TIME)
|
|
95
|
+
: DEFAULT_L1_BLOCK_TIME;
|
|
96
|
+
const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
|
|
97
|
+
const aztecSlotDuration = opts.aztecSlotDuration ?? ethereumSlotDuration * 2;
|
|
98
|
+
const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
|
|
99
|
+
const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
|
|
100
|
+
const l1PublishingTime = opts.l1PublishingTime ?? 1;
|
|
101
|
+
return {
|
|
102
|
+
l1PublishingTime,
|
|
103
|
+
ethereumSlotDuration,
|
|
104
|
+
aztecSlotDuration,
|
|
105
|
+
aztecEpochDuration,
|
|
106
|
+
aztecProofSubmissionEpochs,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
61
110
|
public async setup(opts: EpochsTestOpts = {}) {
|
|
111
|
+
const {
|
|
112
|
+
ethereumSlotDuration,
|
|
113
|
+
aztecSlotDuration,
|
|
114
|
+
aztecEpochDuration,
|
|
115
|
+
aztecProofSubmissionEpochs,
|
|
116
|
+
l1PublishingTime,
|
|
117
|
+
} = EpochsTestContext.getSlotDurations(opts);
|
|
118
|
+
|
|
119
|
+
this.L1_BLOCK_TIME_IN_S = ethereumSlotDuration;
|
|
120
|
+
this.L2_SLOT_DURATION_IN_S = aztecSlotDuration;
|
|
121
|
+
|
|
62
122
|
// Set up system without any account nor protocol contracts
|
|
63
123
|
// and with faster block times and shorter epochs.
|
|
64
|
-
const context = await setup(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
124
|
+
const context = await setup(
|
|
125
|
+
opts.numberOfAccounts ?? 0,
|
|
126
|
+
{
|
|
127
|
+
automineL1Setup: true,
|
|
128
|
+
checkIntervalMs: 50,
|
|
129
|
+
archiverPollingIntervalMS: ARCHIVER_POLL_INTERVAL,
|
|
130
|
+
worldStateBlockCheckIntervalMS: WORLD_STATE_BLOCK_CHECK_INTERVAL,
|
|
131
|
+
aztecEpochDuration,
|
|
132
|
+
aztecSlotDuration,
|
|
133
|
+
ethereumSlotDuration,
|
|
134
|
+
aztecProofSubmissionEpochs,
|
|
135
|
+
aztecTargetCommitteeSize: opts.initialValidators?.length ?? 0,
|
|
136
|
+
minTxsPerBlock: 0,
|
|
137
|
+
realProofs: false,
|
|
138
|
+
startProverNode: true,
|
|
139
|
+
proverTestDelayMs: opts.proverTestDelayMs ?? 0,
|
|
140
|
+
// We use numeric incremental prover ids for simplicity, but we can switch to
|
|
141
|
+
// using the prover's eth address if the proverId is used for something in the rollup contract
|
|
142
|
+
// Use numeric EthAddress for deterministic prover id
|
|
143
|
+
proverId: EthAddress.fromNumber(1),
|
|
144
|
+
worldStateBlockHistory: WORLD_STATE_BLOCK_HISTORY,
|
|
145
|
+
exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
|
|
146
|
+
slasherFlavor: 'none',
|
|
147
|
+
l1PublishingTime,
|
|
148
|
+
...opts,
|
|
149
|
+
},
|
|
150
|
+
// Use checkpointed chain tip for PXE to avoid issues with blocks being dropped due to pruned anchor blocks.
|
|
151
|
+
{ syncChainTip: 'checkpointed' },
|
|
152
|
+
);
|
|
86
153
|
|
|
87
154
|
this.context = context;
|
|
88
155
|
this.proverNodes = context.proverNode ? [context.proverNode] : [];
|
|
89
156
|
this.nodes = context.aztecNode ? [context.aztecNode as AztecNodeService] : [];
|
|
90
157
|
this.logger = context.logger;
|
|
91
|
-
this.l1Client = context.deployL1ContractsValues.
|
|
158
|
+
this.l1Client = context.deployL1ContractsValues.l1Client;
|
|
92
159
|
this.rollup = RollupContract.getFromConfig(context.config);
|
|
160
|
+
this.epochCache = await EpochCache.create(this.rollup, context.config, { dateProvider: context.dateProvider });
|
|
93
161
|
|
|
94
162
|
// Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
|
|
95
|
-
this.monitor = new ChainMonitor(this.rollup, this.logger).start();
|
|
163
|
+
this.monitor = new ChainMonitor(this.rollup, context.dateProvider, this.logger).start();
|
|
96
164
|
|
|
97
165
|
// This is hideous.
|
|
98
166
|
// We ought to have a definite reference to the l1TxUtils that we're using in both places, provided by the test context.
|
|
99
167
|
this.proverDelayer = context.proverNode
|
|
100
168
|
? (((context.proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils).delayer!
|
|
101
169
|
: undefined!;
|
|
102
|
-
this.sequencerDelayer =
|
|
103
|
-
(
|
|
104
|
-
|
|
170
|
+
this.sequencerDelayer = context.sequencer
|
|
171
|
+
? (
|
|
172
|
+
((context.sequencer as TestSequencerClient).sequencer.publisher as SequencerPublisher)
|
|
173
|
+
.l1TxUtils as DelayedTxUtils
|
|
174
|
+
).delayer!
|
|
175
|
+
: undefined!;
|
|
105
176
|
|
|
106
|
-
if ((context.proverNode && !this.proverDelayer) || !this.sequencerDelayer) {
|
|
177
|
+
if ((context.proverNode && !this.proverDelayer) || (context.sequencer && !this.sequencerDelayer)) {
|
|
107
178
|
throw new Error(`Could not find prover or sequencer delayer`);
|
|
108
179
|
}
|
|
109
180
|
|
|
110
181
|
// Constants used for time calculation
|
|
182
|
+
this.epochDuration = aztecEpochDuration;
|
|
111
183
|
this.constants = {
|
|
112
|
-
epochDuration:
|
|
113
|
-
slotDuration:
|
|
184
|
+
epochDuration: aztecEpochDuration,
|
|
185
|
+
slotDuration: aztecSlotDuration,
|
|
114
186
|
l1StartBlock: await this.rollup.getL1StartBlock(),
|
|
115
187
|
l1GenesisTime: await this.rollup.getL1GenesisTime(),
|
|
116
|
-
ethereumSlotDuration
|
|
188
|
+
ethereumSlotDuration,
|
|
189
|
+
proofSubmissionEpochs: Number(await this.rollup.getProofSubmissionEpochs()),
|
|
117
190
|
};
|
|
118
191
|
|
|
119
192
|
this.logger.info(
|
|
@@ -122,38 +195,98 @@ export class EpochsTestContext {
|
|
|
122
195
|
}
|
|
123
196
|
|
|
124
197
|
public async teardown() {
|
|
125
|
-
this.monitor.stop();
|
|
126
|
-
await Promise.all(this.proverNodes.map(node => node.
|
|
127
|
-
await Promise.all(this.nodes.map(node => node.
|
|
198
|
+
await this.monitor.stop();
|
|
199
|
+
await Promise.all(this.proverNodes.map(node => tryStop(node, this.logger)));
|
|
200
|
+
await Promise.all(this.nodes.map(node => tryStop(node, this.logger)));
|
|
128
201
|
await this.context.teardown();
|
|
129
202
|
}
|
|
130
203
|
|
|
131
|
-
public async createProverNode() {
|
|
204
|
+
public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
|
|
132
205
|
this.logger.warn('Creating and syncing a simulated prover node...');
|
|
133
206
|
const proverNodePrivateKey = this.getNextPrivateKey();
|
|
134
207
|
const suffix = (this.proverNodes.length + 1).toString();
|
|
135
208
|
const proverNode = await withLogNameSuffix(suffix, () =>
|
|
136
209
|
createAndSyncProverNode(
|
|
137
210
|
proverNodePrivateKey,
|
|
138
|
-
{ ...this.context.config
|
|
211
|
+
{ ...this.context.config },
|
|
212
|
+
{
|
|
213
|
+
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
|
|
214
|
+
proverId: EthAddress.fromNumber(parseInt(suffix, 10)),
|
|
215
|
+
dontStart: opts.dontStart,
|
|
216
|
+
...opts,
|
|
217
|
+
},
|
|
139
218
|
this.context.aztecNode,
|
|
140
|
-
|
|
219
|
+
this.context.prefilledPublicData ?? [],
|
|
220
|
+
{ dateProvider: this.context.dateProvider },
|
|
141
221
|
),
|
|
142
222
|
);
|
|
143
223
|
this.proverNodes.push(proverNode);
|
|
144
224
|
return proverNode;
|
|
145
225
|
}
|
|
146
226
|
|
|
147
|
-
public
|
|
227
|
+
public createNonValidatorNode(opts: Partial<AztecNodeConfig> = {}) {
|
|
148
228
|
this.logger.warn('Creating and syncing a node without a validator...');
|
|
229
|
+
return this.createNode({ ...opts, disableValidator: true });
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public createValidatorNode(
|
|
233
|
+
privateKeys: `0x${string}`[],
|
|
234
|
+
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
235
|
+
) {
|
|
236
|
+
this.logger.warn('Creating and syncing a validator node...');
|
|
237
|
+
return this.createNode({ ...opts, disableValidator: false, validatorPrivateKeys: new SecretValue(privateKeys) });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private async createNode(
|
|
241
|
+
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
242
|
+
) {
|
|
149
243
|
const suffix = (this.nodes.length + 1).toString();
|
|
244
|
+
const { mockGossipSubNetwork } = this.context;
|
|
245
|
+
const resolvedConfig = { ...this.context.config, ...opts };
|
|
246
|
+
const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
|
|
247
|
+
const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
|
|
150
248
|
const node = await withLogNameSuffix(suffix, () =>
|
|
151
|
-
AztecNodeService.createAndSync(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
249
|
+
AztecNodeService.createAndSync(
|
|
250
|
+
{
|
|
251
|
+
...resolvedConfig,
|
|
252
|
+
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
|
|
253
|
+
validatorPrivateKeys: opts.validatorPrivateKeys ?? new SecretValue([]),
|
|
254
|
+
p2pEnabled,
|
|
255
|
+
p2pIp,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
dateProvider: this.context.dateProvider,
|
|
259
|
+
p2pClientDeps: {
|
|
260
|
+
p2pServiceFactory: mockGossipSubNetwork ? getMockPubSubP2PServiceFactory(mockGossipSubNetwork) : undefined,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
prefilledPublicData: this.context.prefilledPublicData,
|
|
265
|
+
...opts,
|
|
266
|
+
},
|
|
267
|
+
),
|
|
156
268
|
);
|
|
269
|
+
|
|
270
|
+
// REFACTOR: We're getting too much into the internals of the sequencer here.
|
|
271
|
+
// We should have a single method for constructing an aztec node that returns a TestAztecNodeService
|
|
272
|
+
// which directly exposes the delayer and sets any test config.
|
|
273
|
+
if (opts.txDelayerMaxInclusionTimeIntoSlot !== undefined) {
|
|
274
|
+
this.logger.info(
|
|
275
|
+
`Setting tx delayer max inclusion time into slot to ${opts.txDelayerMaxInclusionTimeIntoSlot} seconds`,
|
|
276
|
+
);
|
|
277
|
+
// Here we reach into the sequencer and hook in a tx delayer. The problem is that the sequencer's l1 utils only uses a public client, not a wallet.
|
|
278
|
+
// The delayer needs a wallet (a client that can sign), so we have to create one here.
|
|
279
|
+
const l1Client = createExtendedL1Client(
|
|
280
|
+
resolvedConfig.l1RpcUrls!,
|
|
281
|
+
resolvedConfig.publisherPrivateKeys![0]!.getValue(),
|
|
282
|
+
);
|
|
283
|
+
const sequencer = node.getSequencer() as TestSequencerClient;
|
|
284
|
+
const publisher = sequencer.sequencer.publisher;
|
|
285
|
+
const delayed = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, this.L1_BLOCK_TIME_IN_S, l1Client);
|
|
286
|
+
delayed.delayer!.setMaxInclusionTimeIntoSlot(opts.txDelayerMaxInclusionTimeIntoSlot);
|
|
287
|
+
publisher.l1TxUtils = delayed;
|
|
288
|
+
}
|
|
289
|
+
|
|
157
290
|
this.nodes.push(node);
|
|
158
291
|
return node;
|
|
159
292
|
}
|
|
@@ -165,53 +298,159 @@ export class EpochsTestContext {
|
|
|
165
298
|
|
|
166
299
|
/** Waits until the epoch begins (ie until the immediately previous L1 block is mined). */
|
|
167
300
|
public async waitUntilEpochStarts(epoch: number) {
|
|
168
|
-
const [start] = getTimestampRangeForEpoch(
|
|
301
|
+
const [start] = getTimestampRangeForEpoch(EpochNumber(epoch), this.constants);
|
|
169
302
|
this.logger.info(`Waiting until L1 timestamp ${start} is reached as the start of epoch ${epoch}`);
|
|
170
|
-
await waitUntilL1Timestamp(
|
|
303
|
+
await waitUntilL1Timestamp(
|
|
304
|
+
this.l1Client,
|
|
305
|
+
start - BigInt(this.L1_BLOCK_TIME_IN_S),
|
|
306
|
+
undefined,
|
|
307
|
+
30 * this.epochDuration,
|
|
308
|
+
);
|
|
171
309
|
return start;
|
|
172
310
|
}
|
|
173
311
|
|
|
174
|
-
/** Waits until the given
|
|
175
|
-
public async
|
|
312
|
+
/** Waits until the given checkpoint number is mined. */
|
|
313
|
+
public async waitUntilCheckpointNumber(target: CheckpointNumber, timeout = 120) {
|
|
176
314
|
await retryUntil(
|
|
177
|
-
() => Promise.resolve(target
|
|
178
|
-
`Wait until
|
|
315
|
+
() => Promise.resolve(target <= this.monitor.checkpointNumber),
|
|
316
|
+
`Wait until checkpoint ${target}`,
|
|
179
317
|
timeout,
|
|
180
318
|
0.1,
|
|
181
319
|
);
|
|
182
320
|
}
|
|
183
321
|
|
|
184
|
-
/** Waits until the given
|
|
185
|
-
public async
|
|
322
|
+
/** Waits until the given checkpoint number is marked as proven. */
|
|
323
|
+
public async waitUntilProvenCheckpointNumber(target: CheckpointNumber, timeout = 120) {
|
|
186
324
|
await retryUntil(
|
|
187
|
-
() => Promise.resolve(
|
|
188
|
-
`Wait proven
|
|
325
|
+
() => Promise.resolve(target <= this.monitor.provenCheckpointNumber),
|
|
326
|
+
`Wait proven checkpoint ${target}`,
|
|
189
327
|
timeout,
|
|
190
328
|
0.1,
|
|
191
329
|
);
|
|
330
|
+
return this.monitor.provenCheckpointNumber;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Waits until the last slot of the proof submission window for a given epoch. */
|
|
334
|
+
public async waitUntilLastSlotOfProofSubmissionWindow(epochNumber: number | bigint) {
|
|
335
|
+
const deadline = getProofSubmissionDeadlineTimestamp(EpochNumber.fromBigInt(BigInt(epochNumber)), this.constants);
|
|
336
|
+
const oneSlotBefore = deadline - BigInt(this.constants.slotDuration);
|
|
337
|
+
const date = new Date(Number(oneSlotBefore) * 1000);
|
|
338
|
+
this.logger.info(`Waiting until last slot of submission window for epoch ${epochNumber} at ${date}`, {
|
|
339
|
+
oneSlotBefore,
|
|
340
|
+
});
|
|
341
|
+
await waitUntilL1Timestamp(this.l1Client, oneSlotBefore);
|
|
192
342
|
}
|
|
193
343
|
|
|
194
344
|
/** Waits for the aztec node to sync to the target block number. */
|
|
195
|
-
public async waitForNodeToSync(blockNumber:
|
|
345
|
+
public async waitForNodeToSync(blockNumber: BlockNumber, type: 'proven' | 'finalized' | 'historic') {
|
|
196
346
|
const waitTime = ARCHIVER_POLL_INTERVAL + WORLD_STATE_BLOCK_CHECK_INTERVAL;
|
|
197
347
|
let synched = false;
|
|
198
348
|
while (!synched) {
|
|
199
349
|
await sleep(waitTime);
|
|
200
|
-
const syncState = await
|
|
201
|
-
|
|
202
|
-
|
|
350
|
+
const [syncState, tips] = await Promise.all([
|
|
351
|
+
this.context.aztecNode.getWorldStateSyncStatus(),
|
|
352
|
+
await this.context.aztecNode.getL2Tips(),
|
|
353
|
+
]);
|
|
354
|
+
this.logger.info(`Wait for node synch ${blockNumber} ${type}`, { blockNumber, type, syncState, tips });
|
|
355
|
+
if (type === 'proven') {
|
|
356
|
+
synched = tips.proven.block.number >= blockNumber && syncState.latestBlockNumber >= blockNumber;
|
|
357
|
+
} else if (type === 'finalized') {
|
|
358
|
+
synched = syncState.finalizedBlockNumber >= blockNumber;
|
|
203
359
|
} else {
|
|
204
360
|
synched = syncState.oldestHistoricBlockNumber >= blockNumber;
|
|
205
361
|
}
|
|
206
362
|
}
|
|
207
363
|
}
|
|
208
364
|
|
|
365
|
+
/** Registers the SpamContract on the given wallet. */
|
|
366
|
+
public async registerSpamContract(wallet: Wallet, salt = Fr.ZERO) {
|
|
367
|
+
const instance = await getContractInstanceFromInstantiationParams(SpamContract.artifact, {
|
|
368
|
+
constructorArgs: [],
|
|
369
|
+
constructorArtifact: undefined,
|
|
370
|
+
salt,
|
|
371
|
+
publicKeys: undefined,
|
|
372
|
+
deployer: undefined,
|
|
373
|
+
});
|
|
374
|
+
await wallet.registerContract(instance, SpamContract.artifact);
|
|
375
|
+
return SpamContract.at(instance.address, wallet);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */
|
|
379
|
+
public async createL1Client() {
|
|
380
|
+
const { client, delayer } = withDelayer(
|
|
381
|
+
createExtendedL1Client(
|
|
382
|
+
[...this.l1Client.chain.rpcUrls.default.http],
|
|
383
|
+
privateKeyToAccount(this.getNextPrivateKey()),
|
|
384
|
+
this.l1Client.chain,
|
|
385
|
+
),
|
|
386
|
+
this.context.dateProvider!,
|
|
387
|
+
{ ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S },
|
|
388
|
+
);
|
|
389
|
+
expect(await client.getBalance({ address: client.account.address })).toBeGreaterThan(0n);
|
|
390
|
+
return { client, delayer };
|
|
391
|
+
}
|
|
392
|
+
|
|
209
393
|
/** Verifies whether the given block number is found on the aztec node. */
|
|
210
|
-
public async verifyHistoricBlock(blockNumber:
|
|
394
|
+
public async verifyHistoricBlock(blockNumber: BlockParameter, expectedSuccess: boolean) {
|
|
395
|
+
// We use `findLeavesIndexes` here, but could use any function that queries the world-state
|
|
396
|
+
// at a particular block, so we know whether that historic block is available or has been
|
|
397
|
+
// pruned. Note that `getBlock` would not work here, since it only hits the archiver.
|
|
211
398
|
const result = await this.context.aztecNode
|
|
212
|
-
.
|
|
399
|
+
.findLeavesIndexes(blockNumber, MerkleTreeId.NULLIFIER_TREE, [Fr.ZERO])
|
|
213
400
|
.then(_ => true)
|
|
214
401
|
.catch(_ => false);
|
|
215
402
|
expect(result).toBe(expectedSuccess);
|
|
216
403
|
}
|
|
404
|
+
|
|
405
|
+
public watchSequencerEvents(
|
|
406
|
+
sequencers: SequencerClient[],
|
|
407
|
+
getMetadata: (i: number) => Record<string, any> = () => ({}),
|
|
408
|
+
) {
|
|
409
|
+
const stateChanges: TrackedSequencerEvent[] = [];
|
|
410
|
+
const failEvents: TrackedSequencerEvent[] = [];
|
|
411
|
+
|
|
412
|
+
// Note we do not include the 'block-tx-count-check-failed' event here, since it is fine if we dont build
|
|
413
|
+
// due to lack of txs available.
|
|
414
|
+
const failEventsKeys: (keyof SequencerEvents)[] = [
|
|
415
|
+
'block-build-failed',
|
|
416
|
+
'checkpoint-publish-failed',
|
|
417
|
+
'proposer-rollup-check-failed',
|
|
418
|
+
];
|
|
419
|
+
|
|
420
|
+
const makeEvent = (
|
|
421
|
+
i: number,
|
|
422
|
+
eventName: keyof SequencerEvents,
|
|
423
|
+
args: Parameters<SequencerEvents[keyof SequencerEvents]>[0],
|
|
424
|
+
) =>
|
|
425
|
+
({
|
|
426
|
+
...args,
|
|
427
|
+
type: eventName,
|
|
428
|
+
sequencerIndex: i + 2,
|
|
429
|
+
...getMetadata(i),
|
|
430
|
+
}) as TrackedSequencerEvent;
|
|
431
|
+
|
|
432
|
+
sequencers.forEach((sequencer, i) => {
|
|
433
|
+
const sequencerIndex = i + 2;
|
|
434
|
+
sequencer.getSequencer().on('state-changed', (args: Parameters<SequencerEvents['state-changed']>[0]) => {
|
|
435
|
+
const noisyStates = [SequencerState.IDLE, SequencerState.PROPOSER_CHECK, SequencerState.SYNCHRONIZING];
|
|
436
|
+
if (!noisyStates.includes(args.newState)) {
|
|
437
|
+
const evt = makeEvent(i, 'state-changed', args);
|
|
438
|
+
stateChanges.push(evt);
|
|
439
|
+
this.logger.verbose(
|
|
440
|
+
`Sequencer ${sequencerIndex} transitioned from state ${args.oldState} to state ${args.newState}`,
|
|
441
|
+
evt,
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
failEventsKeys.forEach(eventName => {
|
|
446
|
+
sequencer.getSequencer().on(eventName, (args: Parameters<SequencerEvents[typeof eventName]>[0]) => {
|
|
447
|
+
const evt = makeEvent(i, eventName, args);
|
|
448
|
+
failEvents.push(evt);
|
|
449
|
+
this.logger.error(`Failed event ${eventName} from sequencer ${sequencerIndex}`, undefined, evt);
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
return { failEvents, stateChanges };
|
|
455
|
+
}
|
|
217
456
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import { Fq } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
6
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
8
|
+
|
|
9
|
+
import { jest } from '@jest/globals';
|
|
10
|
+
import type { Hex } from 'viem';
|
|
11
|
+
|
|
12
|
+
import { FeesTest } from './fees_test.js';
|
|
13
|
+
|
|
14
|
+
jest.setTimeout(300_000);
|
|
15
|
+
|
|
16
|
+
// Regression for https://github.com/AztecProtocol/aztec-packages/issues/12366
|
|
17
|
+
// Similar to e2e_fees/account_init but with no automine
|
|
18
|
+
describe('e2e_fees bridging_race', () => {
|
|
19
|
+
const ETHEREUM_SLOT_DURATION = 4;
|
|
20
|
+
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
21
|
+
|
|
22
|
+
const t = new FeesTest('bridging_race', 1, {
|
|
23
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
24
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
25
|
+
minTxsPerBlock: 0,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
beforeAll(async () => {
|
|
29
|
+
await t.setup();
|
|
30
|
+
({ wallet, logger } = t);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterAll(async () => {
|
|
34
|
+
await t.teardown();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
let logger: Logger;
|
|
38
|
+
let bobsAddress: AztecAddress;
|
|
39
|
+
let wallet: TestWallet;
|
|
40
|
+
|
|
41
|
+
beforeEach(async () => {
|
|
42
|
+
const bobsSecretKey = Fr.random();
|
|
43
|
+
const bobsPrivateSigningKey = Fq.random();
|
|
44
|
+
const bobsSalt = Fr.random();
|
|
45
|
+
const bobsAccountManager = await wallet.createAccount({
|
|
46
|
+
secret: bobsSecretKey,
|
|
47
|
+
salt: bobsSalt,
|
|
48
|
+
contract: new SchnorrAccountContract(bobsPrivateSigningKey),
|
|
49
|
+
});
|
|
50
|
+
bobsAddress = bobsAccountManager.address;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('Alice bridges funds to Bob', async () => {
|
|
54
|
+
// Tweak the token manager so the bridging happens immediately before the end of the current L2 slot
|
|
55
|
+
// This caused the message to be "not in state" when tried to be used
|
|
56
|
+
const l1TokenManager = t.feeJuiceBridgeTestHarness.l1TokenManager;
|
|
57
|
+
const origApprove = l1TokenManager.approve.bind(l1TokenManager);
|
|
58
|
+
l1TokenManager.approve = async (amount: bigint, address: Hex, addressName = '') => {
|
|
59
|
+
await origApprove(amount, address, addressName);
|
|
60
|
+
const sleepTime = (Number(t.chainMonitor.checkpointTimestamp) + AZTEC_SLOT_DURATION) * 1000 - Date.now() - 500;
|
|
61
|
+
logger.info(`Sleeping for ${sleepTime}ms until near end of L2 slot before sending L1 fee juice to L2 inbox`);
|
|
62
|
+
await sleep(sleepTime);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Waiting for the archiver to sync the message _before_ waiting for the mandatory 2 L2 blocks to pass fixed it
|
|
66
|
+
// This was added everywhere we wait for two blocks, which is spread across three different places in the codebase
|
|
67
|
+
// Yes, we need to REFACTOR it at some point
|
|
68
|
+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(bobsAddress);
|
|
69
|
+
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
70
|
+
await t.feeJuiceContract.methods.claim(bobsAddress, claim.claimAmount, secret, index).send({ from: bobsAddress });
|
|
71
|
+
const [balance] = await t.getGasBalanceFn(bobsAddress);
|
|
72
|
+
expect(balance).toEqual(claim.claimAmount);
|
|
73
|
+
});
|
|
74
|
+
});
|