Skip to content

Commit

Permalink
fix: api: exclude reverted events in eth_getLogs results (#11318)
Browse files Browse the repository at this point in the history
* exclude reverted events from results returned by eth_getLogs

* unit test

* update CHANGELOG.md
  • Loading branch information
i-norden authored Oct 24, 2023
1 parent 018c4e8 commit 84b0751
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 @@ -9,6 +9,7 @@
## Improvements
- fix: Add time slicing to splitstore purging step during compaction to reduce lock congestion [filecoin-project/lotus#11269](https://github.com/filecoin-project/lotus/pull/11269)
- feat: Added instructions on how to setup Prometheus/Grafana for monitoring a local Lotus node [filecoin-project/lotus#11276](https://github.com/filecoin-project/lotus/pull/11276)
- fix: Exclude reverted events in `eth_getLogs` results [filecoin-project/lotus#11318](https://github.com/filecoin-project/lotus/pull/11318)

## New features
- feat: Add move-partition command ([filecoin-project/lotus#11290](https://github.com/filecoin-project/lotus/pull/11290))
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 84b0751

Please sign in to comment.