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

Multiple refactors (SegmentWithDelta, broker.account, range unpack, order of params) #334

Merged
merged 7 commits into from
Feb 15, 2023

Conversation

PaulRBerg
Copy link
Member

@PaulRBerg PaulRBerg commented Feb 10, 2023

Description

Closes #328, #329, #330, and #333.

I have implemented #333 rather grudgingly - as I said in #310, I don't like it that there are now multiple ways to access the times: one via the Range struct (e.g. in getRange) and another via the LockupLinear.Stream struct (e.g. in getStream). But I agree that 20k gas is not insignificant.

Regarding #328 - it would be good if @razgraf could also take a look at the new API implemented by this PR, before we merge it.

Changelog

  • chore: improve wording in code comments
  • feat: add "SegmentWithDelta" struct
  • perf: mark helper functions as "pure"
  • refactor: delete "SegmentArrayCountsNotEqual" error
  • refactor: rename "broker.addr" to "broker.account"
  • refactor: reorder params in "create" functions in pro contract
  • refactor: unpack the range structs
  • refactor: use "SegmentWithDelta" struct in "createWithDeltas" function
  • test: add "DEFAULT_SEGMENTS_WITH_DELTAS" constant
  • test: add "getSegmentsWithMilestones" util in "Utils.sol"
  • test: add overloads for "fuzzSegmentAmountsAndCalculateCreateAmounts"
  • test: delete tests related to "SegmentArrayCountsNotEqual" error
  • test: delete unused "sdUint128" and "sdUint40" functions
  • test: move "getBlockTimestamp" to "Utils.sol"
  • test: rename "vars.amounts" to "vars.createAmounts"

Copy link
Member

@razgraf razgraf left a comment

Choose a reason for hiding this comment

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

images

@PaulRBerg PaulRBerg force-pushed the prb/refactors branch 5 times, most recently from dea3688 to 98c0d5e Compare February 12, 2023 14:28
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.

test/shared/helpers/Constants.t.sol Show resolved Hide resolved
test/shared/lockup/pro/Pro.t.sol Outdated Show resolved Hide resolved
@PaulRBerg
Copy link
Member Author

Thanks for reviewing this, @andreivladbrg. I agree with all of your proposed changes.

In the BootstrapProtocol the first stream isn't depleted because the end time can't be equal to the start time.

Good catch, though this isn't strictly the case. It is possible that Forge will process the stream creation and the stream withdrawal in two different blocks, which would deplete the stream when withdrawMax is called.

Nonetheless, I agree that we should remove that call. The solution is to use cast after the script is executed - or write another script.

src/types/DataTypes.sol Outdated Show resolved Hide resolved
PaulRBerg and others added 7 commits February 14, 2023 23:08
chore: improve wording in code comments
perf: mark helper functions as "pure"
refactor: delete "SegmentArrayCountsNotEqual" error
refactor: reorder params in "create" functions in pro contract
refactor: use "SegmentWithDelta" struct in "createWithDeltas" function
test: add "DEFAULT_SEGMENTS_WITH_DELTAS" constant
test: add "getSegmentsWithMilestones" util in "Utils.sol"
test: add overloads for "fuzzSegmentAmountsAndCalculateCreateAmounts"
test: delete tests related to "SegmentArrayCountsNotEqual" error
test: delete unused "sdUint128" and "sdUint40" functions
test: move "getBlockTimestamp" to "Utils.sol"
test: rename "vars.amounts" to "vars.createAmounts"
test: update the tests to match the latest contract API
chore: remove "withdrawMax" call in the bootstrap
test: remove unused "deltas" variables
test: use "DEFAULT_SEGMENTS" values in "DEFAULT_SEGMENTS_WITH_DELTAS"
test: use the assert stream function in the unit tests
@PaulRBerg
Copy link
Member Author

@andreivladbrg I will merge this PR now.

The end-to-end tests have failed, but this is because the fuzzing campaign used an address that is blacklisted by USDC (#317).

@PaulRBerg PaulRBerg merged commit 4bc6828 into main Feb 15, 2023
@PaulRBerg PaulRBerg deleted the prb/refactors branch February 15, 2023 09:24
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.

Create a new struct for the createWithDeltas function
3 participants