Closed andreivladbrg closed 2 months ago
Can you please refactor it to something like 'period'?
i don’t have a specific opinion on this (both work for me) @smol-ninja do you have any suggestions in this regard?
I'd prefer period
too since it represents the pieces of the whole streamed period.
vox populi 865e0311259a9c5757a7048f934377872e0ea410
The commit https://github.com/sablier-labs/flow/pull/248/commits/7ed965eda11c8eacb8a54cc3ecbd4bdfea96d97e increases the invariants' efficiency by a huge margin. Locally I can see ~30% successful runs (15k-20k, warp link) which was ~4% (1000-2000 runs) previously. This means, the new vm.assume
for rps
discards less runs now.
Even the runs in CI have improved.
Closes #133
Depends on #247
This PR is an alternative (a better one IMO) to this https://github.com/sablier-labs/flow/pull/246/. Why I say it is better: in the 246, the invariant is run only if the stream created is left "untouched":
https://github.com/sablier-labs/flow/blob/de5d1ce231813dc1fcb23ceb61f12f0e298978fe/test/invariant/Flow.t.sol#L271-L274
So to run it on various suquence calls, this PR introduces the concept of "segments" in the invariant tests.
A segment represents a time period during which the rate per second remains constant. For example, if a stream is created at
t0
and the rate per second is adjusted att1
, the first segment will be:start = t0, end = t1, ratePerSecond = rate at creation
. The second segment will be:start = t1, end = block.timestamp until next rate per second change, ratePerSecond = adjusted rate
For a better understanding, view the graph below. Each color represents a different segment