I have implemented private chain in ethereum but its difficulty level increases by time as a result the mining process slows down. Is it possible to make the difficulty static or disable it in testnet.
Asked
Active
Viewed 7,368 times
17
eth
- 85,679
- 53
- 285
- 406
Abhishek Ranjan
- 455
- 4
- 12
-
Here you can see the whole explanation to do it: http://blog.coinfabrik.com/fast-smart-contracts-execution-ethereum-private-blockchain-development-environment/ – Paul Exchange Mar 17 '17 at 14:49
2 Answers
16
Modify the CalcDifficulty in Geth to return a static number, then rebuild Geth. Example:
func CalcDifficulty(config *ChainConfig, time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
return big.NewInt(0x4000)
}
Source: Answer to Is it possible to change the block target time?
-
1
-
2@ThorkilVærge I usually won't answer/reply if I don't know. But I'm doing so here since I'm not ignoring the question, and would encourage if there are new answers. – eth May 03 '18 at 07:41
2
If it is private chain you can define difficulty in genesis block.
Something like this
{
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x4000",
"alloc": {},
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "Custem Ethereum Genesis Block",
"gasLimit": "0xffffffff"
}
Here is a good read to How to Set up testnet
niksmac
- 9,673
- 2
- 40
- 72
-
1I have used this format only. Initially the mining is fast but as the time flows the difficulty increases and mining goes very slow. – Abhishek Ranjan Jul 18 '16 at 07:19
-
1The difficulty is adjusted automatically so the average block time is within the hard-coded time in ethereum. The difficulty you specify in the genesis file is just the starting difficulty. To make difficulty static you need to modify the source code. – dragosb Jul 18 '16 at 12:42
-
1
-
1what genesis block has to do with difficulty as it is only to create inital blockchain . difficulty is measured by CalcDifficulty algo. – Himanshu sharma Dec 05 '16 at 12:18
-
1@Himanshusharma I understand that. OP is asking about creating the initial set up. – niksmac Dec 05 '16 at 16:16