Skip to content

Commit

Permalink
fix: api: exclude reverted events in eth_getLogs results (filecoin-…
Browse files Browse the repository at this point in the history
…project#11318)

* exclude reverted events from results returned by eth_getLogs

* unit test

* update CHANGELOG.md
  • Loading branch information
i-norden committed Nov 20, 2023
1 parent 44c27f7 commit 658884f
Show file tree
Hide file tree
Showing 4 changed files with 625 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Lotus-workers can now be built to leverage the SupraSeal C2 sealing optimization
- fix(client): single-root error message ([filecoin-project/lotus#11214](https://github.com/filecoin-project/lotus/pull/11214))
- fix: worker: Convert `DC_[SectorSize]_[ResourceRestriction]` if set ([filecoin-project/lotus#11224](https://github.com/filecoin-project/lotus/pull/11224))
- chore: backport #11338 onto release/v1.25.0 ([filecoin-project/lotus#11350](https://github.com/filecoin-project/lotus/pull/11350))
- fix: Exclude reverted events in `eth_getLogs` results [filecoin-project/lotus#11318](https://github.com/filecoin-project/lotus/pull/11318)

## Dependencies
- deps: update go-libp2p to v0.28.1 ([filecoin-project/lotus#10998](https://github.com/filecoin-project/lotus/pull/10998))
Expand Down
2 changes: 1 addition & 1 deletion chain/events/filter/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (m *EventFilterManager) Install(ctx context.Context, minHeight, maxHeight a

if m.EventIndex != nil && minHeight != -1 && minHeight < currentHeight {
// Filter needs historic events
if err := m.EventIndex.PrefillFilter(ctx, f); err != nil {
if err := m.EventIndex.PrefillFilter(ctx, f, true); err != nil {
return nil, err
}
}
Expand Down
7 changes: 6 additions & 1 deletion chain/events/filter/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever
}

// PrefillFilter fills a filter's collection of events from the historic index
func (ei *EventIndex) PrefillFilter(ctx context.Context, f *EventFilter) error {
func (ei *EventIndex) PrefillFilter(ctx context.Context, f *EventFilter, excludeReverted bool) error {
clauses := []string{}
values := []any{}
joins := []string{}
Expand All @@ -500,6 +500,11 @@ func (ei *EventIndex) PrefillFilter(ctx context.Context, f *EventFilter) error {
}
}

if excludeReverted {
clauses = append(clauses, "event.reverted=?")
values = append(values, false)
}

if len(f.addresses) > 0 {
subclauses := []string{}
for _, addr := range f.addresses {
Expand Down
Loading

0 comments on commit 658884f

Please sign in to comment.