diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 4914d961ec..b6fe2540c4 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -694,8 +694,24 @@ type receiptLogs struct { // DecodeRLP implements rlp.Decoder. func (r *receiptLogs) DecodeRLP(s *rlp.Stream) error { + // Retrieve the entire receipt blob as we need to try multiple decoders + blob, err := s.Raw() + if err != nil { + return err + } + // Check to see if this is a celo dynamic fee receipt. + if types.IsCeloDynamicFeeReceipt(blob) { + var stored types.CeloDynamicFeeStoredReceiptRLP + err := rlp.DecodeBytes(blob, &stored) + if err != nil { + return err + } + r.Logs = stored.Logs + return nil + } + var stored storedReceiptRLP - if err := s.Decode(&stored); err != nil { + if err := rlp.DecodeBytes(blob, &stored); err != nil { return err } r.Logs = stored.Logs diff --git a/core/types/receipt.go b/core/types/receipt.go index 19593bd32f..9d2aad03e8 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -168,7 +168,7 @@ type storedReceiptRLP struct { DepositReceiptVersion *uint64 `rlp:"optional"` } -type celoDynamicFeeStoredReceiptRLP struct { +type CeloDynamicFeeStoredReceiptRLP struct { CeloDynamicReceiptMarker []interface{} // Marker to distinguish this from storedReceiptRLP PostStateOrStatus []byte CumulativeGasUsed uint64 @@ -465,7 +465,7 @@ func (r *ReceiptForStorage) EncodeRLP(_w io.Writer) error { // Detect CeloDynamicFee receipts by looking at the first list element // To distinguish these receipts from the very similar normal receipts, an // empty list is added as the first element of the RLP-serialized struct. -func isCeloDynamicFeeReceipt(blob []byte) bool { +func IsCeloDynamicFeeReceipt(blob []byte) bool { listHeaderSize := 1 // Length of the list header representing the struct in bytes if blob[0] > 0xf7 { listHeaderSize += int(blob[0]) - 0xf7 @@ -483,7 +483,7 @@ func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error { return err } // First try to decode the latest receipt database format, try the pre-bedrock Optimism legacy format otherwise. - if isCeloDynamicFeeReceipt(blob) { + if IsCeloDynamicFeeReceipt(blob) { return decodeStoredCeloDynamicFeeReceiptRLP(r, blob) } if err := decodeStoredReceiptRLP(r, blob); err == nil { @@ -523,7 +523,7 @@ func decodeLegacyOptimismReceiptRLP(r *ReceiptForStorage, blob []byte) error { } func decodeStoredCeloDynamicFeeReceiptRLP(r *ReceiptForStorage, blob []byte) error { - var stored celoDynamicFeeStoredReceiptRLP + var stored CeloDynamicFeeStoredReceiptRLP if err := rlp.DecodeBytes(blob, &stored); err != nil { return err }