paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.79k stars 646 forks source link

Customizing SyncingEngine #499

Open ShahakShama opened 1 year ago

ShahakShama commented 1 year ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Motivation

I want to be able to run a substrate node with a custom syncing logic instead of using SyncingEngine.

Request

Let's have a trait for the struct SyncingEngine and change the function build_network to create a generic engine that follows this trait instead of a SyncingEngine

Solution

To not break the API of build_network, we'll need to create a new function that receives the engine type as a generic data type. Then we'll change the existing function to call this new function. We'll need to add a new function to the new trait that will behave the same way as we use it in build_network

Are you willing to help with this request?

Yes!

ShahakShama commented 1 year ago

I've also asked in StackExchange to see if it's possible to solve this without changing Substrate.

altonen commented 1 year ago

Sounds like a decent plan. We have started refactoring the syncing subsystem so the trait will likely change at least a little as we make progress.

ShahakShama commented 1 year ago

When do you expect finishing the refactoring? Will the option of customizing the SyncingEngine come naturally out of this refactor?

altonen commented 1 year ago

It doesn't have the highest of priorities and there is a lot of work to do so it's expected to finish by the end of Q3 but that's not 100% certain.

The goal is not really to allow an easy way to swap the syncing implementation but we can keep this issue open and when we're at a point where the API has stabilized we can revisit the issue.

ShahakShama commented 1 year ago

I see. So currently, my only way to have a custom syncing logic is to make my own version of build_network and keep it updated as this refactor advances. Is this the correct way?

ShahakShama commented 1 year ago

Thanks for all the help so far. Could you also share with me the plan for the refactorization? what do we plan to change?

altonen commented 1 year ago

Your own version of build_network() sounds correct. Substrate service files are most likely eventually refactored into something nicer but it's not a high-priority task so I don't know when (or even if) it's going to happen and who is going to do it.

Design for the new syncing subsystem is here: https://hackmd.io/@altonen/B1SLLoVw3

ShahakShama commented 1 year ago

Great, I'll read that. Thanks :pray: So, for now we're keeping this issue open for when SyncingEngine's API will be final?