Use GRANDPA hard forks as warp sync checkpoints#28
Open
UnArbosFive wants to merge 2 commits into
Open
Conversation
UnArbosFive
force-pushed
the
fix/grandpa-warp-checkpoints
branch
from
July 11, 2026 11:18
9d715e5 to
3a84359
Compare
UnArbosFive
marked this pull request as ready for review
July 11, 2026 11:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This changes GRANDPA warp-proof generation so configured, finalized
AuthoritySetHardForkentries can serve as trusted checkpoints. A proof can begin again from a checkpoint and then include the ordinary authority-set transitions recorded after it.The proof wire format is unchanged. This only changes which existing
WarpSyncFragments a provider selects and serves.Why testnet warp sync currently stalls
The affected testnet history contains GRANDPA authority transitions that cannot be replayed as a continuous proof from set 0. In particular, a historical delayed transition does not have the stored justification needed to construct a normal warp-sync fragment. Nodes that have already warp-synced may also retain authority-change history whose first available record has a nonzero set ID, plus an obsolete lower-set record after the usable checkpoint.
Before this change,
WarpSyncProof::generatealways calledAuthoritySetChanges::iter_from(begin). That API deliberately rejects an incomplete historical prefix: if the first retained record is not set 0, it returnsNone, which becomesError::MissingData. It also has no knowledge of configured GRANDPA hard forks. Consequently, a testnet proof provider cannot bridge the unprovable historical transition even though both sides are configured with a later trusted authority-set checkpoint. A fresh node remains in theDownloading warp proofsphase because it cannot obtain a complete proof chain from its peers.Why the change is needed in the SDK
Subtensor owns the chain-specific checkpoint hashes, set IDs, and authority lists, and supplies them through the existing
HardForksconfiguration. The generic proof-selection logic, however, lives insidesc-consensus-grandpaand has private access to the backend, finalized chain, stored authority-set changes, proof-size limits, andWarpSyncFragmentconstruction.Subtensor can configure a checkpoint, but it cannot make the SDK generator use that checkpoint without duplicating GRANDPA's internal proof-generation implementation. Teaching the SDK's existing generator how to consume its existing hard-fork configuration keeps chain-specific data out of Polkadot SDK while preserving one implementation of the protocol.
Implementation
HardForksconfiguration intoWarpSyncProof::generate.(hash, number)is canonical in the provider's finalized chain.iter_frombehavior when there is no usable finalized checkpoint.Canonical-hash filtering is important because hard forks are keyed by both hash and height: alternate-fork entries at the same height must not influence proof generation. Verification remains fail-closed and continues to validate the exact checkpoint hash, GRANDPA justification, authority list, and subsequent scheduled transitions.
Compatibility and mainnet safety
HardForks::new_initial_set_id, which is the existing Subtensor mainnet mode, retains the previous generator path. The regression test requires its generated proof bytes to be identical to the legacy path.Verification
SKIP_WASM_BUILD=1 cargo clippy -p sc-consensus-grandpa --all-targets -- -D warningsSKIP_WASM_BUILD=1 cargo test -p sc-consensus-grandpa warp_sync_proof_generate_verify --libDownloading warp proofs, completed state sync, and caught up to the testnet head.The regression coverage includes:
Rollout order
polkadot-stable2506-2-otf-patches.The SDK merge alone changes no deployed network behavior. Provider-first deployment prevents updated clients from depending on peers that still use the old generator. Mainnet does not receive the testnet checkpoint configuration and continues using its existing initial-set-ID path.