首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何核实在以太姆的矿工的报酬?

如何核实在以太姆的矿工的报酬?
EN

Ethereum用户
提问于 2018-08-20 03:01:25
回答 1查看 363关注 0票数 3

在ethash共识的Finalize()函数中,直接通过state.AddBalance()向矿工和叔父提供奖励。

在哪里我可以验证奖励?我想有两个地方

1)VerifyHeader

2)VerifySeal

我不知道这些奖励在哪里被储存在上面。

EN

回答 1

Ethereum用户

回答已采纳

发布于 2018-08-20 03:12:19

当节点从规范链导入批块时,它将运行块验证,验证之一是验证状态根。奖励/平衡包括在状态根验证中。

您可以在下面的路径中找到源代码

./go-ethereum/core/block_valdator.go

代码语言:javascript
复制
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
}
票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/56911

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档