Skip to content

fix: deduplicate QRINFO base blocks#7349

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

fix: deduplicate QRINFO base blocks#7349
thepastaclaw wants to merge 1 commit 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e08f0fea-6577-4b11-819b-7abfcf410fc8

📥 Commits

Reviewing files that changed from the base of the PR and between 317917a and e34105f.

📒 Files selected for processing (3)
  • src/llmq/snapshot.cpp
  • src/test/llmq_snapshot_tests.cpp
  • test/functional/feature_llmq_rotation.py

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/llmq/snapshot.cpp

src/llmq/snapshot.cpp:5:10: fatal error: 'llmq/snapshot.h' file not found
5 | #include <llmq/snapshot.h>
| ^~~~~~~~~~~~~~~~~
1 error generated.
src/llmq/snapshot.cpp:39:9-44:9: ERROR translating statement 'IfStmt'
Aborting translation of method 'anonymous_namespace_src_llmq_snapshot.cpp::ConstructCycle' in file 'src/llmq/snapshot.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/list.ml", line 944, characters 13-17
Called from Base__List.filter_map

... [truncated 2200 characters] ...

, characters 22-60
Called from ClangFrontend__CTrans.CTrans_funct.instruction_scope in file "src/clang/cTrans.ml", line 4850, characters 22-79
Called from ClangFrontend__CTrans.CTrans_funct.instruction_log.(fun) in file "src/clang/cTrans.ml", line 4782, characters 12-47
Re-raised at IStdlib__IExn.reraise_after in file "src/istd/IExn.ml" (inlined), line 13, characters 2-50
Called from ClangFrontend__CTrans.CTrans_funct.instruction_log.(fun) in file "src/clang/cTrans.ml", line 4784, characters 10-1023
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml", line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_instrs_rev in file "src/clang/cTrans.ml", line 5365, characters 28-54
Called from ClangFro

src/test/llmq_snapshot_tests.cpp

src/test/llmq_snapshot_tests.cpp:5:10: fatal error: 'test/util/llmq_tests.h' file not found
5 | #include <test/util/llmq_tests.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/e34105f0a3d6eb1960e32e62fae62630c805822b-4e1e3cf4d48d3d5e/tmp/clang_command_.tmp.d1379e.txt
++Contents of '/tmp/coderabbit-infer/e34105f0a3d6eb1960e32e62fae62630c805822b-4e1e3cf4d48d3d5e/tmp/clang_command_.tmp.d1379e.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-

... [truncated 1115 characters] ...

ll/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/4e1e3cf4d48d3d5e/file.o" "-x" "c++"
"src/test/llmq_snapshot_tests.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


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 complete (commit e34105f)

@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.

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.

1 participant