Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checking requested against actual end block #78

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
Expand All @@ -34,7 +31,6 @@ impl From<L1FetcherOptions> 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,
}
Expand Down
17 changes: 13 additions & 4 deletions state-reconstruct-fetcher/src/l1_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
/// If present, don't poll for new blocks after reaching the end.
Expand Down Expand Up @@ -225,7 +223,7 @@ impl L1Fetcher {
hash_tx: mpsc::Sender<H256>,
cancellation_token: CancellationToken,
mut current_l1_block_number: U64,
mut end_block: Option<U64>,
max_end_block: Option<U64>,
disable_polling: bool,
) -> Result<tokio::task::JoinHandle<u64>> {
let metrics = self.metrics.clone();
Expand All @@ -236,6 +234,7 @@ impl L1Fetcher {
async move {
let mut latest_l2_block_number = U256::zero();
let mut previous_hash = None;
let mut end_block = None;
loop {
// Break on the receivement of a `ctrl_c` signal.
if cancellation_token.is_cancelled() {
Expand All @@ -251,7 +250,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();
}
Expand Down