2

If you want to start a private net with Geth, then you need to create a Genesis Block. You specify the attributes of this block through a config file. One of these configurations is 'difficulty'.

An example I've seen is this: "difficulty": "0x0400".

My question is, what does this number represent? From what I've gathered, it means set the target such that there's a 1/1024 chance in finding a hash that meets the target.

3

The difficulty value here is the reciprocal of the probability that the hash for mining the first block is "good" and that the block gets included in the blockchain. For example, in the Ethereum main net, this value is 0x400000000, or 17179869184 in decimal. So about one in 17179869184 hashes lead to a valid block. If the total hash power of miners is 1717986918 hashes per second (one tenth of the genesis block's difficulty), then it would take about 10 seconds to mine a block.

The value was set much higher than you would use for a private net because there was projected to be a lot more competition for mining main net Ethereum at the very beginning than most/all private chains to date would see.

If the genesis block's difficulty is too low for a decentralized set of miners with relatively high latency, the effects of "instamining" (blocks found very quickly) would lead to extreme blockchain forking. This is not a problem on a private network with one computer or very few computers in a higher-latency environment; forking is less of an issue (or not at all on one computer) and the automatic difficulty retargeting should readily adjust the difficulty so as to avoid future forking. Setting this value too high means it would take considerable time to mine the first several blocks before the difficulty retargeting algorithm makes block times more reasonable.

Otherwise, this difficulty is no different from the difficulty of any other block.

  • 1
    Thanks, lungj. So if this is the reciprocal, then we're saying there's a 1 in 1024 chance of getting the hash of a block such that it gets included in the blockchain. Correct? – Bastien Jul 20 '17 at 14:46
  • Yes, you were correct in your initial post. I've updated my answer to be a bit clearer on that front. – lungj Jul 20 '17 at 14:49

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.