[Ethereum] How is DAG related to Merkle Tree

dagethashmerkle-patricia-triesmining

After reading the Ethash wiki, I kind of get DAG is something that every node can identically generate to verify the work. However I don't get how the DAG is related to Merkle Tree. Can anyone explain in detail?

Best Answer

The Ethash DAG is not related to merkle trees (the word "merkle" does not appear on either wiki page). The Ethash DAG only serves as a big dataset (i.e. too big to fit in memory) for making Ethash mining be "memory-hard".

Ethereum's merkle tree is what keeps track of the state of all accounts and contracts. The state of all accounts is not directly related to the Ethash mining algorithm. When the Ethereum protocol switches from Ethash PoW to Casper PoS, the Ethash DAG will be completely dropped. But the merkle tree of all account states is essential and will remain.

You might be confusing the Ethash DAG with the phrase "Merkle DAG" used to describe the IPLD data structure of IPFS. IPFS uses the phrase "Merkle DAG" (Merkle Directed Acyclic Graph) because each IPFS address is a merkle hash, and links from address to address form something like a "merkle graph". Since IPFS is natural fit for merkle trees, some Ethereum and IPFS developers are working on hosting the Ethereum state on IPFS.