Skip to content

fix: deduplicate QRINFO base blocks#7349

Open
thepastaclaw wants to merge 2 commits into
dashpay:developfrom
thepastaclaw:fix/qrinfo-dedupe-base-hashes
Open

fix: deduplicate QRINFO base blocks#7349
thepastaclaw wants to merge 2 commits into
dashpay:developfrom
thepastaclaw:fix/qrinfo-dedupe-base-hashes

Conversation

@thepastaclaw

Copy link
Copy Markdown

Issue being fixed or feature implemented

QRINFO request handling accepts caller-provided base block hashes and carries the
validated block indexes through quorum rotation response construction. Repeated
base hashes do not add useful information, so this change canonicalizes those
base indexes before the builder phases use them.

Provenance: thepastaclaw/tracker#1450

What was done?

  • Sort validated QRINFO base block indexes by height for both construction
    paths.
  • Remove duplicate base block index pointers before response construction.
  • Add focused unit coverage for repeated base block selection behavior.
  • Add RPC functional coverage showing repeated base hashes produce the same
    result as a single base hash.

How Has This Been Tested?

Environment: macOS arm64, local Dash Core worktree based on upstream/develop.

Commands run:

  • git diff --check upstream/develop..HEAD — passed
  • make -C src -j$(sysctl -n hw.ncpu) test/test_dash — passed earlier in this
    worktree before the final Python-only test addition
  • src/test/test_dash --run_test=llmq_snapshot_tests/get_last_base_block_hash_repeated_base_blocks_test
    — passed
  • test/functional/feature_llmq_rotation.py — skipped locally because this
    worktree was configured with --disable-wallet
  • code-review dashpay/dash upstream/develop fix/qrinfo-dedupe-base-hashes ...
    — passed with recommendation: ship

Also checked:

  • gh api repos/dashpay/dash --jq '.default_branch'develop
  • Open PR search for duplicate QRINFO/baseBlockHashes dedupe work — no duplicate
    open PR found

Breaking Changes

None expected.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thepastaclaw, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 4 minutes and 8 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 36a2f33d-9858-4cf4-b6ac-378fab424159

📥 Commits

Reviewing files that changed from the base of the PR and between e34105f and 9f30867.

📒 Files selected for processing (2)
  • src/llmq/snapshot.cpp
  • src/test/llmq_snapshot_tests.cpp

Walkthrough

This PR modifies the quorum rotation snapshot construction to unconditionally sort and deduplicate base block indexes by ascending block height. Previously, this sorting was applied only under legacy construction; now it applies to all paths. The change adds <algorithm> header usage and modifies BuildQuorumRotationInfo to call std::sort and std::unique/erase on baseBlockIndexes. A unit test verifies GetLastBaseBlockHash behavior with repeated block entries, and a functional test confirms the RPC returns consistent results when the same base block hash is provided multiple times.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • UdjinM6
  • bigwalter1979-cloud
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: deduplicating QRINFO base blocks, which aligns with the primary objective of the PR.
Description check ✅ Passed The description comprehensively explains the issue, changes made, testing performed, and breaking changes, all directly related to the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw thepastaclaw marked this pull request as ready for review June 9, 2026 03:38
@thepastaclaw

thepastaclaw commented Jun 9, 2026

Copy link
Copy Markdown
Author

🔍 Review in progress — actively reviewing now (commit 9f30867)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Code Review

Both agents converged on no findings for this small, well-scoped fix that sorts and deduplicates QRINFO baseBlockIndexes. CodeRabbit also reported no inline findings. The change is covered by both unit and functional tests.

@PastaPastaPasta

Copy link
Copy Markdown
Member

Might this be a breaking change? Especially how we have the "legacy construction" flag? seems for some reason at some point the exact structure was deemed important?

Address review feedback: the prior commit unconditionally sorted and
deduplicated baseBlockIndexes, which touched the legacy construction path
used to serve peers < EFFICIENT_QRINFO_VERSION. Restrict deduplication to
the non-legacy path so the wire response to older peers stays bit-for-bit
identical to the pre-fix behavior. The legacy path keeps the sort it
always relied on for baseBlockIndexes.back() and GetLastBaseBlockHash().

Strengthen the unit test to explicitly prove the legacy no-op invariant:
GetLastBaseBlockHash returns the same hash whether the sorted input
contains duplicates or not, so legacy multiplicity is harmless.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thepastaclaw

Copy link
Copy Markdown
Author

Good catch. I narrowed the change in 9f3086755d so the legacy-construction path keeps the old normalization behavior: sort only, no dedupe.

The repeated-base-hash fix now applies to the non-legacy path used by the RPC. I also added a direct unit assertion documenting that duplicates are a no-op for legacy GetLastBaseBlockHash, so we preserve compatibility while still fixing the repeated-base RPC behavior.

Validation:

./src/test/test_dash --run_test=llmq_snapshot_tests

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