|
1 | 1 | //! Contains tests related to RN and EN sync.
|
2 | 2 |
|
| 3 | +use alloy_primitives::b256; |
3 | 4 | use alloy_provider::{Provider, ProviderBuilder};
|
4 | 5 | use futures::StreamExt;
|
| 6 | +use reqwest::Url; |
5 | 7 | use reth_e2e_test_utils::NodeHelperType;
|
6 |
| -use reth_scroll_chainspec::SCROLL_DEV; |
| 8 | +use reth_provider::{BlockIdReader, BlockReader}; |
| 9 | +use reth_scroll_chainspec::{SCROLL_DEV, SCROLL_SEPOLIA}; |
7 | 10 | use rollup_node::{
|
8 | 11 | test_utils::{
|
9 | 12 | default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
|
10 | 13 | setup_engine,
|
11 | 14 | },
|
12 |
| - ScrollRollupNode, |
| 15 | + BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, NetworkArgs, |
| 16 | + ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs, |
13 | 17 | };
|
14 | 18 | use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent};
|
15 | 19 | use tokio::sync::oneshot;
|
16 | 20 |
|
| 21 | +#[tokio::test] |
| 22 | +async fn test_should_consolidate_to_block_15k() -> eyre::Result<()> { |
| 23 | + reth_tracing::init_test_tracing(); |
| 24 | + |
| 25 | + // Prepare the config for a L1 consolidation. |
| 26 | + let alchemy_key = std::env::var("ALCHEMY_KEY")?; |
| 27 | + let node_config = ScrollRollupNodeConfig { |
| 28 | + test: false, |
| 29 | + network_args: NetworkArgs { |
| 30 | + enable_eth_scroll_wire_bridge: false, |
| 31 | + enable_scroll_wire: false, |
| 32 | + }, |
| 33 | + database_args: DatabaseArgs::default(), |
| 34 | + l1_provider_args: L1ProviderArgs { |
| 35 | + url: Some(Url::parse(&format!("https://eth-sepolia.g.alchemy.com/v2/{alchemy_key}"))?), |
| 36 | + compute_units_per_second: 500, |
| 37 | + max_retries: 10, |
| 38 | + initial_backoff: 100, |
| 39 | + }, |
| 40 | + engine_driver_args: EngineDriverArgs { |
| 41 | + en_sync_trigger: 10000000000, |
| 42 | + sync_at_startup: false, |
| 43 | + }, |
| 44 | + sequencer_args: SequencerArgs { sequencer_enabled: false, ..Default::default() }, |
| 45 | + beacon_provider_args: BeaconProviderArgs { |
| 46 | + url: Some(Url::parse("https://eth-beacon-chain.drpc.org/rest/")?), |
| 47 | + compute_units_per_second: 100, |
| 48 | + max_retries: 10, |
| 49 | + initial_backoff: 100, |
| 50 | + }, |
| 51 | + signer_args: Default::default(), |
| 52 | + }; |
| 53 | + |
| 54 | + let chain_spec = (*SCROLL_SEPOLIA).clone(); |
| 55 | + let (mut nodes, _tasks, _) = setup_engine(node_config, 1, chain_spec.clone(), false).await?; |
| 56 | + let node = nodes.pop().unwrap(); |
| 57 | + |
| 58 | + // We perform consolidation up to block 15k. This allows us to capture a batch revert event at |
| 59 | + // block 11419 (batch 1653). |
| 60 | + while node.inner.provider.safe_block_num_hash()?.map(|x| x.number).unwrap_or_default() < 15000 { |
| 61 | + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await |
| 62 | + } |
| 63 | + |
| 64 | + let block_hash_15k = node.inner.provider.block(15000.into())?.unwrap(); |
| 65 | + |
| 66 | + assert_eq!( |
| 67 | + block_hash_15k.hash_slow(), |
| 68 | + b256!("86901ebce1840ee45c1d5c70bf85ce6924f7a066ef11575d0f381858c83845d4") |
| 69 | + ); |
| 70 | + |
| 71 | + Ok(()) |
| 72 | +} |
| 73 | + |
17 | 74 | /// We test if the syncing of the RN is correctly triggered and released when the EN reaches sync.
|
18 | 75 | #[allow(clippy::large_stack_frames)]
|
19 | 76 | #[tokio::test]
|
|
0 commit comments