Gas Optimization After Dencun: What Still Matters
EIP-4844 rewrote the cost model for Ethereum. Storage operations still dominate, but the tricks that save gas have changed.
For most of Ethereum’s history, gas optimization was a dark art practised by a small guild of assembly-literate engineers. Much of that folklore is now outdated. The EVM has changed, the compiler has improved and the cost model itself has been rewritten by the Dencun upgrade.
An SSTORE to a cold slot costs 20,000 gas. An SLOAD from a cold slot costs 2,100 gas. By comparison, an ADD costs 3 gas. Storage operations dominate the gas profile of almost every contract, and the most effective optimisation you can do is to reduce the number of them. Struct packing remains valuable — two uint128 values in one 256-bit slot cost one SLOAD instead of two.
Transient storage, introduced in EIP-1153, is the new option for data that only needs to survive within a single transaction. TSTORE and TLOAD cost 100 gas each — a fraction of their persistent counterparts. Reentrancy guards, callback flags and single-transaction accumulators are natural candidates.
“The deployment cost is paid once. Execution gas is paid on every call. Optimise for the thing that repeats.”