Persistent and transient storage opcodes: SLOAD, SSTORE, TLOAD, and TSTORE.
Persistent Storage (SLOAD/SSTORE)
Persistent storage is a key-value mapping (256-bit → 256-bit) that persists across transactions. Gas costs depend on the hardfork:
- SLOAD (0x54) — reads a storage slot. Costs 2,100 (cold) or 100 (warm) per
EIP-2929 from Berlin; a flat static price before (see
EEVM.Gas.Static). - SSTORE (0x55) — writes a storage slot. Cost depends on the transition from
original → current → new value (
EEVM.Gas.Dynamic.sstore_cost/4), plus 2,100 for a cold slot from Berlin. From Istanbul it fails out of gas when no more than 2,300 gas remains (EIP-2200).
Transient Storage (TLOAD/TSTORE)
Transient storage (EIP-1153) provides a key-value mapping that is automatically cleared at the end of each transaction. Useful for reentrancy locks and temporary state.
- TLOAD (0x5C) — reads from transient storage. Costs 100 gas (warm access).
- TSTORE (0x5D) — writes to transient storage. Costs 100 gas (warm access).
Summary
Functions
@spec execute(non_neg_integer(), EEVM.Interpreter.MachineState.t()) :: {:ok, EEVM.Interpreter.MachineState.t()} | {:error, atom(), EEVM.Interpreter.MachineState.t()}