-
Notifications
You must be signed in to change notification settings - Fork 46
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
feat: pass the storage pointer #74
Conversation
6cbcbe0
to
93e851a
Compare
11ae272
to
5ae0f4a
Compare
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.
Code looks fine, but my eyes could fail me. Do you feel confident the compiler+test suite would have caught any code paths you might have missed?
src/TokenizedStrategy.sol
Outdated
@@ -201,7 +201,7 @@ contract TokenizedStrategy { | |||
* | |||
* Loading the corresponding storage slot for the struct does not | |||
* load any of the contents of the struct into memory. So the size | |||
* has no effect on gas usage. | |||
* wont increase gas usage. |
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.
* wont increase gas usage. | |
* won't increase gas usage. |
@@ -498,15 +502,16 @@ contract TokenizedStrategy { | |||
uint256 assets, | |||
address receiver | |||
) external nonReentrant returns (uint256 shares) { | |||
StrategyData storage S = _strategyStorage(); |
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.
So TLDR, external/public functions load the point, internal/private functions receive the pointer?
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.
yup
? shares | ||
: shares.mulDiv(totalAssets(), supply, Math.Rounding.Down); | ||
function convertToAssets(uint256 shares) external view returns (uint256) { | ||
return _convertToAssets(_strategyStorage(), shares); |
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.
What is the advantage of separating the public and private methods like this? Code paths that have the storage pointer loaded can call the internal/private versions?
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.
Yes, _convertToAssets is used by multiple other functions within the contract. So any other function will call the internal one with the storage pointer already loaded
Yes I would have to think so. Added some additional asserts in the tests so that we now have 100% coverage across the TokenizedStrategy lines and functions c100407 |
* feat: pass the storage pointer * chore: rebase * chore: formatting and comments * chore: rebase * fix: formatting functions * fix: test coverage * fix: remove lcov file * fix: ignore coverage file
* feat: version 302 * fix: remove increase and decrease allowance (#75) * feat: just track total assets (#73) * feat: just track total assets * fix: comments * feat: pass the storage pointer (#74) * feat: pass the storage pointer * chore: rebase * chore: formatting and comments * chore: rebase * fix: formatting functions * fix: test coverage * fix: remove lcov file * fix: ignore coverage file * fix: max redeem rounding (#83) * fix: use convert to shares * fix: tests * test: add check * test: fix invariants * fix: formatting (#78) * fix: naming * fix: pack struct (#81) * fix: pack struct further * fix: format * chore: dont use modifier require * chore: organize * chore: remove is functions * chore: add chain id to symbol * chore: organize * fix: revert symbol change * chore: fix symbol bakc * fix: minor changes (#82) * chore: remove min fee * fix: tests * build: cheaper reentrancy * chore: fix spech * feat: remove internal preview * feat: make factory immutable (#87) * feat: lower report costs (#76) * feat: only update unlock date * feat: dont burn unlocked (#77) * feat: burn shares once * feat: dont convert twice * fix: loss shares to burn * chore: comments * fix: report updates * fix: dont burn unless there is shares * chore: rebase to storage pointer * chore: organize reporting * chore: rebase * chore: final formatting and script (#88) * fix: solc * chore: comments * chore: deployment script * chore: yarn
Description
Pass the storage pointer to all internal functions to avoid reloading it multiple times a call.
Fixes # (issue)
Checklist