Skip to content

Gasgas - #1458

Closed
cburgdorf wants to merge 2 commits into
argotorg:masterfrom
cburgdorf:gasgas
Closed

Gasgas#1458
cburgdorf wants to merge 2 commits into
argotorg:masterfrom
cburgdorf:gasgas

Conversation

@cburgdorf

Copy link
Copy Markdown
Collaborator
Differential deposit — correctness OK across 3 deposits.
call             fe gas        sol    sol+opt     sol-IR sol-IR+opt       best     fe vs best
----------------------------------------------------------------------------------------------
deposit#0         83974      90965      84626      98697      81089      81089    +2885 (+3.6%)
deposit#1         69414      77502      70411      85745      66629      66629    +2785 (+4.2%)
deposit#2         49762      56753      50414      64485      46877      46877    +2885 (+6.2%)

cburgdorf added 2 commits May 20, 2026 21:42
Annotates the small, hot std helpers in the deposit contract's call path
plus `compute_deposit_data_root` itself. Measured against
`differential_deposit`:

  deposit#0  85637 -> 84507  (-1130, +5.6% -> +4.2% vs sol-IR+opt)
  deposit#1  71111 -> 69947  (-1164, +6.7% -> +5.0%)
  deposit#2  51425 -> 50295  (-1130, +9.7% -> +7.3%)

deposit#1 now beats sol+opt (69947 vs 70411); only sol-IR+opt remains
ahead. The savings come from the JUMP/PUSH/SWAP/MLOAD that disappear
when these small functions are folded into their callers.

The following were tried and reverted because they cost gas (revert
strings get duplicated at each callsite, blowing up bytecode and memory
expansion):
  - `assert` (`#[inline(always)]` cost +209 gas/deposit)
  - `assert_msg` (`#[inline]` likewise)
The previous lowering allocated memory and then wrote the length word plus
each 32-byte chunk with its own MSTORE (and ADD per chunk). Now the literal
payload is packed into a `[u256; N]` const region whose word-packed layout
exactly matches the runtime `[len_word || padded_data]` shape, and a single
CODECOPY copies it from the code segment.

Adds a `RuntimeBuiltin::ConstRegionAddr { region }` that lowers to a
`SymAddr` of the const region's data — accepted by EvmCodeCopy as the
`code_offset` operand without going through the `ConstRef` rewrite pass.

For a 38-byte revert message the old path emitted ~3 MSTOREs + 2 PUSH32s +
2 ADDs per chunk; the new path emits one CODECOPY of 64 bytes plus the
length-word + size-word constants needed for the DynString header. Larger
messages benefit linearly: no per-word PUSH32/MSTORE/ADD overhead.
@sbillig sbillig mentioned this pull request May 30, 2026
@cburgdorf cburgdorf closed this May 30, 2026
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.

1 participant