paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.89k stars 696 forks source link

Syncing strategy refactoring (part 2) #5666

Closed nazar-pc closed 2 months ago

nazar-pc commented 2 months ago

Description

Follow-up to https://github.com/paritytech/polkadot-sdk/pull/5469 and mostly covering https://github.com/paritytech/polkadot-sdk/issues/5333.

The primary change here is that syncing strategy is no longer created inside of syncing engine, instead syncing strategy is an argument of syncing engine, more specifically it is an argument to build_network that most downstream users will use. This also extracts addition of request-response protocols outside of network construction, making sure they are physically not present when they don't need to be (imagine syncing strategy that uses none of Substrate's protocols in its implementation for example).

This technically allows to completely replace syncing strategy with whatever strategy chain might need.

There will be at least one follow-up PR that will simplify SyncingStrategy trait and other public interfaces to remove mentions of block/state/warp sync requests, replacing them with generic APIs, such that strategies where warp sync is not applicable don't have to provide dummy method implementations, etc.

Integration

Downstream projects will have to write a bit of boilerplate calling build_polkadot_syncing_strategy function to create previously default syncing strategy.

Review Notes

Please review PR through individual commits rather than the final diff, it will be easier that way. The changes are mostly just moving code around one step at a time.

Checklist

nazar-pc commented 2 months ago

@dmitry-markin @lexnv another one for you folks

dmitry-markin commented 2 months ago

Impeccable! Once again thanks for excellent work!

nazar-pc commented 2 months ago

What else is left here? I have another set of changes that depend on this for review already :slightly_smiling_face: