Accounts and State
Accounts
Same as Ethereum, Scroll has two account types: Externally-owned account (EOA) and contract account that holds the smart contract and additional storage.
Scroll stores additional information of the contract bytecode in the account to facilitate the zkEVM circuit to prove the state transition more efficiently.
The account in Scroll contains the following fields:
nonce
: A counter that indicates the number of transactions sent by the sender.balance
: The balance ofETH
token in the account (unit in wei).storageRoot
: The root hash of the storage trie. Since Scroll uses the zkTrie for the storage trie, thestorageRoot
stores the Poseidon hash digest in a 256-bit integer.codeHash
: The Keccak hash digest of the contract bytecode.PoseidonCodeHash
(new field): The Poseidon hash digest of the contract bytecode in a 256-bit integer.CodeSize
(new field): The size of the contract bytecode in bytes.
State
The state of a blockchain is a collection of account data. The state trie encodes account data and their corresponding addresses to a Merkle tree data structure. The root of tree, or the state of the blockchain, is a cryptographic digest of all the account data contained in the tree.
Ethereum uses a data structure called Patricia Merkle Trie for both the state trie and the storage trie that stores the key-value entries stored in a smart contract. In Scroll, we replace the Patricia Merkle Trie with a more zk-friendly data structure, called zkTrie, for both state trie and storage trie. At a high level, the zkTrie data structure is a sparse binary Merkle tree with the Poseidon hash, a zk-friendly hash function. The zkTrie document describes more details about this data structure.