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.

2
  • 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. Commented Apr 26, 2017 at 13:45
  • 2
    (I couldn't see that this exact question had been asked before, so I'll add an answer.) Commented Apr 26, 2017 at 16:18

1 Answer 1

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?

4
  • 1
    After 30,000 blocks, does the old file get deleted? Commented Apr 27, 2017 at 17:33
  • 2
    Yes, the old DAG is removed to prevent you ending up with lots of large files. Commented May 1, 2017 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? Commented May 1, 2017 at 8:11
  • 2
    Yep, correct. Every 30,000 blocks the same thing will happen. Commented May 1, 2017 at 8:17

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.