-
Notifications
You must be signed in to change notification settings - Fork 976
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
Support arbitrary bytes on test routers #343
Conversation
@ewilz any chance i can get reviewers on this? |
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!
contracts/test/PoolSwapTest.sol
Outdated
@@ -35,21 +36,29 @@ contract PoolSwapTest is ILockCallback { | |||
payable | |||
returns (BalanceDelta delta) | |||
{ | |||
delta = | |||
abi.decode(manager.lock(abi.encode(CallbackData(msg.sender, testSettings, key, params))), (BalanceDelta)); | |||
return swap(key, params, testSettings, new bytes(0)); |
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.
looks like gas snapshots went up by >1k for all swaps...wonder if consolidating the swap functions here makes more sense than having 2 external calls (or just keeping them separate altogether)
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 prefer removing the old function signature and moving everything over to the new function signature w/ bytes memory hookData
(instead of duplicating the logic). I wanted to keep the original for backwards compatibility with v4-periphery and community repos, but I suppose theres been breaking changes already so might as well keep it up 😝
Will try it for both swap + modifyPosition
} | ||
|
||
function modifyPosition(PoolKey memory key, IPoolManager.ModifyPositionParams memory params) | ||
external | ||
payable | ||
returns (BalanceDelta delta) | ||
{ | ||
delta = abi.decode(manager.lock(abi.encode(CallbackData(msg.sender, key, params))), (BalanceDelta)); | ||
return modifyPosition(key, params, new bytes(0)); |
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.
same as swap, but only 977
gas increase for modify position. I wonder if we can minimize the impact on gas
per test contracts by either consolidating the functions..
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 removed the old modifyPosition()
and the gas is practically the same, or worse in some cases 🤔
Here's the diff
https://github.com/saucepoint/v4-core/pull/1/files
Also looks like the hardhat tests are failing. Since we still have some coverage with hardhat unfortunately we should get those updated even though we are in the process of deprecating. Can reproduce with |
This comment was marked as outdated.
This comment was marked as outdated.
To recap the outstanding changes, there's two paths we could take:
|
Consolidate overloaded `modifyPosition` and `swap`
I'm in favor of option #1. Don't think we need to maintain backwards compatibility in tests - we should just update them to match the new functionality. Gas seems to just be overhead of the new ZERO_BYTES param so I'm not that worried about it but curious to hear your thoughts @ewilz. |
…ed hardhat gas snapshots
@saucepoint Hm looks like hardhat tests are still failing, and I think you need to run yarn prettier but other than that happy to merge! I think for the hardhat tests you just need to update the snapshots |
Closing in favor of #361 |
Related Issue
Which issue does this pull request resolve?
The test routers (i.e.
PoolSwapTest
) did not support arbitrary data arguments (new in #332). This PR updates the test routers to support the flow of arbitrary bytes from the router to the hooks.Description of changes
Updated the main function(s) in
PoolSwapTest
,PoolModifyPositionTest
, andPoolDonateTest
to support arbitrary data argsUpdated
MockHooks
to write arbitrary data to storage. Used to verify that test routers are providing arbitrary bytes correctly (Hooks.t.sol
)