In the Finalize() function of ethash consensus, the rewards to miner and uncles are given by directly state.AddBalance().

where I can validate the rewards? I guess there are two places



I am not sure where rewards are stored in one of the above.

1 Answer 1


When node import batch of blocks from canonical chain then it will run block validation and one of the validations is to verify the state root. Reward/Balance was include in the state root validation.

You can find the source code in below path


func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64) error {
    header := block.Header()
    if block.GasUsed() != usedGas {
        return fmt.Errorf("invalid gas used (remote: %d local: %d)", block.GasUsed(), usedGas)
    // Validate the received block's bloom with the one derived from the generated receipts.
    // For valid blocks this should always validate to true.
    rbloom := types.CreateBloom(receipts)
    if rbloom != header.Bloom {
        return fmt.Errorf("invalid bloom (remote: %x  local: %x)", header.Bloom, rbloom)
    // Tre receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, R1]]))
    receiptSha := types.DeriveSha(receipts)
    if receiptSha != header.ReceiptHash {
        return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", header.ReceiptHash, receiptSha)
    // Validate the state root against the received state root and throw
    // an error if they don't match.
    if root := statedb.IntermediateRoot(v.config.IsEIP158(header.Number)); header.Root != root {
        return fmt.Errorf("invalid merkle root (remote: %x local: %x)", header.Root, root)
    return nil
  • ValidateState check the validation of statdb, but not verify the value of reward a miner add to coinbase address.
    – Peng Liu
    Aug 28, 2018 at 8:12
  • 1
    but if any difference reward will make the state root of remote and local difference then this error will return return fmt.Errorf("invalid merkle root (remote: %x local: %x)", header.Root, root) a.k.a broken the consensus rule
    – Ha ĐANG
    Aug 28, 2018 at 8:14

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.