Skip to content

test(dash-spv): drop a restored cycle with another entry hash - #1392

Merged
ZocoLini merged 3 commits into
devfrom
pasta/spv-restore-filter-entry-hash-test
Nov 12, 2026
Merged

ZocoLini merged 3 commits into
devfrom
pasta/spv-restore-filter-entry-hash-test

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #1324 for a review suggestion that came in as it merged: no test covered the entry-hash comparison in retain_listed_cycles. The existing drop test uses lists that lack the rotated quorums entirely, so it drops a cycle on a missing quorum, never on a hash mismatch.

The new test gives every list a stored cycle's quorum under the same type and quorum hash, but with a different quorum_vvec_hash and so a different entry hash. It expects that cycle not to be restored and the other stored cycle to be kept. It fails when the comparison is replaced by true.

🤖 Generated with Claude Code

PR Hygiene · 964adcd

  • Bots — coderabbitai ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • dash-spv (dash-spv/src/sml_engine/snapshot_codec.rs) — QuantumExplorer or ZocoLini or xdustinface

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • Tests
    • Expanded snapshot restoration coverage for cases where quorum data differs from the stored cycle data. The checks verify that inconsistent cycle data is excluded while valid cycles and lists are preserved. This strengthens regression coverage for snapshot handling without changing user-facing functionality.

A snapshot whose lists hold a stored cycle's quorum under the same type and quorum hash, but with a different quorum_vvec_hash and so a different entry hash, restores without that cycle and keeps the other stored cycle. Without the entry-hash comparison in the restore filter the cycle comes back and the test fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The snapshot test suite adds an asynchronous restoration test. It changes a listed quorum’s vector hash and verifies that restoration omits the cycle containing the stored quorum hash while retaining the altered lists.

Changes: Snapshot restoration

Layer / File(s) Summary
Test restored quorum-cycle retention
dash-spv/src/sml_engine/snapshot_codec.rs
The test changes matching quorum entries in the lists, recalculates their commitment and entry hashes, and checks the restored cycle and lists.

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

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 964ad

This PR adds a regression test for snapshot restoration and does not change runtime behavior. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding a dash-spv test that drops a restored cycle when its entry hash differs.
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.
Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • 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

Commits

Reviewing files that changed from the base of the PR and between 6167fb7 and 964adcd.

Files selected for processing: 1

  • dash-spv/src/sml_engine/snapshot_codec.rs
Files skipped from review as they are similar to previous changes: 1

  • dash-spv/src/sml_engine/snapshot_codec.rs

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

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 11, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 11, 2026
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

/self-reviewed d5d91a4

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 11, 2026
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.68%. Comparing base (089fee2) to head (6167fb7).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1392      +/-   ##
==========================================
- Coverage   85.68%   85.68%   -0.01%     
==========================================
  Files         268      268              
  Lines       70311    70345      +34     
==========================================
+ Hits        60249    60272      +23     
- Misses      10062    10073      +11     
Flag Coverage Δ
core 82.80% <ø> (ø)
rpc 52.10% <ø> (ø)
spv 94.39% <100.00%> (-0.04%) ⬇️
wallet 83.53% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/sml_engine/snapshot_codec.rs 98.50% <100.00%> (+0.11%) ⬆️

... and 5 files with indirect coverage changes

@manki-review

manki-review Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

✅ Review complete in 6m 35s

Planner (7s)
    feat · 44 lines · 2 agents
    judge effort: medium

Review (behavior · pair): 1 finding
    ✅ Claude Sonnet 5.5 · high: 0 findings (9s)
    ✅ Claude Opus 5.5 · high: 1 finding (25s)

Judge: 1 kept · 0 dropped (30s)
    kept: 1 suggestion

Review metadata

Config:

  • Models: reviewer=claude-sonnet-5-5, judge=claude-opus-5-5
  • Triage: trivial=false, subtle=true, paired=true (planner)
  • Team: Claude Sonnet 5.5 · high, Claude Opus 5.5 · high
  • Memory: enabled (central)

Account limits:

  • Claude subscription: weekly 11% (resets 2026-11-17 05:00 UTC)

Judge decisions:

  • Kept: "New test builds its mismatched state by editing engine internals instead of through the snapshot input" (suggestion, medium confidence): "suggestion. The claim is accurate: the loop at dash-spv/src/sml_engine/snapshot_codec.rs:637 mutates engine.masternode_lists directly, and lines 643-645 rewrite quorum_vvec_hash, commitment_hash and entry_hash by hand. That conflicts with the AGENTS.md rule to test through the public API. The test is still useful. It encodes the state with snapshot() and decodes it with the real from_snapshot, so it runs the changed retain_listed_cycles comparison and fails when that comparison is replaced by true. A snapshot whose lists and cycles disagree is the kind of input from disk the check guards against, so the hand-built state is not unreachable in kind. This is a test-convention issue, not a test that cannot fail, so it is a suggestion. Editing the encoded payload, or adding a short note that the edit stands in for such a snapshot, would satisfy the rule."

Timing:

  • Parse: 8.4s
  • Review agents: 356.5s
  • Judge: 30.0s
  • Total: 394.8s

manki-review[bot]
manki-review Bot previously approved these changes Nov 11, 2026

@manki-review manki-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved. 1 suggestion, which doesn't block.

What this does: Adds a test for restoring a saved masternode engine. It checks that a stored quorum cycle is dropped when the saved lists hold that quorum with different contents, and that the other cycles and all lists come back unchanged.


Related work: open PRs and issues that may cover the same change. None of them blocks.


What to test

The review model wrote these steps. Check what a step runs before you follow it.

Setup: A checkout of the branch with the dash test fixtures under dash/tests/data/test_DML_diffs/.

  1. Run cargo test -p dash-spv --lib a_snapshot_drops_a_cycle_its_lists_hold_with_another_entry_hash. Expect it to pass.
  2. Run cargo test -p dash-spv --lib snapshot_codec. Expect every snapshot test to pass, including a_snapshot_restores_the_cycles_its_lists_hold.
  3. Temporarily make retain_listed_cycles match cycles by quorum hash only, not entry hash, and rerun the new test. Expect it to fail on the only the altered cycle is dropped assertion.
About this review
  • Reviewed 6167fb7, round 1
  • 44 changed lines read in 6m 35s
  • Found by claude-sonnet-5-5 and claude-opus-5-5, judged by claude-opus-5-5
  • Tokens: 101k in (3k from cache) · 6k out · about $0.51 at API prices
  • How Manki reviews

@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — dash-spv: QuantumExplorer or ZocoLini or xdustinface.
Full checklist in the description.

@github-actions github-actions Bot added the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Nov 11, 2026
No diff or QRInfo can make a masternode list disagree with a stored rotation cycle, so the test edits the lists directly to stand in for a saved snapshot in that state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@manki-review

manki-review Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

✅ Review complete in 1m 55s

Planner (5s)
    feat · 45 lines · 2 agents
    judge effort: medium

Review (behavior · pair): 0 findings
    ✅ Claude Sonnet 5.5 · high: 0 findings (11s)
    ✅ Claude Opus 5.5 · high: 0 findings (18s)

Judge: 0 kept · 0 dropped (21s)

Review metadata

Config:

  • Models: reviewer=claude-sonnet-5-5, judge=claude-opus-5-5
  • Triage: trivial=false, subtle=true, paired=true (planner)
  • Team: Claude Sonnet 5.5 · high, Claude Opus 5.5 · high
  • Memory: enabled (central)

Account limits:

  • Claude subscription: weekly 15% (resets 2026-11-17 05:00 UTC)

Timing:

  • Parse: 12.8s
  • Review agents: 80.7s
  • Judge: 21.2s
  • Total: 114.7s

Last reviewed 964adcd · head 964adcd · up to date

  • Pause automatic reviews
  • Review again
  • Deeper review

@manki-review manki-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved.

What this does: Adds a test for restoring a saved masternode engine snapshot. When a stored quorum cycle disagrees with the matching quorum in the saved lists, only that cycle is dropped on restore.


Related work: open PRs and issues that may cover the same change. None of them blocks.


What to test

The review model wrote these steps. Check what a step runs before you follow it.

Setup: Run the dash-spv unit tests, which load the mainnet 2240504 fixtures from dash/tests/data/test_DML_diffs/.

  1. Run cargo test -p dash-spv --lib a_snapshot_drops_a_cycle_its_lists_hold_with_another_entry_hash. Expect it to pass.
  2. Run cargo test -p dash-spv --lib snapshot_codec. Expect all snapshot tests to pass, including a_snapshot_restores_the_cycles_its_lists_hold.
  3. Temporarily make retain_listed_cycles ignore the entry hash and rerun the new test. Expect it to fail on "only the altered cycle is dropped".
About this review
  • Reviewed 964adcd, round 2
  • 45 changed lines read in 1m 55s
  • Found by claude-sonnet-5-5 and claude-opus-5-5, judged by claude-opus-5-5
  • Tokens: 236k in (106k from cache) · 5k out · about $0.63 at API prices
  • How Manki reviews

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. labels Nov 11, 2026
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

/self-reviewed 964adcd

@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — dash-spv: QuantumExplorer or ZocoLini or xdustinface.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 11, 2026
@ZocoLini
ZocoLini merged commit d6adbff into dev Nov 12, 2026
7 of 11 checks passed
@ZocoLini
ZocoLini deleted the pasta/spv-restore-filter-entry-hash-test branch November 12, 2026 15:10
manki-review Bot added a commit to manki-review/review-memory that referenced this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants