Skip to main content

Module state

Module state 

Source
Expand description

State variables at a step, read through the compiler’s storage layout.

solc --storage-layout says where every state variable lives; the trace says what the words there held. Putting the two together answers print counter or print balances[0xabc] without ETHDebug variable information, and does so from compiler-issued fact only: the slot arithmetic is the language’s own rule, and the words are what the backend recorded.

A backend records a slot at the SLOAD or SSTORE that touches it, not at every step, so the value at a step is the most recent record for that slot in the same storage context. A trace is a complete recording, so that is a lookup on the tape rather than a guess: StorageTape indexes every record once, keyed by the account whose storage it belongs to, and a DELEGATECALL writes the caller’s. A frame that reverted did not keep its writes, so after it a slot holds what it held before the frame — and if that was never read, it is unknown again.

A slot with no record yet is unknown here, because the trace does not say what is in it. A frontend that has a node can supply one through ChainStorage, which is read only for slots the trace never recorded, and the value is then marked as coming from the chain rather than from the recording. Without one, unknown is reported as unknown and never as zero: this crate has no chain to ask, and it does not pretend to.

Transient storage is a second tape, StorageTape::transient, where a slot with no record is zero: the space starts empty in every transaction.

Structs§

CachedChain
A ChainStorage that reads each slot once, through a function the frontend gives.
StateVariable
One state variable, or one place inside one, with its value at a step.
StorageTape
Every storage word a trace recorded, by storage context and slot.
StorageWords
The storage words known at one step, in one storage context.

Enums§

StateSource
Where a value came from.

Traits§

ChainStorage
A chain a frontend can read storage from, for slots the trace never recorded.

Functions§

short_hex
0x-prefixed hex without leading zeros; 0x0 for zero.
state_value
The value at a storage path such as owner, balances[0xabc], items[2], or config.limit. Err says why the path does not name a place in storage.
state_variables
Every state variable in the layout, with its value at the step.

Type Aliases§

ChainRead
The reading a frontend supplies: one storage word of one account, or nothing.