Skip to content

Commit

Permalink
Merge pull request #11 from bobanetwork/fix-legacy-transactions
Browse files Browse the repository at this point in the history
Fix legacy transactions
  • Loading branch information
boyuan-chen authored Nov 26, 2024
2 parents 489f364 + ef56b7b commit 92c2cfc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions core/rawdb/accessors_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 92c2cfc

Please sign in to comment.