From ab9d9bd42932299ae64a291099de0227eb82bce3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 14 Feb 2023 21:28:44 -0800 Subject: [PATCH] fix: events: handle decoded events in database We merged https://github.com/filecoin-project/lotus/pull/10085 without a migration, so the event database will contain both cbor and non-cbor values. We need to handle that. --- chain/events/filter/index.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chain/events/filter/index.go b/chain/events/filter/index.go index 6962fcaa37c..1c74f6cdf0a 100644 --- a/chain/events/filter/index.go +++ b/chain/events/filter/index.go @@ -488,9 +488,12 @@ func (ei *EventIndex) RunMigration(from, to int) error { } after, err := cbg.ReadByteArray(bytes.NewReader(before), 4<<20) if err != nil { - return xerrors.Errorf("failed to decode cbor: %w; value: %s", err, hex.EncodeToString(before)) + // Before Jan 23 we decoded events before putting them into the database. So + // we're just going to assume that that's what's happening here, log an + // error, and continue. + after = before } - if _, ok := topics[key]; ok && len(before) < 32 { + if _, ok := topics[key]; ok && len(after) < 32 { // if this is a topic, leftpad to 32 bytes pvalue := make([]byte, 32) copy(pvalue[32-len(after):], after)