Make Warp/Light sync and custom sync protocols work by design rather than by accident #5366
Open
2 tasks done
Labels
I5-enhancement
An additional feature request.
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Motivation
Unless using
SyncMode::LightState
orSyncMode::Warp
when attempting to insert a block significantly higher than the tip it will fail here:polkadot-sdk/substrate/client/state-db/src/noncanonical.rs
Lines 263 to 274 in 05a8ba6
The reason it works in those cases is because of this awkwardness:
polkadot-sdk/substrate/client/service/src/config.rs
Lines 241 to 245 in 05a8ba6
Which essentially says we will generate, but not store genesis state on disk, which in turns allows to bypass previous snippet because suddenly when the first block is inserted
self.last_canonicalized.is_some() == false
.This whole thing if basically working by accident as far as I'm concerned. There is no fundamental reason why it should be this way and in fact I'd like to have a sync mechanism that can make those jumps at a later time as well, not just after genesis.
Imagine chain has 10M blocks and current database has 1M blocks only, why shouldn't it be possible to Warp sync close to 10M in this case without wiping the whole database first?
This is one of the issues leading to #4407
cc @shamil-gadelshin
Request
I'm not sure what I'm requesting exactly, but I'm looking for some refactoring that would decouple these things and ideally make it possible to insert blocks much higher than current tip if there is a need for that in the protocol.
Solution
Could be as simple as another boolean to bypass mentioned check, but I'm not sure about expected invariants, so things might be more complex than that. Open for suggestions.
Are you willing to help with this request?
Yes!
The text was updated successfully, but these errors were encountered: