Repository navigation
fix(dash-spv)!: refuse QRInfo entries missing from the tip list
#1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a3be62e
fix(dash-spv)!: refuse `QRInfo` entries missing from the tip list
PastaPastaPasta 0ab2ac8
fix(dash-spv)!: drop persisted rotated cycles on restore
PastaPastaPasta 28a1aea
fix(dash-spv): restore persisted rotated cycles their lists hold
PastaPastaPasta ef04a47
test(dash-spv): drop the test that edits a stored cycle by hand
PastaPastaPasta 9256281
fix(dash-spv): keep partial rotated cycles on restore
PastaPastaPasta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ Suggestion, not blocking · Testing · Moderate
No test covers the entry-hash checks, which are the core of the fix
Why:
retain_listed_cyclesdrops a restored cycle when a list holds its quorum with a different entry hash. That is the case the PR names: an earlier build stored a served entry that no list held. The only drop test,a_snapshot_drops_a_cycle_no_restored_list_holds, uses lists that lack the rotated quorums entirely, so changing.is_some_and(|listed| listed.entry_hash == ...)to.is_some()fails no test. The newentry_hashcomparison inknown_qualified_quorum_entry(line 615) has no test either, becauseactive_set_from_tip_listrefuses every altered entry before the reuse lookup runs.How to fix it, 4 places read, and 2 other checks
How to fix it
Add a snapshot test that stores a cycle whose entry has the same type and quorum hash as a list's entry but a different field, such as
quorum_vvec_hash, and expects the cycle dropped on restore. Add a feed test where a stored cycle holds a commitment that differs from the tip list's, and expect the listed entry to be validated rather than the stored one reused.Checked in the code
.is_some_and(|listed| { listed.entry_hash == stored.quorum_entry.calculate_entry_hash() })is the entry-hash comparisonrust-dashcore/dash-spv/src/sml_engine.rs
Lines 725 to 729 in 9256281
a_snapshot_drops_a_cycle_no_restored_list_holdsusesmainnet_fixture, whose lists, per its doc comment, hold 'only theirChainLockquorums'. The quorum loo…rust-dashcore/dash-spv/src/sml_engine/snapshot_codec.rs
Lines 606 to 610 in 9256281
&& qualified_entry.entry_hash == listed.entry_hashwas added toknown_qualified_quorum_entryrust-dashcore/dash-spv/src/sml_engine.rs
Lines 614 to 618 in 9256281
dash-spv/src/sml_engine.rs:915:active_set_from_tip_listruns before the reuse loop and refuses any served entry whose hash differs from the tip list's, soan_altered_served_entry_is_refu…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is valid for the restore filter. This PR merged before the test landed, so it is in the follow-up #1392:
a_snapshot_drops_a_cycle_its_lists_hold_with_another_entry_hash. It changes thequorum_vvec_hashof a stored cycle's quorum in every list the snapshot holds (recomputing that entry's hashes), then expects that cycle not to be restored and the other stored cycle to be kept. It fails when the entry-hash comparison inretain_listed_cyclesis replaced bytrue.I added no feed test for the clause in
known_qualified_quorum_entry, because no public path stores an entry that differs from the tip list's under the same type and quorum hash.active_set_from_tip_listpasses only entries the tip list holds with the served entry hash, each list comes from a coinbase-checked diff, a restore keeps a cycle only when a list holds it with the same entry hash, andtruncate_abovedrops every cycle whose commitments may have been mined on a dropped branch. A test would have to build that state by hand, as the stored-cycle test this PR removed did. The clause stays so the reuse lookup matches entries by the same type, quorum hash and entry hash as the tip-list check and the restore filter.🤖 Posted autonomously by Claude on behalf of pasta.