Skip to main content

2 posts tagged with "data-structure"

Back to overview

· 8 min read

The state of Ethereum (the totality of all accounts, balances, and smart contracts), is encoded into a special version of data structure known generally in computer science as Merkle Tree. This structure is useful for many applications in cryptography because it creates a relationship between all individual pieces of data entangled in the tree, resulting in a single root value that can be used to prove things about the data.

Ethereum's data structure is a 'modified Merkle-Patricia Trie', named so because it borrows some features of PATRICA ( the Practical Algorithm to Retrieve Information Coded in Alphanumeric), and because it is designed for efficient data retrieval of items that comprise the Ethereum state.

A Merkle-Patricia trie is deterministic and cryptographically verifiable: The only way to generate a state root is by computing it from each individual piece of state, and two states that are identical can be easily proven by comparing the root hash and the hashes that led to it (a Merkle proof). Conversely, there is no way to create two different states with the same root hash, and any attempt to modify state with different values will result in different state root hash. Theoretically, this structure provides 'holy grail' of Olog(n)O\log(n) efficiency for inserts, lookups, and deletes.

· 5 min read

A Merkle tree is nothing but a hash-based data structure that is a generalization of hash list. It is a tree structure in which leaf node is a hash of a block of data, and each non-leaf node is a hash of its children. Typically Merkle trees have a branching factor of 2, meaning that each node has up to two children.01