Open cristaloleg opened 2 months ago
As we are removing the adequateHeight
sanity check for the sync target since it is based on a parameter that may become variable in the future, we should introduce additional light-weight sync target verification. This comes in the form of skipping verification.
Skipping verification will allow go-header to verify a recent network head (either inbound from headersub or served by the p2p.Exchange) against a subjective head that is non-adjacent. We already have non-adjacent header verification but skipping verification via bifurcated header sync.
Bifurcated header sync just means that if a sync target cannot be verified non-adjacently against a subjective head due to lack of sufficient validator set overlap, then the halfway point between those two headers should be downloaded and attempted.
For example: Subjective head is 500, network head is 1000. Header at height 1000 does not have sufficient validator set overlap, so the client downloads height 750 (which does have enough sufficient overlap), verifies it against 500 and advances the subjective head to 750. Client tries to apply height 1000 against 750 and if there is sufficient overlap, it applies 1000 as the subjective head. If not, it downloads the halfway point and retries the process.
Please keep in mind, for the first iteration, it is okay not to cache the downloaded blocks if they cannot be applied -- we can redownload them via the p2p.Exchange once the sync target is set as it will be initially complicated for the syncer to use that cache to fill out gaps in sync ranges.
For later iterations, a cache for this bifurcation process would reduce the need to do redundant requests for the same information from the network.
https://github.com/celestiaorg/celestia-core/blob/v0.34.x-celestia/light/client.go#L777
TODO