What is DAG in Ethereum Blockchain

Dagger Hashimoto is a the mining algorithm for Ethereum.

What is DAG in Ethereum Blockchain

Dagger Hashimoto is a proposed spec for the mining algorithm for Ethereum 1.0. Dagger Hashimoto aims to simultaneously satisfy two goals:

  1. ASIC-resistance: the benefit from creating specialized hardware for the algorithm should be as small as possible, ideally to the point that even in an economy where ASICs have been developed the speedup is sufficiently small that it is still marginally profitable for users on ordinary computers to mine with spare CPU power.
  2. Light client verifiability: a block should be relatively efficiently verifiable by a light client.

Why do we need DAG in Ethereum?

Ethereum uses Ethash (Proof of Work system). as of now
Ethash PoW is memory hard, making it basically ASIC resistant. This basically means that calculating the PoW requires choosing subsets of a fixed resource dependent on the nonce and block header. This resource (a few gigabyte size data) is called a DAG. Clients wishing to store the DAG in a cache should conform to this spec in order to share the cache with other clients:

Where is DAG stored

The DAG should be stored in a 1GB dump (for the initial epoch, anyway), in a file:

Mac/Linux: $(HOME)/.ethash/full-R<REVISION>-<SEEDHASH> Windows: $(HOME)/Appdata/Local/Ethash/full-R<REVISION>-<SEEDHASH>

Format

Each file should begin with an 8-byte magic number, 0xfee1deadbaddcafe, written in little-endian format (i.e., bytes fe ca dd ba ad de e1 fe).

The Ethash algorithm expects the DAG as a two-dimensional array of uint32s (4-byte unsigned ints), with dimension (n ├Ś 16) where n is a large number. (n starts at 16777186 and grows from there.) Following the magic number, the rows of the DAG should be written sequentially into the file, with no delimiter between rows and each unint32 encoded in little-endian format.

Sources

  1. Dagger-Hashimoto
  2. Ethash DAG
  3. Directed acyclic graph - In mathematics and computer science
All product names, logos, and brands are property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.

Write a comment on What is DAG in Ethereum Blockchain