Skip to content

Commit 0b8dd48

Browse files
committed
fix: chainspec dev l1 config
1 parent 8765085 commit 0b8dd48

File tree

5 files changed

+36
-138
lines changed

5 files changed

+36
-138
lines changed

crates/node/src/test_utils/fixture.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
};
1111

1212
use alloy_eips::BlockNumberOrTag;
13-
use alloy_primitives::{address, Address};
13+
use alloy_primitives::Address;
1414
use alloy_provider::{Provider, ProviderBuilder};
1515
use alloy_rpc_types_eth::Block;
1616
use alloy_signer_local::PrivateKeySigner;
@@ -226,11 +226,6 @@ impl TestFixture {
226226
self.anvil.as_ref().map(|a| a.http_endpoint())
227227
}
228228

229-
/// Check if Anvil is running.
230-
pub const fn has_anvil(&self) -> bool {
231-
self.anvil.is_some()
232-
}
233-
234229
/// Generate Anvil blocks by calling anvil_mine RPC method.
235230
pub async fn anvil_mine_blocks(&self, num_blocks: u64) -> eyre::Result<()> {
236231
// Ensure Anvil is running
@@ -557,23 +552,6 @@ impl TestFixtureBuilder {
557552
self
558553
}
559554

560-
/// Set custom L1 config addresses for Anvil testing.
561-
/// This method reads contract addresses from tests/anvil.env.
562-
pub fn with_anvil_l1_config(mut self) -> Self {
563-
let chain_spec = self.chain_spec.take().unwrap_or_else(|| SCROLL_DEV.clone());
564-
let mut spec = (*chain_spec).clone();
565-
spec.config.l1_config.scroll_chain_address =
566-
address!("0x5FC8d32690cc91D4c39d9d3abcBD16989F875707");
567-
spec.config.l1_config.l1_message_queue_address =
568-
address!("0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9");
569-
spec.config.l1_config.l1_message_queue_v2_address =
570-
address!("0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9");
571-
spec.config.l1_config.l2_system_config_address =
572-
address!("0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0");
573-
self.chain_spec = Some(Arc::new(spec));
574-
self
575-
}
576-
577555
/// Build the test fixture.
578556
pub async fn build(self) -> eyre::Result<TestFixture> {
579557
let mut config = self.config;

crates/node/tests/l1_sync.rs

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//! Related to: https://github.com/scroll-tech/rollup-node/issues/420
77
88
use alloy_primitives::Bytes;
9-
use reth_scroll_chainspec::SCROLL_DEV;
109
use rollup_node::test_utils::{EventAssertions, TestFixture};
1110
use serde_json::Value;
1211

@@ -47,14 +46,13 @@ fn read_test_transaction(tx_type: &str, index: &str) -> eyre::Result<Bytes> {
4746
/// Test: BatchCommit during Syncing state should have no effect.
4847
///
4948
/// Expected: The node should not update the safe head since we only process
50-
/// BatchCommit events after the node is synced (post L1Synced notification).
49+
/// BatchCommit eventds after the node is synced (post L1Synced notification).
5150
#[tokio::test]
5251
async fn test_l1_sync_batch_commit() -> eyre::Result<()> {
5352
reth_tracing::init_test_tracing();
5453

5554
let mut fixture = TestFixture::builder()
5655
.followers(1)
57-
.with_chain_spec(SCROLL_DEV.clone())
5856
.skip_l1_synced_notifications()
5957
.with_anvil_default_state()
6058
.with_anvil_chain_id(22222222)
@@ -103,7 +101,6 @@ async fn test_l1_sync_batch_finalized() -> eyre::Result<()> {
103101

104102
let mut fixture = TestFixture::builder()
105103
.followers(1)
106-
.with_chain_spec(SCROLL_DEV.clone())
107104
.skip_l1_synced_notifications()
108105
.with_anvil_default_state()
109106
.with_anvil_chain_id(22222222)
@@ -170,8 +167,8 @@ async fn test_l1_sync_batch_finalized() -> eyre::Result<()> {
170167
}
171168
fixture.anvil_mine_blocks(64).await?;
172169

173-
// Wait for l1 blocks to be processed
174-
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
170+
// Wait for batch finalized event
171+
fixture.expect_event().batch_finalized().await?;
175172

176173
// Check that finalized head was updated
177174
let batch_finalized_status = fixture.get_sequencer_status().await?;
@@ -193,7 +190,6 @@ async fn test_l1_sync_batch_revert() -> eyre::Result<()> {
193190

194191
let mut fixture = TestFixture::builder()
195192
.followers(1)
196-
.with_chain_spec(SCROLL_DEV.clone())
197193
.skip_l1_synced_notifications()
198194
.with_anvil_default_state()
199195
.with_anvil_chain_id(22222222)
@@ -257,58 +253,58 @@ async fn test_l1_reorg_batch_commit() -> eyre::Result<()> {
257253

258254
let mut fixture = TestFixture::builder()
259255
.followers(1)
260-
.with_chain_spec(SCROLL_DEV.clone())
261256
.skip_l1_synced_notifications()
262257
.with_anvil_default_state()
263258
.with_anvil_chain_id(22222222)
264259
.build()
265260
.await?;
266261

267-
// Send BatchCommit transactions 0-2
268-
for i in 0..=2 {
262+
// Trigger L1 synced event
263+
fixture.l1().sync().await?;
264+
fixture.expect_event().l1_synced().await?;
265+
266+
// Send BatchCommit transactions 0-3
267+
for i in 0..=3 {
269268
let commit_batch_tx = read_test_transaction("commitBatch", &i.to_string())?;
270269
fixture.anvil_send_raw_transaction(commit_batch_tx).await?;
270+
if i!=0 {fixture.expect_event().batch_consolidated().await?;}
271271
}
272272

273-
// Trigger L1 sync
274-
fixture.l1().sync().await?;
275-
fixture.expect_event().l1_synced().await?;
276-
fixture.expect_event().batch_consolidated().await?;
277-
278273
// Check that safe head was updated to batch 2
279-
let status_after_sync = fixture.get_sequencer_status().await?;
280-
let safe_after_batch_2 = status_after_sync.l2.fcs.safe_block_info().number;
281-
tracing::info!("Safe head after batch 2: {}", safe_after_batch_2);
274+
let status_after_batch_3 = fixture.get_sequencer_status().await?;
275+
let safe_after_batch_3 = status_after_batch_3.l2.fcs.safe_block_info().number;
276+
tracing::info!("Safe head after batch 3: {}", safe_after_batch_3);
282277

283-
// Send BatchCommit transaction 3
284-
let commit_batch_3_tx = read_test_transaction("commitBatch", "3")?;
285-
fixture.anvil_send_raw_transaction(commit_batch_3_tx).await?;
278+
// Send BatchCommit transactions 4-6
279+
for i in 4..=6 {
280+
let commit_batch_tx = read_test_transaction("commitBatch", &i.to_string())?;
281+
fixture.anvil_send_raw_transaction(commit_batch_tx).await?;
282+
}
286283

287284
// Wait for processing
288285
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
289286

290287
// Check that safe head advanced to batch 3
291-
let status_after_batch_3 = fixture.get_sequencer_status().await?;
292-
let safe_after_batch_3 = status_after_batch_3.l2.fcs.safe_block_info().number;
293-
tracing::info!("Safe head after batch 3: {}", safe_after_batch_3);
288+
let status_after_batch_6: rollup_node_chain_orchestrator::ChainOrchestratorStatus = fixture.get_sequencer_status().await?;
289+
let safe_after_batch_6 = status_after_batch_6.l2.fcs.safe_block_info().number;
290+
tracing::info!("Safe head after batch 6: {}", safe_after_batch_6);
294291
assert!(
295-
safe_after_batch_3 > safe_after_batch_2,
292+
safe_after_batch_6 > safe_after_batch_6,
296293
"Safe head should advance after BatchCommit when L1Synced"
297294
);
298295

299296
// Reorg to remove batch 3 (reorg depth 1)
300-
fixture.anvil_reorg(1).await?;
297+
fixture.anvil_reorg(3).await?;
301298
fixture.anvil_mine_blocks(1).await?;
302299

303-
// Wait for reorg to be detected and processed
304-
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
300+
fixture.expect_event().l1_reorg().await?;
305301

306-
// Check that safe head reverted to batch 2
302+
// Check that safe head reverted
307303
let status_after_reorg = fixture.get_sequencer_status().await?;
308304
let safe_after_reorg = status_after_reorg.l2.fcs.safe_block_info().number;
309305
tracing::info!("Safe head after reorg: {}", safe_after_reorg);
310306
assert_eq!(
311-
safe_after_reorg, safe_after_batch_2,
307+
safe_after_reorg, safe_after_batch_3,
312308
"Safe head should revert to previous BatchCommit after reorg"
313309
);
314310

@@ -326,7 +322,6 @@ async fn test_l1_reorg_batch_finalized() -> eyre::Result<()> {
326322

327323
let mut fixture = TestFixture::builder()
328324
.followers(1)
329-
.with_chain_spec(SCROLL_DEV.clone())
330325
.skip_l1_synced_notifications()
331326
.with_anvil_default_state()
332327
.with_anvil_chain_id(22222222)
@@ -388,7 +383,6 @@ async fn test_l1_reorg_batch_revert() -> eyre::Result<()> {
388383

389384
let mut fixture = TestFixture::builder()
390385
.followers(1)
391-
.with_chain_spec(SCROLL_DEV.clone())
392386
.skip_l1_synced_notifications()
393387
.with_anvil_default_state()
394388
.with_anvil_chain_id(22222222)

crates/node/tests/testdata/send_commit_batch.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

crates/primitives/src/node/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const SEPOLIA_ROLLUP_CONTRACT_ADDRESS: Address =
1414

1515
/// The address of the Scroll Rollup contract on Devnet.
1616
pub const DEVNET_ROLLUP_CONTRACT_ADDRESS: Address =
17-
address!("000000000000000000000000000000000000dead");
17+
address!("0x5FC8d32690cc91D4c39d9d3abcBD16989F875707");
1818

1919
/// The address of the Scroll L1 message queue v1 contract on Mainnet.
2020
pub const MAINNET_L1_MESSAGE_QUEUE_V1_CONTRACT_ADDRESS: Address =
@@ -26,7 +26,7 @@ pub const SEPOLIA_L1_MESSAGE_QUEUE_V1_CONTRACT_ADDRESS: Address =
2626

2727
/// The address of the Scroll L1 message queue v1 contract on Devnet.
2828
pub const DEVNET_L1_MESSAGE_QUEUE_V1_CONTRACT_ADDRESS: Address =
29-
address!("000000000000000000000000000000000001dead");
29+
address!("0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9");
3030

3131
/// The address of the Scroll L1 message queue v2 contract on Mainnet.
3232
pub const MAINNET_L1_MESSAGE_QUEUE_V2_CONTRACT_ADDRESS: Address =
@@ -38,7 +38,7 @@ pub const SEPOLIA_L1_MESSAGE_QUEUE_V2_CONTRACT_ADDRESS: Address =
3838

3939
/// The address of the Scroll L1 message queue v2 contract on Devnet.
4040
pub const DEVNET_L1_MESSAGE_QUEUE_V2_CONTRACT_ADDRESS: Address =
41-
address!("000000000000000000000000000000000002dead");
41+
address!("0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9");
4242

4343
/// The address of the system contract on Mainnet.
4444
pub const MAINNET_SYSTEM_CONTRACT_ADDRESS: Address =
@@ -50,7 +50,7 @@ pub const SEPOLIA_SYSTEM_CONTRACT_ADDRESS: Address =
5050

5151
/// The address of the system contract on Devnet.
5252
pub const DEV_SYSTEM_CONTRACT_ADDRESS: Address =
53-
address!("000000000000000000000000000000000003dead");
53+
address!("0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0");
5454

5555
/// The L1 start block for Mainnet.
5656
pub const MAINNET_L1_START_BLOCK_NUMBER: u64 = 18306000;

crates/watcher/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use metrics::WatcherMetrics;
1111
pub mod test_utils;
1212

1313
use alloy_network::Ethereum;
14-
use alloy_primitives::{address, ruint::UintTryTo, BlockNumber, B256};
14+
use alloy_primitives::{ruint::UintTryTo, BlockNumber, B256};
1515
use alloy_provider::{Network, Provider};
1616
use alloy_rpc_types_eth::{BlockNumberOrTag, Filter, Log, TransactionTrait};
1717
use alloy_sol_types::SolEvent;
@@ -826,16 +826,12 @@ where
826826
/// [`field@L1Watcher::log_query_block_range`]\].
827827
async fn next_filtered_logs(&self, latest_block_number: u64) -> L1WatcherResult<Vec<Log>> {
828828
// set the block range for the query
829-
// let address_book = &self.config.address_book;
829+
let address_book = &self.config.address_book;
830830
let mut filter = Filter::new()
831831
.address(vec![
832-
address!("0x5FC8d32690cc91D4c39d9d3abcBD16989F875707"), /* address_book.rollup_node_contract_address,
833-
* address_book.
834-
* v1_message_queue_address,
835-
*
836-
* address_book.
837-
* v2_message_queue_address,
838-
*/
832+
address_book.rollup_node_contract_address,
833+
address_book.v1_message_queue_address,
834+
address_book.v2_message_queue_address,
839835
])
840836
.event_signature(vec![
841837
QueueTransaction::SIGNATURE_HASH,

0 commit comments

Comments
 (0)