在ethash共识的Finalize()函数中,直接通过state.AddBalance()向矿工和叔父提供奖励。
在哪里我可以验证奖励?我想有两个地方
1)VerifyHeader
2)VerifySeal
我不知道这些奖励在哪里被储存在上面。
发布于 2018-08-20 03:12:19
当节点从规范链导入批块时,它将运行块验证,验证之一是验证状态根。奖励/平衡包括在状态根验证中。
您可以在下面的路径中找到源代码
./go-ethereum/core/block_valdator.go
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
}https://ethereum.stackexchange.com/questions/56911
复制相似问题