What is DAG in Ethereum Blockchain

Sat Jul 02 2016

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
Leave a comment

To make a comment, please send an e-mail using the button below. Your e-mail address won't be shared and will be deleted from our records after the comment is published. If you don't want your real name to be credited alongside your comment, please specify the name you would like to use. If you would like your name to link to a specific URL, please share that as well. Thank you.

Comment via email
Nikhil M
Nikhil M

Entrepreneur / Privacy Freak / Humanist / Blockchain / Ethereum / Elixir / Digital Security / Online Privacy

Tags Recent Blogs