Commit 2b1378f1 authored by EvanJRichard's avatar EvanJRichard

return withdrawals check in rpc block verification.

parent 5376fc80
...@@ -204,6 +204,23 @@ func (block *rpcBlock) verify() error { ...@@ -204,6 +204,23 @@ func (block *rpcBlock) verify() error {
if computed := types.DeriveSha(types.Transactions(block.Transactions), trie.NewStackTrie(nil)); block.TxHash != computed { if computed := types.DeriveSha(types.Transactions(block.Transactions), trie.NewStackTrie(nil)); block.TxHash != computed {
return fmt.Errorf("failed to verify transactions list: computed %s but RPC said %s", computed, block.TxHash) return fmt.Errorf("failed to verify transactions list: computed %s but RPC said %s", computed, block.TxHash)
} }
if block.WithdrawalsRoot != nil {
if block.Withdrawals == nil {
return fmt.Errorf("expected withdrawals")
}
for i, w := range *block.Withdrawals {
if w == nil {
return fmt.Errorf("block withdrawal %d is null", i)
}
}
if computed := types.DeriveSha(*block.Withdrawals, trie.NewStackTrie(nil)); *block.WithdrawalsRoot != computed {
return fmt.Errorf("failed to verify withdrawals list: computed %s but RPC said %s", computed, block.WithdrawalsRoot)
}
} else {
if block.Withdrawals != nil {
return fmt.Errorf("expected no withdrawals due to missing withdrawals-root, but got %d", len(*block.Withdrawals))
}
}
return nil return nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment