feat(stream-contract): protocol pause, milestone vesting, upgrades, b… - #1460
Merged
blurbeast merged 2 commits intoSep 26, 2026
Conversation
…atch withdraw Adds four protocol features to stream_contract, each with test coverage. Protocol circuit breaker: ProtocolConfig gains is_protocol_paused and an optional emergency_guardian. set_protocol_pause takes the caller explicitly so authorization is unambiguous: admin or guardian may trip the breaker, only the admin may clear it. Creation and top-up entrypoints are gated, while withdraw, batch_withdraw and cancel_stream stay open so a pause can never trap or censor funds that have already vested. Milestone vesting: VestingStep/VestingSchedule with a StepTranches variant (max 12 strictly increasing milestones that must sum to the post-fee net deposit) and a HybridCliffLinear variant. Claim and projected-end-time maths became schedule-aware. Step schedules reject top-ups, since extra deposit would have nowhere legitimate to go. In-place upgrades: upgrade swaps the executable while preserving the address, and migrate moves state to schema v2. Streams are migrated lazily rather than in bulk because Soroban cannot enumerate persistent storage, so both loaders decode the legacy shape on read and rewrite on next write. Record shape is chosen by field count: a contracttype decode that overruns a shorter map raises a host error that aborts the invocation, so "try current, fall back to legacy" is not a recoverable path. Batch withdrawals: batch_withdraw pays up to 30 streams in one call, working during a protocol pause and across mixed tokens and schedules. Per-stream ownership is enforced and each stream is committed to storage before its own transfer (CEI). Verified: cargo fmt, clippy -D warnings, release wasm build, 216 tests passing, 97.5% line coverage.
4 tasks
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.
Verified: cargo fmt, clippy -D warnings, release wasm build, 216 tests passing, 97.5% line coverage.
Description
Type of Change
Adds four protocol features to stream_contract, each with test coverage.
Protocol circuit breaker: ProtocolConfig gains is_protocol_paused and an optional emergency_guardian. set_protocol_pause takes the caller explicitly so authorization is unambiguous: admin or guardian may trip the breaker, only the admin may clear it. Creation and top-up entrypoints are gated, while withdraw, batch_withdraw and cancel_stream stay open so a pause can never trap or censor funds that have already vested.
Milestone vesting: VestingStep/VestingSchedule with a StepTranches variant (max 12 strictly increasing milestones that must sum to the post-fee net deposit) and a HybridCliffLinear variant. Claim and projected-end-time maths became schedule-aware. Step schedules reject top-ups, since extra deposit would have nowhere legitimate to go.
In-place upgrades: upgrade swaps the executable while preserving the address, and migrate moves state to schema v2. Streams are migrated lazily rather than in bulk because Soroban cannot enumerate persistent storage, so both loaders decode the legacy shape on read and rewrite on next write. Record shape is chosen by field count: a contracttype decode that overruns a shorter map raises a host error that aborts the invocation, so "try current, fall back to legacy" is not a recoverable path.
Batch withdrawals: batch_withdraw pays up to 30 streams in one call, working during a protocol pause and across mixed tokens and schedules. Per-stream ownership is enforced and each stream is committed to storage before its own transfer (CEI).y)
Related Issues
Closes #
Changes Made
Testing
Test Coverage
Test Steps
Breaking Changes
Breaking Changes:
Migration Guide:
Screenshots/Demo
Checklist
Additional Notes