Skip to content

Commit

Permalink
fix: events: handle decoded events in database
Browse files Browse the repository at this point in the history
We merged #10085 without a
migration, so the event database will contain both cbor and non-cbor
values. We need to handle that.
  • Loading branch information
Stebalien committed Feb 15, 2023
1 parent 392f1b8 commit ab9d9bd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chain/events/filter/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ab9d9bd

Please sign in to comment.