diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 678df62743..a79037e325 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -623,6 +623,7 @@ type storedReceiptRLP struct { PostStateOrStatus []byte CumulativeGasUsed uint64 Logs []*types.LogForStorage + L1Fee *big.Int } // ReceiptLogs is a barebone version of ReceiptForStorage which only keeps diff --git a/core/state_processor.go b/core/state_processor.go index 5d8d557267..e6d0a538e0 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -139,6 +139,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon receipt.BlockHash = blockHash receipt.BlockNumber = blockNumber receipt.TransactionIndex = uint(statedb.TxIndex()) + receipt.L1Fee = result.L1Fee return receipt, err } diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index f69fa2bf26..4655dda22c 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -28,6 +28,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) { BlockHash common.Hash `json:"blockHash,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex hexutil.Uint `json:"transactionIndex"` + ReturnValue []byte `json:"returnValue,omitempty"` + L1Fee *big.Int `json:"l1Fee" gencodec:"required"` } var enc Receipt enc.Type = hexutil.Uint64(r.Type) @@ -42,6 +44,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) { enc.BlockHash = r.BlockHash enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) + enc.ReturnValue = r.ReturnValue + enc.L1Fee = r.L1Fee return json.Marshal(&enc) } @@ -60,6 +64,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { BlockHash *common.Hash `json:"blockHash,omitempty"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` TransactionIndex *hexutil.Uint `json:"transactionIndex"` + ReturnValue []byte `json:"returnValue,omitempty"` + L1Fee *big.Int `json:"l1Fee" gencodec:"required"` } var dec Receipt if err := json.Unmarshal(input, &dec); err != nil { @@ -106,5 +112,12 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.TransactionIndex != nil { r.TransactionIndex = uint(*dec.TransactionIndex) } + if dec.ReturnValue != nil { + r.ReturnValue = dec.ReturnValue + } + if dec.L1Fee == nil { + return errors.New("missing required field 'l1Fee' for Receipt") + } + r.L1Fee = dec.L1Fee return nil } diff --git a/core/types/receipt.go b/core/types/receipt.go index bf20cfbc65..2e769c8a8e 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -73,6 +73,9 @@ type Receipt struct { // The value of evm execution result. ReturnValue []byte `json:"returnValue,omitempty"` + + // Scroll rollup + L1Fee *big.Int `json:"l1Fee,omitempty" gencodec:"required"` } type receiptMarshaling struct { @@ -98,6 +101,14 @@ type storedReceiptRLP struct { PostStateOrStatus []byte CumulativeGasUsed uint64 Logs []*LogForStorage + L1Fee *big.Int +} + +// v5StoredReceiptRLP is the storage encoding of a receipt used in database version 5. +type v5StoredReceiptRLP struct { + PostStateOrStatus []byte + CumulativeGasUsed uint64 + Logs []*LogForStorage } // v4StoredReceiptRLP is the storage encoding of a receipt used in database version 4. @@ -295,6 +306,7 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error { PostStateOrStatus: (*Receipt)(r).statusEncoding(), CumulativeGasUsed: r.CumulativeGasUsed, Logs: make([]*LogForStorage, len(r.Logs)), + L1Fee: r.L1Fee, } for i, log := range r.Logs { enc.Logs[i] = (*LogForStorage)(log) @@ -319,7 +331,10 @@ func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error { if err := decodeV3StoredReceiptRLP(r, blob); err == nil { return nil } - return decodeV4StoredReceiptRLP(r, blob) + if err := decodeV4StoredReceiptRLP(r, blob); err == nil { + return nil + } + return decodeV5StoredReceiptRLP(r, blob) } func decodeStoredReceiptRLP(r *ReceiptForStorage, blob []byte) error { @@ -336,6 +351,25 @@ func decodeStoredReceiptRLP(r *ReceiptForStorage, blob []byte) error { r.Logs[i] = (*Log)(log) } r.Bloom = CreateBloom(Receipts{(*Receipt)(r)}) + r.L1Fee = stored.L1Fee + + return nil +} + +func decodeV5StoredReceiptRLP(r *ReceiptForStorage, blob []byte) error { + var stored v5StoredReceiptRLP + if err := rlp.DecodeBytes(blob, &stored); err != nil { + return err + } + if err := (*Receipt)(r).setStatus(stored.PostStateOrStatus); err != nil { + return err + } + r.CumulativeGasUsed = stored.CumulativeGasUsed + r.Logs = make([]*Log, len(stored.Logs)) + for i, log := range stored.Logs { + r.Logs[i] = (*Log)(log) + } + r.Bloom = CreateBloom(Receipts{(*Receipt)(r)}) return nil } diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index f30e6ca2cd..3d9759ee3f 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -100,6 +100,10 @@ func TestLegacyReceiptDecoding(t *testing.T) { "StoredReceiptRLP", encodeAsStoredReceiptRLP, }, + { + "V5StoredReceiptRLP", + encodeAsV5StoredReceiptRLP, + }, { "V4StoredReceiptRLP", encodeAsV4StoredReceiptRLP, @@ -175,6 +179,19 @@ func encodeAsStoredReceiptRLP(want *Receipt) ([]byte, error) { PostStateOrStatus: want.statusEncoding(), CumulativeGasUsed: want.CumulativeGasUsed, Logs: make([]*LogForStorage, len(want.Logs)), + L1Fee: want.L1Fee, + } + for i, log := range want.Logs { + stored.Logs[i] = (*LogForStorage)(log) + } + return rlp.EncodeToBytes(stored) +} + +func encodeAsV5StoredReceiptRLP(want *Receipt) ([]byte, error) { + stored := &v5StoredReceiptRLP{ + PostStateOrStatus: want.statusEncoding(), + CumulativeGasUsed: want.CumulativeGasUsed, + Logs: make([]*LogForStorage, len(want.Logs)), } for i, log := range want.Logs { stored.Logs[i] = (*LogForStorage)(log) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index fe4952e0c8..76f0bc0602 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1579,6 +1579,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha "logs": receipt.Logs, "logsBloom": receipt.Bloom, "type": hexutil.Uint(tx.Type()), + "l1Fee": receipt.L1Fee, } // Assign the effective gas price paid if !s.b.ChainConfig().IsLondon(bigblock) { diff --git a/params/version.go b/params/version.go index a777501503..6804f33aa5 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 3 // Major version component of the current release VersionMinor = 1 // Minor version component of the current release - VersionPatch = 0 // Patch version component of the current release + VersionPatch = 1 // Patch version component of the current release VersionMeta = "alpha" // Version metadata to append to the version string )