Vaibhav Saini


How to reduce block difficulty in ethereum private testnet

bait for ethereum lovers

One of the greatest problems when it comes to development on ethereum private testnet is it’s slow consensus. Thanks to POW(Proof of Work). This problem also increases with time as the block difficulty increases. So, our testnet becomes slower and slower, block by block.

dog: How it feels like to use POW (source)

One obvious solution to this problem is to use a bigger machine as your miner. But eventually, after some time it will also get slow when it hits some big difficulty rate. But there is another easy solution to this problem, that is to reduce the rate at which blockchain difficulty increases to as low as 1/block.(i.e. your block difficulty rate will increase by only 1 per block)

Let’s see how it’s done.

Step 1: Clone go-ethereum

git clone

Step 2: Create your own mutant ethereum

Open consensus.go which resides at consensus/ethash/consensus.go . Now search for the line given below.

return CalcDifficulty(chain.Config(), time, parent)

And replace it with

return big.NewInt(1)

Step 3: Build your mutant ethereum

Head out to the root folder(go-ethereum) and run following command.

make geth

And after you are done, you will see this line at the end.

Now, you can run this command to make your mutant geth globally available.

 sudo mv build/bin/geth /usr/bin

Step 4: Let’s test it out

Create a custom genesis file like one given below.


Now, run the following command to start your private testnet using your mutant geth.

geth --datadir ./DataDir init ./genesis.json
geth --datadir ./DataDir --networkid 1212 --mine --minerthreads=1 --etherbase="0x30f28686aef33adbfbc13797b1d9f5a2f2759f56" console
starting up private testnet

Now check the block difficulty using admin.nodeInfo console command.

at block: 9, difficulty: 9

Voila, you are done. You have just created your own version of ethereum. That deserves some celebration.

More by Vaibhav Saini

Topics of interest

More Related Stories