From 31cd53f4e0f10a2338881fec24df06f0e90c519a Mon Sep 17 00:00:00 2001 From: ucwong Date: Tue, 2 May 2023 02:32:27 -0600 Subject: [PATCH] core/types: go generate (#27196) Fixes a discrepancy between source and generated files, which was introduced when ExcessDataGas was added in https://github.com/ethereum/go-ethereum/pull/27046. --- core/types/gen_header_json.go | 6 ++++++ core/types/gen_header_rlp.go | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index 74746d033..7ee29e34d 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -32,6 +32,7 @@ func (h Header) MarshalJSON() ([]byte, error) { MixDigest common.Hash `json:"mixHash"` Nonce BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` + ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"` Hash common.Hash `json:"hash"` } var enc Header @@ -51,6 +52,7 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.MixDigest = h.MixDigest enc.Nonce = h.Nonce enc.BaseFee = (*hexutil.Big)(h.BaseFee) + enc.ExcessDataGas = h.ExcessDataGas enc.Hash = h.Hash() return json.Marshal(&enc) } @@ -74,6 +76,7 @@ func (h *Header) UnmarshalJSON(input []byte) error { MixDigest *common.Hash `json:"mixHash"` Nonce *BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` + ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"` } var dec Header if err := json.Unmarshal(input, &dec); err != nil { @@ -139,5 +142,8 @@ func (h *Header) UnmarshalJSON(input []byte) error { if dec.BaseFee != nil { h.BaseFee = (*big.Int)(dec.BaseFee) } + if dec.ExcessDataGas != nil { + h.ExcessDataGas = dec.ExcessDataGas + } return nil } diff --git a/core/types/gen_header_rlp.go b/core/types/gen_header_rlp.go index d8cf4746a..631b96d26 100644 --- a/core/types/gen_header_rlp.go +++ b/core/types/gen_header_rlp.go @@ -44,7 +44,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { w.WriteBytes(obj.MixDigest[:]) w.WriteBytes(obj.Nonce[:]) _tmp1 := obj.BaseFee != nil - if _tmp1 { + _tmp3 := obj.ExcessDataGas != nil + if _tmp1||_tmp3 { if obj.BaseFee == nil { w.Write(rlp.EmptyString) } else { @@ -54,6 +55,16 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { w.WriteBigInt(obj.BaseFee) } } + if _tmp3 { + if obj.ExcessDataGas == nil { + w.Write(rlp.EmptyString) + } else { + if obj.ExcessDataGas.Sign() == -1 { + return rlp.ErrNegativeBigInt + } + w.WriteBigInt(obj.ExcessDataGas) + } + } w.ListEnd(_tmp0) return w.Flush() }