Accounts and State
Accounts and State in Wischain
Accounts
Similar to Ethereum, Wischain features two primary types of accounts: Externally Owned Accounts (EOAs) and Contract Accounts. EOAs are controlled by private keys and can initiate transactions, while Contract Accounts contain smart contracts and additional storage.
Wischain enhances the efficiency of zkEVM circuits by storing supplementary information about the contract bytecode directly within the account. This design facilitates a more streamlined process for proving state transitions.
Each account in Wischain contains the following fields:
Nonce: A counter that tracks the number of transactions initiated by the account holder.
Balance: Represents the amount of ETH held in the account, denoted in wei.
Storage Root: This field holds the root hash of the storage trie. Wischain employs the zkTrie for its storage structure, meaning the
storageRoot
contains the Poseidon hash digest, represented as a 256-bit integer.Code Hash: The Keccak hash digest of the contract bytecode, which serves as a unique identifier for the contract.
Poseidon Code Hash (New Field): A new addition that holds the Poseidon hash digest of the contract bytecode in a 256-bit integer format, improving compatibility with zk-proof systems.
Code Size (New Field): This field indicates the size of the contract bytecode in bytes, providing insight into the contract's complexity and resource requirements.
State
The state of a blockchain encompasses a comprehensive collection of account data. In Wischain, this data is organized in a state trie, which encodes account information and their corresponding addresses using a Merkle tree data structure. The root of this tree acts as the cryptographic digest representing the entire state of the blockchain.
While Ethereum utilizes a Patricia Merkle Trie for both its state and storage trier structures, Wischain opts for a more zk-friendly data structure known as the zkTrie. This structure is designed specifically to enhance zero-knowledge proofs and is characterized by the following features:
Sparse Binary Merkle Tree: The zkTrie functions as a sparse binary Merkle tree, allowing for efficient verification of account data and state transitions.
Poseidon Hash: Employing the Poseidon hash, a hash function optimized for zk-SNARKs, ensures that the hashing process is more efficient and compatible with zero-knowledge proof systems.
The details of the zkTrie data structure are documented in the zkTrie documentation, which provides further insights into its design and advantages over traditional data structures. This innovative approach not only improves the performance of state transitions but also enhances the overall scalability and efficiency of the Wischain network.
Last updated