ValidateBody validates the header's transaction root. The headers are assumed to be already validated at this point.
(block *types.Block)
| 48 | // ValidateBody validates the header's transaction root. |
| 49 | // The headers are assumed to be already validated at this point. |
| 50 | func (v *BlockValidator) ValidateBody(block *types.Block) error { |
| 51 | // check whether the block's known, and if not, that it's linkable |
| 52 | if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) { |
| 53 | return ErrKnownBlock |
| 54 | } |
| 55 | |
| 56 | if !v.bc.HasBlockAndState(block.ParentHash(), block.NumberU64()-1) { |
| 57 | // we do not have the parent block |
| 58 | if !v.bc.HasBlock(block.ParentHash(), block.NumberU64()-1) { |
| 59 | return consensus.ErrUnknownAncestor |
| 60 | } |
| 61 | // we have the parent block but its state is pruned |
| 62 | return consensus.ErrPrunedAncestor |
| 63 | } |
| 64 | |
| 65 | // if a block already exists, but the state is missing. we will also try to insert it. |
| 66 | // header validity is known at this point, check the transactions validity |
| 67 | header := block.Header() |
| 68 | if hash := types.DeriveSha(block.Transactions()); hash != header.TxsRoot { |
| 69 | return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxsRoot) |
| 70 | } |
| 71 | return nil |
| 72 | } |
| 73 | |
| 74 | // ValidateState validates the various changes that happen after a state |
| 75 | // transition, such as amount of used gas, the receipt roots and the state root |
nothing calls this directly
no test coverage detected