From 40be104949471c33112e57372e9fbca792302ab6 Mon Sep 17 00:00:00 2001 From: Vaclav Barta Date: Tue, 2 Apr 2024 10:33:55 +0200 Subject: [PATCH 1/2] checking requested against actual end block --- state-reconstruct-fetcher/src/l1_fetcher.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/state-reconstruct-fetcher/src/l1_fetcher.rs b/state-reconstruct-fetcher/src/l1_fetcher.rs index e3f4386..d65df2d 100644 --- a/state-reconstruct-fetcher/src/l1_fetcher.rs +++ b/state-reconstruct-fetcher/src/l1_fetcher.rs @@ -225,7 +225,7 @@ impl L1Fetcher { hash_tx: mpsc::Sender, cancellation_token: CancellationToken, mut current_l1_block_number: U64, - mut end_block: Option, + max_end_block: Option, disable_polling: bool, ) -> Result> { let metrics = self.metrics.clone(); @@ -236,6 +236,7 @@ impl L1Fetcher { async move { let mut latest_l2_block_number = U256::zero(); let mut previous_hash = None; + let mut end_block: Option = None; loop { // Break on the receivement of a `ctrl_c` signal. if cancellation_token.is_cancelled() { @@ -251,7 +252,17 @@ impl L1Fetcher { .await { if let Some(found_block) = new_end { - if let Some(end_block_number) = found_block.number { + if let Some(ebn) = found_block.number { + let end_block_number = + if let Some(end_block_limit) = max_end_block { + if end_block_limit < ebn { + end_block_limit + } else { + ebn + } + } else { + ebn + }; end_block = Some(end_block_number); metrics.lock().await.last_l1_block = end_block_number.as_u64(); } From 293aa1560dcae2f05b74a2f547b6e987834bf28d Mon Sep 17 00:00:00 2001 From: Vaclav Barta Date: Tue, 2 Apr 2024 11:15:31 +0200 Subject: [PATCH 2/2] removed L1FetcherOptions.block_step --- src/cli.rs | 4 ---- state-reconstruct-fetcher/src/l1_fetcher.rs | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index c88607f..b3fca59 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -16,9 +16,6 @@ pub struct L1FetcherOptions { /// Ethereum block number to start state import from. #[arg(short, long, default_value_t = ethereum::GENESIS_BLOCK)] pub start_block: u64, - /// The number of blocks to filter & process in one step over. - #[arg(short, long, default_value_t = ethereum::BLOCK_STEP)] - pub block_step: u64, /// The number of blocks to process from Ethereum. #[arg(long)] pub block_count: Option, @@ -34,7 +31,6 @@ impl From for FetcherOptions { http_url: opt.http_url, blobs_url: opt.blobs_url, start_block: opt.start_block, - block_step: opt.block_step, block_count: opt.block_count, disable_polling: opt.disable_polling, } diff --git a/state-reconstruct-fetcher/src/l1_fetcher.rs b/state-reconstruct-fetcher/src/l1_fetcher.rs index d65df2d..791ca5f 100644 --- a/state-reconstruct-fetcher/src/l1_fetcher.rs +++ b/state-reconstruct-fetcher/src/l1_fetcher.rs @@ -52,8 +52,6 @@ pub struct L1FetcherOptions { pub blobs_url: String, /// Ethereum block number to start state import from. pub start_block: u64, - /// The number of blocks to filter & process in one step over. - pub block_step: u64, /// The number of blocks to process from Ethereum. pub block_count: Option, /// If present, don't poll for new blocks after reaching the end. @@ -236,7 +234,7 @@ impl L1Fetcher { async move { let mut latest_l2_block_number = U256::zero(); let mut previous_hash = None; - let mut end_block: Option = None; + let mut end_block = None; loop { // Break on the receivement of a `ctrl_c` signal. if cancellation_token.is_cancelled() {