Skip to content

perf(contracts): share submitMerkleRoot call across submitRoot* wrappers#2016

Merged
jonastheis merged 1 commit into
jonas/router-decouplingfrom
jonas/market-bytecode-shrink
May 28, 2026
Merged

perf(contracts): share submitMerkleRoot call across submitRoot* wrappers#2016
jonastheis merged 1 commit into
jonas/router-decouplingfrom
jonas/market-bytecode-shrink

Conversation

@jonastheis

@jonastheis jonastheis commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Extract a private _submitRoot(setVerifier, root, seal) helper from the five submitRoot* external entrypoints. The optimizer was duplicating the entire IRiscZeroSetVerifier.submitMerkleRoot call setup (~140 B per site: selector push, ABI-encode for bytes 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

BoundlessMarket runtime: 30,165 B → 29,456 B (−709 B).

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
@jonastheis jonastheis changed the title perf(contracts): BoundlessMarket bytecode shrink + upgrade-path work perf(contracts): share submitMerkleRoot call across submitRoot* wrappers May 28, 2026
@jonastheis jonastheis merged commit e2fedc7 into jonas/router-decoupling May 28, 2026
@jonastheis jonastheis deleted the jonas/market-bytecode-shrink branch May 28, 2026 02:30
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.

2 participants