diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index 8a898648386..a9c886aedac 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -7,9 +7,8 @@ import ( "errors" "math/big" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -18,18 +17,24 @@ var _ = (*receiptMarshaling)(nil) // MarshalJSON marshals as JSON. func (r Receipt) MarshalJSON() ([]byte, error) { type Receipt struct { - Type hexutil.Uint64 `json:"type,omitempty"` - PostState hexutility.Bytes `json:"root"` - Status hexutil.Uint64 `json:"status"` - CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` - Bloom Bloom `json:"logsBloom" gencodec:"required"` - Logs []*Log `json:"logs" gencodec:"required"` - TxHash libcommon.Hash `json:"transactionHash" gencodec:"required"` - ContractAddress libcommon.Address `json:"contractAddress"` - GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` - BlockHash libcommon.Hash `json:"blockHash,omitempty"` - BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` - TransactionIndex hexutil.Uint `json:"transactionIndex"` + Type hexutil.Uint64 `json:"type,omitempty"` + PostState hexutility.Bytes `json:"root" codec:"1"` + Status hexutil.Uint64 `json:"status" codec:"2"` + CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required" codec:"3"` + Bloom Bloom `json:"logsBloom" gencodec:"required" codec:"-"` + Logs Logs `json:"logs" gencodec:"required" codec:"-"` + TxHash common.Hash `json:"transactionHash" gencodec:"required" codec:"-"` + ContractAddress common.Address `json:"contractAddress" codec:"-"` + GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required" codec:"-"` + BlockHash common.Hash `json:"blockHash,omitempty" codec:"-"` + BlockNumber *hexutil.Big `json:"blockNumber,omitempty" codec:"-"` + TransactionIndex hexutil.Uint `json:"transactionIndex" codec:"-"` + L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` + L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` + FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` + DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"` + DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"` } var enc Receipt enc.Type = hexutil.Uint64(r.Type) @@ -44,24 +49,36 @@ func (r Receipt) MarshalJSON() ([]byte, error) { enc.BlockHash = r.BlockHash enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) + enc.L1GasPrice = (*hexutil.Big)(r.L1GasPrice) + enc.L1GasUsed = (*hexutil.Big)(r.L1GasUsed) + enc.L1Fee = (*hexutil.Big)(r.L1Fee) + enc.FeeScalar = r.FeeScalar + enc.DepositNonce = (*hexutil.Uint64)(r.DepositNonce) + enc.DepositReceiptVersion = (*hexutil.Uint64)(r.DepositReceiptVersion) return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. func (r *Receipt) UnmarshalJSON(input []byte) error { type Receipt struct { - Type *hexutil.Uint64 `json:"type,omitempty"` - PostState *hexutility.Bytes `json:"root"` - Status *hexutil.Uint64 `json:"status"` - CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` - Bloom *Bloom `json:"logsBloom" gencodec:"required"` - Logs []*Log `json:"logs" gencodec:"required"` - TxHash *libcommon.Hash `json:"transactionHash" gencodec:"required"` - ContractAddress *libcommon.Address `json:"contractAddress"` - GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` - BlockHash *libcommon.Hash `json:"blockHash,omitempty"` - BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` - TransactionIndex *hexutil.Uint `json:"transactionIndex"` + Type *hexutil.Uint64 `json:"type,omitempty"` + PostState *hexutility.Bytes `json:"root" codec:"1"` + Status *hexutil.Uint64 `json:"status" codec:"2"` + CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required" codec:"3"` + Bloom *Bloom `json:"logsBloom" gencodec:"required" codec:"-"` + Logs *Logs `json:"logs" gencodec:"required" codec:"-"` + TxHash *common.Hash `json:"transactionHash" gencodec:"required" codec:"-"` + ContractAddress *common.Address `json:"contractAddress" codec:"-"` + GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required" codec:"-"` + BlockHash *common.Hash `json:"blockHash,omitempty" codec:"-"` + BlockNumber *hexutil.Big `json:"blockNumber,omitempty" codec:"-"` + TransactionIndex *hexutil.Uint `json:"transactionIndex" codec:"-"` + L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` + L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` + FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` + DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"` + DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"` } var dec Receipt if err := json.Unmarshal(input, &dec); err != nil { @@ -87,7 +104,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.Logs == nil { return errors.New("missing required field 'logs' for Receipt") } - r.Logs = dec.Logs + r.Logs = *dec.Logs if dec.TxHash == nil { return errors.New("missing required field 'transactionHash' for Receipt") } @@ -108,5 +125,23 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.TransactionIndex != nil { r.TransactionIndex = uint(*dec.TransactionIndex) } + if dec.L1GasPrice != nil { + r.L1GasPrice = (*big.Int)(dec.L1GasPrice) + } + if dec.L1GasUsed != nil { + r.L1GasUsed = (*big.Int)(dec.L1GasUsed) + } + if dec.L1Fee != nil { + r.L1Fee = (*big.Int)(dec.L1Fee) + } + if dec.FeeScalar != nil { + r.FeeScalar = dec.FeeScalar + } + if dec.DepositNonce != nil { + r.DepositNonce = (*uint64)(dec.DepositNonce) + } + if dec.DepositReceiptVersion != nil { + r.DepositReceiptVersion = (*uint64)(dec.DepositReceiptVersion) + } return nil } diff --git a/core/types/receipt_codecgen_gen.go b/core/types/receipt_codecgen_gen.go index 35a3d6b5ec3..de6c7b1b103 100644 --- a/core/types/receipt_codecgen_gen.go +++ b/core/types/receipt_codecgen_gen.go @@ -69,7 +69,8 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { var yyn9 bool = x.L1Fee == nil var yyn10 bool = x.FeeScalar == nil var yyn11 bool = x.DepositNonce == nil - z.EncWriteArrayStart(9) + var yyn12 bool = x.DepositReceiptVersion == nil + z.EncWriteArrayStart(10) z.EncWriteArrayElem() r.EncodeUint(uint64(x.Type)) z.EncWriteArrayElem() @@ -131,8 +132,16 @@ func (x *Receipt) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } else { z.EncWriteArrayElem() - yy20 := *x.DepositNonce - r.EncodeUint(uint64(yy20)) + yy21 := *x.DepositNonce + r.EncodeUint(uint64(yy21)) + } + if yyn12 { + z.EncWriteArrayElem() + r.EncodeNil() + } else { + z.EncWriteArrayElem() + yy23 := *x.DepositReceiptVersion + r.EncodeUint(uint64(yy23)) } z.EncWriteArrayEnd() } @@ -266,6 +275,17 @@ func (x *Receipt) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { } *x.DepositNonce = (uint64)(r.DecodeUint64()) } + case "DepositReceiptVersion": + if r.TryNil() { + if x.DepositReceiptVersion != nil { // remove the if-true + x.DepositReceiptVersion = nil + } + } else { + if x.DepositReceiptVersion == nil { + x.DepositReceiptVersion = new(uint64) + } + *x.DepositReceiptVersion = (uint64)(r.DecodeUint64()) + } default: z.DecStructFieldNotFound(-1, yys3) } // end switch yys3 @@ -276,64 +296,64 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer2 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj19 int - var yyb19 bool - var yyhl19 bool = l >= 0 - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + var yyj21 int + var yyb21 bool + var yyhl21 bool = l >= 0 + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.Type = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.PostState = r.DecodeBytes(([]byte)(x.PostState), false) - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.Status = (uint64)(r.DecodeUint64()) - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } z.DecReadArrayElem() x.CumulativeGasUsed = (uint64)(r.DecodeUint64()) - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } @@ -352,13 +372,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.L1GasPrice, false) } } - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } @@ -377,13 +397,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.L1GasUsed, false) } } - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } @@ -402,13 +422,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.L1Fee, false) } } - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } @@ -427,13 +447,13 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { z.DecFallback(x.FeeScalar, false) } } - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { z.DecReadArrayEnd() return } @@ -448,18 +468,39 @@ func (x *Receipt) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } *x.DepositNonce = (uint64)(r.DecodeUint64()) } + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l + } else { + yyb21 = z.DecCheckBreak() + } + if yyb21 { + z.DecReadArrayEnd() + return + } + z.DecReadArrayElem() + if r.TryNil() { + if x.DepositReceiptVersion != nil { // remove the if-true + x.DepositReceiptVersion = nil + } + } else { + if x.DepositReceiptVersion == nil { + x.DepositReceiptVersion = new(uint64) + } + *x.DepositReceiptVersion = (uint64)(r.DecodeUint64()) + } for { - yyj19++ - if yyhl19 { - yyb19 = yyj19 > l + yyj21++ + if yyhl21 { + yyb21 = yyj21 > l } else { - yyb19 = z.DecCheckBreak() + yyb21 = z.DecCheckBreak() } - if yyb19 { + if yyb21 { break } z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj19-1, "") + z.DecStructFieldNotFound(yyj21-1, "") } }