Skip to content

Commit

Permalink
fix(events): order events consistently when querying
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Nov 4, 2024
1 parent 773efae commit 3a34832
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Upgrade go-f3 to 0.7.1 to resolve Tipset not found errors when trying to establish instance start time ([filecoin-project/lotus#12651](https://github.com/filecoin-project/lotus/pull/12651)).
- Try harder in the F3 participation loop to participate using the same lotus node ([filecoin-project/lotus#12664](https://github.com/filecoin-project/lotus/pull/12664)).
- The mining loop will now correctly "stick" to the same upstream lotus node for all operations pertaining to mining a single block ([filecoin-project/lotus#12665](https://github.com/filecoin-project/lotus/pull/12665)).
- Make the ordering of event output for `eth_` APIs and `GetActorEventsRaw` consistent, sorting ascending on: epoch, message index, event index and original event entry order. ([filecoin-project/lotus#12623](https://github.com/filecoin-project/lotus/pull/12623))

## Deps

Expand Down
7 changes: 1 addition & 6 deletions chain/index/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"math"
"sort"
"strings"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -418,10 +417,6 @@ func (si *SqliteIndexer) GetEventsForFilter(ctx context.Context, f *EventFilter)
return nil, nil
}

// collected event list is in inverted order since we selected only the most recent events
// sort it into height order
sort.Slice(ces, func(i, j int) bool { return ces[i].Height < ces[j].Height })

return ces, nil
}

Expand Down Expand Up @@ -597,6 +592,6 @@ func makePrefillFilterQuery(f *EventFilter) ([]any, string, error) {
}

// retain insertion order of event_entry rows
s += " ORDER BY tm.height DESC, ee._rowid_ ASC"
s += " ORDER BY tm.height ASC, tm.message_index ASC, e.event_index ASC, ee._rowid_ ASC"
return values, s, nil
}

0 comments on commit 3a34832

Please sign in to comment.