Skip to content

fix: allow abandonment and consensual termination of underfunded data sets - #520

Merged
wjmelements merged 9 commits into
mainfrom
test/underfunded-payer-scenarios
Jul 22, 2026
Merged

fix: allow abandonment and consensual termination of underfunded data sets#520
wjmelements merged 9 commits into
mainfrom
test/underfunded-payer-scenarios

Conversation

@wjmelements

Copy link
Copy Markdown
Contributor

Reviewer @rvagg
Fixes #519
Consensual termination and abandonment both attempt to set the endEpoch to block.number in order to allow immediate cleanup.
Because we cannot modify the payment rate or the lockup for underfunded data sets before termination (see FilOzone/filecoin-pay#290), we are unable to reduce the lockup period to ensure endEpoch is the current block.
Instead of reverting, we will release the fixed lockup after termination.

Changes

  • add three failing tests
  • catch modifyRailLockup exceptions in abandonment and consensual termination

@wjmelements wjmelements linked an issue Jun 10, 2026 that may be closed by this pull request
@wjmelements
wjmelements requested a review from rvagg June 10, 2026 21:29
@FilOzzy FilOzzy added this to FOC Jun 10, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Jun 10, 2026
@wjmelements wjmelements added the bug Something isn't working label Jun 11, 2026
…ndonRails and updateStorageRates

Assisted-by: Claude:claude-sonnet-4-6
@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC Jun 11, 2026
Comment thread service_contracts/src/lib/Rails.sol Outdated
@BigLep BigLep moved this from 🔎 Awaiting review to ⌨️ In Progress in FOC Jun 16, 2026
@BigLep
BigLep requested a review from Copilot June 16, 2026 17:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the warm-storage payment-rail teardown flow so that consensual termination and abandonment can proceed even when a payer is underfunded and FilecoinPay rejects attempts to reduce the lockup period to zero.

Changes:

  • Update Rails.abandonRails and Rails.updateStorageRates to tolerate modifyRailLockup reverts when attempting lockupPeriod = 0, while still releasing the fixed (lifecycle reserve) portion.
  • Add tests covering abandonment and consent-termination behavior for underfunded payers.
  • Update spec and changelog to document the underfunded-payer termination semantics.

Reviewed changes

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

File Description
SPEC.md Documents how immediate termination/abandonment behave for well-funded vs underfunded payers.
service_contracts/test/Abandonment.t.sol Adds test coverage and helpers for underfunded payer scenarios.
service_contracts/src/lib/Rails.sol Adds try/catch handling around lockup-period zeroing for abandonment and immediate termination paths.
CHANGELOG.md Notes the fix for underfunded payer handling in abandonment / immediate-termination rate updates.

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

Comment thread service_contracts/src/lib/Rails.sol
Comment thread service_contracts/src/lib/Rails.sol Outdated
…termination

Assisted-by: Claude:claude-sonnet-4-6
@BigLep BigLep added this to the M4.5: GA Fast Follows milestone Jun 18, 2026
@BigLep BigLep moved this from ⌨️ In Progress to 🔎 Awaiting review in FOC Jun 24, 2026
Comment thread CHANGELOG.md Outdated
Comment thread service_contracts/test/Abandonment.t.sol Outdated
Comment thread service_contracts/src/lib/Rails.sol Outdated
Comment thread SPEC.md
**CDN rails are not checked**: The settled-up-to requirement above and the `pdpEndEpoch` checks in the timing list both apply to the PDP rail only. FWSS does not verify CDN rail termination or settlement before allowing dataset deletion, because it does not track the CDN rails' `endEpoch` (there is no validator callback to set it). In the normal flow this is safe: CDN rails are terminated as part of the `dataSetDeleted` callback itself.

**Abandonment path**: When `pdpEndEpoch == 0` (the SP never called `terminateService`), the data set can still be deleted once inactive for `INACTIVITY_WINDOW` (30 days from `lastProvenEpoch`, or from `provingActivationEpoch` for activated-but-never-proven data sets). PDPVerifier gates this: SP-only within the window, permissionless after. FWSS layers its own `_verifyInactivity` check on top so the SP cannot use this path to skip `terminateService` on an active data set. Inline teardown via `Rails.abandonRails` settles the PDP rail (advancing through unproven epochs via the pre-activation short-circuit), releases the lifecycle reserve and streaming buffer back to the payer, terminates and finalises the rail, and best-efforts the CDN rails. The SP forfeits any pending one-time op-fees; this is intentional, since the SP walked away.
**Abandonment path**: When `pdpEndEpoch == 0` (the SP never called `terminateService`), the data set can still be deleted once inactive for `INACTIVITY_WINDOW` (30 days from `lastProvenEpoch`, or from `provingActivationEpoch` for activated-but-never-proven data sets). PDPVerifier gates this: SP-only within the window, permissionless after. FWSS layers its own `_verifyInactivity` check on top so the SP cannot use this path to skip `terminateService` on an active data set. Inline teardown via `Rails.abandonRails` settles the PDP rail (advancing through unproven epochs via the pre-activation short-circuit), releases the lifecycle reserve back to the payer, terminates the rail, and best-efforts the CDN rails. The SP forfeits any pending one-time op-fees; this is intentional, since the SP walked away. For well-funded payers the lockup period is zeroed before termination, releasing the streaming buffer immediately. For underfunded payers the lockup period cannot be zeroed, so the PDP rail retains its default 30-day window and the streaming buffer is released only after that window elapses.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could add an extension to this para about how it works now

@rvagg rvagg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice; couple of doc nits, but that CHANGELOG correction needs to be taken care of - don't edit the 1.3.0 section, make a new Unreleased section

@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Jul 7, 2026
Assisted-by: Claude:claude-sonnet-4-6
@rjan90

rjan90 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Is there anything blocking merging this?

@BigLep

BigLep commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@rjan90 : I think we incorporate Rod's doc nits and then merge.

Co-authored-by: Rod Vagg <rod@vagg.org>
@wjmelements
wjmelements merged commit efd13a2 into main Jul 22, 2026
6 checks passed
@wjmelements
wjmelements deleted the test/underfunded-payer-scenarios branch July 22, 2026 14:49
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Jul 22, 2026
hannahhoward added a commit to hannahhoward/filecoin-services that referenced this pull request Jul 24, 2026
Two build fixes from rebasing onto main: abandonRails (underfunded-payer
handling, FilOzone#520) uses DEFAULT_LOCKUP_PERIOD, which this branch moved from
PriceListUSDFC to PriceList — import it from its new home; and the new
announce-upgrade-only-owner test constructs FWSS, which now takes the
optional USDC token parameter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

Support underfunded termination

6 participants