Skip to content

test: cover a genesis notification that reaches an index after its sync - #8210

Merged
PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix/index-late-genesis-notification
Nov 20, 2026
Merged

PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix/index-late-genesis-notification

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

A -txindex node used to segfault in the scheduler thread when an index received the BlockConnected notification for the genesis block after its sync thread had already caught up:

Posix Signal: Segmentation fault
  BaseIndex::Rewind(CBlockIndex const*, CBlockIndex const*)   src/index/base.cpp  (assert(current_tip->GetAncestor(new_tip->nHeight) == new_tip))
  BaseIndex::BlockConnected(...)                               src/index/base.cpp
  CMainSignals::BlockConnected ... SingleThreadedSchedulerClient::ProcessQueue   (scheduler thread)

It showed up in feature_assumeutxo_dash.py on the AssumeUTXO branches, at the step where a node with -txindex restarts with -reindex-chainstate and can connect only the genesis block. loadblk enqueues BlockConnected(genesis), and the index sync finishes at height 0 before the scheduler delivers it. The genesis block has no parent, so the ancestor check passes (GetAncestor(-1) and pprev are both null) and BlockConnected called Rewind(best_block_index, nullptr).

#8047 has since merged. Its early return for a block the index already covers (best_block_index->GetAncestor(pindex->nHeight) == pindex) also covers genesis, so this PR no longer changes src/index/base.cpp.

What was done?

Adds a regression test for that case, baseindex_tests/late_genesis_notification_keeps_index. It syncs an index to height 100, then delivers BlockConnected for genesis through the validation interface, as the queue does. It checks that the index still covers heights 0 to 100 and keeps following the chain (height 101).

How Has This Been Tested?

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (if you have permission to set one)

🤖 Generated with Claude Code

@PastaPastaPasta PastaPastaPasta added this to the 24.1 milestone Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds a test that synchronizes an ErasingIndex through height 100, then delivers a queued genesis-block notification. The test checks that the index retains blocks at heights 0 through 100 and indexes a subsequently connected block at height 101.

Estimated code review effort: 2 (Simple) | ~8 minutes

Possibly related PRs

  • dashpay/dash#8047: Changes BaseIndex::BlockConnected() to skip blocks that are already ancestral to the index's best block; both PRs address late block notifications and index state.
Merge Risk: Minimal · up to 1be8f

This change adds a regression test for a delayed genesis notification arriving after an index has synced. It does not alter production behavior, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names the change: a regression test for a genesis BlockConnected notification that arrives after index sync. The changeset adds only that test (baseindex_tests/late_genesis_notification_keep…
Description check Passed The description covers the crash (segfault in BaseIndex::Rewind when a -txindex node receives a genesis BlockConnected after sync), explains that PR #8047 already covers the fix so this PR adds a regr…
Full details: Title check

Explanation

The title names the change: a regression test for a genesis BlockConnected notification that arrives after index sync. The changeset adds only that test (baseindex_tests/late_genesis_notification_keeps_index in src/test/baseindex_tests.cpp), so the title matches the main change. The 'test:' prefix is accurate and the title is specific. It is 71 characters, which is within a reasonable length.

Full details: Description check

Explanation

The description covers the crash (segfault in BaseIndex::Rewind when a -txindex node receives a genesis BlockConnected after sync), explains that PR #8047 already covers the fix so this PR adds a regression test, and describes the test's checks (index covers heights 0 to 100 and indexes height 101). It also lists how the test was run. This relates directly to the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1908e015-3651-4557-8fdc-9ff6ca39fd06
Commits

Reviewing files that changed from the base of the PR and between c3d2de8 and 1be8fe8.

Files selected for processing: 1

  • src/test/baseindex_tests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@thepastaclaw

thepastaclaw commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 1be8fe8) · triage: low

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The shared BaseIndex guard prevents a late genesis notification from rewinding to a null parent, while a fresh index still appends genesis. The regression test delivers the notification after sync and checks that existing entries remain intact and the next block is indexed; no in-scope issues were found. Develop merges cleanly, and CI reports no failures: lint, Cppcheck, ClangFormat, and the ASan build passed, while the standard Linux build, ASan tests, and several dependency builds are still pending.

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff adds a narrow guard that skips a late genesis notification only when the index already has a best block, with a deterministic regression test.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 96% left, weekly 51% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort medium); agent phase2-reviewer

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failed after approval — commit c3d2de8

The standing review approved this commit; this follow-up moves the verdict to COMMENT: checks that failed after the review may relate to this change, and the evidence does not rule it out.

Failing checks:

Why it is unclear: The log tail shows only test-log collection followed by exit code 1; it does not identify the failing test or show an assertion or crash. The wallet test directory names are not evidence that those tests failed, so the failure cannot be linked to or ruled out as a consequence of the BaseIndex change.

Nothing was re-reviewed: the findings of the standing review are unchanged. The next push gets a full review; a re-run that passes does not restore the approval.

Review provenance

Source: CI-check lane gpt-6.2-sol (agent: triage); no reviewer or verifier lanes ran for this follow-up

  • Verdict moved because CI failed on this commit after the review; failure logs read: 1 GitHub Actions job(s)

@thepastaclaw thepastaclaw added pastaclaw:commented thepastaclaw's latest review was comment-only and removed pastaclaw:approved thepastaclaw's latest review approved this PR labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

When the index sync thread catches up while the BlockConnected
notification for the genesis block is still queued, BaseIndex receives
it with a best block already set. The block has no parent, so the
ancestor check passes (GetAncestor(-1) and pprev are both null). Before
dashpay#8047, BlockConnected then called Rewind(best_block_index, nullptr),
which dereferenced the null target and crashed the scheduler thread.
This happens when -reindex-chainstate can connect only the genesis
block: loadblk queues the genesis notification and the index sync
finishes at height 0 before the scheduler delivers it.

dashpay#8047's early return for a block the index already covers also covers
genesis. Add a regression test that syncs an index, delivers the late
genesis notification, and checks that nothing was un-indexed and the
index keeps following the chain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PastaPastaPasta
PastaPastaPasta force-pushed the fix/index-late-genesis-notification branch from c3d2de8 to 1be8fe8 Compare November 20, 2026 16:21
@PastaPastaPasta PastaPastaPasta changed the title fix: don't crash an index on a genesis notification that arrives after its sync test: cover a genesis notification that reaches an index after its sync Nov 20, 2026
@thepastaclaw thepastaclaw removed the pastaclaw:commented thepastaclaw's latest review was comment-only label Nov 20, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The PR adds a focused regression test covering a late genesis BlockConnected notification after the index has synchronized. The test exercises the queued validation-interface path, verifies the existing indexed chain remains intact, and confirms subsequent blocks are still indexed; the existing #8047 early return prevents the null-parent rewind. No in-scope correctness issues were found. CI has no reported code-check failures; remaining build and test jobs were still pending at the captured review state.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — This is a small, self-contained regression test change in src/test/baseindex_tests.cpp with no production behavior or critical-surface changes.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 92% left, weekly 49% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 20, 2026
@PastaPastaPasta
PastaPastaPasta merged commit deff787 into dashpay:develop Nov 20, 2026
135 of 138 checks passed
@thepastaclaw thepastaclaw removed the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants