Fix stale revert target in polling block stream#6421
Open
incrypto32 wants to merge 3 commits intomasterfrom
Open
Fix stale revert target in polling block stream#6421incrypto32 wants to merge 3 commits intomasterfrom
incrypto32 wants to merge 3 commits intomasterfrom
Conversation
Change `TriggersAdapter::is_on_main_chain` to return `Option<BlockPtr>` instead of `bool`. `None` means the block is on the main chain; `Some(canonical_parent)` provides the revert target directly from the canonical chain. Previously, when a subgraph far behind chain head sat on a stale block from an old reorg, the revert target was derived from the stale block's cached parent_hash — a hash from the pre-reorg chain that may no longer exist. This caused permanent revert failures and an infinite retry loop. Now the Firehose path returns the canonical block's parent_ptr() and the RPC path uses next_existing_ptr_to_number(N-1), both sourced from the canonical chain.
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.
Subgraphs far behind chain head (> reorg_threshold blocks) get stuck in an infinite revert loop when sitting on a stale block from an old reorg. is_on_main_chain correctly identifies the stale block, but parent_ptr fetches the stale block's parent from the block cache — a hash from the pre-reorg chain that no longer exists on the canonical chain.
is_on_main_chainto returnOption<BlockPtr>instead ofbool—Nonemeans on main chain,Some(canonical_parent)is the revert target