Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Network sync refactoring (part 4) #11412

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ae1ceb9
Remove direct dependency of `sc-network` on `sc-network-light`
nazar-pc May 11, 2022
427d316
Move `WarpSyncProvider` trait and surrounding data structures into `s…
nazar-pc May 11, 2022
84ae282
Move `WarpSyncProvider` trait and surrounding data structures into `s…
nazar-pc May 11, 2022
5dd28b0
Create `sync` module in `sc-network-common`, create `ChainSync` trait…
nazar-pc May 11, 2022
922f1ae
Switch from concrete implementation to `ChainSync` trait from `sc-net…
nazar-pc May 12, 2022
d6d0a46
Introduce `OpaqueStateRequest`/`OpaqueStateResponse` to remove generi…
nazar-pc May 12, 2022
a91cd02
Introduce `OpaqueBlockRequest`/`OpaqueBlockResponse`, make `scheme` m…
nazar-pc May 12, 2022
dc4a721
Surface `sc-network-sync` into `sc-service` and make `sc-network` not…
nazar-pc May 12, 2022
38abfd0
Remove now unnecessary dependency from `sc-network`
nazar-pc May 12, 2022
0583c14
Replace crate links with just text since dependencies are gone now
nazar-pc May 14, 2022
95a9ab4
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 6, 2022
835b8fa
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 7, 2022
43bfb5c
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 17, 2022
1032789
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 20, 2022
26b8ab2
Remove `warp_sync` re-export from `sc-network-common`
nazar-pc Jun 20, 2022
4616d25
Update copyright in network-related files
nazar-pc Jun 20, 2022
2e2e6ee
Address review comments about documentation
nazar-pc Jun 20, 2022
93849a1
Apply review suggestion
nazar-pc Jun 20, 2022
6e1eae4
Rename `extra_requests` module to `metrics`
nazar-pc Jun 23, 2022
60be73c
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jun 28, 2022
6ca4645
Merge remote-tracking branch 'upstream/master' into network-sync-refa…
nazar-pc Jul 11, 2022
ba9a85d
Merge remote-tracking branch 'origin/master' into network-sync-refact…
bkchr Jul 12, 2022
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
Prev Previous commit
Next Next commit
Address review comments about documentation
  • Loading branch information
nazar-pc committed Jun 20, 2022
commit 2e2e6eeb21f4cea6433d76781f0cd7e5fde82913
12 changes: 1 addition & 11 deletions client/network/common/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ impl fmt::Debug for OpaqueBlockResponse {
}
}

/// Something that represents the syncing strategy to download past and future blocks of the chain.
pub trait ChainSync<Block: BlockT>: Send {
nazar-pc marked this conversation as resolved.
Show resolved Hide resolved
/// Returns the state of the sync of the given peer.
///
Expand Down Expand Up @@ -249,7 +250,6 @@ pub trait ChainSync<Block: BlockT>: Send {
) -> Result<Option<BlockRequest<Block>>, BadPeer>;

/// Signal that a new best block has been imported.
/// `ChainSync` state with that information.
fn update_chain_info(&mut self, best_hash: &Block::Hash, best_number: NumberFor<Block>);

/// Schedule a justification request for the given block.
Expand All @@ -259,7 +259,6 @@ pub trait ChainSync<Block: BlockT>: Send {
fn clear_justification_requests(&mut self);

/// Request syncing for the given block from given set of peers.
// The implementation is similar to on_block_announce with unknown parent hash.
fn set_sync_fork_request(
&mut self,
peers: Vec<PeerId>,
Expand Down Expand Up @@ -296,25 +295,18 @@ pub trait ChainSync<Block: BlockT>: Send {
) -> Result<OnBlockData<Block>, BadPeer>;

/// Handle a response from the remote to a state request that we made.
///
/// Returns next request if any.
fn on_state_data(
&mut self,
who: &PeerId,
response: OpaqueStateResponse,
) -> Result<OnStateData<Block>, BadPeer>;

/// Handle a response from the remote to a warp proof request that we made.
///
/// Returns next request.
fn on_warp_sync_data(&mut self, who: &PeerId, response: EncodedProof) -> Result<(), BadPeer>;

/// Handle a response from the remote to a justification request that we made.
///
/// `request` must be the original request that triggered `response`.
///
/// Returns `Some` if this produces a justification that must be imported
/// into the import queue.
fn on_block_justification(
&mut self,
who: PeerId,
Expand All @@ -325,8 +317,6 @@ pub trait ChainSync<Block: BlockT>: Send {
///
/// Call this when a batch of blocks have been processed by the import
/// queue, with or without errors.
///
/// `peer_info` is passed in case of a restart.
fn on_blocks_processed(
&mut self,
imported: usize,
Expand Down
1 change: 1 addition & 0 deletions client/network/sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ where
self.extra_justifications.reset();
}

// The implementation is similar to on_block_announce with unknown parent hash.
fn set_sync_fork_request(
&mut self,
mut peers: Vec<PeerId>,
Expand Down