From 028acecb02cae60945c87aa17dde05fa11016ceb Mon Sep 17 00:00:00 2001 From: Max Wolff Date: Tue, 18 Apr 2023 20:12:57 -0700 Subject: [PATCH] fix return type in tx receipt for l1fee type (#254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * edit marshalling override * goimports * not required * encode l1fee --------- Co-authored-by: Péter Garamvölgyi --- core/types/gen_receipt_json.go | 11 +++++------ core/types/receipt.go | 3 ++- internal/ethapi/api.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index 4655dda22c..2add7a8023 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -29,7 +29,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex hexutil.Uint `json:"transactionIndex"` ReturnValue []byte `json:"returnValue,omitempty"` - L1Fee *big.Int `json:"l1Fee" gencodec:"required"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` } var enc Receipt enc.Type = hexutil.Uint64(r.Type) @@ -45,7 +45,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) enc.ReturnValue = r.ReturnValue - enc.L1Fee = r.L1Fee + enc.L1Fee = (*hexutil.Big)(r.L1Fee) return json.Marshal(&enc) } @@ -65,7 +65,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex *hexutil.Uint `json:"transactionIndex"` ReturnValue []byte `json:"returnValue,omitempty"` - L1Fee *big.Int `json:"l1Fee" gencodec:"required"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` } var dec Receipt if err := json.Unmarshal(input, &dec); err != nil { @@ -115,9 +115,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.ReturnValue != nil { r.ReturnValue = dec.ReturnValue } - if dec.L1Fee == nil { - return errors.New("missing required field 'l1Fee' for Receipt") + if dec.L1Fee != nil { + r.L1Fee = (*big.Int)(dec.L1Fee) } - r.L1Fee = dec.L1Fee return nil } diff --git a/core/types/receipt.go b/core/types/receipt.go index 2e769c8a8e..aec4f43b90 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -75,7 +75,7 @@ type Receipt struct { ReturnValue []byte `json:"returnValue,omitempty"` // Scroll rollup - L1Fee *big.Int `json:"l1Fee,omitempty" gencodec:"required"` + L1Fee *big.Int `json:"l1Fee,omitempty"` } type receiptMarshaling struct { @@ -86,6 +86,7 @@ type receiptMarshaling struct { GasUsed hexutil.Uint64 BlockNumber *hexutil.Big TransactionIndex hexutil.Uint + L1Fee *hexutil.Big } // receiptRLP is the consensus encoding of a receipt. diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 183020406e..0f1f191f5f 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1669,7 +1669,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha "logs": receipt.Logs, "logsBloom": receipt.Bloom, "type": hexutil.Uint(tx.Type()), - "l1Fee": receipt.L1Fee, + "l1Fee": hexutil.Uint64(receipt.L1Fee.Uint64()), } // Assign the effective gas price paid if !s.b.ChainConfig().IsLondon(bigblock) {