diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 4914d961ec..a683f475a5 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -683,6 +683,7 @@ type storedReceiptRLP struct { L1GasPrice *big.Int `rlp:"optional"` // OVM legacy L1Fee *big.Int `rlp:"optional"` // OVM legacy FeeScalar string `rlp:"optional"` // OVM legacy + L2BobaFee *big.Int `rlp:"optional"` // OVM legacy } // ReceiptLogs is a barebone version of ReceiptForStorage which only keeps diff --git a/core/rawdb/accessors_chain_test.go b/core/rawdb/accessors_chain_test.go index cf6cac6d07..beb335d92a 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -824,6 +824,38 @@ func TestParseLegacyReceiptRLP(t *testing.T) { require.Equal(t, receipt.FeeScalar, result.FeeScalar) } +func TestParseLegacyReceiptRLPWithBoba(t *testing.T) { + // Create a gasUsed value greater than a uint64 can represent + gasUsed := big.NewInt(0) + gasUsed = gasUsed.SetUint64(math.MaxUint64) + gasUsed = gasUsed.Add(gasUsed, big.NewInt(math.MaxInt64)) + sanityCheck := (&big.Int{}).SetUint64(gasUsed.Uint64()) + require.NotEqual(t, gasUsed, sanityCheck) + receipt := types.LegacyOptimismStoredReceiptRLP{ + CumulativeGasUsed: 1, + Logs: []*types.LogForStorage{ + {Address: common.BytesToAddress([]byte{0x11})}, + {Address: common.BytesToAddress([]byte{0x01, 0x11})}, + }, + L1GasUsed: gasUsed, + L1GasPrice: gasUsed, + L1Fee: gasUsed, + FeeScalar: "6", + L2BobaFee: gasUsed, + } + + data, err := rlp.EncodeToBytes(receipt) + require.NoError(t, err) + var result storedReceiptRLP + err = rlp.DecodeBytes(data, &result) + require.NoError(t, err) + require.Equal(t, receipt.L1GasUsed, result.L1GasUsed) + require.Equal(t, receipt.L1GasPrice, result.L1GasPrice) + require.Equal(t, receipt.L1Fee, result.L1Fee) + require.Equal(t, receipt.FeeScalar, result.FeeScalar) + require.Equal(t, receipt.L2BobaFee, result.L2BobaFee) +} + func TestDeriveLogFields(t *testing.T) { // Create a few transactions to have receipts for to2 := common.HexToAddress("0x2") diff --git a/core/types/receipt.go b/core/types/receipt.go index 4bc83bf988..3aec493ccd 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -166,6 +166,7 @@ type LegacyOptimismStoredReceiptRLP struct { L1GasPrice *big.Int L1Fee *big.Int FeeScalar string + L2BobaFee *big.Int `rlp:"optional"` } // LogForStorage is a wrapper around a Log that handles