-
Notifications
You must be signed in to change notification settings - Fork 48
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
Move all duplicated logic in the abstract contract SablierV2Lockup
#813
Conversation
8ebf8d8
to
aabd935
Compare
The Codecov report is now failing. After debugging, I can see that the lines marked as "Uncovered" are the same as in other PRs. Current PR: https://app.codecov.io/gh/sablier-labs/v2-core/pull/813/blob/src/SablierV2LockupDynamic.sol The issue may be from the fact that the contracts (Linear and Dynamic) now have fewer lines, thereby increasing the percentage of uncovered lines. This is why the report's coverage has decreased. Atm, I am not sure how to address this issue, other than by reducing the coverage threshold on Codecov. What do you say @PaulRBerg ? |
Sorry no time to advise on this issue now. I recommend asking for help on StackOverflow or the Codecov forum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @andreivladbrg. I have left some comments below but I haven't finished the review yet.
7f0a642
to
9f857d0
Compare
cfc07af
to
8e244ac
Compare
Regarding the codecov coverage mention in this comment I did some research, and I was correct. The reason why the coverage fails is because there are fewer lines of code in the targeted files ( GPT answer" One potential solution, is to temporarily add a threshold of 0.3% on What do you say? @PaulRBerg @smol-ninja |
Thanks for investigating, @andreivladbrg.
That shouldn't be needed - as an admin, I have the power to merge the PRs even when the checks fail. Let me know when you want to merge it (and how - squashing or not), and I'll do it. |
I can do that as well. I was just saying this to avoid having the workflow fail. But I guess it is not a problem since the |
Oh ok, got it. Letting the workflow fail it's fine in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed the PR. Please see comments below.
test/integration/concrete/lockup-linear/create-with-durations/createWithDurations.t.sol
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now.
47d702a
to
3f36df4
Compare
refactor: remove _after and _before hooks and implement _update function refactor: use newly added _requireOwned function refactor: use the new named parameter in ERC20 functions test: add mocks for ERC20 and ERC721 test: use openeppelin's custom errors in cheatcode chore: provide a more precise explanation for _update chore: define "_update" alphabetically docs: document "_update" function test: check IERC20Errors custom error revert
feat: add mapping for cliffs in linear feat: add mapping for segments in dynamic refactor: move all common functions in SablierV2Lockup
feat: check if the start time is greater than end time test: update tests accordingly
refactor: make constant functions external
chore: use "override" specifier on nftDescriptor
chore: order functions alphabetically in SablierV2Lockup
8440bbc
to
6174941
Compare
In my opinion, it is better to rename them to avoid mentioning namespaces everytime we are referring to Stream structs. (Later: it might not be a problem as the default is the one defined in Suggestions:
Yes. I am in favour of this (comment). |
Agree
i like these
I was ok with that, but I now changed my mind.
|
We can do this. I am good with this as well. |
4031ace
to
a13f218
Compare
looks good now. |
…813) * build: update openzeppelin to 5.0.0 refactor: remove _after and _before hooks and implement _update function refactor: use newly added _requireOwned function refactor: use the new named parameter in ERC20 functions test: add mocks for ERC20 and ERC721 test: use openeppelin's custom errors in cheatcode chore: provide a more precise explanation for _update chore: define "_update" alphabetically docs: document "_update" function test: check IERC20Errors custom error revert * feat: add Lockup.Stream struct feat: add mapping for cliffs in linear feat: add mapping for segments in dynamic refactor: move all common functions in SablierV2Lockup * perf: use the storages instead of the getters * feat: check if the start time is zero feat: check if the start time is greater than end time test: update tests accordingly * docs: re-add natspec for _calculateStreamedAmountForMultipleSegments * refactor: make start time strictly less than cliff time * chore: update branch from staging * docs: use plural * refactor: order constant functions alphabetically refactor: make constant functions external * refactor: make cliff time strictly greater than start time * docs: correct natspec chore: use "override" specifier on nftDescriptor * test: update comment for using unchecked to allow overflow * docs: improve natspec chore: order functions alphabetically in SablierV2Lockup * refactor: rename Stream structs within LockupLinear and LockupDynamic namespaces --------- Co-authored-by: smol-ninja <[email protected]>
test/integration/concrete/lockup-linear/create-with-timestamps/createWithTimestamps.t.sol
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tree is not aligned with the order of the checks in {Helpers-checkCreateWithTimestamps}.
It is critical that we align them because one of the goals of BTT is to build a circuit-like representation of the function's execution paths.
Specifically, we need to reverse the cliff time checks with the end time check here:
v2-core/src/libraries/Helpers.sol
Lines 95 to 108 in 76e29fe
// Checks: the start time is strictly less than the end time. | |
if (range.start >= range.end) { | |
revert Errors.SablierV2LockupLinear_StartTimeNotLessThanEndTime(range.start, range.end); | |
} | |
// Checks: the start time is strictly less than the cliff time when cliff time is not zero. | |
if (range.cliff > 0 && range.start >= range.cliff) { | |
revert Errors.SablierV2LockupLinear_StartTimeNotLessThanCliffTime(range.start, range.cliff); | |
} | |
// Checks: the cliff time is strictly less than the end time. | |
if (range.cliff >= range.end) { | |
revert Errors.SablierV2LockupLinear_CliffTimeNotLessThanEndTime(range.cliff, range.end); | |
} |
…813) * build: update openzeppelin to 5.0.0 refactor: remove _after and _before hooks and implement _update function refactor: use newly added _requireOwned function refactor: use the new named parameter in ERC20 functions test: add mocks for ERC20 and ERC721 test: use openeppelin's custom errors in cheatcode chore: provide a more precise explanation for _update chore: define "_update" alphabetically docs: document "_update" function test: check IERC20Errors custom error revert * feat: add Lockup.Stream struct feat: add mapping for cliffs in linear feat: add mapping for segments in dynamic refactor: move all common functions in SablierV2Lockup * perf: use the storages instead of the getters * feat: check if the start time is zero feat: check if the start time is greater than end time test: update tests accordingly * docs: re-add natspec for _calculateStreamedAmountForMultipleSegments * refactor: make start time strictly less than cliff time * chore: update branch from staging * docs: use plural * refactor: order constant functions alphabetically refactor: make constant functions external * refactor: make cliff time strictly greater than start time * docs: correct natspec chore: use "override" specifier on nftDescriptor * test: update comment for using unchecked to allow overflow * docs: improve natspec chore: order functions alphabetically in SablierV2Lockup * refactor: rename Stream structs within LockupLinear and LockupDynamic namespaces --------- Co-authored-by: smol-ninja <[email protected]>
…813) * build: update openzeppelin to 5.0.0 refactor: remove _after and _before hooks and implement _update function refactor: use newly added _requireOwned function refactor: use the new named parameter in ERC20 functions test: add mocks for ERC20 and ERC721 test: use openeppelin's custom errors in cheatcode chore: provide a more precise explanation for _update chore: define "_update" alphabetically docs: document "_update" function test: check IERC20Errors custom error revert * feat: add Lockup.Stream struct feat: add mapping for cliffs in linear feat: add mapping for segments in dynamic refactor: move all common functions in SablierV2Lockup * perf: use the storages instead of the getters * feat: check if the start time is zero feat: check if the start time is greater than end time test: update tests accordingly * docs: re-add natspec for _calculateStreamedAmountForMultipleSegments * refactor: make start time strictly less than cliff time * chore: update branch from staging * docs: use plural * refactor: order constant functions alphabetically refactor: make constant functions external * refactor: make cliff time strictly greater than start time * docs: correct natspec chore: use "override" specifier on nftDescriptor * test: update comment for using unchecked to allow overflow * docs: improve natspec chore: order functions alphabetically in SablierV2Lockup * refactor: rename Stream structs within LockupLinear and LockupDynamic namespaces --------- Co-authored-by: smol-ninja <[email protected]>
Addresses #805.
Depends on #806.
Changes
Stream
withinLockup
namespace_streams
mapping toSablierV2Lockup
and use the new data typeSablierV2Lockup
. This change introduced the need of:_calculateStreamedAmount
virtual functiongetStream
function_cliffs
and_segments
mappings in linear contract, and dynamic respectivelyAlso, it would be recommended to read the 805 discussion for the rational behind.
Other decisions
It no longer made sense to allow the start time to equal the cliff time, since now it can be zero (cliff).
I could have DRY-FY the
_createWithTimestamps
function since there is common logic between linear and dynamic. But the reasons I did not were:SablierV2Lockup
Gas comparison
Notes and questions
After this PR the app would need to change how it works when creating a simple linear stream (passing 0 as the cliff time).
Should we rename the
Stream
structs withinLockupLinear
andLockupDynamic
namespaces (which are used only forgetStream
function)?Should we re-order the variables in these structs?