From d9556533c34f9bb44b7c0212ba55a08a047babef Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 27 Jul 2023 16:15:08 +0200 Subject: [PATCH] core/types: put header fields in correct order (#27791) --- core/types/block.go | 8 ++++---- core/types/gen_header_json.go | 12 ++++++------ core/types/gen_header_rlp.go | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/types/block.go b/core/types/block.go index c0373abb15..4452f4bb21 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -85,11 +85,11 @@ type Header struct { // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. - ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` - // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"` + + // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. + ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` } // field type overrides for gencodec @@ -102,8 +102,8 @@ type headerMarshaling struct { Extra hexutil.Bytes BaseFee *hexutil.Big Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON - ExcessBlobGas *hexutil.Uint64 BlobGasUsed *hexutil.Uint64 + ExcessBlobGas *hexutil.Uint64 } // Hash returns the block hash of the header, which is simply the keccak256 hash of its diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index 12a4d1bb7b..bac475959d 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -33,8 +33,8 @@ func (h Header) MarshalJSON() ([]byte, error) { Nonce BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"` + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` Hash common.Hash `json:"hash"` } var enc Header @@ -55,8 +55,8 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.Nonce = h.Nonce enc.BaseFee = (*hexutil.Big)(h.BaseFee) enc.WithdrawalsHash = h.WithdrawalsHash - enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas) enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed) + enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas) enc.Hash = h.Hash() return json.Marshal(&enc) } @@ -81,8 +81,8 @@ func (h *Header) UnmarshalJSON(input []byte) error { Nonce *BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` - ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"` + ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"` } var dec Header if err := json.Unmarshal(input, &dec); err != nil { @@ -151,11 +151,11 @@ func (h *Header) UnmarshalJSON(input []byte) error { if dec.WithdrawalsHash != nil { h.WithdrawalsHash = dec.WithdrawalsHash } - if dec.ExcessBlobGas != nil { - h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas) - } if dec.BlobGasUsed != nil { h.BlobGasUsed = (*uint64)(dec.BlobGasUsed) } + if dec.ExcessBlobGas != nil { + h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas) + } return nil } diff --git a/core/types/gen_header_rlp.go b/core/types/gen_header_rlp.go index efa92c43af..a5ed5cd150 100644 --- a/core/types/gen_header_rlp.go +++ b/core/types/gen_header_rlp.go @@ -42,8 +42,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { w.WriteBytes(obj.Nonce[:]) _tmp1 := obj.BaseFee != nil _tmp2 := obj.WithdrawalsHash != nil - _tmp3 := obj.ExcessBlobGas != nil - _tmp4 := obj.BlobGasUsed != nil + _tmp3 := obj.BlobGasUsed != nil + _tmp4 := obj.ExcessBlobGas != nil if _tmp1 || _tmp2 || _tmp3 || _tmp4 { if obj.BaseFee == nil { w.Write(rlp.EmptyString) @@ -62,17 +62,17 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { } } if _tmp3 || _tmp4 { - if obj.ExcessBlobGas == nil { + if obj.BlobGasUsed == nil { w.Write([]byte{0x80}) } else { - w.WriteUint64((*obj.ExcessBlobGas)) + w.WriteUint64((*obj.BlobGasUsed)) } } if _tmp4 { - if obj.BlobGasUsed == nil { + if obj.ExcessBlobGas == nil { w.Write([]byte{0x80}) } else { - w.WriteUint64((*obj.BlobGasUsed)) + w.WriteUint64((*obj.ExcessBlobGas)) } } w.ListEnd(_tmp0)