Skip to content

fix(dash-spv): settle the requests a peer skipped - #1563

Merged
ZocoLini merged 8 commits into
devfrom
fix/settle-skipped-requests
Dec 2, 2026
Merged

ZocoLini merged 8 commits into
devfrom
fix/settle-skipped-requests

Conversation

@xdustinface

@xdustinface xdustinface commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Dash Core sends nothing for a getcfheaders or getcfilters whose range its filter index lacks, nor for a block it does not have. The byte charge of such a request stayed on the peer's ledger for the life of the connection, so the router saw less room at that peer than it had. A skipped getcfilters was worse: every later cfilter added its bytes to the skipped batch, no later batch of that peer ever settled, and its charges piled up until the peer looked full.

Peers answer in request order, so a filter header, filter or block reply now settles the charge of every earlier request of those kinds the peer still owes, and a cfilter settles the batch whose stop hash it carries. The bytes a skipped batch collected count toward the batch that was actually served.

Split out of #1374, which keeps the retry of a refused request at another peer.

PR Hygiene · 66e7693

  • Bots — coderabbitai skipped after its own rate limit
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

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.

Dash Core sends nothing for a `getcfheaders` or `getcfilters` whose range its filter index lacks, nor for a block it does not have. The byte charge of such a request stayed on the peer's ledger for the life of the connection, which shrank the room the router saw for that peer. A skipped `getcfilters` was worse: every later `cfilter` added its bytes to the skipped batch and no later batch of that peer ever settled, so its charges piled up until the peer looked full.

Peers answer in request order, so a filter header, filter or block reply now settles the charge of every earlier request of those kinds the peer still owes, and a `cfilter` settles the batch whose stop hash it carries. The bytes a skipped batch collected count toward the batch that was actually served.
@manki-review

manki-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

This pull request is a draft, so Manki does not review it automatically. Marking it ready for review starts automatic reviews. Until then, someone with write access to this repository can tick a box below: Review this draft reviews the current commit once, Deeper review does so with more effort, and Review every push reviews it now and again after each push.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9fe5ac1 and 66e7693.

Files selected for processing: 6

  • dash-spv/src/network/broker.rs
  • dash-spv/src/network/costs.rs
  • dash-spv/src/network/manager.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/test_utils/mod.rs
  • dash-spv/src/test_utils/network.rs
  • 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

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

CI does not run on this PR while it is a draft. Someone with write access can start it here:

  • Run CI once on the current commit
  • Run CI on every push, starting now

Marking the PR ready for review also starts CI.

CI started for d510056: Continuous integration, Pre-commit Checks, Sanitizer.

@manki-review

manki-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

✅ Review complete in 11m 0s

Planner (6s)
    feat · 101 lines · 2 agents
    judge effort: medium

Review (behavior · full): 8 findings
    ✅ Claude Opus 5.5 · high: 2 findings (2m 32s)
    ✅ GPT 6.2 Sol · high: 5 findings (3m 24s)
    ✅ Related checks, claim checks, pattern checks and fix checks: 11 of 11 done (1m 41s)
    ✅ Second reads: 1 of 1 done, 1 finding (1m 25s)

Judge (4m 24s)
    graded 8 findings: 5 kept · 1 dropped · 2 merged
    dropped, as the finders filed them: 1 warning
    refuter: 3 checked · 2 confirmed · 1 unsettled
    origin checks: 3 checked
    verdict reader: read the diff (1m 3s)

Posted: 2 findings
    2 suggestions
    not posted: 1 rare trigger · 2 no proof

Review metadata

Config:

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

Account limits:

  • Claude subscription: weekly 9% (resets 2026-12-04 01:00 UTC)
  • ChatGPT subscription: weekly 10% (resets 2026-12-02 01:49 UTC)

Judge decisions:

  • Not listed, a check of the code could not confirm it: "A cfilter from an older overlapping batch settles a newer batch and releases the one still streaming" (warning): "warning. Line 246 now matches the cfilter block hash against every awaited CFilters entry, not only the first one. A filter inside an older batch that equals a newer batch's stop settles the newer batch. Line 266 then drains the older batch as skipped while it is still streaming. Both charges are released early, so in_flight_bytes at that peer reads low and the router over-sends until later batches settle. The byte sample at line 275 also mixes two batches. The damage is transient budgeting and estimate error, not lost data, so the cell is degraded. Whether overlapping batches really share a peer ledger after reset_for_rescan (sync_manager.rs:248, pipeline.rs:84) is not settled by the code shown.
    Refutation confirmed: The path the finding describes exists. After a rescan that clears the stored filters, the new batches start at scan_start, so their boundaries can fall inside old batches the peer is still streaming. The peer ledger keeps those old entries, so line 246 can match a filter from an old batch to a new batch's stop, and line 266 then drains the old batch early. The damage is only a temporary undercount of in_flight_bytes and one mixed byte sample, and it heals once both batches finish streaming, so t... Rule checked: Peers answer getcfilters in order and a cfilter carries only its block hash, so the ledger can only match a filter to a request by its stop hash, and a filter of one batch that equals another batch's stop hash cannot be told apart from that batch's own stop.
  • Premise "After reset_for_rescan, a new getcfilters batch whose stop block lies inside an older batch is charged on the same peer ledger while that peer still streams the older batch" confirmed. reset_for_rescan only releases the broker's request keys, and broker.release just removes the key; nothing removes the old batches' entries from the peer ledger, which only settle removes. The new batches start at scan_start when stored filters do not reach it, so their stops need not line up with the old ones. The router sends each one to any open peer that has room, including a peer still owing an old batch.
    Pair refutation confirmed: The ledger credits the filter to the oldest batch, then can match it to a newer batch’s stop, release both charges, and record the older batch’s partial bytes against the newer batch. That inflates the router’s available budget, but I did not verify the cited Dash Core send loop needed to establish the peer-side sequence in normal use. Rule checked: A block hash identifies a filter, not the request that produced it, so a stop-hash match does not establish which overlapping batch has ended.
  • Premise "After reset_for_rescan, a new getcfilters batch whose stop block lies inside an older batch is charged on the same peer ledger while that peer still streams the older batch" confirmed. On the client side, adding a wallet that needs an earlier scan can shift batch boundaries when stored filters do not cover the new start; the reset unregisters old on-wire requests without clearing their peer charges, and the router can charge a replacement to the same peer if it still has room."
  • Kept: "No test checks that a skipped batch's bytes are added to the served batch" (suggestion): "note. The new test asserts only in_flight_bytes (costs.rs:435). Deleting a.bytes += earlier.bytes at line 271 changes only what record stores at line 275, so no test fails. This is missing coverage."
  • Not listed, its trigger is rated below review.min_warning_trigger: "Unverified filter traffic can inflate the block estimate for every peer" (warning): "warning. Line 244 adds the size of every cfilter to the first awaited CFilters entry, even when its hash matches no stop. When a block reply arrives, line 264 treats Block as in order. Line 266 drains the earlier CFilters entry, and line 271 adds its bytes to the block's sample. Line 275 then records those bytes into the Block estimate. That estimate is shared by every peer (peer.rs:701) and prices every block request (broker.rs:350). A peer's stray or malicious filter traffic can inflate it and slow block downloads everywhere. The comment at line 270 only holds when every filter belongs to a later served batch.
    Refutation confirmed: Every network message reaches settle unfiltered (peer.rs:780). In settle, any cfilter adds its size to the first awaited CFilters entry before its hash is checked against a stop (costs.rs:239-248). A later block reply drains that earlier in-order entry and adds its bytes to the block sample (costs.rs:264-271). That sample is then recorded into the Block estimate, which every peer's ledger shares (costs.rs:275, peer.rs:701). Rule checked: A shared estimate that is a moving average with weight 0.3 takes whatever byte count the ledger attributes to a reply. So bytes from any message the ledger accepts without validating it go straight into the price of every later request of that kind.
  • Premise "This trigger happens in realistic use: when a peer sends cfilter messages that match no awaited stop while a filter batch is charged, then answers a later block request" confirmed. The premise holds for outside input. Nothing before settle checks whether a cfilter was requested, and line 244 adds its size before line 246 checks for a stop. A peer that sends unrequested or stray cfilters and then answers a later block request triggers it. An honest peer serving batches in order does not, because each batch's stop filter settles that batch before the block reply arrives.
    Pair refutation confirmed: The ledger adds filter bytes before checking for a matching stop hash. When a matching block reply settles a later request on the same connection, it inherits those bytes and records them in the shared block estimate. Rule checked: A response-size estimate is only as accurate as the byte accounting that attributes traffic to each reply type.
  • Premise "This trigger happens in realistic use: when a peer sends cfilter messages that match no awaited stop while a filter batch is charged, then answers a later block request" confirmed. The broker can charge a block request while an earlier filter batch remains outstanding on the same connection, and the reader passes both non-stop filters and the subsequent block reply to the ledger without first checking filter membership.", trigger 3 and harm 4 of 10: "The bytes only move into the block estimate when a peer skips a filter batch or sends unrelated cfilters while a filter request is outstanding and a block reply follows; that takes a misbehaving or unusual peer, not normal in-order replies."
  • Dropped: "Skipped requests stay active in the broker after the ledger releases them" (ignore): "ignore. The broker's deadline refresh (broker.rs:269-281) and its retry without kicking (broker.rs:309-319) do not read the ledger and are unchanged by this PR. Before the PR the broker also never learned of a skipped request. The ledger releasing a charge earlier does not change broker timing. The described broker behaviour lies outside what this PR changes or affects."
  • Kept: "The ledger tests duplicate existing request builders" (suggestion): "note. get_cfheaders at costs.rs:304 is identical to broker.rs:798. get_cfilters and get_block are near copies of broker.rs:790 and broker.rs:818. The rule asks to reuse or extend existing helpers. This is duplication with no runtime effect."
  • Not listed, a check of the code could not confirm it: "The peer test for charging in write order passes even when the charge order is wrong" (warning): "warning. The test sends request 1 first, but it is held back, so request 2 is written first. Replies arrive as cfilter(2) then cfilter(1) (peer.rs:973-981). If charges were misordered as [1, 2], the reply cfilter(2) now matches entry 2 at index 1 (costs.rs:246), and line 266 drains entry 1 as skipped. Then cfilter(1) finds no CFilters entry and returns (costs.rs:239). The test reaches 0 in both orders. Before this PR the misordered case left batch 2 charged and failed the test. The PR thus made an existing test unable to fail on the regression it guards.
    Refutation unsettled: If the charges were misordered as [1, 2], reply cfilter(2) adds its bytes to batch 1 at index 0, then finds batch 2 at index 1 (costs.rs:246). The new drain at costs.rs:266 releases batch 1 as skipped, and reply cfilter(1) then finds no CFilters entry and returns at costs.rs:239-241. The correct order also ends at 0, so the assertion at peer.rs:981 holds either way. Before this PR, the misordered case returned early when cfilter(2) did not match batch 1. Reply cfilter(1) then settled batch 1, wh... Rule checked: A regression test protects an invariant only when breaking that invariant changes the value the test asserts. Here the new in-order skip logic sends both charge orders to the same in_flight_bytes value of 0.
  • Premise "This trigger happens in realistic use: when a change moves ledger.charge out of the writer lock at peer.rs:346" unsettled. The premise is about whether a developer will later move ledger.charge out of the writer lock. No code can show what future edits someone will make. The code shows only that charging currently happens under that lock and that no test would catch it if it moved.
    Pair refutation unsettled: With charges ordered [1, 2], reply 2 now settles batch 2 and releases batch 1 as skipped, so reply 1 finds nothing left. With charges ordered [2, 1], each reply settles its own batch; either way, the final balance is zero. Rule checked: A test cannot detect an ordering regression if both orders produce the same value at the assertion.
  • Premise "This trigger happens in realistic use: when a change moves ledger.charge out of the writer lock at peer.rs:346" unsettled. The proposed lock change is not a runtime trigger in the current code: the send path acquires the writer lock before charging and keeps it through the write."

Timing:

  • Parse: 7.7s
  • Review agents: 388.3s
  • Judge: 264.2s
  • Total: 660.2s

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.79%. Comparing base (9fe5ac1) to head (66e7693).
⚠️ Report is 4 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1563   +/-   ##
=======================================
  Coverage   87.79%   87.79%           
=======================================
  Files         270      270           
  Lines       72494    72513   +19     
=======================================
+ Hits        63645    63662   +17     
- Misses       8849     8851    +2     
Flag Coverage Δ
core 83.43% <ø> (ø)
rpc 83.43% <ø> (ø)
spv 95.31% <100.00%> (-0.01%) ⬇️
wallet 83.43% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/network/broker.rs 99.18% <100.00%> (-0.02%) ⬇️
dash-spv/src/network/costs.rs 97.29% <100.00%> (+1.05%) ⬆️
dash-spv/src/network/manager.rs 97.49% <ø> (+0.04%) ⬆️
dash-spv/src/sync/blocks/manager.rs 95.45% <100.00%> (-0.05%) ⬇️

... and 3 files with indirect coverage changes

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

Approval held: this PR is a draft. Mark it ready for review, and Manki approves it if nothing else holds the approval. If the latest commit has no review yet, Manki reviews it first when automatic review runs on this PR. If nothing happens, as for a PR from a fork or while automatic review is off or paused, comment /manki check, and Manki approves or says what holds the approval.

✅ Approved. 2 suggestions, none of which block.

  • Check approval

What this does: When a peer silently skips a block or compact-filter request, the client kept counting those bytes as still owed forever. A reply to a later request of these kinds now clears the earlier unanswered ones, so the peer's in-flight byte budget stays accurate.


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 and a regtest sync against dashd with just dash-spv::test.

  1. Run cargo test -p dash-spv --lib a_reply_settles_the_requests_its_peer_skipped. Expect the filter headers, filters and blocks cases to pass.
  2. Run cargo test -p dash-spv --lib network::costs. Expect the existing header and silence tests to still pass.
  3. Sync a fresh wallet against regtest dashd. Expect filter and block sync to complete with no stalled peer.
  4. Restart the client mid filter sync. Expect it to resume and finish.
  5. Edge case: request a block the node does not have, followed by another block. Expect the second block's arrival to clear the first request from the peer's in-flight bytes, and an outstanding header request to stay counted.

Checked and left out: 3 findings (2 unproven, 1 rare)

Not proven, so not listed · 2 warnings

  • A cfilter from an older overlapping batch settles a newer batch and releases the one still streaming · dash-spv/src/network/costs.rs:246
    A check of the code could not confirm it.
  • The peer test for charging in write order passes even when the charge order is wrong · dash-spv/src/network/costs.rs:266
    A check of the code could not confirm it.

Rare trigger, so not listed · 1 warning

The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.

About this review
  • Reviewed d510056, round 1
  • 101 changed lines read in 11m 0s
  • Found by claude-opus-5-5 and gpt-6.2-sol, judged by claude-opus-5-5
  • Tokens: 3.6M in (2.8M from cache) · 94k out · about $5.10 at API prices
  • Runner: self-hosted · started after 14s · peak memory 3.5 GiB of 30.0 GiB
  • How Manki reviews

Comment thread dash-spv/src/network/costs.rs Resolved
Comment thread dash-spv/src/network/costs.rs Resolved
The ledger test for skipped requests only checked the settled byte charges, so dropping the transfer of a skipped filter batch's bytes to the served batch broke no test. It now also checks that the served reply sizes the `CFilters` estimate exactly as it would with nothing skipped.
@manki-review

manki-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

✅ Review complete in 7m 30s

Planner (4s)
    feat · 106 lines · 2 agents
    judge effort: medium

Review (behavior · full): 6 findings
    ✅ Claude Opus 5.5 · high: 1 finding (1m 46s)
    ✅ GPT 6.2 Sol · high: 5 findings (2m 32s)
    ✅ Related checks, claim checks, pattern checks and fix checks: 12 of 12 done (1m 14s)

Judge (4m 18s)
    before the judge: 1 possible problem not finished checking
    graded 5 findings: 4 kept · 1 dropped
    dropped, as the finders filed them: 1 blocker
    refuter: 2 checked · 1 confirmed · 1 unsettled
    origin checks: 2 checked
    verdict reader: read the diff (50s)

Posted: 2 findings
    1 warning · 1 suggestion
    not posted: 1 already caught by a test · 1 rare trigger

Review metadata

Config:

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

Account limits:

  • Claude subscription: weekly 10% (resets 2026-12-04 01:00 UTC)
  • ChatGPT subscription: weekly 10% (resets 2026-12-02 01:49 UTC)

Judge decisions:

  • Kept: "An intermediate compact filter can settle two requests that are still pending" (warning): "warning. The new search at dash-spv/src/network/costs.rs:246 matches a cfilter against any pending batch's stop hash. The partition at line 266 then releases every earlier filter batch. If the ranges overlap, a filter in the middle of the first batch settles both charges early. The peer then looks emptier than it is, and the rest of the first batch's filters find no stop. Whether the client ever sends overlapping ranges to one peer is not shown, so it is listed as a doubt. The broker half of the claim (manager.rs:1377) is unchanged by this PR and is not graded here.
    Refutation unsettled: The mechanism is real (costs.rs:245-246 matches any pending batch, and 263-273 clears earlier ones). Normal pipeline batches never overlap; only a rescan restart leaves old requests pending in a peer's ledger while new requests with shifted ranges are sent. I could not show those new requests reach the same peer. The effect is also a temporary undercount of in-flight bytes plus one skewed reply-size sample, which clears once the old reply finishes. Rule checked: A ledger that pairs each compact filter with whichever pending getcfilters request has that stop hash, and then clears every earlier pending request, mispairs replies whenever one pending range contains another pending request's stop block.
  • Premise "The filter sync sends getcfilters requests whose ranges overlap, so the stop hash of one in-flight batch lies inside an earlier in-flight batch's range at the same peer" unsettled. Normal batches are disjoint (pipeline.rs:83-88, 100-105). Overlap appears only after a rescan restart: reset_for_rescan releases the old requests only in the broker (manager.rs:256-263, broker.rs:161-170) and start_download sends new batches from a different start. I did not verify that the new batch is sent to the same peer that still owes the old one.
  • Premise "This trigger happens in realistic use: when two getcfilters batches in flight at one peer have overlapping ranges" unsettled. The only realistic sequence is a wallet found behind the committed scan height while filter batches are still pending (sync_manager.rs:222-250), plus the broker choosing the same peer, which I could not check; ordinary sync never sends overlapping batches.
    Pair refutation confirmed: A wallet rescan can change the batch boundaries while an old request remains charged to the same peer. A filter from the old range that matches the new stop hash makes the ledger release both charges. Rule checked: A block hash identifies an individual compact filter, not the request that produced it, so a stop-hash match cannot distinguish overlapping responses.
  • Premise "The filter sync sends getcfilters requests whose ranges overlap, so the stop hash of one in-flight batch lies inside an earlier in-flight batch's range at the same peer" confirmed. Batches within one pipeline are disjoint, but a rescan can shift the boundaries while only unregistering the old requests from the broker, so a new stop can fall inside an old range still charged at the same peer.
  • Premise "This trigger happens in realistic use: when two getcfilters batches in flight at one peer have overlapping ranges" confirmed. The regular sync tick restarts downloads for a newly added wallet that needs earlier history, without waiting for old replies to finish or preventing the same peer from receiving new batches.", trigger 4 and harm 5 of 10: "Only overlapping outstanding filter ranges reach this, e.g. a filter batch re-requested after a restart while the old one is still pending; that is uncommon but plausible."
  • Not listed, its trigger is rated below review.min_warning_trigger: "Unmatched filter traffic can inflate block response costs for every peer" (warning): "warning. Line 244 adds every cfilter frame's size to a pending filter batch, even when no stop matches. Line 266 then picks earlier entries by in_order() whatever the matched reply's kind. So a block reply folds those filter bytes into a.bytes, and line 275 records them in the block estimate. That estimate is shared through state.costs (peer.rs:701) and prices block requests for routing to every peer (broker.rs:350). Before this PR such bytes could only reach the filter estimate. Sync slows because block requests look too costly to fit the budget.
    Refutation disproved: The fold does happen as described: line 244 adds the bytes of each cfilter frame to the first pending filter batch, and lines 264-275 add those bytes into a block reply's sample. But it only occurs when a peer answers part of a filter batch and then serves a later block. An honest Dash Core peer never does that, so whether the defect matters depends on what a hostile peer chooses to send, which reading the code cannot settle. Rule checked: A Dash Core peer handles each message in turn and answers getcfilters synchronously, so the cfilter messages of one batch always arrive before the reply to any later request.
  • Premise "This trigger happens in realistic use: when a peer sends cfilter messages that end no pending batch while a filter batch is pending, then answers a block request" disproved. Dash Core either sends nothing for a getcfilters request (when the lookup fails) or pushes every filter up to the stop hash in one pass. The last frame then matches the batch's stop entry and the bytes go to the filter estimate, so normal use never leaves a partly served batch pending while a later block reply arrives. Only a peer that breaks the protocol produces that sequence.
    Pair refutation confirmed: A CFilter whose hash matches no pending stop still adds bytes to the oldest pending filter batch. When a matching block reply settles a later request, the ledger transfers those bytes to the block sample and updates the shared estimate. Rule checked: A peer-supplied frame can distort a shared response-cost estimate if its bytes are counted before attribution and later recorded under a different reply type.
  • Premise "This trigger happens in realistic use: when a peer sends cfilter messages that end no pending batch while a filter batch is pending, then answers a block request" confirmed. The send path permits a later block request while a filter batch is pending, and the reader accepts both non-stop CFilter frames and the matching block into the ledger without requiring the filter batch to finish first.", trigger 2 and harm 4 of 10: "It needs a peer that streams unmatched or extra CFilter frames and then skips that batch before answering a later block request, which is essentially a misbehaving or malicious peer."
  • Dropped: "Clearing a skipped request's charge can leave its retry waiting indefinitely" (ignore): "ignore. A skipped request stays OnWire in the broker, and refresh (broker.rs:271) keeps refreshing it. Both are behaviour of broker.rs and manager.rs, which this PR does not change. Before this PR the skipped request was refreshed the same way. The ledger release at costs.rs:269 only frees byte room and does not change the broker's timeout handling. The retry is out of this PR's code."
  • Not listed, an existing test already fails when the change it names is reverted: "The cost assertion does not check bytes from a streamed filter response" (suggestion): "note. In the filters case, cfilter(2) adds its 100 bytes to the skipped batch at line 244. The served batch then gets them only through line 271. Removing that line records 0 instead of 100 and fails the assertion at line 440. The cfheaders comparison is vacuous because record skips CfHeaders (line 149), and a multi-frame batch would make the test stronger. This is optional test strengthening."
  • Kept: "The ledger tests duplicate the broker's request fixtures" (suggestion): "note. get_cfheaders at costs.rs:304 is identical to broker.rs:798. get_cfilters and get_block copy the broker builders with small changes, against the repository rule to reuse test helpers. This is the same finding as the earlier round, and the code is unchanged."

Timing:

  • Parse: 8.0s
  • Review agents: 184.0s
  • Judge: 258.0s
  • Total: 449.9s

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

⚠️ 1 warning to address. Fix it, reply in its thread with a reason Manki accepts, or tick Create an issue for this to track it for later. The PR is also a draft, so mark it ready for review too. If no approval follows, comment /manki check.


Checked and left out: 2 findings (1 rare, 1 not finished)

Rare trigger, so not listed · 1 warning

Not finished checking · 1 possible problem

The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.

About this review
  • Reviewed e259c58, round 2
  • 106 changed lines read in 7m 30s
  • Found by claude-opus-5-5 and gpt-6.2-sol, judged by claude-opus-5-5
  • Tokens: 3.2M in (2.5M from cache) · 74k out · about $4.10 at API prices
  • Runner: self-hosted · started after 7s · peak memory 4.4 GiB of 30.0 GiB
  • How Manki reviews

Comment thread dash-spv/src/network/costs.rs Resolved
The broker, network manager, mock network and blocks manager tests each built the same `getcfilters`, `getcfheaders` and block `getdata` requests in their own private helpers. They now share `get_cfilters`, `get_cfheaders` and `get_block` from `test_utils`. `get_block` takes the block hash, so callers keep their own hash source.
The ledger tests for skipped requests kept their own copies of the `getcfheaders`, `getcfilters` and block `getdata` builders. They now use the ones in `test_utils`.
The ledger test for skipped requests only paired requests of the same kind. A block reply also settles a filter batch the peer skipped before it, since peers answer filter, filter header and block requests in one order. A case now pins that.
@manki-review

manki-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

✅ Review complete in 11m 23s

Planner (6s)
    refactor · 206 lines · 2 agents
    judge effort: medium

Review (behavior · full): 5 findings
    ✅ Claude Opus 5.5 · high: 1 finding (3m 7s)
    ✅ GPT 6.2 Sol · high: 3 findings (2m 40s)
    ✅ Related checks, claim checks, pattern checks and fix checks: 12 of 12 done (1m 53s)
    ✅ Second reads: 1 of 1 done, 1 finding (2m 7s)

Judge (4m 21s)
    graded 5 findings: 5 kept · 0 dropped
    refuter: 4 checked · 2 confirmed · 2 unsettled
    origin checks: 3 checked · 1 older than this PR
    verdict reader: read the diff (53s)

Posted: 2 findings
    1 warning · 1 suggestion
    not posted: 1 on code an earlier round reviewed · 2 disproved by a check of the code

Review metadata

Config:

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

Account limits:

  • Claude subscription: weekly 20% (resets 2026-12-04 01:00 UTC)
  • ChatGPT subscription: weekly 11% (resets 2026-12-02 01:49 UTC)

Judge decisions:

  • Not listed, on code an earlier round reviewed: "The skip test does not check that the requests kept on the ledger can still be settled" (suggestion): "note. Deleting awaited.splice(0..0, kept) at costs.rs:267 drops the getheaders2 entry from awaited without calling release. in_flight_bytes therefore stays at owed, and the only ledger assert at costs.rs:421 still passes. Settling headers2() afterwards and checking the remaining bytes would catch that revert."
  • Kept: "Unverified filter traffic can inflate the block budget on every peer" (warning): "warning. Each cfilter adds its size to the first CFilters entry before any stop-hash match (costs.rs:239-244). A later block reply then treats that batch as skipped and adds its bytes to the block's sample (costs.rs:266, 271). record at costs.rs:275 then pushes the block estimate up. A peer's own messages are outside input, so a peer can raise the block cost the router budgets with and cut how many block requests fit under each peer's cap (broker.rs:359). Before this PR those bytes could only reach the filter estimate. This is a throughput cost, not resource exhaustion, so it stays on the degraded row.
    Refutation confirmed: settle() adds each cfilter's size to the first pending CFilters entry before it checks that any batch has that stop hash (costs.rs:239-248). A later Block reply then treats that entry as skipped, adds its bytes to its own (costs.rs:264-271) and records them in the shared block estimate (costs.rs:275, 152-155). Every peer's ledger shares that estimate, and the estimate is what each block request is charged. Rule checked: An EMA cost estimate shared by all peers through one Arc takes in whatever byte count settle() hands it, so bytes one peer sends that were credited to the wrong request also land in every other peer's budget.
  • Premise "This trigger happens in realistic use: When a peer sends cfilter messages that end no requested batch and then answers a later getdata for a block" confirmed. On the code side, the reader hands the peer's cfilter messages to settle unchecked, and settle credits their bytes to the oldest filter batch without a stop-hash match. A later block reply then takes those bytes. An honest Dash Core peer sends a full batch or nothing (ProcessGetCFilters returns early or pushes every filter), so only a misbehaving peer produces stray cfilters, and that is input the code accepts.
    Pair refutation confirmed: The ledger adds filter bytes before checking the stop hash. If no stop hash matches, the bytes stay on the pending filter entry; a matching block reply for a later request removes that entry and records its bytes as part of the block sample. The base code did not transfer bytes between entries. Rule checked: When a response-cost estimator transfers bytes from an unfinished request to a completed request of another kind, those bytes affect future requests priced at the completed kind’s shared estimate.
  • Premise "This trigger happens in realistic use: When a peer sends cfilter messages that end no requested batch and then answers a later getdata for a block" confirmed. The code accepts the sequence from the same connection: a non-ending filter leaves its bytes pending, and the reader can then settle a matching reply to a later block request without first requiring the filter batch to complete.", trigger 4 and harm 5 of 10: "It needs a peer that streams filter bytes without finishing the batch, through partial service or malice, and then answers a later block request; honest peers rarely do this."
  • Dropped: "An in-order filter stream can settle two overlapping requests early" (ignore): "warning. The code at costs.rs:245-249 is unchanged since the prior round, and that round's checks confirmed the trigger. A filter inside the first range that carries the second batch's stop hash settles the second batch. The drain at costs.rs:266 then releases the first batch while both replies are still owed. This keeps the prior cell.
    Refutation disproved: The only producer of GetCFilters in the crate is FiltersPipeline::send_pending, which sends back-to-back batches that never overlap. A pipeline is rebuilt only when it is idle, and it resumes after the stored filter tip, so no in-flight batch's range ever contains another batch's stop hash. Rule checked: A filter whose block hash equals another in-flight batch's stop hash can only settle that batch early if a later request's stop hash falls inside an earlier request's range at the same peer, so the defect needs a sender that issues overlapping getcfilters ranges.
  • Premise "This trigger happens in realistic use: When two getcfilters batches with overlapping ranges are in flight at one peer" unsettled. The crate sends getcfilters only from pipeline.rs:154. init and extend_target split the range into back-to-back non-overlapping batches, and start_download runs only when the pipeline is idle and resumes past the stored filter tip, so overlapping batches with a later stop inside an earlier range are never in flight together.
    Pair refutation unsettled: An intermediate filter matching a later stop would release both charges and record only the bytes received so far. The public send path permits that overlap, but the checked sync path creates disjoint ranges and the same-peer concurrency test does not supply overlapping ranges. Rule checked: In an ordered stream of multi-message replies, a filter hash matching a later request’s stop hash does not identify that request if the hash also occurs in an earlier reply.
  • Premise "This trigger happens in realistic use: When two getcfilters batches with overlapping ranges are in flight at one peer" unsettled. The public API forwards requests without an overlap check, but the sync pipeline advances past each batch’s end and the concurrency test uses distinct single-block requests, so neither shows overlapping ranges in flight at one peer."
  • Dropped: "A compact-block fallback may be mistaken for a later full-block reply" (ignore): "warning, unproven open lead. of_item at costs.rs:84-91 tracks only Inventory::Block, so a full block sent as a compact-block fallback would match a charged full-block entry and clear the in-order entries before it. The code shown does not show the client ever asking for compact blocks. The lead rests on that.
    Refutation disproved: dash-spv never asks a peer for a compact block. All four places that build a 'getdata' use full-block, InstantSend-lock, chain-lock or transaction items. No compact-block inventory, 'sendcmpct' or 'getblocktxn' appears anywhere in dash-spv/src. So a block reply always answers a tracked Inventory::Block request. Rule checked: A full 'block' that Dash Core sends instead of a compact block can only be mistaken for a full-block reply if the client sent a compact-block 'getdata' in the first place.
  • Premise "dash-spv sends a getdata with a compact block inventory item to a peer while a full-block getdata for the same hash is charged on that peer's ledger" unsettled. None of dash-spv's 'getdata' senders (block request, InstantSend, mempool, chain lock) puts a compact-block item in the message, and a search for CompactBlock in dash-spv/src finds nothing.
    Pair refutation unsettled: Dash Core's fallback sends a full block, and the changed ledger would use it to settle a matching full-block entry and release earlier in-order charges. The public send API permits both inventory items in one message, but no checked caller, test, or usage example sends both for the same hash. Rule checked: A reply matched only by block hash cannot distinguish a compact-block fallback from the reply to a full-block request for the same hash.
  • Premise "dash-spv sends a getdata with a compact block inventory item to a peer while a full-block getdata for the same hash is charged on that peer's ledger" unsettled. The public send path charges the message before writing it and does not wait for a reply, so the writer lock does not rule out overlap, but the built-in block request uses only full-block inventory and no checked usage supplies the same-hash pair."
  • Kept: "A getmnlistd or getqrinfo that Dash Core drops still stays charged for the life of the connection" (warning): "warning. This PR fixes the leak of skipped-request charges for three kinds through in_order at costs.rs:81 and leaves the sibling kinds out, so the fix is incomplete in the same file. Dash Core drops a rate-limited getmnlistd without a reply (dashpay/dash:src/net_processing.cpp:5667-5669). It also sends nothing when BuildSimplifiedMNListDiff fails (5681-5692). The 64 KB MnListDiff charge (costs.rs:30, 71) then stays on the peer's ledger, and the router sees less room at that peer for the rest of the connection.
    Refutation confirmed: Nothing in Ledger ever removes or expires an awaited MnListDiff or QrInfo entry except a reply with the same key (or, for unkeyed QrInfo, the first matching entry). Dash Core silently drops rate-limited or unbuildable getmnlistd and getqrinfo requests, so their 64 KB or 1 MB charge stays in in_flight_bytes until the connection closes. Rule checked: An entry on a peer's ledger is cleared only by a matching reply, a notfound, or a later in_order reply; Dash Core sends no reply to a getmnlistd or getqrinfo it rate-limits or cannot build, and in_order leaves out MnListDiff and QrInfo.
  • Premise "This trigger happens in realistic use: When a peer rate-limits a getmnlistd or cannot build the diff it asks for" confirmed. Dash Core returns with no reply when the token bucket is empty or when it cannot build the diff, and the client sends tip diffs to whichever peer the broker picks right after headers arrive, so normal use reaches both paths.
    Pair refutation confirmed: A silent drop leaves an extra charge: settlement keeps skipped masternode-list entries, and an unkeyed QRInfo reply removes only the oldest QRInfo entry. The broker subtracts that charge from the peer's available budget, but the cited retry tests cover a rejected QRInfo and a disconnected peer, not a live peer silently dropping either request. Rule checked: A later reply can clear skipped requests only if it identifies where the peer reached in the request queue and the ledger retires the skipped entries.
  • Premise "This trigger happens in realistic use: When a peer rate-limits a getmnlistd or cannot build the diff it asks for" confirmed. On the code path, a normal header-tip update can dispatch a targeted diff without checking whether the selected peer can serve that block, and Dash Core returns without replying if its token check or diff build fails."

Timing:

  • Parse: 9.5s
  • Review agents: 412.4s
  • Judge: 260.8s
  • Total: 682.7s

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

⚠️ 2 warnings to address. Fix each one, reply in its thread with a reason Manki accepts, or tick Create an issue for this to track it for later. The PR is also a draft, so mark it ready for review too. If no approval follows, comment /manki check.

Still open from earlier reviews:

  • dash-spv/src/network/costs.rs:246: An intermediate compact filter can settle two requests that are still pending (view thread)

1 suggestion · not blocking
✨ A getmnlistd or getqrinfo that Dash Core drops still stays charged for the life of the connection
Suggestion, not blocking · Pre-existing · Correctness · Moderate · dash-spv/src/network/costs.rs:81

The same problem remains here. This PR fixes it at dash-spv/src/network/costs.rs:263 but not on this path.

Already broken before this PR. Two checks found the same problem on dev at dash-spv/src/network/costs.rs:71, so it doesn't block this PR.

Why: in_order covers only CfHeaders, CFilters and Block. Dash Core also skips a getmnlistd or getqrinfo without replying: when its per-peer token bucket rate-limits the request, when it cannot build the diff (for example a block it does not know yet), or when its history is pruned. Each skipped request keeps its charge on the peer's ledger with no reply to clear it: 64 KB for a getmnlistd, 1 MB for a getqrinfo. This is the leak the PR fixes for the other three kinds. Both replies meet the condition in the in_order doc: Core sends mnlistdiff and qrinfo only when asked, and it penalises a peer that sends an mnlistdiff unasked. Reply::QrInfo also carries no key. So a later qrinfo settles the first, skipped entry instead of its own, and one 1 MB charge stays on the ledger in either case.

How to fix it
Add Reply::MnListDiff(_) to in_order. Key Reply::QrInfo by the requested tip hash so a reply matches its own request, then add it to in_order too. Add a test_case for each kind to a_reply_settles_the_requests_its_peer_skipped. Caveat: this assumes the qrinfo tip diff carries block_request_hash as its block_hash, which still needs to be checked against BuildQuorumRotationInfo.

  • Create an issue for this

Checked and left out: 2 findings

Disproved by a check of the code · 2 findings

  • An in-order filter stream can settle two overlapping requests early · dash-spv/src/network/costs.rs:246
    The only producer of GetCFilters in the crate is FiltersPipeline::send_pending, which sends back-to-back batches that never overlap. A pipeline is rebuilt only when it is idle, and it resumes after the stored filter tip, so no in-flight batch's range ever contains another batch's stop hash.
  • A compact-block fallback may be mistaken for a later full-block reply · dash-spv/src/network/costs.rs:81
    dash-spv never asks a peer for a compact block. All four places that build a 'getdata' use full-block, InstantSend-lock, chain-lock or transaction items.

The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.

About this review
  • Reviewed 1335e48, round 3
  • 206 changed lines read in 11m 23s
  • Found by claude-opus-5-5 and gpt-6.2-sol, judged by claude-opus-5-5
  • Tokens: 6.2M in (5.1M from cache) · 109k out · about $7.21 at API prices
  • Runner: self-hosted · started after 13s · peak memory 4.1 GiB of 30.0 GiB
  • How Manki reviews

Comment thread dash-spv/src/network/costs.rs Resolved
A skipped filter batch holds the bytes of filters streamed after it. When a block or filter header reply settled that batch, those bytes were added to the reply's size sample, so filter traffic inflated the block estimate that every peer is budgeted with. They now count only toward a reply that ends a filter batch, and are dropped otherwise, since a filter batch still pending was sent after the reply and has not started streaming.
@manki-review

manki-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

✅ Review complete in 7m 53s

Planner (5s)
    refactor · 211 lines · 2 agents
    judge effort: high

Review (behavior · full): 5 findings
    ✅ Claude Opus 5.5 · high: 0 findings (3m 17s)
    ✅ GPT 6.2 Sol · high: 5 findings (2m 47s)
    ✅ Related checks, claim checks, pattern checks and fix checks: 12 of 12 done (1m 44s)

Judge (3m 2s)
    graded 5 findings: 2 kept · 3 dropped
    dropped, as the finders filed them: 1 blocker · 2 warnings
    refuter: 1 checked · 1 disproved
    verdict reader: read the diff (1m 7s)

Posted: 1 finding
    1 suggestion
    not posted: 1 disproved by a check of the code

Review metadata

Config:

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

Account limits:

  • Claude subscription: weekly 23% (resets 2026-12-04 01:00 UTC)
  • ChatGPT subscription: weekly 12% (resets 2026-12-02 01:49 UTC)

Judge decisions:

  • Dropped: "A reply can clear requests the peer has not served yet" (ignore): "warning, if the doubt holds. The overlapping-filter-range half repeats P1, which was settled with the author's reason, so it is not graded again here. The new half is the compact-block fallback. of_item at dash-spv/src/network/costs.rs:90 tracks no compact-block item. A block reply is matched by hash at costs.rs:255, and the new code at costs.rs:264-269 then releases every earlier in-order charge. If the client ever sends a compact-block getdata and then a full-block getdata for the same hash, the fallback full block settles the later request and frees charges the peer still owes. The real reply then finds nothing to settle. The cost is a wrong byte ledger, which puts it on the degraded row. The diff does not show whether dash-spv requests compact blocks at all.
    Refutation disproved: dash-spv only ever puts four kinds of item in a getdata: Inventory::Block, Transaction, InstantSendLock and ChainLock. There is no CompactBlock/CmpctBlock anywhere in dash-spv/src, and none in the consumer repos dash-evo-tool or platform. So the compact-request-then-full-block sequence never happens, and the in-order drain at costs.rs:264-269 cannot be set off by a fallback block. The overlapping filter-range half was settled earlier and is not regraded here. Rule checked: A peer sends a full block back for a compact-block request only if the client first asked with a getdata holding an Inventory::CompactBlock item. A client that never builds that item cannot have a pending compact request for the reply to be wrongly matched against.
  • Premise "dash-spv sends one peer a getdata with an Inventory::CompactBlock item and, while that is pending, a getdata for the full block of the same hash" disproved. Every getdata that dash-spv builds holds only Block, Transaction, InstantSendLock or ChainLock items. A search of dash-spv/src, dashpay/dash-evo-tool and dashpay/platform finds no CompactBlock item, so no compact-block request is ever pending.
  • Premise "This trigger happens in realistic use: when the client asks one peer for the same block first as a compact block and then as a full block" disproved. Normal use never asks a peer for a compact block, because no caller in dash-spv or its consumer repos builds a compact-block getdata. The block requests it does send, built at network/mod.rs:79, are always full blocks.
    Pair refutation disproved: Dash Core can return a full block for a compact-block request, which the ledger does not track, so that reply would settle a pending full-block request for the same hash and clear earlier in-order charges. The built-in sync pipeline requests only full blocks, and no caller or test was found that sends the compact-then-full pair through the raw send API. Rule checked: A reply can establish that earlier requests were skipped only if it unambiguously identifies which request the peer served.
  • Premise "dash-spv sends one peer a getdata with an Inventory::CompactBlock item and, while that is pending, a getdata for the full block of the same hash" disproved. The built-in block sync pipeline sends BlockRequest, which always encodes a full-block request and never starts with a compact-block request.
  • Premise "This trigger happens in realistic use: when the client asks one peer for the same block first as a compact block and then as a full block" unsettled. The public send_to API forwards raw messages to a chosen peer, but that capability does not show that a caller actually sends both requests for the same hash while the first is pending."
  • Dropped: "Unvalidated filter replies can free a peer's byte budget" (ignore): "ignore. Before this PR, a peer could already release any request's charge by sending a junk cfheaders or block that matches it, through the unchanged msg => branch at dash-spv/src/network/costs.rs:251-261. Releasing an earlier charge through a later junk reply gives the peer no capability it did not already have. The only effect is that more work is routed to the misbehaving peer itself, which the broker's timeouts already handle. An honest Dash Core peer only sends cfheaders and cfilter messages for ranges it serves."
  • Dropped: "A skipped request still looks active to the retry timer" (ignore): "ignore. This PR changes only the ledger's byte charges in costs.rs. The broker's request tracking, progress, refresh and expire at dash-spv/src/network/broker.rs:258-301 are untouched, since the broker.rs changes are test fixtures only. Before this PR, a skipped request already stayed OnWire and was refreshed by later replies in the same way, so this PR neither causes nor exposes the stall. Releasing the ledger charge does not change the broker's retry behaviour."
  • Kept: "The byte-transfer test uses a filter outside its requested range" (suggestion): "note. The test still fails if the byte transfer at dash-spv/src/network/costs.rs:272-273 is reverted or the kind check is dropped. In the filters case the recorded cost would be 100 against 200. In the block case it would be 200 against 100. A non-terminal cfilter is counted toward the first pending filter batch whatever its hash. Using cfilter(0) for batches that start at blocks 1 and 2 makes the fixture unrealistic and can mislead a reader, but it is no defect."
  • Dropped: "Each nonterminal filter now scans the outstanding reply queue" (ignore): "ignore. The existing line at dash-spv/src/network/costs.rs:239 already scans awaited with position for every cfilter. The new scan at line 246 adds one more pass over the same list, which is bounded by the peer's byte cap. The finding names no cost anyone would notice, and at most this would be an improvement note resting on a queue depth the code shown does not show."

Timing:

  • Parse: 9.5s
  • Review agents: 281.0s
  • Judge: 182.2s
  • Total: 472.8s

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

Approval held: this PR is a draft. Mark it ready for review, and Manki approves it if nothing else holds the approval. If the latest commit has no review yet, Manki reviews it first when automatic review runs on this PR. If nothing happens, as for a PR from a fork or while automatic review is off or paused, comment /manki check, and Manki approves or says what holds the approval.

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

  • Check approval

What this does: A peer that silently skips a filter-header, filter or block request used to keep it charged against its byte budget forever. A later reply of those kinds now clears the skipped charges, so the peer gets work again and response sizes stay accurate.


📌 1 follow-up agreed for later

Agreed in their threads as later work. None of them blocks.

  • dash-spv/src/network/costs.rs:246: An intermediate compact filter can settle two requests that are still pending (view thread)

Related work: open PRs and issues this PR may duplicate or fix. 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 and a filter sync against peers, with peer_speed debug logging on.

  1. Run cargo test -p dash-spv --lib a_reply_settles_the_requests_its_peer_skipped. Expect all four cases to pass.
  2. Run cargo test -p dash-spv --lib network::. Expect the broker and manager tests to pass with the shared get_cfilters, get_cfheaders and get_block helpers.
  3. Sync filters on testnet with cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir>. Expect each peer's in_flight in the peer_speed lines to drop back toward zero between bursts instead of creeping up.
  4. Watch the resp KB array in the bandwidth line. Expect the filter and block sizes to stay plausible and not jump after a skipped request.
  5. Edge case: request a block that a peer does not serve, so it does not answer, then let it serve a later block. Expect that peer's in-flight bytes to drop by the skipped block's charge.

Checked and left out: 1 finding

Disproved by a check of the code · 1 finding

  • A reply can clear requests the peer has not served yet · dash-spv/src/network/costs.rs:246
    dash-spv only ever puts four kinds of item in a getdata: Inventory::Block, Transaction, InstantSendLock and ChainLock. There is no CompactBlock/CmpctBlock anywhere in dash-spv/src, and none in the consumer repos dash-evo-tool or platform.

The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.

About this review
  • Reviewed 3f84bb5, round 4
  • 211 changed lines read in 7m 53s
  • Found by claude-opus-5-5 and gpt-6.2-sol, judged by claude-opus-5-5
  • Tokens: 3.5M in (2.8M from cache) · 71k out · about $4.60 at API prices
  • Runner: self-hosted · started after 12s · peak memory 3.7 GiB of 30.0 GiB
  • How Manki reviews

Comment thread dash-spv/src/network/costs.rs Resolved
The shared `get_cfilters` builder only asks for the filter of one block, so no test could stream a filter from inside a batch. `get_cfilter_range` takes the stop height too, and `get_cfilters` builds on it, so its callers keep their values.
The skipped-request test fed every case a filter from outside the served batch, so the filters case counted an unrelated filter toward the batch instead of showing that a filter from inside it carries over. The served filter batch now spans two blocks and its first filter streams before the stop filter. The block case keeps a filter that ends no batch, which must not change the block estimate.
@manki-review

manki-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

✅ Review complete in 14m 29s

Planner (7s)
    refactor · 219 lines · 2 agents
    judge effort: high

Review (behavior · full): 4 findings
    ✅ Claude Opus 5.5 · high: 0 findings (2m 18s)
    ✅ GPT 6.2 Sol · high: 4 findings (2m 36s)
    ✅ Related checks, claim checks, pattern checks and fix checks: 10 of 10 done (1m 50s)

Judge (10m 30s)
    graded 4 findings: 4 kept · 0 dropped
    refuter: 3 checked · 1 confirmed · 1 disproved · 1 unsettled
    verdict reader: read the diff (1m 2s)

Posted: 0 findings
    not posted: 1 disproved by a check of the code
    not finished checking: 1 possible problem
    left out as repeats of other findings: 1
    left out: 1 suggestion on test files, which Manki posts only in the first round

Review metadata

Config:

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

Account limits:

  • Claude subscription: weekly 24% (resets 2026-12-04 01:00 UTC)
  • ChatGPT subscription: weekly 12% (resets 2026-12-02 01:49 UTC)

Judge decisions:

  • Dropped: "An overlapping filter range can settle two requests before either finishes" (warning): "warning. This is the same defect as settled P1 at the same line. costs.rs:246 matches a cfilter against any awaited stop hash, so an intermediate filter of an earlier batch can end a later overlapping batch. Lines 264-274 then release the earlier batch as well. The code at this spot has not changed since that round, so the cell P1 had stands.
    Refutation confirmed: settle looks up a cfilter's block hash among all awaited filter batches (costs.rs:246). When it finds a later batch, it drains every earlier batch as skipped (costs.rs:263-276). A rescan path leaves the old batches charged at the peer and sends new batches aligned differently, so an earlier batch can cover a later batch's stop. Rule checked: A peer answers getcfilters requests in order and sends one cfilter per block, so a block can end one batch while it sits in the middle of another. Matching a cfilter's block hash against every awaited stop hash ends the wrong batch when an earlier-sent batch spans a later batch's stop.
  • Premise "This trigger happens in realistic use: when two getcfilters batches with overlapping ranges are in flight at one peer" confirmed. The rescan path in tick() resets the pipeline and sends new getcfilters batches with a different layout. Old batches already on the wire stay owed and charged at the same peer, because the broker release does not touch the peer ledger and a peer can take more requests while under its cap.
    Pair refutation unsettled: If both requests are outstanding, the first batch's filter at the second batch's stop hash releases both charges and records the first batch's partial bytes as one completed batch. The direct-send API permits those writes without waiting for replies, but the checked usage does not show callers sending nested ranges to the same peer. Rule checked: A filter's block hash does not identify which request produced it when two outstanding ranges contain that block.
  • Premise "This trigger happens in realistic use: when two getcfilters batches with overlapping ranges are in flight at one peer" unsettled. The public direct-send path allows successive writes to one peer without waiting for replies, but no checked caller or documented use supplies overlapping ranges, and the standard sync pipeline builds adjacent, non-overlapping batches."
  • Dropped: "A block sent in place of a compact block may retire unrelated requests" (ignore): "warning cell, unproven. Reply::of_item at costs.rs:84-91 tracks no compact-block inventory. A full block that Core sends as the fallback for a compact-block request would only be misattributed when a full-block request for the same hash is also awaited. Line 264 would then drain earlier in-order requests early. The damage is ledger accounting only. Nothing shown has dash-spv requesting compact blocks, so no realistic trigger is named.
    Refutation disproved: Nothing in dash-spv builds a compact-block inventory item. Every getdata it sends uses only Block, Transaction, InstantSendLock or ChainLock items, so the fallback 'block' never arrives and the drain at line 264 is never reached that way. Rule checked: A peer answers with a full 'block' as a compact-block fallback only when the getdata asked for a compact-block inventory item, so the client has to send that kind of item before the ledger can mistake the fallback for the reply to a full-block request.
  • Premise "dash-spv sends a getdata with a compact-block inventory item and later a full-block getdata for the same hash to the same peer" disproved. Searching dash-spv/src for CompactBlock or SendCmpct finds no match, and every Inventory variant it constructs is Block, Transaction, InstantSendLock or ChainLock. So dash-spv never sends a getdata with a compact-block item.
    Pair refutation unsettled: Dash Core can answer a compact-block request with a full block. The ledger does not track the compact request, so that reply can match a pending full-block request for the same hash and release earlier requests’ byte charges, but no checked caller, test, or documented usage supplies that sequence. Rule checked: A reply can prove that earlier requests were skipped only if it is matched to the request that actually elicited it.
  • Premise "dash-spv sends a getdata with a compact-block inventory item and later a full-block getdata for the same hash to the same peer" unsettled. The public send_to API forwards either inventory variant to the specified peer, but the built-in block request uses full-block inventory and no checked use sends a compact request followed by a full request for the same hash to that peer."
  • Not finished: "Silently dropped masternode list requests can still leave permanent charges" (warning): "warning. This is the same issue as P2, and the code at costs.rs:81 is unchanged. The PR settles skipped requests only for CfHeaders, CFilters and Block. A getmnlistd charge booked at costs.rs:71 is kept by the partition at line 266 when a later in-order reply arrives. The sibling reply kind lives in the same changed file, so the incomplete fix is part of this change. The prior round confirmed the trigger.
    Refutation confirmed: Line 71 books a MnListDiff charge for each getmnlistd. NotFound can only release inventory replies (lines 84-92, 229-236), and the cleanup at lines 264-266 keeps every entry that is not in_order. So a getmnlistd that Core drops without reply keeps its bytes in in_flight_bytes and stays in the awaited list, where silent_for can read it as owed. Rule checked: A Ledger entry is removed only when a reply matches it, when a notfound names an inventory item, or by the in-order prefix cleanup, and MnListDiff is in none of those three, so an unanswered getmnlistd entry stays for the life of the connection.
  • Premise "No code path in costs.rs or the peer releases a MnListDiff charge for a getmnlistd that gets no reply before the connection closes" confirmed. Ledger has only charge and settle. settle releases MnListDiff only on a matching MnListDiff reply. NotFound maps only inventory items, which MnListDiff is not. The in-order cleanup keeps non-in_order entries. The ledger is per peer, so the charge goes away only when the connection's Ledger is dropped.
  • Premise "This trigger happens in realistic use: when a peer cannot build a requested masternode list diff and drops the getmnlistd without a reply" confirmed. Core's code drops getmnlistdiff without a reply when the diff cannot be built because data is unavailable (a target block without data, or lists a snapshot does not carry), and also when it rate-limits the request. Snapshot nodes that are not pruned advertise NODE_NETWORK, which is the flag dash-spv requires.
    Pair refutation unsettled: Dash Core’s only MNLISTDIFF producer sends the reply directly from the request handler and sends nothing when the required history is unavailable. A reply that unambiguously answers a later request on the same Core connection can establish that an earlier diff was skipped, but the ledger keeps the diff charge; broker retries without a disconnect do not clear it. Rule checked: A connection’s in-flight byte budget stays charged until its ledger removes the corresponding entry; retrying or releasing a broker key does not remove that entry.
  • Premise "No code path in costs.rs or the peer releases a MnListDiff charge for a getmnlistd that gets no reply before the connection closes" disproved. The pipeline can replace a request with one for the same target from a different base, and if that request is served on the same connection, the ledger matches only the target and releases the oldest charge, leaving the replacement’s charge behind instead.
  • Premise "This trigger happens in realistic use: when a peer cannot build a requested masternode list diff and drops the getmnlistd without a reply" confirmed. The normal work-block sync request uses a historical target, and Core explicitly returns without sending a reply if it knows that target but no longer has its block data."
  • Dropped: "The test block request helper duplicates the production constructor" (suggestion): "note. get_block at test_utils/network.rs:50 builds the same one-item GetData that BlockRequest::into_message builds at network/mod.rs:79. The repository asks to reuse before adding. The helper is a one-line test fixture, so this is a small reuse point with no behavioural effect."

Timing:

  • Parse: 10.4s
  • Review agents: 228.5s
  • Judge: 630.3s
  • Total: 869.2s

Last reviewed 66e7693 · head 66e7693 · up to date

  • Pause automatic reviews
  • Review again
  • Deeper review
  • Review this draft
  • Review every push

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

Approval held: this PR is a draft. Mark it ready for review, and Manki approves it if nothing else holds the approval. If the latest commit has no review yet, Manki reviews it first when automatic review runs on this PR. If nothing happens, as for a PR from a fork or while automatic review is off or paused, comment /manki check, and Manki approves or says what holds the approval.

✅ Approved.

  • Check approval

What this does: A peer that silently ignored a filter or block request kept it counted as owed, which shrank how much work the client sent that peer. Now, when a later filter or block reply arrives, every earlier request the peer skipped is released.


📌 1 follow-up agreed for later

Agreed in their threads as later work. None of them blocks.

  • dash-spv/src/network/costs.rs:246: An intermediate compact filter can settle two requests that are still pending (view thread)

Related work: open PRs and issues this PR may duplicate or fix. None of them blocks.


What to test

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

Setup: A dash-spv checkout with the test-utils feature, and optionally a testnet data directory for a manual sync.

  1. Run cargo test -p dash-spv --lib a_reply_settles_the_requests_its_peer_skipped. Expect all four cases to pass.
  2. Run cargo test -p dash-spv --lib network::. Expect the broker, manager and costs tests to pass with the shared helpers.
  3. Run cargo test -p dash-spv --lib sync::blocks. Expect the block manager tests that use get_block to pass.
  4. Sync testnet with cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir> and RUST_LOG=peer_speed=debug. Expect in_flight per peer to fall back toward zero between bursts instead of creeping up.
  5. Run the same sync with blocks requested from a peer that cannot serve them. Expect that peer's in_flight to drop once it sends a later block or filter reply.
  6. Run just dash-spv::test. Expect the dashd integration tests to complete syncs and reconnects as before.

Checked and left out: 2 findings (1 disproved, 1 not finished)

Disproved by a check of the code · 1 finding

  • A block sent in place of a compact block may retire unrelated requests · dash-spv/src/network/costs.rs:264
    Nothing in dash-spv builds a compact-block inventory item. Every getdata it sends uses only Block, Transaction, InstantSendLock or ChainLock items, so the fallback 'block' never arrives and the drain at line 264 is never reached that way.

Not finished checking · 1 possible problem

  • Silently dropped masternode list requests can still leave permanent charges · dash-spv/src/network/costs.rs:81
    Dash Core’s only MNLISTDIFF producer sends the reply directly from the request handler and sends nothing when the required history is unavailable.

The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.

About this review
  • Reviewed 66e7693, round 5
  • 219 changed lines read in 14m 29s
  • Found by claude-opus-5-5 and gpt-6.2-sol, judged by claude-opus-5-5
  • Tokens: 3.3M in (2.5M from cache) · 74k out · about $4.69 at API prices
  • Runner: self-hosted · started after 14s · peak memory 4.0 GiB of 30.0 GiB
  • How Manki reviews

@xdustinface
xdustinface marked this pull request as ready for review December 2, 2026 00:33
@xdustinface

Copy link
Copy Markdown
Collaborator Author

/self-reviewed

@github-actions

github-actions Bot commented Dec 2, 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 bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Dec 2, 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. All blocking threads are resolved, and no warning thread holds the approval.

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

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@xdustinface
xdustinface requested a review from ZocoLini December 2, 2026 01:11
@ZocoLini
ZocoLini merged commit 58f0518 into dev Dec 2, 2026
54 checks passed
@ZocoLini
ZocoLini deleted the fix/settle-skipped-requests branch December 2, 2026 19:41
manki-review Bot added a commit to manki-review/review-memory that referenced this pull request Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants