From 4663b82f69021493a1bdf495dd180c2d60032947 Mon Sep 17 00:00:00 2001 From: Cesare Valitutto Date: Sat, 6 Jan 2024 18:56:49 +0100 Subject: [PATCH] feat(cli): add withdrawals --- ethrpc/block.go | 11 ++++++----- go-ethereum/core/types/withdrawal.go | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ethrpc/block.go b/ethrpc/block.go index 40634e1a..84e7cb2e 100644 --- a/ethrpc/block.go +++ b/ethrpc/block.go @@ -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 { @@ -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 @@ -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 diff --git a/go-ethereum/core/types/withdrawal.go b/go-ethereum/core/types/withdrawal.go index 2538813e..63c08c6e 100644 --- a/go-ethereum/core/types/withdrawal.go +++ b/go-ethereum/core/types/withdrawal.go @@ -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