Ethereum On-chain Data
A review of Ethereum data structures
On-chain data in Ethereum is stored in four different mappings, each of which are encoded in a Merkle-Patricia trie. Each block header contains commitments to these four tries, thereby committing to all of the current Ethereum state. The types of data this comprises are:
State trie: This is a mapping between
keccak(address)
andrlp(acct)
, whererlp
denotes the RLP serialization andacct
is the array[nonce, balance, storageRoot, codeHash]
of information associated to each Ethereum account.Storage trie: Each account has a storage trie which is a mapping between
keccak(slot)
andrlp(slotValue)
which encodes the storage of each account, which is a mapping between theuint256
slot anduint256
slot value.Transaction trie: Each block also commits to the transactions in that block via a mapping between the encoded transaction index
rlp(txIndex)
and the serializationrlp(tx)
.Receipt trie: Finally, the receipts trie commits to a mapping between the encoded receipt index
rlp(receiptIndex)
and the serializationrlp(receipt)
.
The block header of each block contains the roots stateRoot
, transactionsRoot
, and receiptsRoot
, which together commit to each of these tries and thus all of the Ethereum on-chain data.
Last updated