8

I'm trying to make sense of geth's hashrate and Ethereum's difficulty setting. I'm running a private test net and set the difficulty to a fixed value (to big.NewInt(250)) as described by https://ethereum.stackexchange.com/a/7159/5293. I start the CPU mining in geth using one thread with miner.start(1). Then I measure the hashrate with eth.hashrate, it's usually a value between 8 and 12 (let's say h = 10 H/s on average). I measured the average blocktime by mining for 15 minutes and it was around 65 seconds.

Now, I'd like to use the difficulty setting and hashrate to calculate the expected blocktime. If I'd calculate it in the way the terms 'difficulty' (d) and 'hashrate' (h) are used in Bitcoin, I'd get

t = 2^32 * d / h,

which is not even close to 65 seconds.

I'm running geth on a Intel(R) Core(TM) i5 CPU, with 2.80GHz. I assume that the value h = 10 H/s is rather useless as it should be much higher (but where does it come from then)? With my processor, I'd assume that I cannot get higher than maybe h = 50 kH/s. However, to yield the 65 seconds, I'd need a hash rate of

h = 2^32 * d / t = 1.7 * 10^10

which is much higher than my maximum hashrate.

  • No, this is not how the difficulty is calculated. Have you checked the yellow paper on page 6 equations 39 through 44? – Afr Jan 13 '17 at 14:21
  • 1
    Yes, I checked equations 39-44. But since I set the difficulty to a fixed value, I think only equations 39 and 40 are relevant for me. Therefore, my difficulty D(H) is always D_0 = 250. Then, a valid block should have a hash smaller than or equal to (2^256) / 250. – Pold Jan 13 '17 at 14:48
1

You're not correct.

  1. Chance that hash is a solution of the problem is 1 / d.
  2. Average amount of hashes to be calculated to solve the problem is enter image description here
  3. So average amount of hashes per block is 250.
  4. Since your hashrate is 10H/S, we can calculate average time - 25s. Which is not your exact number, but whatever.

Exact formula you're asking is t = d / h.

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.