Skip to content
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: improve _getV3RelayHash method #779

Merged
merged 6 commits into from
Dec 3, 2024

Conversation

chrismaree
Copy link
Member

@chrismaree chrismaree commented Nov 28, 2024

This PR re-works the _getV3RelayHash method.

The internal _getV3RelayHash method has been updated & simplified. Previously, the internal relay hash was the hashed concatenation of all relay message props. Now, the relay hash is the hashed concatenation of all props, except the message field is first hashed. this makes the relay hash([…relayPropsExceptForMessage,hash(message)]). This change was made as the recent update to FilledV3Relay event sees this event no longer emitting the full message, but rather now just the messageHash. given this event change, the previous method for finding v3RelayHashes meant that off-chain actors could not re-compute the relayhash using just off-chain FilledV3Relay event data but would rather need to find associated deposits to find the corresponding message to find the relayHash.

Gas comparison:

Comparison of fills with no Message field ("0x")
Old: 111308
New: 111236
saving: 72

Comparison of fill with 1kb message field ("0x"+"69".repeat(512))
Old: 123987
New: 122837
Saving: 1150

Comparison of fill with 10kb message field ("0x"+"69".repeat(10240))
Old: 316828
New: 293517
Saving: 23311

Signed-off-by: chrismaree <[email protected]>
@chrismaree chrismaree changed the base branch from master to svm-dev November 28, 2024 09:58
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
relayData.depositId,
relayData.fillDeadline,
relayData.exclusivityDeadline,
relayData.message.length > 0 ? keccak256(relayData.message) : bytes32(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

we can also use _hashNonEmptyMessage, or that adds overhead?

Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Signed-off-by: chrismaree <[email protected]>
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

This will definitely require offchain bot changes. Lgtm

@chrismaree chrismaree merged commit fa137a2 into svm-dev Dec 3, 2024
9 checks passed
@chrismaree chrismaree deleted the chrismaree/change-fill-hash-function branch December 3, 2024 09:31
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.

4 participants