Provider lifecycle fixes#80
Merged
Merged
Conversation
bkontur
approved these changes
May 14, 2026
Collaborator
bkontur
left a comment
There was a problem hiding this comment.
@danielbui12 please fix the tests
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Resolve these issues:
update_provider_settingsallows shrinkingmax_capacityto barely-above-committed, but does not validate that existing agreements still satisfy other invariants; settings change is not gated by an event payload that includes the new valuesadd_stakereserves currency before mutating provider stake; onchecked_addoverflow the reserved funds remain lockedset_extensions_blockedallows a provider to block extensions on an agreement for anybucket_idthey have — but does not validate the caller is still a registered provider with that agreement; relies onAgreementNotFoundfor indirect protection[Breaking Changes]
deregister_providerignores pending checkpoint rewards, unclaimed pool balance, and outstanding challengesSolution
Two-step exit modeled:
accepting_primary = false,accepting_extensions = false. Stampsderegister_at = System::block_number() + DeregisterAnnouncementPeriod. Stake stays reserved; provider remains slashable.CheckpointRewardsviaiter_prefix(&who)into free balance, unreserves stake, removes provider.Changes:
-
DeregisterAnnouncementPeriodconfig constant (is setChallengeTimeout = 48 HOURS). Theperiod >= ChallengeTimeoutguarantees every pre-announce challenge matures while the provider is still slashable.-
CheckpointRewardsdouble map storage layout flipped to(AccountId, BucketId)soiter_prefix(&provider)enables the drain.-
update_provider_settingsblocked whenderegister_at.is_some()so the freeze can't be undone mid-window.- New errors
DeregisterAnnounced,DeregisterNotAnnounced,DeregisterPeriodNotElapsed, new eventsDeregisterAnnounced,DeregisterCancelled.