In this track: Storage, memory and layout
advanced · 4 MIN READ

Storage layout and proxies

Delegate execution makes layout compatibility part of correctness.

LET’S PICTURE IT

A new cabinet instruction manual must still match the positions of existing drawers.

SEE IT FOR YOURSELF
Pack small values into Solidity storage slotsStep 1 / 4
Pack small values into Solidity storage slotsFirstuint128 A16 bytesSeconduint128 B16 bytesThirduint256 C32 bytesSimple elementary types only; not a complete compiler layoutSlot 0 · 32 bytesUnused · 16 BA · 16 BHigh-order bytes ← → low-order bytesSlot 0 · fullB · 16 BA · 16 BDeclaration order and sizes determine this packingSlot 0BASlot 1C · 32 bytesTry different sequences in the storage-layout tool

In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Identify whose storage is used

With delegatecall, implementation code operates on the caller’s storage context. For a typical proxy, stored application state belongs to the proxy address.

Preserve existing field meaning

Moving or changing a field can make new code interpret old bytes under a different type or position. Successful compilation does not detect every upgrade compatibility problem.

Compare both complete layouts

Include inherited variables, structs, packed offsets and dynamic roots. Checking only a list of top-level variable names is insufficient.

Treat initialization separately

An implementation constructor does not initialize proxy storage through a later delegatecall. Initializer access and one-time execution need their own design and tests.

Inspect the layout

Old: slot 0 = uint256 count
Unsafe new interpretation: slot 0 = address owner

The existing bytes do not move themselves into a compatible new schema.

A conceptual compatibility example, not an upgrade recipe.

TURN UNDERSTANDING INTO PRACTICEOpen the Storage layout →
QUICK CHECK · NO PRESSURE

Whose storage does delegated implementation code typically use?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.