我刚接触到Ethereum,我正试图通过一些定制来打造一个专用的Ethereum网络。我做了以下工作:
1)安装geth 1.5.4-源稳定
2)修改后的params/protocol_pars.go将事务气体设置为零(我想删除交易费用)
TxGas = big.NewInt(0)3)改进的核/块验证器,以降低挖掘难度。
func calcDifficultyFrontier(time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
//...
diff.SetInt64(0x20000)
return diff
}4) make all
5)启动geth控制台和miner.start(2)
现在,几乎所有的事情都如我所愿:一个简单的交易不需要任何费用。事务几乎立即被挖掘(最坏的情况是在几秒钟内)
问题是,DAG的生成是在上一个时代结束后开始的(我猜)
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因此,采矿每隔几个小时就暂停几分钟(大约30,000秒)。
当我在没有修改源代码的情况下启动geth时,日志如下所示:
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我想知道:
1)造成这个问题的原因--两个线程太少了吗?CPU是不是太慢了?
2)有什么解决办法--手动miner.makeDAG()吗?在其他计算机中生成DAG并复制DAG文件(如果可能的话)?
如有任何建议,将不胜感激。谢谢。
发布于 2017-10-24 23:58:23
生成DAG是设计为内存硬,我不认为你的CPU是瓶颈。我以前遇到过这种情况,我的解决方案是您的第二个建议,即在更好的机器上生成DAG (具有更多内存),并将其导入目标主机。
https://ethereum.stackexchange.com/questions/11518
复制相似问题