flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Use the checked end-time helper in resume_stream

Open blurbeast opened this issue 2 weeks ago • 4 comments

Overview & Background

resume_stream computes the linear end time as now + (remaining / stream.rate_per_second) as u64 — the exact panicking pattern project_end_time was written to eliminate. That helper's doc explicitly says: "The plain now + (remaining / rate) as u64 this replaces silently truncated the quotient and then panicked on the addition under overflow-checks, aborting an otherwise valid top-up or resume." The workspace sets overflow-checks = true, and resume_stream's own doc promises ArithmeticOverflow — but the unchecked path traps instead. modify_rate/top_up_stream already use the checked helper.


Technical Specification & Architecture

  1. Replace contracts/stream_contract/src/lib.rs:2412 with Self::project_end_time(now, remaining, stream.rate_per_second)?.
  2. Add a resume test with values that would overflow the unchecked add, asserting ArithmeticOverflow is returned (not a panic).

Target Files

  • contracts/stream_contract/src/lib.rs
  • contracts/stream_contract/src/test.rs

Acceptance Criteria

  • [ ] resume_stream uses project_end_time for all vesting modes.
  • [ ] Overflowing inputs return ArithmeticOverflow instead of panicking.
  • [ ] A regression test locks the behavior.

blurbeast avatar Nov 18 '26 19:11 blurbeast

@Kami-no-san has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

Hi Maintainer,

I’d like to take this on. I will replace the unchecked end-time calculation in resume_stream (contracts/stream_contract/src/lib.rs) with Self::project_end_time(now, remaining, stream.rate_per_second)? across vesting modes, and add a regression test in contracts/stream_contract/src/test.rs verifying that overflowing inputs return ArithmeticOverflow instead of panicking.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Kami-no-san to this issue.

Kami-no-san avatar Nov 20 '26 20:11 Kami-no-san

@abrcrmb has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

please assign to me

ℹ️ Repo Maintainers: To accept this application, review their application or assign @abrcrmb to this issue.

abrcrmb avatar Nov 21 '26 07:11 abrcrmb

Congratulations, @abrcrmb! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

🧑‍💻 @abrcrmb: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Nov 21 '26 07:11 drips-wave[bot]

This issue has been completed by @abrcrmb as part of the Stellar Wave Program's 11th Wave 🥳

😎 @abrcrmb: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Nov 21 '26 14:11 drips-wave[bot]