Move syncing code from sc-network-common to sc-network-sync#1912
Move syncing code from sc-network-common to sc-network-sync#1912dmitry-markin merged 13 commits intomasterfrom
sc-network-common to sc-network-sync#1912Conversation
sc-network-common to sc-network-syncsc-network-common to sc-network-sync
altonen
left a comment
There was a problem hiding this comment.
I don't think this should be silent. There are at least two external teams that are working on their own syncing implementations so this will likely affect them. At least the removal of ChainSync is something that should be mentioned, with a note that there will be some kind of new ChainSync trait in the near future.
bkchr
left a comment
There was a problem hiding this comment.
Looking good. Just a little bit confused why some types are being made public?
| /// Action that [`engine::SyncingEngine`] should perform after reporting imported blocks with | ||
| /// [`ChainSync::on_blocks_processed`]. | ||
| enum BlockRequestAction<B: BlockT> { | ||
| pub enum BlockRequestAction<B: BlockT> { |
There was a problem hiding this comment.
Why do we need to make this public?
There was a problem hiding this comment.
It's consumed by SyncingEngine, that owns ChainSync.
There was a problem hiding this comment.
But isn't this in the same crate?
There was a problem hiding this comment.
Technically, SyncingEngine is in the same root module as ChainSync, because ChainSync is defined in lib.rs. So pub is not needed at all (even as pub(crate)). Semantically, these types are public for SyncingEngine, so I feel inclined to highlight this with either pub or pub(crate).
pub(crate) is probably a better option, but may be it's also worth moving ChainSync to a separate chain_sync.rs file.
@bkchr would it be better to move ChainSync and its types to a separate file and use pub(crate) for types consumed by SyncingEngine?
There was a problem hiding this comment.
@bkchr would it be better to move
ChainSyncand its types to a separate file and use pub(crate) for types consumed by SyncingEngine?
Done. PR looks scary now due to moved code, but overall situation with ChainSync should have improved.
There was a problem hiding this comment.
pub(crate)is probably a better option, but may be it's also worth movingChainSyncto a separatechain_sync.rsfile.
Yeah sorry for these dumb questions :P I should have realized that the module is private to the crate. Pub is fine by me here.
There was a problem hiding this comment.
I was thinking this reordering could've been done in another PR but whatever. SyncingEngine should be moved to sync/src/lib.rs but that can be done in another PR.
There was a problem hiding this comment.
Why SyncingEngine should be moved to the root module and not kept in it's own module, may be reexporting it in the root module?
What is the status of completely getting rid off sync in the networking crate? Because ideally there should not exist a chain sync trait at all. |
There won't be |
Do we really need to make sync itself generic? I don't think so? As this is some self contained implementation. |
That is not the current plan at least. We are most likely going to introduce some traits for the strategies that we discussed earlier, simply to make the code easier to maintain and plug additional syncing implementations without major headache. |
|
Okay :) |
bkchr
left a comment
There was a problem hiding this comment.
Moving to its own file sounds reasonable!
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod test { |
There was a problem hiding this comment.
If you are at it, why not also move them into their own file?
…tytech#1912) This PR moves syncing-related code from `sc-network-common` to `sc-network-sync`. Unfortunately, some parts are tightly integrated with networking, so they were left in `sc-network-common` for now: 1. `SyncMode` in `common/src/sync.rs` (used in `NetworkConfiguration`). 2. `BlockAnnouncesHandshake`, `BlockRequest`, `BlockResponse`, etc. in `common/src/sync/message.rs` (used in `src/protocol.rs` and `src/protocol/message.rs`). More substantial refactoring is needed to decouple syncing and networking completely, including getting rid of the hardcoded sync protocol. ## Release notes Move syncing-related code from `sc-network-common` to `sc-network-sync`. Delete `ChainSync` trait as it's never used (the only implementation is accessed directly from `SyncingEngine` and exposes a lot of public methods that are not part of the trait). Some new trait(s) for syncing will likely be introduced as part of Sync 2.0 refactoring to represent syncing strategies.
This PR moves syncing-related code from
sc-network-commontosc-network-sync.Unfortunately, some parts are tightly integrated with networking, so they were left in
sc-network-commonfor now:SyncModeincommon/src/sync.rs(used inNetworkConfiguration).BlockAnnouncesHandshake,BlockRequest,BlockResponse, etc. incommon/src/sync/message.rs(used insrc/protocol.rsandsrc/protocol/message.rs).More substantial refactoring is needed to decouple syncing and networking completely, including getting rid of the hardcoded sync protocol.
Release notes
Move syncing-related code from
sc-network-commontosc-network-sync. DeleteChainSynctrait as it's never used (the only implementation is accessed directly fromSyncingEngineand exposes a lot of public methods that are not part of the trait). Some new trait(s) for syncing will likely be introduced as part of Sync 2.0 refactoring to represent syncing strategies.Builds upon #1736.