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

Refactoring preparation: Extract import queue out of Sync. #11295

Closed
the-right-joyce opened this issue Apr 26, 2022 · 3 comments
Closed

Refactoring preparation: Extract import queue out of Sync. #11295

the-right-joyce opened this issue Apr 26, 2022 · 3 comments
Assignees
Labels
I7-refactor Code needs refactoring.

Comments

@the-right-joyce
Copy link
Contributor

Improve the import queue, allow importing blocks without execution.
Long-term it shouldn’t import justifications, we can remove the JustificationImport trait.

@the-right-joyce the-right-joyce added this to the Sync. State prepared milestone Apr 26, 2022
@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Apr 26, 2022
@the-right-joyce the-right-joyce added I7-refactor Code needs refactoring. and removed J2-unconfirmed Issue might be valid, but it’s not yet known. labels Apr 26, 2022
@the-right-joyce the-right-joyce removed this from the Sync. State prepared milestone Sep 1, 2022
@the-right-joyce
Copy link
Contributor Author

the-right-joyce commented Oct 19, 2022

hi @altonen, so here are the main ideas/solutions we had planned for the Sync in general:

  • We want to have explicit separate components for different sync modes, i.e. decouple the sync protocol and state machine. Have a state machine controlling which sync mode we should be using.
  • Sync should be its own protocol like all the other protocols that are defined on top of sc-network

The state machine would have the following flows:
Disclaimer: we have here no scenarios for the case that those sync. mode fails
image

Here are details of how each sync. mode would look like:
image

You can also find all the related issues to this here: https://github.com/orgs/paritytech/projects/18/views/13

@bkchr
Copy link
Member

bkchr commented Oct 19, 2022

Disclaimer: we have here no scenarios for the case that those sync. mode fails

When sync fails, there is no real solution than let the operator step in. For example, If something like warp sync fails because some block can not be verified, we can not just fall back to initial sync.

While the above images mainly concentrate on the different syncing strategies and how they work on a high level. They also contain some useful information for this issue. Currently in Substrate we have two ways of how blocks get imported, via block authoring and via the import queue. The only difference is that the import queue is verifying the blocks before importing them, after that the code path should be the same. If you take a look the pictures above, we already have added this behavior to syncing. It first verifies headers on announcement and only requests the blocks on successful verification. Verification should only include stuff like checking the seal of the header. Then when the block is imported we could directly forward it to the block import. Block authoring would use the same block import code path in contrast to the current implementation where these code paths are differ a little bit. For Parachains we have another path of where we can receive blocks and that is via pov recovery. This will also benefit from these changes here.

@altonen
Copy link
Contributor

altonen commented Nov 14, 2022

I've started working on this as well, mainly just getting it out of NetworkWorker. Right now it has been moved to ChainSync which is not really in line with what we want to do (long term) but it's a step closer to getting syncing out of sc-network. Maybe I will move it into a separate, standalone task so it would poll itself and expose some interface for ChainSync instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring.
Projects
Status: done
Development

No branches or pull requests

3 participants