Skip to content

Conversation

@ark0f
Copy link
Member

@ark0f ark0f commented Sep 28, 2025

No description provided.

@ark0f ark0f added A0-pleasereview PR is ready to be reviewed by the team D8-gearexe gear.exe-related PR labels Sep 28, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 28, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  ethexe/observer/src/lib.rs  60% smaller
  ethexe/observer/src/utils.rs  47% smaller
  ethexe/observer/src/sync.rs  41% smaller
  ethexe/service/src/fast_sync.rs Unsupported file format

@ark0f ark0f changed the title chore(ethexe): Download BLOCK_HASHES_WINDOW_SIZE blocks in fast-sync refactor(ethexe): Implement BlockLoader Oct 2, 2025
@ark0f ark0f requested review from breathx and ukint-vs October 2, 2025 14:36
…-tx-window

# Conflicts:
#	ethexe/service/src/fast_sync.rs
@ark0f ark0f added the A5-dontmerge PR should not be merged yet label Oct 20, 2025
Copy link
Member

@grishasobol grishasobol left a comment

Choose a reason for hiding this comment

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

Overall I'm not agree with this approach. Writing data in on-chain storage bypassing observer, is unsafe.

Optimisation in this PR does not make a significant contribution. Observer already tries to upload only not-synced blocks. And in almost all cases "synced" means "header set" and "events set" and vice versa.

header,
events,
},
(Some(_), None) | (None, Some(_)) => unreachable!("inconsistent database state"),
Copy link
Member

Choose a reason for hiding this comment

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

  1. It's definetely not unreachable, because state of DB can be changed outside. This is error case.
  2. As soon as you added BlockLoader - this situation can be. When two threads have their own block loaders, so one thread write header, then events. In the same time second thread is in this function. Between two moments when thread1 has already set header, but still not set events - this case would appear on thread2.

Comment on lines +299 to +310
let data = match (header, events) {
(Some(header), Some(events)) => BlockData {
hash: block,
header,
events,
},
(Some(_), None) | (None, Some(_)) => unreachable!("inconsistent database state"),
(None, None) => {
missing_end_block = Some(bn);
break;
}
};
Copy link
Member

Choose a reason for hiding this comment

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

This match looks weird for me.
To identify whether block has on-chain information in db, we have already block_synced(). If you wanna to skip here loading of already loaded data - much more clear solution can be: use observer Stream:

observer.force_block_sync(block);
observer.wait_block_synced(block).await;

Using observer stream would be more safe and services style solution.

let end_block = self
.provider
.get_block_by_number((*range.end()).into())
.await?
Copy link
Member

Choose a reason for hiding this comment

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

You have additional rpc call here, which is not presented in previous solution, making it less efficient.

self.request_block_batch(start..=end)
});

let batches = future::try_join_all(batch_futures).await?;
Copy link
Member

Choose a reason for hiding this comment

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

Why not FuturesUnordered ?

.collect();
}

async fn load_many(&self, range: RangeInclusive<u64>) -> Result<HashMap<H256, BlockData>> {
Copy link
Member

Choose a reason for hiding this comment

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

It looks dirty for me: writing blocks data in db and returns in the same time. You can write data in db outside of block loader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview PR is ready to be reviewed by the team A5-dontmerge PR should not be merged yet D8-gearexe gear.exe-related PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants