Skip to content

Conversation

@ozwaldorf
Copy link
Member

@ozwaldorf ozwaldorf commented Feb 9, 2026

Overall improves contract size by 50-55%.

Final erc20 escrow size: 8Kib
Final native eth escrow size: 7Kib

Changes

  • Split native and erc20 into unique contracts
    • 15Kib -> 10 Kib native, 11Kib escrow
  • Fix forge lints
    • erc20 transfer requires success response
    • hardcode runtime keccak computation
    • mark external-only functions as external
  • Custom errors
    • ~2.2k bytes saved
  • Inline constants
    • ~60 bytes saved
  • Unchecked loops
    • ~7 bytes saved
  • refactor: eliminate memory allocations in calldata parsing #18
    • ~600 bytes saved

Sol optimization attempt

Sol optimization passes at ~200 is near-optimal already for bytecode size:

  • Tested with 10k optimization passes, contract size grew ~20% due to aggressive inlining.
  • Tested with 1 optimization pass, contract size was only 7 bytes difference.

@ozwaldorf ozwaldorf requested a review from g4titanx February 9, 2026 18:40
@ozwaldorf ozwaldorf changed the title refactor: size optimizations refactor: size optimizations, split native eth Feb 9, 2026
@g4titanx
Copy link
Member

this is great tbh @ozwaldorf
i've got minor improvements to the proofs that will remove ~600 bytes and then we can merge this i guess, i'd open another pr now based off of this

* refactor: eliminate memory allocations in calldata parsing

* chore: update artifacts
@ozwaldorf ozwaldorf merged commit b116322 into master Feb 11, 2026
4 checks passed
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