Skip to content

Commit 6fdb2fb

Browse files
authored
fix: L1 consolidation (#216)
* test: move sync test from pure CI to e2e * test: increase time out and fix integration * feat: only run sync on push to main
1 parent 44267a9 commit 6fdb2fb

File tree

3 files changed

+94
-38
lines changed

3 files changed

+94
-38
lines changed

.github/workflows/sync.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: sync
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
sync:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 25
18+
env:
19+
RUST_BACKTRACE: 1
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: rui314/setup-mold@v1
23+
- uses: dtolnay/rust-toolchain@stable
24+
- uses: Swatinem/rust-cache@v2
25+
with:
26+
cache-on-failure: true
27+
- name: Run consolidation test
28+
env:
29+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
30+
RUST_LOG: "sqlx=off,info,scroll::engine=debug"
31+
run: |
32+
cargo test --release -p rollup-node test_should_consolidate_to_block_15k

.github/workflows/test.yaml

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,7 @@ jobs:
5151
with:
5252
5353
- name: Run integration tests
54-
run: cargo nextest run --all-features --workspace --locked --no-tests=pass -E 'kind(test)'
55-
56-
sync:
57-
runs-on: ubuntu-latest
58-
timeout-minutes: 15
59-
env:
60-
RUST_BACKTRACE: 1
61-
steps:
62-
- uses: actions/checkout@v4
63-
- uses: rui314/setup-mold@v1
64-
- uses: dtolnay/rust-toolchain@stable
65-
- uses: Swatinem/rust-cache@v2
66-
with:
67-
cache-on-failure: true
68-
- uses: foundry-rs/foundry-toolchain@v1
69-
- name: Start rollup node
70-
env:
71-
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
72-
run: |
73-
cargo run --bin rollup-node --release -- \
74-
node --chain scroll-sepolia --datadir=./l2reth --disable-discovery \
75-
--http --http.addr=0.0.0.0 --http.port=8545 --http.api eth \
76-
--trusted-peers enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303 \
77-
--log.stdout.format log-fmt -vvv \
78-
--l1.url "https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_KEY" --l1.cups 500 \
79-
--beacon.url https://eth-beacon-chain.drpc.org/rest/ --beacon.cups 100 --engine.en-sync-trigger 10000000000 \
80-
--engine.sync-at-startup=false --engine.always-process-payload-attributes-on-canonical-head &
81-
- name: Get hash for block 50000
8254
run: |
83-
echo "Waiting for block 50000..."
84-
while ! cast block 50000 --rpc-url http://localhost:8545 2>/dev/null | grep -q hash; do
85-
sleep 10
86-
done
87-
echo "Block 50000 found!"
88-
89-
EXPECTED_HASH="0x8333d8cd1274d49dcf9b130971d1b485a01f2a2604e73ea7caf9d721fbdf5859"
90-
cast block 50000 --rpc-url http://localhost:8545 | grep -q "$EXPECTED_HASH"
55+
cargo nextest run --all-features --workspace --locked \
56+
--no-tests=pass -E 'kind(test)' \
57+
-- --skip test_should_consolidate_to_block_15k

crates/node/tests/sync.rs

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,76 @@
11
//! Contains tests related to RN and EN sync.
22
3+
use alloy_primitives::b256;
34
use alloy_provider::{Provider, ProviderBuilder};
45
use futures::StreamExt;
6+
use reqwest::Url;
57
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};
710
use rollup_node::{
811
test_utils::{
912
default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
1013
setup_engine,
1114
},
12-
ScrollRollupNode,
15+
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, NetworkArgs,
16+
ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
1317
};
1418
use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent};
1519
use tokio::sync::oneshot;
1620

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+
1774
/// We test if the syncing of the RN is correctly triggered and released when the EN reaches sync.
1875
#[allow(clippy::large_stack_frames)]
1976
#[tokio::test]

0 commit comments

Comments
 (0)