Skip to content

feat: support logs in eth_subscribe#790

Open
0xpinara wants to merge 1 commit intoa16z:masterfrom
0xpinara:feat/subscribe-logs
Open

feat: support logs in eth_subscribe#790
0xpinara wants to merge 1 commit intoa16z:masterfrom
0xpinara:feat/subscribe-logs

Conversation

@0xpinara
Copy link
Copy Markdown

Summary

  • Implements eth_subscribe('logs', filter) per the Ethereum JSON-RPC spec
  • Each log subscriber stores its own filter and broadcast channel
  • On each new block, logs are fetched using the existing verified get_logs() pipeline and sent to matching subscribers
  • Updates the HeliosApi trait, JSON-RPC layer, WASM bindings, and TypeScript provider

Design

  • Per-subscriber broadcast::Sender since each subscriber has unique filter criteria
  • Reuses get_logs() so logs go through the same receipt verification as eth_getLogs
  • Lock is held only during subscriber list cleanup/clone, not during async log fetching
  • Consistent with how newHeads subscriptions already work

Files changed (9)

  • common/src/types.rs — added Logs(Log) variant to SubscriptionEvent
  • core/src/client/api.rs — added filter: Option<Filter> to subscribe()
  • core/src/client/node.rs — log subscriber storage and block-level log distribution
  • core/src/jsonrpc/mod.rs — accept filter param in RPC subscription
  • helios-ts/src/{ethereum,opstack,linea}.rs — pass filter in WASM bindings
  • helios-ts/lib.ts — pass params[1] as filter
  • rpc.md

Not included

  • removed: true for reorged logs (not handled for newHeads either, can be a follow-up)
  • newPendingTransactions subscription (separate scope)

Closes #741

Implement eth_subscribe('logs', filter) as described in a16z#741.

Each log subscriber gets its own broadcast channel with a stored
filter. When a new block arrives, logs are fetched using the
existing get_logs() pipeline (which verifies logs against receipts)
and sent to matching subscribers.

Changes:
- Add Logs(Log) variant to SubscriptionEvent
- Add optional Filter param to subscribe() across the API trait,
  Node impl, JSON-RPC layer, and WASM bindings
- Store per-subscriber (Filter, Sender) pairs in Node
- On each new block, fetch and distribute logs to subscribers
- Update rpc.md docs

Closes a16z#741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support logs w/ eth_subscribe RPC

1 participant