1

Related to this and this.

The difficulty adjustment algorithm is:

block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**((block.number // 100000) - 2))

where // is the integer division operator, eg. 6 // 2 = 3, 7 // 2 = 3, 8 // 2 = 4.

From what I understand, a 10 second threshold was chosen to keep the block time in the range of 10-20 seconds. Also, the source code is available here. So, can I modify the algorithm (maybe change //10 to //5) and create a blockchain network which takes 5 seconds to confirm a block? Is this achievable? I hoped to get an answer to this question through this blog post but couldn't figure out the exact downfalls in doing this.

P.S: Basically, I have an application running on a private blockchain which requires less block confirmation time. I started the blockchain with low difficulty (0x400) but it increased over time to maintain a 15 second average block time. So, I am looking for a way to prevent this difficulty from increasing. Is this possible to achieve without a compromise in security?

I'm using geth-1.4.9

1 Answer 1

3

One thing to consider would be the orphan rate, which is alluded to in the comments for the thread you linked to.

The lower you set the difficulty, the shorter the block time, which is what you're aiming for.

However, the lower the difficulty, the greater the chance of multiple miners solving the block at the same time, and the chain forking. This ultimately leads to the blocks in one of the forks being orphaned, and which is why Ethereum (with it's 15 second blocktime) already uses the GHOST protocol (or a limited version of it). You'd have to experiment to see if the chain rearrangements would cause your network any problems.

Note that the algorithm you've linked to includes the changes made for the difficulty bomb, which means the difficulty will increase with block number.

... int(2**((block.number // 100000) - 2)) <---- this part

The aim of this is to eventually make mining (effectively) impossible, paving the way for the move to PoS. You will presumably want to use the algorithm as it was before those changes.

1
  • Do you know of any platform where I can run simulations and experiment with reduced block times?
    – galahad
    Aug 5, 2016 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.