Skip to content

Improvement: chainsync asynchronism #340

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

gsegatti
Copy link
Contributor

@JannikSt JannikSt requested a review from Copilot June 11, 2025 10:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the asynchronism in the chainsync functionality and related contract interactions by refining error types, enhancing error handling, and introducing concurrent processing for node synchronization.

  • Updated error return types in compute registry and compute pool contracts to include Send + Sync.
  • Enhanced error handling in the compute pool’s is_node_blacklisted function.
  • Refactored chainsync code to perform concurrent node syncing using futures::stream::iter.
  • Added the futures dependency in Cargo.toml.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
crates/shared/src/web3/contracts/implementations/compute_registry_contract.rs Updated error return type to enforce thread-safety with Send + Sync.
crates/shared/src/web3/contracts/implementations/compute_pool_contract.rs Improved error handling for node blacklist checks.
crates/discovery/src/chainsync/sync.rs Refactored sync_single_node to use async join and concurrent processing with for_each_concurrent.
crates/discovery/Cargo.toml Included futures dependency to support asynchronous stream operations.
Comments suppressed due to low confidence (3)

crates/shared/src/web3/contracts/implementations/compute_pool_contract.rs:187

  • Consider using a consistent error conversion helper to wrap these string errors with more contextual information.
let first_value = result.first().ok_or("Empty response when checking if node is blacklisted")?;

crates/discovery/src/chainsync/sync.rs:65

  • Consider using the log crate (e.g., error!) for error reporting instead of eprintln, in order to maintain consistent logging throughout the code.
eprintln!("Error retrieving node info: {}", e);

crates/discovery/src/chainsync/sync.rs:110

  • [nitpick] It may be beneficial to include additional context (e.g., node identifier) in the error logs within the concurrent stream to improve debugging clarity.
futures::stream::iter(nodes).for_each_concurrent(10, |node| {

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.

1 participant