-
Notifications
You must be signed in to change notification settings - Fork 73
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: hash orderinfo separately #135
Conversation
Avoids stack too deep without bricking EIP712 and cleaner
src/lib/DutchLimitOrderLib.sol
Outdated
"uint256 startTime,", | ||
"uint256 endTime,", | ||
"address inputToken,", | ||
"uint256 inputStartAmount,", | ||
"uint256 inputEndAmount,", | ||
"DutchOutput[] outputs)", | ||
DUTCH_OUTPUT_TYPE | ||
DUTCH_OUTPUT_TYPE, | ||
OrderInfoLib.ORDER_INFO_TYPE |
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.
Is Dutch before OrderInfo because of alphabetical?
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.
yeah exactly
|
||
bytes internal constant ORDER_TYPE = abi.encodePacked( | ||
bytes internal constant EXCLUSIVE_DUTCH_LIMIT_ORDER_TYPE = abi.encodePacked( |
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.
Nit: inconsistency that sometimes you defined a TYPE constant just using a singular string, and sometimes you use encodePacked
- even with this one that doesnt use any variables.
For readability you could use a multi-line encodePacked
everywhere? Just a nit though, feel free to ignore
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.
yea my general approach has been: if small, single line else multiline
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.
but will switch around for consistency
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.
actually ehhh it looks pretty ugly for single liners
bytes internal constant TOKEN_PERMISSIONS_TYPE =
abi.encodePacked("TokenPermissions(", "address token", "uint256 amount)");
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.
mm yeah i think single line fine to just keep w/o abi.encodePacked
src/lib/DutchLimitOrderLib.sol
Outdated
@@ -42,25 +43,23 @@ struct DutchLimitOrder { | |||
|
|||
/// @notice helpers for handling dutch limit order objects | |||
library DutchLimitOrderLib { | |||
using OrderInfoLib for OrderInfo; | |||
|
|||
bytes internal constant DUTCH_OUTPUT_TYPE = | |||
"DutchOutput(address token,uint256 startAmount,uint256 endAmount,address recipient,bool isFeeOutput)"; | |||
bytes32 internal constant DUTCH_OUTPUT_TYPE_HASH = keccak256(DUTCH_OUTPUT_TYPE); | |||
|
|||
bytes internal constant ORDER_TYPE = abi.encodePacked( |
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.
Nit: Could be neat to separate this out like you do with EXCLUSIVE_DUTCH_LIMIT_ORDER_TYPE
?
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.
truu
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.
strangely this changes gas even though its a constant?
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.
Couple of nits, but LGTM
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.
only thing is that we should add some tests to make sure these match wallet standard
); | ||
|
||
bytes internal constant ORDER_TYPE = | ||
abi.encodePacked(DUTCH_LIMIT_ORDER_TYPE, DUTCH_OUTPUT_TYPE, OrderInfoLib.ORDER_INFO_TYPE); |
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.
Can we leave a comment about it being important that we encode the types in alphabetical order.. feel like thats a nuanced bit in the 712 standard for nested types.
|
||
bytes internal constant ORDER_TYPE = abi.encodePacked( | ||
bytes internal constant EXCLUSIVE_DUTCH_LIMIT_ORDER_TYPE = abi.encodePacked( |
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.
mm yeah i think single line fine to just keep w/o abi.encodePacked
how do you do that in foundry? without foundry-rs/foundry#4818 |
Yeah I think can just make it a future todo, but we have some static/hardcoded tests in permit2 comparing signatures generated from mm. |
* feat: hash orderinfo separately Avoids stack too deep without bricking EIP712 and cleaner * fix: struct ordering * fix: alice comments * feat: add comment
Avoids stack too deep without bricking EIP712 and cleaner