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

feat: map l1 batch numbers to their l1 block number equivalent #113

Merged
merged 5 commits into from
Aug 7, 2024

Conversation

zeapoz
Copy link
Member

@zeapoz zeapoz commented Aug 6, 2024

  • Adds a mapping function to L1 fetcher that takes in any L1 batch number and tries to find its corresponding L1 block number by using binary search on fetched logs.
  • Removes num_chunks argument. We now use the default chunk size of 1_000_000 to calculate how many chunks we need instead.
  • Fixes some smaller miscellaneous issues with the snapshots

@zeapoz zeapoz requested a review from vbar August 6, 2024 10:43
@zeapoz zeapoz force-pushed the feat/l1-batch-mapper branch from 06885c4 to 9e30635 Compare August 6, 2024 10:46
src/main.rs Show resolved Hide resolved
@@ -108,17 +111,17 @@ impl SnapshotExporter {
.database
.iterator_cf(index_to_key_map, rocksdb::IteratorMode::Start);

let chunk_size = num_logs / num_chunks as u64;
let num_chunks = (num_logs / SNAPSHOT_CHUNK_SIZE as u64) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't that produce an empty last chunk, when num_logs is exactly divisible by SNAPSHOT_CHUNK_SIZE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but that println! probably shouldn't have stayed...

state-reconstruct-fetcher/src/l1_fetcher.rs Show resolved Hide resolved
state-reconstruct-fetcher/src/l1_fetcher.rs Show resolved Hide resolved
state-reconstruct-fetcher/src/l1_fetcher.rs Show resolved Hide resolved
@@ -232,13 +222,14 @@ impl L1Fetcher {
let tx_handle = self.spawn_tx_handler(
hash_rx,
calldata_tx,
token.clone(),
self.cancellation_token.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd; if the cancellation token is included in L1Fetcher, it doesn't have to be passed separately - no?

state-reconstruct-fetcher/src/l1_fetcher.rs Show resolved Hide resolved
@zeapoz zeapoz merged commit ab79f68 into main Aug 7, 2024
4 checks passed
@zeapoz zeapoz deleted the feat/l1-batch-mapper branch August 7, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants