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

fix: fetch data from hardcoded start block #2794

Closed
Closed
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
2 changes: 1 addition & 1 deletion crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
pub async fn fetch_data(&mut self, cursors: &Cursors) -> Result<FetchDataResult> {
let latest_block = self.provider.block_hash_and_number().await?;

let from = cursors.head.unwrap_or(0);
let from = cursors.head.unwrap_or(948000);

Check warning on line 326 in crates/torii/core/src/engine.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/engine.rs#L326

Added line #L326 was not covered by tests
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ohayo sensei! Consider making the start block configurable.

The hardcoded start block (948000) should be moved to a configuration option to allow flexibility in data syncing requirements.

Apply this diff to make it configurable:

-        let from = cursors.head.unwrap_or(948000);
+        let from = cursors.head.unwrap_or(self.config.start_block);

Then add the configuration option to the EngineConfig struct:

 pub struct EngineConfig {
     pub polling_interval: Duration,
     pub blocks_chunk_size: u64,
     pub events_chunk_size: u64,
     pub max_concurrent_tasks: usize,
     pub flags: IndexingFlags,
     pub event_processor_config: EventProcessorConfig,
+    pub start_block: u64,
 }

 impl Default for EngineConfig {
     fn default() -> Self {
         Self {
             polling_interval: Duration::from_millis(500),
             blocks_chunk_size: 10240,
             events_chunk_size: 1024,
             max_concurrent_tasks: 100,
             flags: IndexingFlags::empty(),
             event_processor_config: EventProcessorConfig::default(),
+            start_block: 948000, // Default to current hardcoded value
         }
     }
 }

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Member

Choose a reason for hiding this comment

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

put comment on why this exact value is chosen

let total_remaining_blocks = latest_block.block_number - from;
let blocks_to_process = total_remaining_blocks.min(self.config.blocks_chunk_size);
let to = from + blocks_to_process;
Expand Down
Loading