Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: bound rps to realistic ranges #263

Merged
merged 4 commits into from
Sep 27, 2024
Merged

test: bound rps to realistic ranges #263

merged 4 commits into from
Sep 27, 2024

Conversation

smol-ninja
Copy link
Member

Continuing from this argument, I suggest we use the realistic ranges for RPS so that our fuzz and invariant tests can test the contract for tight realistic ranges rather than a wide ranges for RPS.

I also think that it's a good idea to set the rps bounds in the Utils file for fuzz and invariant tests to a very reasonable range. Currently, the lower bound is 0.0000000001e18, which is $0.000259 per month in terms of USDC. We have agreed upon the assumption that we don't expect Flow to be used to stream such a low amount, so why waste runs on such a low stream?
I'd recommend it to set something like [$100 per month, $10000 per month] so atleast we are confident that it wont bother us in that range.

PS: the test fails that means our tests have some issues.

@andreivladbrg
Copy link
Member

Although I understand your rationale, I don’t agree with this change, as keeping the lower range for rps might help us find other problems we are not yet aware of.

@smol-ninja
Copy link
Member Author

smol-ninja commented Sep 25, 2024

On the contrary, changing the rps to realistic range is leading us to new problems that we could not find otherwise. See the failing tests in the CI of this PR.

The problem is that, 100,000 runs are insufficient given the wide range of RPS. If we want to keep lower range for RPS, then based on the above argument, we should have 1M runs. Wider the range, higher the runs.

The only good argument in keeping low ranged rps is to check that no value of rps should lead to over streaming. Other than that, I dont see any value in using ranges of rps that can only stream $0.1 a year in terms of USDC. Thus I propose the following:

  1. Include a test in WithdrawMultiple contract that assert that actual withdrawn is always less than expected for a very wide range rps.
  2. Change rps to realistic range for all other tests

@smol-ninja

This comment was marked as outdated.

@smol-ninja

This comment was marked as outdated.

@PaulRBerg
Copy link
Member

Great idea @smol-ninja, I'm in favor as long as we're still testing the wide range in at least one or a few places.

@andreivladbrg
Copy link
Member

  • Include a test in WithdrawMultiple contract that assert that actual withdrawn is always less than expected for a very wide range rps.
  • Change rps to realistic range for all other tests

the idea of WithdrawMultiple contract test is to see if there is a long delay for a realistic range for rps

so, i would do it the other way around - withdrawMultiple test, small range, other fuzz/invariant tests, wide range

@smol-ninja

This comment was marked as resolved.

@andreivladbrg

This comment was marked as resolved.

@smol-ninja

This comment was marked as resolved.

@smol-ninja
Copy link
Member Author

smol-ninja commented Sep 26, 2024

Meanwhile, @andreivladbrg can you please respond to my comment? You haven't said why you refuse to agree with them.

You mentioned that "keeping the lower range for rps might help us find other problems", to which I replied "The only good argument in keeping low ranged rps is to check that no value of rps should lead to over streaming". What other problems you think you can find with keeping lower range of rps?


The reason tests were failing is the following:

  • A low rps was chosen by the foundry, low in the realistic range.
  • Since deposit bounds were between 1 and descaled(1_000_000_000e18), the foundry was choosing a higher deposit amount
  • The depletion time was over max(uint40) but uint40 function was wrapping over it.

So, as a fix, I adjusted bounds for deposit amount based on 2 years depletion period. Also, changed uint40(solvencyPeriod) to solvencyPeriod.toUint40().

This is another good argument why realistic ranges are useful. Previously, in wide ranges, even though foundry could choose ultra low RPS and extremely high deposit, it could not because the range is so large that even millions of runs that we had run through CI could not detect it.


Your concern that low RPS might be useful to find issues is valid. But I am saying the only issue we need to care about is over streaming and for that, I agree to include wide range RPS in such tests but for all other tests, I haven't seen an argument to why we should not choose realistic ranges.


A perfect solution would be to run all the tests for various ranges of RPS similar to web2 software testing practices. However, I am not sure if foundry accept inputs from a separate file. That will also take a long time to run. In the long term, we should try to achieve that though.

@smol-ninja
Copy link
Member Author

Given how tight the timeline is, I'd appreciate if we can take decision on this before the weekend. @PaulRBerg is in favour so @andreivladbrg I am just waiting for your comment / agreement / disagreement.

Copy link
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it’s becoming one of those things that cause decision fatigue, so feel free to merge it

src/SablierFlow.sol Show resolved Hide resolved
@PaulRBerg
Copy link
Member

Let's merge and do this afterward: #272

@smol-ninja
Copy link
Member Author

I believe it’s becoming one of those things that cause decision fatigue, so feel free to merge it

Thank you. I believe its the right approach :)). And as I mentioned in my comment:

A perfect solution would be to run all the tests for various ranges of RPS similar to web2 software testing practices. However, I am not sure if foundry accept inputs from a separate file. That will also take a long time to run. In the long term, we should try to achieve that though.

We can run the same tests suite for wide range of RPS in a much better way through the use of ffi (yet to figure out if its possible). We can pass different small ranges for RPS through CI and let the test run (CI-Deep or a new workflow) on all those various ranges. This will help us achieve the same as before but in a very efficient manner.

@smol-ninja smol-ninja merged commit 8eb58ac into main Sep 27, 2024
7 checks passed
@smol-ninja smol-ninja deleted the test/rps-bounds branch September 27, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants