Skip to content

Commit

Permalink
Bring back ArbitrumLegacy receipt reading for logs
Browse files Browse the repository at this point in the history
Classic (pre-Nitro) receipts are stored as arbLegacyStoredReceiptRLPs.
We had removed reading of them for serving ReadLogs by mistake when
merging in upstream geth changes to remove their legacy receipt format.
This change adds the code path back in that will trigger
ReceiptForStorage.DecodeRLP, which first tries the new stored receipt
format and then uses the Arbitrum legacy format, when reading logs.
  • Loading branch information
Tristan-Wilson committed Jul 28, 2023
1 parent 3725b60 commit 247b596
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,10 @@ func ReadLogs(db ethdb.Reader, hash common.Hash, number uint64, config *params.C
}
receipts := []*receiptLogs{}
if err := rlp.DecodeBytes(data, &receipts); err != nil {
if logs := readLegacyLogs(db, hash, number, config); logs != nil {
return logs
}

log.Error("Invalid receipt array RLP", "hash", hash, "err", err)
return nil
}
Expand All @@ -745,6 +749,22 @@ func ReadLogs(db ethdb.Reader, hash common.Hash, number uint64, config *params.C
return logs
}

// readLegacyLogs is a temporary workaround for when trying to read logs
// from a block which has its receipt stored in the legacy format. It'll
// be removed after users have migrated their freezer databases.
// Arbitrum: we are keeping this to handle classic (legacy) receipts
func readLegacyLogs(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) [][]*types.Log {
receipts := ReadReceipts(db, hash, number, config)
if receipts == nil {
return nil
}
logs := make([][]*types.Log, len(receipts))
for i, receipt := range receipts {
logs[i] = receipt.Logs
}
return logs
}

// ReadBlock retrieves an entire block corresponding to the hash, assembling it
// back from the stored header and body. If either the header or body could not
// be retrieved nil is returned.
Expand Down

0 comments on commit 247b596

Please sign in to comment.