Skip to content

Gas optimization opportunities in TokenMessenger.sol ~$49K/month at current volume #112

Description

@NthMOMENT

Hi Circle team,

I had the opportunity to run a full gas audit on src/TokenMessenger.sol as part of Fourier's open protocol optimization series.


Summary of Findings

Finding Category Gas Saved Location
localMinter read twice in _getLocalMinter() SLOAD Reduction ~100 gas/call _getLocalMinter()
remoteTokenMessengers[domain] read twice SLOAD Reduction ~100 gas/call removeRemoteTokenMessenger()
12 string require → Custom Errors Bytecode + Revert Gas ~50–200 gas/revert + ~3–5KB bytecode Contract-wide
Zero check on immutable in _isLocalMessageTransmitter() Dead Code Elimination ~100 gas/call _isLocalMessageTransmitter()
> 0!= 0 on amount check Opcode Selection ~5 gas/call _depositForBurn()

The Arc-Specific Case

Finding #4 is the cleanest single-line fix: _isLocalMessageTransmitter() checks address(localMessageTransmitter) != address(0) but
localMessageTransmitter is immutable and guaranteed non-zero by the constructor. This is provably dead code the EVM evaluates on every handleReceiveMessage call. One line deleted, ~100 gas saved per USDC receive, zero risk.

Finding #3 (Custom Errors) requires upgrading from Solidity 0.7.6 → 0.8.x. All other findings apply to the current codebase without a version change.

Why Arc changes the calculus: On Ethereum and Arbitrum, gas price volatility means developers tolerate small inefficiencies. On Arc, gas is priced in USDC at a fixed rate. Every wasted opcode costs the same dollar amount every single time, forever. With BlackRock, Visa, and Goldman Sachs as confirmed testnet participants, the volume through this contract will make these per-transaction inefficiencies significant at scale.

Estimated impact at current testnet volume: ~$49K/month. At mainnet institutional volume, this goes into the millions or even billions.


All findings are syntactic only. There's no message routing, burn/mint accounting, attestation validation, or access control were modified.

Full report with before/after code snippets:
https://github.com/NthMOMENT/Fourier.u/blob/main/reports/CircleCCTP_TokenMessenger.md

Happy to provide production-ready diffs against your test suite. I work on a risk-reversal basis. Payment only if gas measurably drops and your tests pass.

Ram | Fourier | fouriers.xyz | @0xfourier

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions