Skip to content

Commit

Permalink
Merge pull request ethereum#81 from Inphi/json-rpc
Browse files Browse the repository at this point in the history
Withdrawal Fixes
  • Loading branch information
Inphi authored Dec 15, 2022
2 parents c312131 + ce68688 commit c29a6e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,10 @@ func (g *Genesis) ToBlock() *types.Block {
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
}
}
if g.Config.IsSharding(0) {
if g.Config.IsShanghai(g.Timestamp) {
head.WithdrawalsHash = &types.EmptyRootHash
}
if g.Config.IsSharding(g.Timestamp) {
head.SetExcessDataGas(g.ExcessDataGas)
}
}
Expand Down
7 changes: 5 additions & 2 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,12 @@ func (h *Header) SanityCheck() error {
}

// EmptyBody returns true if there is no additional 'body' to complete the header
// that is: no transactions and no uncles.
// that is: no transactions, no uncles and no withdrawals.
func (h *Header) EmptyBody() bool {
return h.TxHash == EmptyRootHash && h.UncleHash == EmptyUncleHash
if h.WithdrawalsHash == nil {
return h.TxHash == EmptyRootHash && h.UncleHash == EmptyUncleHash
}
return h.TxHash == EmptyRootHash && h.UncleHash == EmptyUncleHash && *h.WithdrawalsHash == EmptyRootHash
}

// EmptyReceipts returns true if there are no receipts for this header/block.
Expand Down
3 changes: 3 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,9 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
}
}
fields["transactions"] = transactions
// inclTx also expands withdrawals
// TODO @MariusVanDerWijden: add a second flag similar to inclTx to enable withdrawals
fields["withdrawals"] = block.Withdrawals()
}
uncles := block.Uncles()
uncleHashes := make([]common.Hash, len(uncles))
Expand Down

0 comments on commit c29a6e1

Please sign in to comment.