fix(core): verify stored section heads to fix flaky chain indexer reorg, #19748 #20506 - #2555
fix(core): verify stored section heads to fix flaky chain indexer reorg, #19748 #20506#2555gzliudan wants to merge 1 commit into
Conversation
…rg, ethereum#19748 ethereum#20506 Port upstream go-ethereum fixes ethereum#19748 and ethereum#20506 (fixes the flaky 'Canonical section count mismatch' in TestChainIndexerWithChildren, see upstream issue ethereum#20497): - newHead: on reorg, revert from section (head+1)/sectionSize since the common ancestor head itself is still valid - updateLoop: verify the last stored section head against the canonical chain before processing and after a failed processing, rolling back stale sections so the indexer can never get stuck with an invalid stored section (the root cause of the flaky 'Canonical section count mismatch: have 79, want 78' failure in TestChainIndexerWithChildren) - Sections(): report an up-to-date section count via verifyLastHead - updateLoop: guard SectionHead underflow with section == 0 - chain_indexer_test: sync reorg expectation helper with the new revert semantics
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The reviewed changes address the reorg issue with aligned test expectations and no unresolved findings.
Pull request overview
Fixes flaky chain indexer reorg handling by detecting and rolling back stale section metadata.
Changes:
- Preserves sections ending at the common ancestor.
- Validates stored section heads against the canonical chain.
- Updates reorg test expectations.
File summaries
| File | Description |
|---|---|
core/chain_indexer.go |
Corrects reorg boundaries and safely rolls back stale sections. |
core/chain_indexer_test.go |
Aligns expected section rollback behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Proposed changes
fix ci error: https://github.com/XinFinOrg/XDPoSChain/actions/runs/34191522129/job/101950397917?pr=2545
Ref:
Changes:
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that