20

The block hash has to be below certain difficulty, right? In bitcoin this means, that there are many leading zeroes in hash value, eg. for bitcoin block #402329 hash is 000000000000000006efd706f4467e2d7ed6f0fed757ca7d59e2cc8c81a2d9e3.

But for the ethereum blockchain the hash of block #1138224 is 0xa4f80a26aecb5fc975e12a9d3d0f6a7907c60b1d7e6b5205dfb4c984dad7f1ba.

Why are there no leading zeroes?

11

In the Ethereum blockchain, the difficulty is used to calculate a target.

Here are the ethminer logs for block number 1257006 :

ℹ  35:02:42.89 ethminer  Solution found; Submitting to http://192.168.4.120:8545 ...
ℹ  35:02:42.89 ethminer    Nonce: ff4136b6b6a244ec
ℹ  35:02:42.89 ethminer    Mixhash: 47da5e47804594550791c24331163c1f1fde5bc622170e83515843b2b13dbe14
ℹ  35:02:42.89 ethminer    Header-hash: f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445
ℹ  35:02:42.89 ethminer    Seedhash: 1730dd810f27fdefcac730fcab75814b7286002ecf541af5cdf7875440203215
ℹ  35:02:42.89 ethminer    Target: 00000000000baef6895d630131521d65d984555906990f43f352be4350291f92
ℹ  35:02:42.89 ethminer    Ethash: 0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74
ℹ  35:02:42.89 ethminer  B-) Submitted and accepted.

Here is a snippet of Java to compute the difficulty from the target :

import java.math.BigInteger;

public class DifficultyDemo {
    public static void main(String[] args) {
        BigInteger numTwoPow256 = new BigInteger("2").pow(256);
        BigInteger target = new BigInteger("00000000000baef6895d630131521d65d984555906990f43f352be4350291f92", 16);
        BigInteger difficulty = numTwoPow256.divide(target);
        System.out.println(difficulty.toString());
    }
}

And the difficulty is calculated as 24091770185844 which corresponds to the difficulty in the blockchain explorer screen.

We can use ethminer --check-pow <headerHash> <seedHash> <difficulty> <nonce> to check the proof-of-work for validity as follows:

beefee@Rasterbator:~$ ethminer --check-pow f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445 1730dd810f27fdefcac730fcab75814b7286002ecf541af5cdf7875440203215 24091770185844 ff4136b6b6a244ec
VALID :-)
0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74 < 00000000000baef6895d630131521d65d984555906990f43f352be4350291f93
  where 00000000000baef6895d630131521d65d984555906990f43f352be4350291f93 = 2^256 / 24091770185844
  and 0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74 = ethash(f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445, ff4136b6b6a244ec)
  with seed as 1730dd810f27fdefcac730fcab75814b7286002ecf541af5cdf7875440203215
(mixHash = 47da5e47804594550791c24331163c1f1fde5bc622170e83515843b2b13dbe14)
SHA3( light(seed) ) = 35ded12eecf2ce2e8da2e15c06d463aae9b84cb2530a00b932e4bbc484cde353

The miner's GPU would iterate through a range of random Nonces. This Nonce, combined with the Seedhash and Header-hash using a hash function need to calculate a number below the Target. If this calculated number is below the target, the miner has successfully mined a block and the block details will be submitted to the Ethereum network nodes.

In the example above, the calculated hash Ethash is larger than the Target and is therefore an incorrectly mined block (which is mentioned in the bug report).

In Bitcoin, the target is the block hash. As difficulty rises, you will see the number of leading zeroes increase.

Block 405390 has 17 leading zeroes. Block 40539 has 8 leading zeroes (mined in 2010).

The Ethereum Target is sort of equivalent to the Bitcoin block hash.

  • 1
    very cool, didn't know that! – Waqar Lim Apr 2 '16 at 12:01
  • Thank you. So where can the final result, Ethash, been seen for each block? Eg this etherchain.org/block/1268022 does not report the Ethash of the block? – Matias Apr 3 '16 at 9:14
  • Unfortunately the Ethash is not published on the blockchain explorers. This number can be worked out from the transaction hash, the previous parent hash, the seed, the block data and the nonce - I'll try to work out the algorithm sometime. – The Officious BokkyPooBah Apr 3 '16 at 11:04
  • 1
    There's an overview here: github.com/ethereum/wiki/wiki/Ethash. Essentially there's no reason to actually publish the result of the computation, since everyone will need to recompute it to verify, anyways. – Tjaden Hess Mar 22 '17 at 22:47
  • 1
    Bitcoin: hash(block header, nonce) < TARGET. Ethereum: Ethash(hash(block header), nonce) < TARGET. Right? – Константин Ван Sep 15 '17 at 17:30
8

What you see in block explorers is the sha3 of the block header, not the ethash.

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.