forked from cerc-io/plugeth
core/types: put header fields in correct order (#27791)
This commit is contained in:
parent
57268f7e6c
commit
d9556533c3
@ -85,11 +85,11 @@ type Header struct {
|
|||||||
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
|
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
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 was added by EIP-4844 and is ignored in legacy headers.
|
||||||
BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"`
|
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
|
// field type overrides for gencodec
|
||||||
@ -102,8 +102,8 @@ type headerMarshaling struct {
|
|||||||
Extra hexutil.Bytes
|
Extra hexutil.Bytes
|
||||||
BaseFee *hexutil.Big
|
BaseFee *hexutil.Big
|
||||||
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
||||||
ExcessBlobGas *hexutil.Uint64
|
|
||||||
BlobGasUsed *hexutil.Uint64
|
BlobGasUsed *hexutil.Uint64
|
||||||
|
ExcessBlobGas *hexutil.Uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
|
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
|
||||||
|
@ -33,8 +33,8 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
|||||||
Nonce BlockNonce `json:"nonce"`
|
Nonce BlockNonce `json:"nonce"`
|
||||||
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
}
|
}
|
||||||
var enc Header
|
var enc Header
|
||||||
@ -55,8 +55,8 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
|||||||
enc.Nonce = h.Nonce
|
enc.Nonce = h.Nonce
|
||||||
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
|
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
|
||||||
enc.WithdrawalsHash = h.WithdrawalsHash
|
enc.WithdrawalsHash = h.WithdrawalsHash
|
||||||
enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas)
|
|
||||||
enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed)
|
enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed)
|
||||||
|
enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas)
|
||||||
enc.Hash = h.Hash()
|
enc.Hash = h.Hash()
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
@ -81,8 +81,8 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||||||
Nonce *BlockNonce `json:"nonce"`
|
Nonce *BlockNonce `json:"nonce"`
|
||||||
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
}
|
}
|
||||||
var dec Header
|
var dec Header
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
@ -151,11 +151,11 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||||||
if dec.WithdrawalsHash != nil {
|
if dec.WithdrawalsHash != nil {
|
||||||
h.WithdrawalsHash = dec.WithdrawalsHash
|
h.WithdrawalsHash = dec.WithdrawalsHash
|
||||||
}
|
}
|
||||||
if dec.ExcessBlobGas != nil {
|
|
||||||
h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
|
||||||
}
|
|
||||||
if dec.BlobGasUsed != nil {
|
if dec.BlobGasUsed != nil {
|
||||||
h.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
h.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
||||||
}
|
}
|
||||||
|
if dec.ExcessBlobGas != nil {
|
||||||
|
h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
|
|||||||
w.WriteBytes(obj.Nonce[:])
|
w.WriteBytes(obj.Nonce[:])
|
||||||
_tmp1 := obj.BaseFee != nil
|
_tmp1 := obj.BaseFee != nil
|
||||||
_tmp2 := obj.WithdrawalsHash != nil
|
_tmp2 := obj.WithdrawalsHash != nil
|
||||||
_tmp3 := obj.ExcessBlobGas != nil
|
_tmp3 := obj.BlobGasUsed != nil
|
||||||
_tmp4 := obj.BlobGasUsed != nil
|
_tmp4 := obj.ExcessBlobGas != nil
|
||||||
if _tmp1 || _tmp2 || _tmp3 || _tmp4 {
|
if _tmp1 || _tmp2 || _tmp3 || _tmp4 {
|
||||||
if obj.BaseFee == nil {
|
if obj.BaseFee == nil {
|
||||||
w.Write(rlp.EmptyString)
|
w.Write(rlp.EmptyString)
|
||||||
@ -62,19 +62,19 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _tmp3 || _tmp4 {
|
if _tmp3 || _tmp4 {
|
||||||
if obj.ExcessBlobGas == nil {
|
|
||||||
w.Write([]byte{0x80})
|
|
||||||
} else {
|
|
||||||
w.WriteUint64((*obj.ExcessBlobGas))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if _tmp4 {
|
|
||||||
if obj.BlobGasUsed == nil {
|
if obj.BlobGasUsed == nil {
|
||||||
w.Write([]byte{0x80})
|
w.Write([]byte{0x80})
|
||||||
} else {
|
} else {
|
||||||
w.WriteUint64((*obj.BlobGasUsed))
|
w.WriteUint64((*obj.BlobGasUsed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if _tmp4 {
|
||||||
|
if obj.ExcessBlobGas == nil {
|
||||||
|
w.Write([]byte{0x80})
|
||||||
|
} else {
|
||||||
|
w.WriteUint64((*obj.ExcessBlobGas))
|
||||||
|
}
|
||||||
|
}
|
||||||
w.ListEnd(_tmp0)
|
w.ListEnd(_tmp0)
|
||||||
return w.Flush()
|
return w.Flush()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user