ChainSafe / ChainSafe/forest

Investigate: eth_getFilterLogs stateful behavior — Lotus parity or spec deviation?

Open
#7,193 0 comments 0 reactions 1 assignee Claimed by @akaladarshi View on GitHub
Dominant language
Rust
Stars
697
Forks
200
Avg merge
1d 5h
Merged PRs (30d)
65

Description

## Background

During review of PR #7172 (https://github.com/ChainSafe/forest/pull/7172), a question was raised about the behavior of `eth_getFilterLogs` vs `eth_getFilterChanges`.

**Standard Ethereum spec** defines:
- `eth_getFilterChanges` — incremental/polling; returns only logs **since the last poll** (stateful).
- `eth_getFilterLogs` — returns **all** logs matching the filter at the time of the call, regardless of previous polls (idempotent/non-stateful).

**Lotus behavior** (observed in `node/impl/eth/events.go`):
Both `EthGetFilterLogs` and `EthGetFilterChanges` call `fc.TakeCollectedEvents(ctx)`, which **drains** the filter's accumulated event list. This makes both methods stateful and incremental — a deliberate (or accidental?) deviation from the standard Ethereum spec.

**Forest's current behavior** (after PR #7172):
Forest mirrors Lotus by using a shared `poll_event_filter` helper for both methods, making both stateful/incremental.

## Question

Is the Lotus behavior intentional (i.e., Filecoin/Lotus defines its own semantics for `eth_getFilterLogs`) or is it a bug in Lotus?

Concretely, consider this sequence:
```
1. eth_getFilterChanges → returns [log A, log B], poll state updated
2. eth_getFilterLogs → returns [] (A and B already consumed!) ← is this correct?
```

According to the Ethereum spec, step 2 should return `[log A, log B]`, but both Lotus and Forest currently return `[]`.

## Action Items

- [ ] Verify with the Lotus team / spec whether this is intentional behavior or a bug.
- [ ] If it is a bug in Lotus, decide whether Forest should deviate from Lotus and implement the spec-compliant behavior for `eth_getFilterLogs`.
- [ ] Update Forest accordingly and document the chosen behavior.

## References

- PR #7172: https://github.com/ChainSafe/forest/pull/7172
- Review comment: https://github.com/ChainSafe/forest/pull/7172#discussion_r3435688903
- Lotus source: `node/impl/eth/events.go` — `EthGetFilterLogs` and `EthGetFilterChanges`
- Ethereum JSON-RPC spec: https://eips.ethereum.org/EIPS/eip-1474

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.