Gasgas - #1458
Closed
cburgdorf wants to merge 2 commits into
Closed
Conversation
cburgdorf
commented
May 20, 2026
Collaborator
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.
Merged
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.