1

Is the "hash" value reported by geth: eth.getBlock("849245").hash, for example, the same "hash" that is given to the miner in the work package?

Sorry if this is a naive query. The reason for the question is that the header hash coming into my miner is not the same as reported by the geth function given above.

What's the hash displayed in the miner?

2

I don't have ethminer installed, so I can't verify this myself just yet. However, looking at the code I'd venture to guess that ethminer is partially encoding the bytes constituting the block header hash as an ASCII or UTF-8 string (or something along those lines) while geth interprets them as a hexadecimal string. Same data, essentially, but different presentation. (It's also possible that it's truncating the hash before partially encoding and displaying it, as the other examples I've seen out there don't encode nearly enough bytes to constitute a block header hash.)

1

The header_hash that the miner uses is the keccak256 hash of the RLP. Or in otherwords, its everything in the header except the mix_hash.

In the golang implementation of ethash its called the SealHash.

https://github.com/expanse-org/go-expanse/blob/master/consensus/ethash/consensus.go#L596

func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
    hasher := sha3.NewLegacyKeccak256()

    rlp.Encode(hasher, []interface{}{
        header.ParentHash,
        header.UncleHash,
        header.Coinbase,
        header.Root,
        header.TxHash,
        header.ReceiptHash,
        header.Bloom,
        header.Difficulty,
        header.Number,
        header.GasLimit,
        header.GasUsed,
        header.Time,
        header.Extra,
    })
    hasher.Sum(hash[:0])
    return hash
}

The SealHash or header_hash then gets combined with the nonce and turned into the seed, then the seed is copied and turned into the mix_hash which is then hashed one last time with.

result = keccak256(seed, mix_hash)

This last hash is then compared to the mining target to see if its valid.

   if(result <= target){
      hashIsGood
   }else{
      hashIsBad
   }

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.