fix(streaming): reject backdated start_time, add pagination overflow regression test - #697
Merged
Austinaminu2 merged 1 commit intoAug 27, 2026
Conversation
…regression test - create_stream and create_streams_batch now return the new typed StreamError::PastStartTime when start_time is before the current ledger timestamp, so a sender can no longer backdate a stream and unlock a large chunk of the deposit immediately on creation (FlowwStar#221). The batch check runs in phase-1 validation, so a single backdated input rejects the whole batch atomically with no funds moved. - Add tests: backdated start_time (single-stream, with no-funds-moved assertion), backdated cliff_time (InvalidCliff), and batch atomicity. - Add a pagination regression test covering offset+limit combinations that overflow u32, asserting the call clamps/returns empty instead of aborting (FlowwStar#222). The clamping fix itself already landed on main via the paginate helper (FlowwStar#475); this closes the loop with the missing test the issue requested. Fixes FlowwStar#221, FlowwStar#222 Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
davidsoniaudin2-oss
had a problem deploying
to
staging
August 27, 2026 18:37 — with
GitHub Actions
Failure
|
@davidsoniaudin2-oss 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
Solves the four issues assigned to this account on the streaming contract and the affected frontend surfaces. Two required real changes (both in
contracts/streaming), and two turned out to already be fixed onmain— details below.Fixes #221, #222
#221 —
create_stream/create_streams_batchnow reject backdatedstart_time✅ fixedProblem: Neither entrypoint validated
start_timeagainst the current ledger time, so a sender could backdatestart_time/cliff_timeand have a large chunk of the deposit unlocked (and withdrawable) the moment the stream was created, bypassing the vesting UX.Change (
contracts/streaming/src/lib.rs):StreamError::PastStartTime = 21.create_stream: rejectsstart_time < env.ledger().timestamp()(returningPastStartTime) before any funds move.create_streams_batch: same check per-input in phase-1 validation, so a single backdated input rejects the entire batch atomically with no partial state and no funds moved.cliff_time(cliff before start) was already rejected asInvalidCliff; it now has explicit test coverage.Tests added (
test.rs,test_batch.rs):test_create_stream_rejects_past_start_time— assertsPastStartTimeand that no funds moved.test_create_stream_rejects_backdated_cliff— assertsInvalidCliff.test_batch_rejects_past_start_time— assertsPastStartTimeplus atomicity (no stream created, contract balance unchanged).#222 — pagination no longer aborts on
offset + limitoverflow ✅ fixed (fix on main) + regression test addedProblem:
get_sent_streams/get_received_streams/get_archived_*computedoffset + limitas a rawu32; withoverflow-checks = trueinCargo.tomla large combination aborted the read call.Status: The clamping fix already landed on
main— the sharedpaginatehelper (introduced in #475) usesoffset.checked_add(limit)and clamps both bounds to the vector length, returning an empty page for out-of-range offsets instead of aborting. What was missing is exactly what the issue asked for: a regression test.Test added (
test.rs):test_pagination_clamps_large_offset_limit— creates 5 streams and asserts:offset=2, limit=u32::MAX(overflowsu32) → clamps to the tail (3 entries) instead of aborting;offset=u32::MAX, limit=u32::MAX→ empty page, no abort;offset=0, limit=u32::MAX→ full page still works.#224 —
use-batch-createunmount cleanup ✅ already fixed onmainhooks/use-batch-create.tsalready contains the unmount cleanup:Landed in
d535901("fix(hooks): add unmount cleanup to useBatchCreate", merged via PR #335). The in-flight batch loop aborts as soon as the component unmounts, so no wallet-signature prompts fire after navigating away. No code change needed — the issue can be closed.#456 — landing page SSR/hydration mismatch ✅ already fixed on
maincomponents/landing/live-stream-preview.tsxno longer computes a module-levelNOW. The demo stream is seeded inside theuseStateinitializer:so server and client render the same markup on first paint (the initializer-based approach the issue's suggested fix calls for). Landed in
59ba171("…fix SSR hydration mismatch…"). No code change needed — the issue can be closed.Verification
cargo testlocally — this environment has no Rust toolchain (and the user opted to skip installing one). The contract changes were reviewed manually against the existing code and test conventions:env.ledger().timestamp()pattern already used bytop_up/withdraw/cancel.start_time >=the current ledger timestamp (they callset_time(now)beforecreate_streamwithstart_time: now), so the new check should not break any of them.assert_eq!(result, Err(Ok(StreamError::…)))pattern used throughout the suite.Please let CI (
cargo testincontracts/streaming) confirm. The frontend issues required no changes, so no frontend verification was needed.closes #456
closes #222
closes #224
closes #221