Skip to content

Commit 371bc70

Browse files
committed
fix: ci
1 parent d560c36 commit 371bc70

File tree

5 files changed

+51
-62
lines changed

5 files changed

+51
-62
lines changed

crates/node/src/args.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,15 @@ impl ScrollRollupNodeConfig {
366366
.filter(|_| !self.test_args.test || self.blob_provider_args.anvil_url.is_some())
367367
{
368368
tracing::info!(target: "scroll::node::args", ?l1_block_startup_info, "Starting L1 watcher");
369-
let (tx, rx) = L1Watcher::spawn(
370-
provider,
371-
l1_block_startup_info,
372-
node_config,
373-
self.l1_provider_args.logs_query_block_range,
374-
self.test_args.test && self.test_args.skip_l1_synced,
375-
)
376-
.await;
377-
(Some(tx), Some(rx))
369+
let (tx, rx) = L1Watcher::spawn(
370+
provider,
371+
l1_block_startup_info,
372+
node_config,
373+
self.l1_provider_args.logs_query_block_range,
374+
self.test_args.test && self.test_args.skip_l1_synced,
375+
)
376+
.await;
377+
(Some(tx), Some(rx))
378378
} else {
379379
// Create a channel for L1 notifications that we can use to inject L1 messages for
380380
// testing

crates/node/src/test_utils/fixture.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,12 @@ impl TestFixture {
216216
self.get_status(0).await
217217
}
218218

219-
/// Get the Anvil instance if one was started.
220-
pub const fn anvil(&self) -> Option<&anvil::NodeHandle> {
221-
self.anvil.as_ref()
222-
}
223-
224219
/// Get the Anvil HTTP endpoint if Anvil was started.
225220
pub fn anvil_endpoint(&self) -> Option<String> {
226221
self.anvil.as_ref().map(|a| a.http_endpoint())
227222
}
228223

229-
/// Generate Anvil blocks by calling anvil_mine RPC method.
224+
/// Generate Anvil blocks by calling `anvil_mine` RPC method.
230225
pub async fn anvil_mine_blocks(&self, num_blocks: u64) -> eyre::Result<()> {
231226
// Ensure Anvil is running
232227
let anvil_endpoint =
@@ -277,9 +272,7 @@ impl TestFixture {
277272
// Parameters: (depth, transactions)
278273
// - depth: number of blocks to rewind from current head
279274
// - transactions: empty array means reorg without adding new transactions
280-
let _: () = client
281-
.request("anvil_reorg", (depth, Vec::<String>::new()))
282-
.await?;
275+
let _: () = client.request("anvil_reorg", (depth, Vec::<String>::new())).await?;
283276

284277
tracing::info!("Reorged Anvil by {} blocks", depth);
285278

@@ -371,14 +364,14 @@ impl TestFixtureBuilder {
371364
}
372365

373366
/// Toggle the test field.
374-
pub fn with_test(mut self, test: bool) -> Self {
367+
pub const fn with_test(mut self, test: bool) -> Self {
375368
self.config.test_args.test = test;
376369
self
377370
}
378371

379372
/// Enable test mode to skip L1 watcher Synced notifications.
380373
/// This is useful for tests that don't want to wait for L1 sync completion events.
381-
pub fn skip_l1_synced_notifications(mut self) -> Self {
374+
pub const fn skip_l1_synced_notifications(mut self) -> Self {
382375
self.config.test_args.skip_l1_synced = true;
383376
self
384377
}
@@ -520,21 +513,15 @@ impl TestFixtureBuilder {
520513
&mut self.config
521514
}
522515

523-
/// Enable Anvil with default settings.
524-
pub const fn with_anvil(mut self) -> Self {
525-
self.enable_anvil = true;
526-
self
527-
}
528-
529516
/// Enable Anvil with the default state file (`./tests/testdata/anvil_state.json`).
530-
pub fn with_anvil_default_state(mut self) -> Self {
517+
pub fn with_anvil(mut self) -> Self {
531518
self.enable_anvil = true;
532519
self.anvil_state_path = Some(PathBuf::from("./tests/testdata/anvil_state.json"));
533520
self
534521
}
535522

536523
/// Enable Anvil with a custom state file.
537-
pub fn with_anvil_state(mut self, path: impl Into<PathBuf>) -> Self {
524+
pub fn with_anvil_custom_state(mut self, path: impl Into<PathBuf>) -> Self {
538525
self.enable_anvil = true;
539526
self.anvil_state_path = Some(path.into());
540527
self

crates/node/tests/l1_sync.rs

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
//! This test suite covers the behavior of the rollup node when consuming events from L1
44
//! in different sync states, handling reorgs, and recovering from shutdowns.
55
//!
6-
//! Related to: https://github.com/scroll-tech/rollup-node/issues/420
6+
//! Related to: <https://github.com/scroll-tech/rollup-node/issues/420>
77
88
use alloy_primitives::Bytes;
99
use rollup_node::test_utils::{EventAssertions, TestFixture};
1010
use serde_json::Value;
1111

12-
13-
/// Helper to read transaction from test_transactions.json
12+
/// Helper to read transaction from `test_transactions.json`
1413
fn read_test_transaction(tx_type: &str, index: &str) -> eyre::Result<Bytes> {
1514
let tx_json_path = "./tests/testdata/test_transactions.json";
1615
let tx_json_content = std::fs::read_to_string(tx_json_path)
@@ -43,18 +42,18 @@ fn read_test_transaction(tx_type: &str, index: &str) -> eyre::Result<Bytes> {
4342
// Test Suite 1: Correct behavior when consuming events from L1
4443
// =============================================================================
4544

46-
/// Test: BatchCommit during Syncing state should have no effect.
45+
/// Test: `BatchCommit` during Syncing state should have no effect.
4746
///
4847
/// Expected: The node should not update the safe head since we only process
49-
/// BatchCommit eventds after the node is synced (post L1Synced notification).
48+
/// `BatchCommit` eventds after the node is synced (post `L1Synced` notification).
5049
#[tokio::test]
5150
async fn test_l1_sync_batch_commit() -> eyre::Result<()> {
5251
reth_tracing::init_test_tracing();
5352

5453
let mut fixture = TestFixture::builder()
5554
.followers(1)
5655
.skip_l1_synced_notifications()
57-
.with_anvil_default_state()
56+
.with_anvil()
5857
.with_anvil_chain_id(22222222)
5958
.build()
6059
.await?;
@@ -94,15 +93,14 @@ async fn test_l1_sync_batch_commit() -> eyre::Result<()> {
9493
Ok(())
9594
}
9695

97-
9896
#[tokio::test]
9997
async fn test_l1_sync_batch_finalized() -> eyre::Result<()> {
10098
reth_tracing::init_test_tracing();
10199

102100
let mut fixture = TestFixture::builder()
103101
.followers(1)
104102
.skip_l1_synced_notifications()
105-
.with_anvil_default_state()
103+
.with_anvil()
106104
.with_anvil_chain_id(22222222)
107105
.build()
108106
.await?;
@@ -173,11 +171,13 @@ async fn test_l1_sync_batch_finalized() -> eyre::Result<()> {
173171
// Check that finalized head was updated
174172
let batch_finalized_status = fixture.get_sequencer_status().await?;
175173
assert!(
176-
batch_finalized_status.l2.fcs.safe_block_info().number == l1_synced_status.l2.fcs.safe_block_info().number,
174+
batch_finalized_status.l2.fcs.safe_block_info().number ==
175+
l1_synced_status.l2.fcs.safe_block_info().number,
177176
"Safe head should not advance after BatchFinalized event when L1 Synced"
178177
);
179178
assert!(
180-
batch_finalized_status.l2.fcs.finalized_block_info().number > l1_synced_status.l2.fcs.finalized_block_info().number,
179+
batch_finalized_status.l2.fcs.finalized_block_info().number >
180+
l1_synced_status.l2.fcs.finalized_block_info().number,
181181
"Finalized head should advance after BatchFinalized event when L1 Synced"
182182
);
183183

@@ -191,7 +191,7 @@ async fn test_l1_sync_batch_revert() -> eyre::Result<()> {
191191
let mut fixture = TestFixture::builder()
192192
.followers(1)
193193
.skip_l1_synced_notifications()
194-
.with_anvil_default_state()
194+
.with_anvil()
195195
.with_anvil_chain_id(22222222)
196196
.build()
197197
.await?;
@@ -206,10 +206,11 @@ async fn test_l1_sync_batch_revert() -> eyre::Result<()> {
206206
fixture.anvil_send_raw_transaction(commit_batch_tx).await?;
207207
}
208208

209+
fixture.anvil_mine_blocks(64).await?;
210+
211+
// Trigger L1 synced event
209212
fixture.l1().sync().await?;
210213
fixture.expect_event().l1_synced().await?;
211-
fixture.expect_event().batch_consolidated().await?;
212-
fixture.anvil_mine_blocks(64).await?;
213214

214215
// Wait for l1 blocks to be processed
215216
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
@@ -218,13 +219,13 @@ async fn test_l1_sync_batch_revert() -> eyre::Result<()> {
218219
let new_status = fixture.get_sequencer_status().await?;
219220
assert!(
220221
new_status.l2.fcs.safe_block_info().number > initial_safe,
221-
"Safe head should advance after BatchCommit when synced and L1Synced"
222+
"Safe head should advance after BatchCommit when L1Synced"
222223
);
223224

224225
// Send BatchRevert transactions
225226
let revert_batch_tx = read_test_transaction("revertBatch", "0")?;
226227
fixture.anvil_send_raw_transaction(revert_batch_tx).await?;
227-
fixture.anvil_mine_blocks(64).await?;
228+
fixture.anvil_mine_blocks(10).await?;
228229

229230
// Wait for l1 blocks to be processed
230231
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
@@ -243,18 +244,18 @@ async fn test_l1_sync_batch_revert() -> eyre::Result<()> {
243244
// Test Suite 2: L1 Reorg handling for different batch events
244245
// =============================================================================
245246

246-
/// Test: L1 reorg of BatchCommit after L1Synced.
247+
/// Test: L1 reorg of `BatchCommit` after `L1Synced`.
247248
///
248-
/// Expected: When a BatchCommit is reorged after the node has synced (L1Synced),
249-
/// the safe head should revert to the last block of the previous BatchCommit.
249+
/// Expected: When a `BatchCommit` is reorged after the node has synced (`L1Synced`),
250+
/// the safe head should revert to the last block of the previous `BatchCommit`.
250251
#[tokio::test]
251252
async fn test_l1_reorg_batch_commit() -> eyre::Result<()> {
252253
reth_tracing::init_test_tracing();
253254

254255
let mut fixture = TestFixture::builder()
255256
.followers(1)
256257
.skip_l1_synced_notifications()
257-
.with_anvil_default_state()
258+
.with_anvil()
258259
.with_anvil_chain_id(22222222)
259260
.build()
260261
.await?;
@@ -267,7 +268,9 @@ async fn test_l1_reorg_batch_commit() -> eyre::Result<()> {
267268
for i in 0..=3 {
268269
let commit_batch_tx = read_test_transaction("commitBatch", &i.to_string())?;
269270
fixture.anvil_send_raw_transaction(commit_batch_tx).await?;
270-
if i!=0 {fixture.expect_event().batch_consolidated().await?;}
271+
if i != 0 {
272+
fixture.expect_event().batch_consolidated().await?;
273+
}
271274
}
272275

273276
// Check that safe head was updated to batch 2
@@ -285,7 +288,8 @@ async fn test_l1_reorg_batch_commit() -> eyre::Result<()> {
285288
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
286289

287290
// Check that safe head advanced to batch 3
288-
let status_after_batch_6: rollup_node_chain_orchestrator::ChainOrchestratorStatus = fixture.get_sequencer_status().await?;
291+
let status_after_batch_6: rollup_node_chain_orchestrator::ChainOrchestratorStatus =
292+
fixture.get_sequencer_status().await?;
289293
let safe_after_batch_6 = status_after_batch_6.l2.fcs.safe_block_info().number;
290294
tracing::info!("Safe head after batch 6: {}", safe_after_batch_6);
291295
assert!(
@@ -311,10 +315,10 @@ async fn test_l1_reorg_batch_commit() -> eyre::Result<()> {
311315
Ok(())
312316
}
313317

314-
/// Test: L1 reorg of BatchFinalized event.
318+
/// Test: L1 reorg of `BatchFinalized` event.
315319
///
316-
/// Expected: Reorging BatchFinalized should have no effect because we only update
317-
/// the finalized head after the BatchFinalized event is itself finalized on L1,
320+
/// Expected: Reorging `BatchFinalized` should have no effect because we only update
321+
/// the finalized head after the `BatchFinalized` event is itself finalized on L1,
318322
/// meaning it can never be reorged in practice.
319323
#[tokio::test]
320324
async fn test_l1_reorg_batch_finalized() -> eyre::Result<()> {
@@ -323,7 +327,7 @@ async fn test_l1_reorg_batch_finalized() -> eyre::Result<()> {
323327
let mut fixture = TestFixture::builder()
324328
.followers(1)
325329
.skip_l1_synced_notifications()
326-
.with_anvil_default_state()
330+
.with_anvil()
327331
.with_anvil_chain_id(22222222)
328332
.build()
329333
.await?;
@@ -372,9 +376,9 @@ async fn test_l1_reorg_batch_finalized() -> eyre::Result<()> {
372376
Ok(())
373377
}
374378

375-
/// Test: L1 reorg of BatchRevert event.
379+
/// Test: L1 reorg of `BatchRevert` event.
376380
///
377-
/// Expected: When a BatchRevert is reorged, the safe head should be restored to
381+
/// Expected: When a `BatchRevert` is reorged, the safe head should be restored to
378382
/// the state before the revert was applied. If the reverted batches are re-committed
379383
/// after the reorg, the safe head should advance again.
380384
#[tokio::test]
@@ -384,7 +388,7 @@ async fn test_l1_reorg_batch_revert() -> eyre::Result<()> {
384388
let mut fixture = TestFixture::builder()
385389
.followers(1)
386390
.skip_l1_synced_notifications()
387-
.with_anvil_default_state()
391+
.with_anvil()
388392
.with_anvil_chain_id(22222222)
389393
.build()
390394
.await?;
@@ -420,10 +424,7 @@ async fn test_l1_reorg_batch_revert() -> eyre::Result<()> {
420424
let status_after_revert = fixture.get_sequencer_status().await?;
421425
let safe_after_revert = status_after_revert.l2.fcs.safe_block_info().number;
422426
tracing::info!("Safe head after revert: {}", safe_after_revert);
423-
assert!(
424-
safe_after_revert < safe_after_commits,
425-
"Safe head should decrease after BatchRevert"
426-
);
427+
assert!(safe_after_revert < safe_after_commits, "Safe head should decrease after BatchRevert");
427428

428429
// Reorg to remove the BatchRevert event (reorg depth 1)
429430
fixture.anvil_reorg(2).await?;
@@ -442,4 +443,4 @@ async fn test_l1_reorg_batch_revert() -> eyre::Result<()> {
442443
);
443444

444445
Ok(())
445-
}
446+
}

crates/providers/src/l1/blob/anvil.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ impl AnvilBlobProvider {
2121

2222
#[async_trait::async_trait]
2323
impl BlobProvider for AnvilBlobProvider {
24+
#[allow(clippy::large_stack_frames)]
2425
async fn blob(
2526
&self,
2627
_block_timestamp: u64,

crates/watcher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct L1Watcher<EP> {
9999
is_synced: bool,
100100
/// The log query block range.
101101
log_query_block_range: u64,
102-
/// Test mode: skip sending L1Notification::Synced events.
102+
/// Test mode: skip sending `L1Notification::Synced` events.
103103
test_mode_skip_synced_notification: bool,
104104
}
105105

0 commit comments

Comments
 (0)