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.
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 https://github.com/ethereum/go-ethereum
Step 2: Create your own mutant ethereum
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
Step 3: Build your mutant ethereum
Head out to the root folder(go-ethereum) and run following command.
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
Now check the block difficulty using
admin.nodeInfo console command.
Voila, you are done. You have just created your own version of ethereum. That deserves some celebration.
Learned something? Click the 👏 to say “thanks!” and help others find this article.
Hold down the clap button if you liked the content! It helps me gain exposure .
Want to learn more? Check out my previous articles…
Experts are suggesting quantum computing may render blockchain obsolete. As the tech giants such as Google and IBM are…hackernoon.com
The only blockchain which has blocktime of less than a second: 0.5 sec!hackernoon.com
This post marks the first in a new Quorum series I am starting in an effort to provide some easy to read instructions…hackernoon.com
The whole world is going through the blockchain revolution. But wait…is this really what we dreamed of? Present…medium.com