Unverified Commit a9d7cdaf authored by ucwong's avatar ucwong Committed by GitHub

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. 
parent ae660096
...@@ -33,6 +33,7 @@ func (h Header) MarshalJSON() ([]byte, error) { ...@@ -33,6 +33,7 @@ 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"`
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"`
Hash common.Hash `json:"hash"` Hash common.Hash `json:"hash"`
} }
var enc Header var enc Header
...@@ -53,6 +54,7 @@ func (h Header) MarshalJSON() ([]byte, error) { ...@@ -53,6 +54,7 @@ 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.ExcessDataGas = h.ExcessDataGas
enc.Hash = h.Hash() enc.Hash = h.Hash()
return json.Marshal(&enc) return json.Marshal(&enc)
} }
...@@ -77,6 +79,7 @@ func (h *Header) UnmarshalJSON(input []byte) error { ...@@ -77,6 +79,7 @@ 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"`
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"`
} }
var dec Header var dec Header
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
...@@ -145,5 +148,8 @@ func (h *Header) UnmarshalJSON(input []byte) error { ...@@ -145,5 +148,8 @@ 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.ExcessDataGas != nil {
h.ExcessDataGas = dec.ExcessDataGas
}
return nil return nil
} }
...@@ -42,7 +42,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { ...@@ -42,7 +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
if _tmp1 || _tmp2 { _tmp3 := obj.ExcessDataGas != nil
if _tmp1 || _tmp2 || _tmp3 {
if obj.BaseFee == nil { if obj.BaseFee == nil {
w.Write(rlp.EmptyString) w.Write(rlp.EmptyString)
} else { } else {
...@@ -52,13 +53,23 @@ func (obj *Header) EncodeRLP(_w io.Writer) error { ...@@ -52,13 +53,23 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
w.WriteBigInt(obj.BaseFee) w.WriteBigInt(obj.BaseFee)
} }
} }
if _tmp2 { if _tmp2 || _tmp3 {
if obj.WithdrawalsHash == nil { if obj.WithdrawalsHash == nil {
w.Write([]byte{0x80}) w.Write([]byte{0x80})
} else { } else {
w.WriteBytes(obj.WithdrawalsHash[:]) w.WriteBytes(obj.WithdrawalsHash[:])
} }
} }
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) w.ListEnd(_tmp0)
return w.Flush() return w.Flush()
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment