Skip to content

Fix RPC free sectors edge case#406

Merged
n8mgr merged 2 commits intomasterfrom
nate/free-edge-case
Mar 11, 2026
Merged

Fix RPC free sectors edge case#406
n8mgr merged 2 commits intomasterfrom
nate/free-edge-case

Conversation

@n8mgr
Copy link
Member

@n8mgr n8mgr commented Mar 10, 2026

Fixes an edge case in RPCFreeSectors where the swap-and-truncate deletion logic could keep a deleted sector root and lose a kept one when indices overlap with the replacement zone at the tail of the slice. The client now sorts indices descending and deduplicates before sending.

Copilot AI review requested due to automatic review settings March 10, 2026 20:40
@github-project-automation github-project-automation bot moved this to In Progress in Sia Mar 10, 2026
@n8mgr n8mgr moved this from In Progress to In Review in Sia Mar 10, 2026
@n8mgr n8mgr self-assigned this Mar 10, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an edge case in RPCFreeSectors where swap-and-truncate deletion could produce incorrect sector-root sets when deletion indices overlap with the tail replacement zone.

Changes:

  • Normalize RPCFreeSectors indices client-side by sorting descending and deduplicating before sending/verification.
  • Update/add tests to compute expected roots using the same normalized swap behavior and add a regression suite covering overlap cases.
  • Add a changeset entry documenting the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
rhp/v4/rpc.go Normalizes free-sector indices (descending sort + dedupe) to avoid incorrect swaps and proof mismatches.
rhp/v4/rpc_test.go Adds assertSectorsFreed helper and a table-driven regression test for overlap scenarios; updates existing test to use the helper.
.changeset/...rpcfreesectors...md Adds a patch-level changelog entry for the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@n8mgr n8mgr merged commit 49aa869 into master Mar 11, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Sia Mar 11, 2026
@n8mgr n8mgr deleted the nate/free-edge-case branch March 11, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants