3

I need a long-running private Ethereum net (at least for 2 weeks) with fast block times. I have a single machine which is mining. When setting the difficulty very low, the block-time is very fast in the beginning. "Unfortunately" the difficulty gets adjusted so that after some hours the block-time gets towards the usual 14s. Is there a way to change that? I assume I can re-build geth and set the target block-time somewhere? Or is there any easier method?

2
  • If you're using a private network, do you really want PoW? You might want to loo into a PBFT solution Dec 12 '16 at 0:12
  • correct, but geth seems to be the most stable bet on the market right now. desperately trying with eris:db but not really getting far right now.
    – SCBuergel
    Dec 12 '16 at 0:30
3

It is actually quite easy to edit the source code for geth to do what you want.

Simply comment out the body of CalcDifficulty (line 265 in core/block_validator.go) and replace it with

return parentDiff;

Then set the difficulty in the genesis block file.

6
  • Thanks a lot, as a getting-started project I am building a fast-geth version: github.com/SCBuergel/go-ethereum Figuring out the build tools (go + gopath and friends....) took a bit longer but now it is already building the DAG :)
    – SCBuergel
    Dec 12 '16 at 16:38
  • Congrats! Just my opinion, but I think you should keep looking into eris. A blockchain without a strong consensus mechanism is just a bad database Dec 12 '16 at 16:44
  • Agree. But I want some "plan B" and also want an ease "PoC"-ethereum.
    – SCBuergel
    Dec 12 '16 at 16:47
  • BTW: every now and then I get We are too far in the future. Waiting for 5s I assume that is due to the hard-code of the difficulty and cant be avoided?
    – SCBuergel
    Dec 12 '16 at 16:48
  • 1
    I edited to make it easier to change difficulty; now it should just use the difficulty in the genesis block, so you don't need to recompile every time you change it Dec 12 '16 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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