Skip to content

refactor!: new implementation of subscriptions#122

Open
markspanbroek wants to merge 13 commits into
logos-storage:mainfrom
durability-labs:rework-subscriptions
Open

refactor!: new implementation of subscriptions#122
markspanbroek wants to merge 13 commits into
logos-storage:mainfrom
durability-labs:rework-subscriptions

Conversation

@markspanbroek
Copy link
Copy Markdown
Contributor

New implementation of subscriptions, that keeps a local view of all subscriptions instead of letting the JSON-RPC node handle the subscriptions.

Main advantages:

  • falls back to polling if websocket updates no longer happen
  • no need to resubscribe when something goes wrong with the connection
  • reduces the number of RPC calls because we now check the block's bloom filter before getting logs

Additionally:

  • JsonRpcProvider.new() is replaced by JsonRpcProvider.connect(), to get an error when the connection fails
  • subscription callbacks no longer get a Result type, because subscription errors are now handled elsewhere

@AuHau
Copy link
Copy Markdown
Contributor

AuHau commented Sep 11, 2025

Hey @markspanbroek!

Thanks for the PR! I will try to have a look by the end of the week.

@AuHau AuHau self-requested a review September 11, 2025 09:59
@arnetheduck
Copy link
Copy Markdown
Contributor

fyi, json-rpc has gained support for bidirectional comms and will be deprecating the existing message hook: status-im/nim-json-rpc#249 in an upcoming release. It's an open question whether the hook will be replaced, but likely not, since subscriptions can (and should) use the rpc router instead. Possibly there might be a hook for already-decoded messages or post-router lookup for messages that don't match the router, depending on demand.

In the new setup, notifications are handled via the regular RpcRouter.

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.

3 participants