4

I am using Ubuntu 14.04 and running go-ethereum in it. In the ~/.ethash/ folder, I see that there are two DAG files created when mining begins. The first one is created immediately after mining starts and the second one after some time.I am interested in knowing the reason for it.

  • 3
    One is a future DAG, pregenerated so that switching between the current and future DAGs can be done quickly. I think this has been asked before... Let me check. – Richard Horrocks Apr 26 '17 at 13:45
  • 2
    (I couldn't see that this exact question had been asked before, so I'll add an answer.) – Richard Horrocks Apr 26 '17 at 16:18
2

Every 30,000 blocks - where 30,000 blocks is called an epoch - a new DAG file is generated. This mechanism provides the Ethash algorithm something fresh to work on.

At the end of 30,000 blocks, clients want to switch from their current DAG to the next one as quickly as possible. To this end, the next DAG file is generated in advance.

From the documentation:

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. The DAG is totally different every 30000 blocks (a 100 hour window, called an epoch) and takes a while to generate. Since the DAG only depends on block height, it can be pregenerated but if its not, the client need to wait the end of this process to produce a block.

If you want to prevent the pregeneration (I can't see why you would, but it's your network... ), then you can do so on the command line.

Disable automatic pregeneration of DAG?

  • 1
    After 30,000 blocks, does the old file get deleted? – spharish Apr 27 '17 at 17:33
  • 2
    Yes, the old DAG is removed to prevent you ending up with lots of large files. – Richard Horrocks May 1 '17 at 7:42
  • 1
    Also, I guess a new DAG file will be created to be used after the next 30,000 blocks. Is it true? – spharish May 1 '17 at 8:11
  • 2
    Yep, correct. Every 30,000 blocks the same thing will happen. – Richard Horrocks May 1 '17 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.