6

I'm new to Ethereum and I'm trying to make a private Ethereum network, with some customization. I've done the following:

1) installed geth 1.5.4-stable from source

2) modified params/protocol_params.go to set the transaction gas to be zero ( I wanted to remove transaction fee )

TxGas                  = big.NewInt(0)

3) modified core/block_validator.go to reduce the mining difficulty

func calcDifficultyFrontier(time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
    //...
    diff.SetInt64(0x20000) 
    return diff
}

4) make all

5) launched geth console and miner.start(2)

Now, almost everything is working as I wished: a simple transaction costs no fee. Transactions are mined almost immediately (within a few seconds, at worst)

The problem is that the generation of DAG starts AFTER the previous epoch finished (I guess)

I0119 03:58:00.211526 miner/worker.go:548] commit new work on block 149999 with 0 txs & 0 uncles. Took 233.195µs
I0119 03:58:00.211573 miner/worker.go:443]    Mined 5 blocks back: block #149993
I0119 03:58:01.815188 miner/worker.go:347]   Mined block (#149999 / c0a4e591). Wait 5 blocks for confirmation
I0119 03:58:01.815488 miner/worker.go:548] commit new work on block 150000 with 0 txs & 0 uncles. Took 258.938µs
I0119 03:58:01.815526 miner/worker.go:443]    Mined 5 blocks back: block #149994
I0119 03:58:01.815588 vendor/github.com/ethereum/ethash/ethash.go:259] Generating DAG for epoch 5 (size 1115684224) (f2e59013a0a379837166b59f871b20a8a0d101d1c355ea85d35329360e69c000)
I0119 03:58:03.153827 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 0%
I0119 03:58:06.980748 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 1%
I0119 03:58:10.800176 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 2%
...
I0119 04:04:24.854653 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 98%
I0119 04:04:28.665616 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 99%
I0119 04:04:32.475877 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 100%
I0119 04:04:32.477414 vendor/github.com/ethereum/ethash/ethash.go:276] Done generating DAG for epoch 5, it took 6m30.661840702s
I0119 04:04:33.278301 miner/worker.go:347]   Mined block (#150000 / 300955dc). Wait 5 blocks for confirmation
I0119 04:04:33.289874 miner/worker.go:548] commit new work on block 150001 with 0 txs & 0 uncles. Took 11.522128ms
I0119 04:04:33.290013 miner/worker.go:443]    Mined 5 blocks back: block #149995
I0119 04:04:34.158186 miner/worker.go:347]   Mined block (#150001 / 5ccc5bc0). Wait 5 blocks for confirmation
I0119 04:04:34.158455 miner/worker.go:548] commit new work on block 150002 with 0 txs & 0 uncles. Took 221.145µs

Therefore, mining pauses several minutes every few hours(about 30,000 seconds).

When I've launched geth without any modification of source, the log was something like:

I0119 11:39:49.189501 miner/worker.go:548] commit new work on block 173327 with 0 txs & 0 uncles. Took 442.561µs
I0119 11:39:49.189609 eth/backend.go:494] Pregenerating DAG for epoch 6 (full-R23-582b06447f087674)
I0119 11:39:49.189716 vendor/github.com/ethereum/ethash/ethash.go:259] Generating DAG for epoch 6 (size 1124070016) (582b06447f087674bcc0a32a19961e77dafb9e17955792f79ec8936e3d9742fc)
   <--- start generation BEFORE current epoch finishes
I0119 11:39:49.979477 miner/worker.go:347]   Mined block (#173327 / 9b8911da). Wait 5 blocks for confirmation
I0119 11:39:49.979763 miner/worker.go:548] commit new work on block 173328 with 0 txs & 0 uncles. Took 238.368µs
I0119 11:39:49.979806 miner/worker.go:443]    Mined 5 blocks back: block #173322
I0119 11:39:50.024806 miner/worker.go:347]   Mined block (#173328 / 8db0580d). Wait 5 blocks for confirmation
I0119 11:39:50.025385 miner/worker.go:548] commit new work on block 173329 with 0 txs & 0 uncles. Took 217.005µs
I0119 11:39:50.025670 miner/worker.go:443]    Mined 5 blocks back: block #173323
I0119 11:39:51.307860 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 0%
   <--- generating dag and minig are done concurrently
I0119 11:39:53.656535 miner/worker.go:347]   Mined block (#173329 / cd7ef5e5). Wait 5 blocks for confirmation
I0119 11:39:53.656868 miner/worker.go:548] commit new work on block 173330 with 0 txs & 0 uncles. Took 277.024µs
I0119 11:39:53.657164 miner/worker.go:443]    Mined 5 blocks back: block #173324
I0119 11:39:54.816776 miner/worker.go:347]   Mined block (#173330 / d88d3e59). Wait 5 blocks for confirmation
...
I0119 11:48:12.193978 miner/worker.go:548] commit new work on block 173734 with 0 txs & 0 uncles. Took 227.698µs
I0119 11:48:12.194025 miner/worker.go:443]    Mined 5 blocks back: block #173728
I0119 11:48:13.785809 vendor/github.com/ethereum/ethash/ethash.go:291] Generating DAG: 100%
   <--- block #180000 can be mined with no delay
I0119 11:48:13.788707 vendor/github.com/ethereum/ethash/ethash.go:276] Done generating DAG for epoch 6, it took 8m24.599017544s
I0119 11:48:15.113884 miner/worker.go:347]   Mined block (#173734 / c08554ca). Wait 5 blocks for confirmation
I0119 11:48:15.114334 miner/worker.go:548] commit new work on block 173735 with 0 txs & 0 uncles. Took 370.517µs
I0119 11:48:15.114378 miner/worker.go:443]    Mined 5 blocks back: block #173729

I wish to know:

1) the reason for this problem - are 2 threads too few? is the CPU too slow? ...

2) any workaround - miner.makeDAG() manually? generate DAG in other computer and copy DAG files from it (if this is possible)? ...

Any advice would be appreciated. Thank you.

  • 2
    I am noticing that you posted this question more than six months ago and did not get an answer. Did you find a way to solve this problem? If so, would you post the answer below and accept it so others can learn? – Tesa Jun 27 '17 at 13:47
  • 1
    @Tesa I'm sorry I didn't find one. – gypark Oct 30 '17 at 3:28
2

Generating the DAG is designed to be memory-hard, I don't think your CPU is the bottle neck. I've come across this before and my solution was your second suggestion, to generate the DAG on a better machine (with more memory), and import it to the target host.

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.