fix: credit origin chain ID on SignedFills #93
Merged
+56
−29
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.
Problem
Within Fills, the Output chain ID is intended to indicate the origin chain ID, NOT the destination chain ID.
Confusion arose because the Solidity was designed to "overload" the
chainIdfield on the Output struct depending on the context; in the context of Orders, it should specify the destination chain ID; in the context of Fills, it should specify the origin chain ID.Previously, the SDK Fill signing logic incorrectly populated Outputs with the destination chain ID.
Fix
Fill Outputs must specify the origin chain ID.
Approach
This PR updates the Fill signing logic in the
UnsignedFillstruct to explicitly add the origin chain ID before signing.Alternate Approach
If, at some point in the future,
AggregateOrderswas used to agg Orders from different origin chains, this logic could become problematic. It may be prudent to address this one step sooner within theAggregateOrderstype instead -- by specifying a single origin chain ID for a givenAggregateOrders, or else by splitting Orders up withinAggregateOrdersby respective origin chain IDs. However, this change is more involved.Open to discussion on which approach is preferred.