Skip to content

feat: add QRInfoFeedResult and return it from feed_qr_info#686

Draft
xdustinface wants to merge 2 commits intov0.42-devfrom
feat/qr-info-feed-summary
Draft

feat: add QRInfoFeedResult and return it from feed_qr_info#686
xdustinface wants to merge 2 commits intov0.42-devfrom
feat/qr-info-feed-summary

Conversation

@xdustinface
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface commented Apr 24, 2026

For now just add logging for the result. This will also be used more in follow up PRs.

Summary by CodeRabbit

  • Refactor
    • Enhanced validation and error recovery for masternode synchronization operations.
    • Improved diagnostic tracking for quorum validation processes.

For now just add logging for the result. This will also be used more in follow up PRs.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@xdustinface has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 13 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 13 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ddfe2ac-29d2-40ff-af05-53f5d32a4470

📥 Commits

Reviewing files that changed from the base of the PR and between 426bcc6 and 103f890.

📒 Files selected for processing (1)
  • dash-spv/src/sync/masternodes/sync_manager.rs
📝 Walkthrough

Walkthrough

The changes enhance QRInfo processing by capturing and logging metadata about rotated quorum validation counts, while preserving existing retry logic for signature validation errors.

Changes

Cohort / File(s) Summary
QRInfoFeedResult Return Type
dash/src/sml/masternode_list_engine/mod.rs
Introduces QRInfoFeedResult struct with rotated_quorum_count, freshly_validated_count, and stored_cycle_height fields. Updates feed_qr_info signature to return Result<Option<QRInfoFeedResult>, QuorumValidationError> and computes these metrics when quorum_validation is enabled.
QRInfo Sync Manager Integration
dash-spv/src/sync/masternodes/sync_manager.rs
Updates QRInfo handling to capture the summary from feed_qr_info, conditionally logs processing metrics, and preserves existing RequiredRotatedChainLockSigNotPresent retry/error handling with chainlock_retry_after scheduling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related issues

Poem

🐰 With metrics bundled in each call,
The QRInfo now tells it all,
Rotated quorums tracked with care,
Observability blooms everywhere! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main changes: adding QRInfoFeedResult and modifying feed_qr_info to return it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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
  • Commit unit tests in branch feat/qr-info-feed-summary

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
dash/src/sml/masternode_list_engine/mod.rs (1)

618-662: ⚠️ Potential issue | 🟡 Minor

freshly_validated_count increments regardless of verify_rotated_quorums.

The counter is bumped inside the else branch of the known_qualified_quorum_entry lookup (line 627), which runs unconditionally for every entry in last_commitment_per_index. However, the actual validation (validate_rotation_cycle_quorums_validation_statuses) only runs inside if verify_rotated_quorums further down. So when a caller passes verify_rotated_quorums = false, freshly_validated_count reports quorums that went through the signature-attachment path but were never actually validated — which contradicts the docstring wording "Rotated quorums that went through the fresh-validation path this call".

In the current PR the only caller (sync_manager.rs) always passes true, so this is a latent concern rather than an active bug. Consider either:

  • renaming to something like freshly_qualified_count / newly_seen_rotated_quorum_count, or
  • gating the increment on verify_rotated_quorums so the field's name matches its semantics.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash/src/sml/masternode_list_engine/mod.rs` around lines 618 - 662, Summary:
freshly_validated_count is incremented even when verify_rotated_quorums is
false, so it misreports quorums that weren’t actually validated. Fix: in the
mapping that builds qualified_last_commitment_per_index (the closure over
last_commitment_per_index where known_qualified_quorum_entry is checked and the
else branch attaches VerifyingChainLockSignaturesType::Rotating), only increment
freshly_validated_count when verify_rotated_quorums is true; alternatively, if
you prefer semantics that count newly seen rotated quorums regardless of
validation, rename freshly_validated_count to freshly_qualified_count and update
any uses (including where validate_rotation_cycle_quorums_validation_statuses is
called) to reflect the new name. Reference symbols: freshly_validated_count,
known_qualified_quorum_entry, verify_rotated_quorums,
validate_rotation_cycle_quorums_validation_statuses, QualifiedQuorumEntry,
VerifyingChainLockSignaturesType::Rotating.
🧹 Nitpick comments (2)
dash/src/sml/masternode_list_engine/mod.rs (1)

574-581: Nit: stored_cycle_height is resolved before the diffs are applied.

stored_cycle_height is computed here, but the apply_diff calls below can themselves feed new block heights into self.block_container (see apply_difffeed_block_height path). In practice this is fine because callers are contractually required to pre-populate heights for all hashes returned by qr_info_referenced_block_hashes (which includes last_commitment_per_index[*].quorum_hash), so the lookup succeeds either way. Still, computing it alongside cycle_key after the diffs are applied would make the relationship to what actually gets stored in rotated_quorums_per_cycle more obvious and avoids wasted work when an earlier apply_diff? bails out.

Purely a readability/robustness nit — no functional bug.

dash-spv/src/sync/masternodes/sync_manager.rs (1)

304-311: Consider a structured info! event and including the tip height for correlation.

The current format string is fine, but since this is currently the main consumer of the new summary and is stated in the PR description to be the primary near-term use, a couple of small improvements would pay off later:

  • Emit structured fields instead of interpolating into the message, which plays better with log aggregation:
♻️ Proposed tweak
-                if let Some(summary) = summary {
-                    tracing::info!(
-                        "QRInfo processed: stored_cycle_height={:?}, rotated_quorum_count={}, freshly_validated_count={}",
-                        summary.stored_cycle_height,
-                        summary.rotated_quorum_count,
-                        summary.freshly_validated_count,
-                    );
-                }
+                if let Some(summary) = summary {
+                    tracing::info!(
+                        stored_cycle_height = ?summary.stored_cycle_height,
+                        rotated_quorum_count = summary.rotated_quorum_count,
+                        freshly_validated_count = summary.freshly_validated_count,
+                        "QRInfo processed"
+                    );
+                }
  • Consider logging at debug! if this fires on every QRInfo message in steady-state incremental updates, to avoid noisy info! output after initial sync. Alternatively, only log at info! when freshly_validated_count > 0.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dash-spv/src/sync/masternodes/sync_manager.rs` around lines 304 - 311, The
current tracing::info! call interpolates values into the message and omits the
chain tip, so change the log to emit structured fields and include the tip
height for correlation: replace the formatted string usage around the QRInfo
summary (the block that inspects summary and logs stored_cycle_height,
rotated_quorum_count, freshly_validated_count) with a structured event that
passes those values as named fields (e.g.,
stored_cycle_height=summary.stored_cycle_height,
rotated_quorum_count=summary.rotated_quorum_count,
freshly_validated_count=summary.freshly_validated_count, tip_height=<obtain tip
value>) and reduce noise by logging at debug level or only using info! when
summary.freshly_validated_count > 0.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@dash/src/sml/masternode_list_engine/mod.rs`:
- Around line 618-662: Summary: freshly_validated_count is incremented even when
verify_rotated_quorums is false, so it misreports quorums that weren’t actually
validated. Fix: in the mapping that builds qualified_last_commitment_per_index
(the closure over last_commitment_per_index where known_qualified_quorum_entry
is checked and the else branch attaches
VerifyingChainLockSignaturesType::Rotating), only increment
freshly_validated_count when verify_rotated_quorums is true; alternatively, if
you prefer semantics that count newly seen rotated quorums regardless of
validation, rename freshly_validated_count to freshly_qualified_count and update
any uses (including where validate_rotation_cycle_quorums_validation_statuses is
called) to reflect the new name. Reference symbols: freshly_validated_count,
known_qualified_quorum_entry, verify_rotated_quorums,
validate_rotation_cycle_quorums_validation_statuses, QualifiedQuorumEntry,
VerifyingChainLockSignaturesType::Rotating.

---

Nitpick comments:
In `@dash-spv/src/sync/masternodes/sync_manager.rs`:
- Around line 304-311: The current tracing::info! call interpolates values into
the message and omits the chain tip, so change the log to emit structured fields
and include the tip height for correlation: replace the formatted string usage
around the QRInfo summary (the block that inspects summary and logs
stored_cycle_height, rotated_quorum_count, freshly_validated_count) with a
structured event that passes those values as named fields (e.g.,
stored_cycle_height=summary.stored_cycle_height,
rotated_quorum_count=summary.rotated_quorum_count,
freshly_validated_count=summary.freshly_validated_count, tip_height=<obtain tip
value>) and reduce noise by logging at debug level or only using info! when
summary.freshly_validated_count > 0.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6146bb62-3e6d-4074-abe1-7ca25d185872

📥 Commits

Reviewing files that changed from the base of the PR and between 0f48c98 and 426bcc6.

📒 Files selected for processing (2)
  • dash-spv/src/sync/masternodes/sync_manager.rs
  • dash/src/sml/masternode_list_engine/mod.rs

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.24%. Comparing base (0093278) to head (103f890).
⚠️ Report is 1 commits behind head on v0.42-dev.

Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #686      +/-   ##
=============================================
+ Coverage      70.22%   70.24%   +0.02%     
=============================================
  Files            319      319              
  Lines          66686    66774      +88     
=============================================
+ Hits           46830    46907      +77     
- Misses         19856    19867      +11     
Flag Coverage Δ
core 75.82% <100.00%> (+0.01%) ⬆️
ffi 45.04% <ø> (-0.15%) ⬇️
rpc 20.00% <ø> (ø)
spv 86.61% <ø> (+0.10%) ⬆️
wallet 68.79% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/sync/masternodes/sync_manager.rs 59.74% <ø> (ø)
dash/src/sml/masternode_list_engine/mod.rs 78.75% <100.00%> (+0.23%) ⬆️

... and 15 files with indirect coverage changes

@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label Apr 24, 2026
@github-actions github-actions Bot removed the ready-for-review CodeRabbit has approved this PR label Apr 24, 2026
@xdustinface xdustinface marked this pull request as draft April 24, 2026 14:11
@xdustinface xdustinface marked this pull request as draft April 24, 2026 14:11
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