Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect freezer migrate #244

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/scwallet"
"github.com/ethereum/go-ethereum/accounts/usbwallet"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/internal/ethapi"
Expand Down
4 changes: 4 additions & 0 deletions core/types/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func IsLegacyStoredReceipts(raw []byte) (bool, error) {
if err := rlp.DecodeBytes(raw, &v5); err == nil {
return false, nil
}
var arbReceipt []arbLegacyStoredReceiptRLP
if err := rlp.DecodeBytes(raw, &arbReceipt); err == nil {
return true, nil
}
return false, errors.New("value is not a valid receipt encoding")
}

Expand Down
22 changes: 8 additions & 14 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,26 +295,17 @@ type ReceiptForStorage Receipt
func (r *ReceiptForStorage) EncodeRLP(_w io.Writer) error {
w := rlp.NewEncoderBuffer(_w)
outerList := w.List()
if r.Type == ArbitrumLegacyTxType {
w.WriteBytes(receiptRootArbitrumLegacy)
w.WriteUint64(r.CumulativeGasUsed)
w.WriteUint64(r.GasUsed)
w.WriteUint64(r.GasUsedForL1)
w.WriteUint64(r.Status)
rlp.Encode(w, r.ContractAddress)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to maintain the old encoding here or else gas used for old legacy receipts are wrong. Basically in Arbitrum Classic the cumulative gas used didn't match up with the gas used nicely IIRC. We should try querying for old receipt gas used values on a migrated databases and make sure they match (particularly for classic blocks with multiple txs)

} else {
w.WriteBytes((*Receipt)(r).statusEncoding())
w.WriteUint64(r.CumulativeGasUsed)
w.WriteUint64(r.GasUsedForL1)
}
w.WriteBytes((*Receipt)(r).statusEncoding())
w.WriteUint64(r.CumulativeGasUsed)
w.WriteUint64(r.GasUsedForL1)
logList := w.List()
for _, log := range r.Logs {
if err := rlp.Encode(w, log); err != nil {
return err
}
}
w.ListEnd(logList)
if r.Type >= ArbitrumDepositTxType && r.Type != ArbitrumLegacyTxType && r.ContractAddress != (common.Address{}) {
if r.Type >= ArbitrumDepositTxType && r.ContractAddress != (common.Address{}) {
w.WriteBytes(r.ContractAddress[:])
}
w.ListEnd(outerList)
Expand Down Expand Up @@ -361,7 +352,10 @@ func decodeArbitrumLegacyStoredReceiptRLP(r *ReceiptForStorage, blob []byte) err
r.GasUsed = stored.GasUsed
r.GasUsedForL1 = stored.L1GasUsed
r.ContractAddress = stored.ContractAddress
r.Logs = stored.Logs
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
Expand Down