Skip to content

Commit

Permalink
feat(cli): add withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
czar0 committed Jan 6, 2024
1 parent d1cf6fa commit 4663b82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions ethrpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ type txExtraInfo struct {
}

type rpcBlock struct {
Hash common.Hash `json:"hash"`
Transactions []rpcTransaction `json:"transactions"`
UncleHashes []common.Hash `json:"uncles"`
Hash common.Hash `json:"hash"`
Transactions []rpcTransaction `json:"transactions"`
UncleHashes []common.Hash `json:"uncles"`
Withdrawals types.Withdrawals `json:"withdrawals"`
}

func (tx *rpcTransaction) UnmarshalJSON(msg []byte) error {
Expand All @@ -50,7 +51,7 @@ func IntoBlock(raw json.RawMessage, ret **types.Block) error {
if len(raw) == 0 {
return ethereum.NotFound
}

// Decode header and transactions
var (
head *types.Header
Expand Down Expand Up @@ -88,7 +89,7 @@ func IntoBlock(raw json.RawMessage, ret **types.Block) error {
}

// return types.NewBlockWithHeader(head).WithBody(txs, uncles), nil
block := types.NewBlockWithHeader(head).WithBody(txs, nil)
block := types.NewBlockWithHeader(head).WithBody(txs, nil).WithWithdrawals(body.Withdrawals)

// TODO: Remove this, we shouldn't need to use the block cache
// in order for it to contain the correct block hash
Expand Down
6 changes: 3 additions & 3 deletions go-ethereum/core/types/withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (

// Withdrawal represents a validator withdrawal from the consensus layer.
type Withdrawal struct {
Index uint64 `json:"index"` // monotonically increasing identifier issued by consensus layer
Validator uint64 `json:"validatorIndex"` // index of validator associated with withdrawal
Index hexutil.Uint64 `json:"index"` // monotonically increasing identifier issued by consensus layer
Validator hexutil.Uint64 `json:"validatorIndex"` // index of validator associated with withdrawal
Address common.Address `json:"address"` // target address for withdrawn ether
Amount uint64 `json:"amount"` // value of withdrawal in Gwei
Amount hexutil.Uint64 `json:"amount"` // value of withdrawal in Gwei
}

// field type overrides for gencodec
Expand Down

0 comments on commit 4663b82

Please sign in to comment.