Repository navigation
perf(encoding): encode execute and enqueue calldata with a cached ox AbiFunction - #60
Merged
Merged
Conversation
…AbiFunction viem's encodeFunctionData looks up the ABI item and hashes the selector on every call: 14.6us for a one-mutation execute, against 3.5us for ox with the function resolved once. The runtime encodes execute calldata for each accepted mutation. Counter benchmark, open loop at 8,000/s: 4,200-4,320 -> 4,770-4,930 mutations/s.
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.
Summary
viem's
encodeFunctionDatalooks up the ABI item and hashes the selector on every call. The runtime encodesexecutecalldata for each accepted mutation. This PR usesAbiFunction.encodeDatafrom ox with theexecuteandenqueuefunctions resolved once at module load. This follows the "prefer ox" rule inAGENTS.md.Results
executecalldata: 14.6 µs (viem) → 3.5 µs (ox, cached).Test plan
bun run lint,bun run typecheck,bun run test(the encoding and runtime tests compare calldata)🤖 Generated with Claude Code

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Replaces viem calls with cached ox functions when encoding
executeandenqueuecalldata.Reviews (1) · Last reviewed commit: "perf(encoding): encode execute and enque..." · Reviewed by Greptile