8000 Pool.State Library (extsload) by saucepoint · Pull Request #579 · Uniswap/v4-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pool.State Library (extsload) #579

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

Merged
merged 37 commits into from
May 15, 2024
Merged

Pool.State Library (extsload) #579

merged 37 commits into from
May 15, 2024

Conversation

saucepoint
Copy link
Collaborator

Related Issue

Closes #278

Description of changes

Added a library (PoolStateLibrary) for nested storage slots with extsload

Copy link
github-actions bot commented Apr 10, 2024

Forge code coverage:

File % Lines % Statements % Branches % Funcs
src/ERC6909.sol 91.30% (21/23) 85.71% (24/28) 100.00% (4/4) 85.71% (6/7)
src/ERC6909Claims.sol 100.00% (6/6) 100.00% (8/8) 100.00% (4/4) 100.00% (1/1)
src/Extsload.sol 100.00% (3/3) 100.00% (4/4) 100.00% (0/0) 100.00% (3/3)
src/Exttload.sol 100.00% (1/1) 100.00% (1/1) 100.00% (0/0) 50.00% (1/2)
src/NoDelegateCall.sol 100.00% (3/3) 100.00% (5/5) 100.00% (2/2) 100.00% (3/3)
src/PoolManager.sol 100.00% (79/79) 99.09% (109/110) 97.22% (35/36) 100.00% (18/18)
src/ProtocolFees.sol 100.00% (20/20) 97.06% (33/34) 91.67% (11/12) 100.00% (6/6)
src/libraries/BitMath.sol 100.00% (47/47) 100.00% (57/57) 100.00% (36/36) 100.00% (2/2)
src/libraries/CurrencyDelta.sol 100.00% (4/4) 100.00% (6/6) 100.00% (0/0) 100.00% (3/3)
src/libraries/CurrencySettleTake.sol 100.00% (10/10) 100.00% (10/10) 50.00% (3/6) 100.00% (2/2)
src/libraries/FullMath.sol 100.00% (29/29) 100.00% (33/33) 100.00% (8/8) 100.00% (2/2)
src/libraries/Hooks.sol 100.00% (80/80) 99.30% (141/142) 98.21% (55/56) 100.00% (15/15)
src/libraries/LPFeeLibrary.sol 100.00% (5/5) 100.00% (9/9) 100.00% (4/4) 100.00% (3/3)
src/libraries/LiquidityMath.sol 100.00% (2/2) 100.00% (1/1) 100.00% (1/1) 100.00% (1/1)
src/libraries/Lock.sol 100.00% (4/4) 100.00% (4/4) 100.00% (0/0) 100.00% (3/3)
src/libraries/NonZeroDeltaCount.sol 100.00% (6/6) 100.00% (6/6) 100.00% (0/0) 100.00% (3/3)
src/libraries/Pool.sol 99.33% (148/149) 98.15% (159/162) 94.32% (83/88) 100.00% (13/13)
src/libraries/PoolGetters.sol 66.67% (2/3) 66.67% (2/3) 100.00% (0/0) 66.67% (2/3)
src/libraries/Position.sol 100.00% (11/11) 100.00% (12/12) 100.00% (4/4) 100.00% (2/2)
src/libraries/ProtocolFeeLibrary.sol 100.00% (10/10) 100.00% (18/18) 100.00% (4/4) 100.00% (4/4)
src/libraries/Reserves.sol 100.00% (8/8) 100.00% (13/13) 100.00% (6/6) 100.00% (3/3)
src/libraries/SafeCast.sol 100.00% (10/10) 100.00% (26/26) 100.00% (10/10) 100.00% (6/6)
src/libraries/SqrtPriceMath.sol 100.00% (32/32) 100.00% (66/66) 87.50% (21/24) 100.00% (8/8)
src/libraries/StateLibrary.sol 100.00% (65/65) 100.00% (94/94) 100.00% (4/4) 100.00% (14/14)
src/libraries/SwapMath.sol 100.00% (23/23) 100.00% (30/30) 100.00% (12/12) 100.00% (1/1)
src/libraries/TickBitmap.sol 100.00% (19/19) 100.00% (34/34) 100.00% (6/6) 100.00% (3/3)
src/libraries/TickMath.sol 100.00% (94/94) 100.00% (148/148) 97.83% (45/46) 100.00% (4/4)
src/libraries/TransientStateLibrary.sol 88.89% (8/9) 85.71% (12/14) 100.00% (0/0) 75.00% (3/4)
src/libraries/UnsafeMath.sol 100.00% (1/1) 100.00% (1/1) 100.00% (0/0) 100.00% (1/1)
src/types/BalanceDelta.sol 100.00% (2/2) 100.00% (2/2) 100.00% (0/0) 100.00% (2/2)
src/types/BeforeSwapDelta.sol 100.00% (2/2) 100.00% (2/2) 100.00% (0/0) 100.00% (2/2)
src/types/Currency.sol 100.00% (15/15) 91.67% (22/24) 80.00% (8/10) 100.00% (6/6)
src/types/PoolId.sol 100.00% (1/1) 100.00% (1/1) 100.00% (0/0) 100.00% (1/1)
Total 84.08% (1357/1614) 84.23% (1869/2219) 61.62% (517/839) 76.88% (296/385)

@snreynolds snreynolds added the blocked Waiting a dependency label Apr 18, 2024
@snreynolds
Copy link
Member

I actually think we are probably almost ready for this change cause I don't think many of the open PRs change storage slots. Is it ready for review?

@saucepoint
Copy link
Collaborator Author

@snreynolds the library is ready but still need to work the tests / remove the native getters & replace them with the library

@saucepoint saucepoint removed the blocked Waiting a dependency label May 9, 2024
@saucepoint saucepoint marked this pull request as ready for review May 9, 2024 20:53
@saucepoint saucepoint marked this pull request as draft May 9, 2024 20:54
@saucepoint
Copy link
Collaborator Author

oops still blocked. #635 has a fix for too many rejected fuzz runs, so we'll merge that before this ones ready

@saucepoint saucepoint marked this pull request as ready for review May 13, 2024 20:22
Copy link
Member
@snreynolds snreynolds left a comment

Choose a reason for hiding this comment

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

looks great - is there a reason we change though getFeeGrowthGlobals -> getFeeGrowthGlobal? It still returns feeGrowthGlobal0 and feeGrowthGlobal1

gretzke and others added 2 commits May 14, 2024 21:04
* Add exttload to read transient storage from outside the contract

* regenerate snapshots

* Separate Extsload and Exttload

* reduce amount of cases where vm.assume is used to reduce rejected inputs in high intensity fuzzing

* make variable public

* adjust natspec for exttload

* Move isUnlocked, getNonzeroDeltaCount and currencyDelta view functions to pool state library

* Don't bound swap amount to liquidity

* Don't revert within the view function

* regenerate gas snapshots

* regenerate gas snapshots

* regenerate gas snapshot for getting reserves

* adjust comment to reflect new behaviour

* include library code in gas snapshot

* make slots bytes32

* rename PoolStateLibrary to StateLibrary

* Separate transient and storage state libraries

* adjust naming of test file

* adjust comments to reflect new behaviour

* Add sparse exttload

* regenerate gas snapshots
@gretzke gretzke self-requested a review May 15, 2024 13:49
@gretzke gretzke merged commit 7d97026 into main May 15, 2024
6 checks passed
@gretzke gretzke deleted the poolstate-library branch May 15, 2024 13:55
@havi-kim havi-kim mentioned this pull request May 21, 2024
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 Getters Library Once v4-core ossifies
6 participants
0