Skip links

Fast Execution of Smart Contracts in Ethereum Private Blockchain

We describe a geth source code change which enables faster block mining. We hope this option will be included in Ethereum command lines.

Private Ethereum blockchains may be deployed by private entities to use in production or in the software development process.

There are different ways of speeding the development environment. Some developers choose an Ethereum branch which does not depend on mining via slow proof-of-x methods. Others prefer a modification of the most up to date Ethereum node. The unchanged Ethereum node takes about 15 seconds per new block, while the mining difficulty function below dramatically reduces this lag time.

For developers, this means faster transaction and smart contract execution since every smart contract function, every event fired, and every state change depends on block mining time.

Source Code Change

In the current version you should replace CalcDifficulty here with the following:

func CalcDifficulty(config *params.ChainConfig, time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
   return big.NewInt(1)
}

Note

Increasing the mining rate will reduce your filesystem capacity much faster than usual due to the underlying Ethash DAG. You can safely remove your ~/.ethash directory to free space. Be sure to stop geth first.

Alternatives

Private blockchains which use different consensus algorithms can still take advantage of the Ethereum virtual machine and the programming languages supported there (e.g. Solidity). See the following technologies: