Skip to content

improve(SpokeUtils): Use viem for RelayData hash computation #979

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented Apr 10, 2025

The Viem ABI encoder permits supplying the ABI as an object, which is faster than ethers, which apparently requires that the ABI be supplied to AbiCoder.encode() as a string. This implies re-parsing the same ABI on each call.

Brief testing showed that the new implementation is 50% faster than the existing one. Producing 500 RelayData hashes locally with takes ~0.5 seconds with viem and ~1 second with ethers. This is relevant in the relayer because performs bulk fillStatus queries of up to 250 RelayData hashes per chain on update, and it has a loop time in the order of low-digit seconds.

The Viem ABI encoder permits supplying the ABI as an object, which is
faster than ethers, which apparently requires that the ABI be supplied
to AbiCoder.encode() as a string, which implies re-parsing the same ABI
on each call.

Brief testing showed that the new implementation is 50% faster than the
existing one. Producing 500 RelayData hashes with each approach took 0.5
seconds with viem and 1 second with ethers. This is relevant in the
relayer because performs bulk fillStatus queries of up to 250 RelayData
hashes per chain on update.
@pxrl pxrl requested a review from bmzig April 10, 2025 21:23
@pxrl
Copy link
Contributor Author

pxrl commented Apr 10, 2025

One comment on the safety of this change - test/SpokePoolClient.ValidateFill.ts has tests that make fills and then query the FillStatus in the SpokePool, using getRelayDataHash() to compute the hash. If the hashes are not computed identically to the SpokePool's own RelayData hashes then these tests will fail.

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.

1 participant