feat: stream withdrawal validation, factory cancel verification, fee documentation, and migration bounds (#621, #622, #623, #624) - #733
Merged
Jaydbrown merged 1 commit intoSep 28, 2026
Conversation
…documentation, and migration bounds (conduit-protocol#621, conduit-protocol#622, conduit-protocol#623, conduit-protocol#624) - conduit-protocol#621 (stream): Add read-only `validate_withdraw(env, amount)` preview query running all pre-transfer validation checks without mutating state. - conduit-protocol#622 (factory): Secure `record_cancel(env, stream)` to require deployed stream address, verify `IsKnownStream`, check `info().is_cancelled()`, and track `CancelledStream` for idempotency. - conduit-protocol#623 (factory): Add detailed doc comments on `estimate_fee()` describing baseline reference profiling estimates and RPC simulateTransaction expectations; add unit tests covering all StreamOperation variants. - conduit-protocol#624 (factory): Bound `max_pages` with `MAX_MIGRATION_PAGES` cap and add early short-circuit return for already-migrated index migration calls. Closes conduit-protocol#621 Closes conduit-protocol#622 Closes conduit-protocol#623 Closes conduit-protocol#624
|
@thefadah Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary of Changes
This unified PR resolves issues #621, #622, #623, and #624:
Issue stream: withdraw() has no dry-run/preview variant separate from withdrawable() #621 —
stream: Dry-run withdrawal preview query (validate_withdraw)pub fn validate_withdraw(env: Env, amount: i128) -> Result<(), Error>tocontracts/stream/src/lib.rs.withdraw()(positive amount check, non-cancelled stream state, minimum withdrawal rate-limit interval, entitlement accrual, token balance availability, and split arithmetic validation) without mutating storage or transferring tokens.Issue factory: record_cancel() has no auth check and no stream identifier — callable by anyone, any number of times #622 —
factory: Stream verification and idempotency forrecord_cancelpub fn record_cancel(env: Env, stream: Address)incontracts/factory/src/lib.rsto take the stream contract address.streamis a legitimate deployed stream (IsKnownStream), that it is currently in a cancelled state (stream.info().is_cancelled()), and that its cancellation has not already been recorded inCancelledStream(stream)storage.cancel_batch_streamsto recordCancelledStream(stream)to ensure direct or subsequentrecord_cancelcalls do not double decrement.docs/security.mdand added unit tests covering unverified addresses, active streams, once-only decrements, and idempotency.Issue factory: estimate_fee() returns fully hardcoded constants — the _env parameter is unused #623 —
factory:estimate_feedocumentation and variant test coverageestimate_fee()documenting that returned CPU instructions and ledger entries are baseline profiling reference estimates for standard deployments, preserving_envfor interface uniformity and potential dynamic fee adjustments.contracts/factory/src/tests.rsverifying positive fee estimates and ledger entries across all 13StreamOperationvariants.Issue factory: migrate_sender_index/migrate_recipient_index are permissionless with no cost bound on repeated calls #624 —
factory: Migration page cap and already-migrated short-circuitMAX_MIGRATION_PAGES = 20to cap caller-suppliedmax_pagesincontracts/factory/src/index.rs.!has(legacy_key)orcursor >= legacy_count), avoiding redundant page scans and unbounded transaction resource consumption.Closes #621
Closes #622
Closes #623
Closes #624