core/types: fix receipt blob fields marshaling (#27793)

This commit is contained in:
Mario Vega 2023-07-28 01:08:38 -06:00 committed by GitHub
parent d9556533c3
commit 8f2ae29b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

@ -26,8 +26,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
ContractAddress common.Address `json:"contractAddress"` ContractAddress common.Address `json:"contractAddress"`
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
BlobGasUsed uint64 `json:"blobGasUsed,omitempty"` BlobGasUsed hexutil.Uint64 `json:"blobGasUsed,omitempty"`
BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"` BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"`
BlockHash common.Hash `json:"blockHash,omitempty"` BlockHash common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex hexutil.Uint `json:"transactionIndex"` TransactionIndex hexutil.Uint `json:"transactionIndex"`
@ -43,8 +43,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
enc.ContractAddress = r.ContractAddress enc.ContractAddress = r.ContractAddress
enc.GasUsed = hexutil.Uint64(r.GasUsed) enc.GasUsed = hexutil.Uint64(r.GasUsed)
enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice) enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice)
enc.BlobGasUsed = r.BlobGasUsed enc.BlobGasUsed = hexutil.Uint64(r.BlobGasUsed)
enc.BlobGasPrice = r.BlobGasPrice enc.BlobGasPrice = (*hexutil.Big)(r.BlobGasPrice)
enc.BlockHash = r.BlockHash enc.BlockHash = r.BlockHash
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
@ -64,8 +64,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
ContractAddress *common.Address `json:"contractAddress"` ContractAddress *common.Address `json:"contractAddress"`
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
BlobGasUsed *uint64 `json:"blobGasUsed,omitempty"` BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"`
BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"` BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"`
BlockHash *common.Hash `json:"blockHash,omitempty"` BlockHash *common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex *hexutil.Uint `json:"transactionIndex"` TransactionIndex *hexutil.Uint `json:"transactionIndex"`
@ -110,10 +110,10 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice) r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice)
} }
if dec.BlobGasUsed != nil { if dec.BlobGasUsed != nil {
r.BlobGasUsed = *dec.BlobGasUsed r.BlobGasUsed = uint64(*dec.BlobGasUsed)
} }
if dec.BlobGasPrice != nil { if dec.BlobGasPrice != nil {
r.BlobGasPrice = dec.BlobGasPrice r.BlobGasPrice = (*big.Int)(dec.BlobGasPrice)
} }
if dec.BlockHash != nil { if dec.BlockHash != nil {
r.BlockHash = *dec.BlockHash r.BlockHash = *dec.BlockHash

@ -80,6 +80,8 @@ type receiptMarshaling struct {
CumulativeGasUsed hexutil.Uint64 CumulativeGasUsed hexutil.Uint64
GasUsed hexutil.Uint64 GasUsed hexutil.Uint64
EffectiveGasPrice *hexutil.Big EffectiveGasPrice *hexutil.Big
BlobGasUsed hexutil.Uint64
BlobGasPrice *hexutil.Big
BlockNumber *hexutil.Big BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint TransactionIndex hexutil.Uint
} }