perf(contracts): share submitMerkleRoot call across submitRoot* wrappers#2016
Merged
Merged
Conversation
Each of the five submitRoot* external entrypoints inlined its own `IRiscZeroSetVerifier.submitMerkleRoot(root, seal)` call site — selector push, free-memory-pointer math, ABI-encode of `bytes seal`, external CALL, return-path / revert-bubble. Five duplicated copies of that ~140 B pattern. Factor into a `private _submitRoot(setVerifier, root, seal)` helper. With five call sites, the optimizer keeps the helper body out-of-line and the wrappers JUMP to it instead of inlining. ABI unchanged: same external selectors, same parameter layout — brokers call the same functions with the same calldata. BoundlessMarket runtime: 30,165 -> 29,456 B (-709 B) Margin vs EIP-170: -5,589 -> -4,880 B
willpote
approved these changes
May 27, 2026
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
Extract a
private _submitRoot(setVerifier, root, seal)helper from the fivesubmitRoot*external entrypoints. The optimizer was duplicating the entireIRiscZeroSetVerifier.submitMerkleRootcall setup (~140 B per site: selector push, ABI-encode forbytes seal,CALL, return path) at each site. With five call sites, the optimizer keeps the helper factored.ABI / selectors / calldata layout unchanged — brokers call the same five functions with the same inputs.
Result
BoundlessMarketruntime: 30,165 B → 29,456 B (−709 B).