fix: add consistency of orderData#195
Closed
rymcol wants to merge 1 commit into
Closed
Conversation
in certain edge cases, orderData could come up with an incorrect orderId or fill deadline
evchip
requested changes
Sep 25, 2025
evchip
left a comment
Contributor
There was a problem hiding this comment.
Could you please run forge fmt to lint the contracts?
Comment on lines
+30
to
+32
| /// Custom Errors | ||
| error InvalidSender(bytes32 provided, address expected); | ||
| error InvalidFillDeadline(uint32 provided, uint32 expected); |
Comment on lines
+115
to
+120
| // Encode a modified OrderData instead of _order.orderData to keep context clean across instances | ||
| OrderData memory orderData = OrderEncoder.decode(_order.orderData); | ||
| orderData.fillDeadline = _order.fillDeadline; // Use the resolved fillDeadline | ||
| orderData.sender = TypeCasts.addressToBytes32(msg.sender); // Use the resolved sender | ||
|
|
||
| openOrders[orderId] = abi.encode(_order.orderDataType, orderData); // must not use _orderData for consistency |
Contributor
There was a problem hiding this comment.
this level of inline comments feels excessive. I feel that the code is fairly clear already.
| openOrders[orderId] = abi.encode(_order.orderDataType, _order.orderData); | ||
| // Encode a modified OrderData instead of _order.orderData to keep context clean across instances | ||
| OrderData memory orderData = OrderEncoder.decode(_order.orderData); | ||
| orderData.fillDeadline = _order.fillDeadline; // Use the resolved fillDeadline |
Contributor
There was a problem hiding this comment.
this isn't the resolved fillDeadline. that would be resolvedOrder.fillDeadline. Is this intentional?
| // Encode a modified OrderData instead of _order.orderData to keep context clean across instances | ||
| OrderData memory orderData = OrderEncoder.decode(_order.orderData); | ||
| orderData.fillDeadline = _order.fillDeadline; // Use the resolved fillDeadline | ||
| orderData.sender = TypeCasts.addressToBytes32(msg.sender); // Use the resolved sender |
Contributor
There was a problem hiding this comment.
this isn't the resolved sender. that would be resolvedOrder.user
Comment on lines
+157
to
+161
| // Encode the modified OrderData (orderDataResolved) instead of orderDataOriginal | ||
| OrderData memory orderData = OrderEncoder.decode(_order.orderData); | ||
| orderData.fillDeadline = resolvedOrder.fillDeadline; // Use the resolved fillDeadline | ||
| orderData.sender = TypeCasts.addressToBytes32(_order.user); // Use the resolved sender | ||
| openOrders[orderId] = abi.encode(_order.orderDataType, OrderEncoder.encode(orderData)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fixes certain edge cases where orderData could come up with an incorrect orderId or fill deadline
Motivation and Context
We do not want inconsistencies in orderData (provided vs stored). This is meant to ensure that is checked.
How Has This Been Tested?
manually
Types of changes (remove all unchecked types)
Checklist: