Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/soroban-rpc: design event streaming API interface #4676

Closed
tsachiherman opened this issue Oct 31, 2022 · 6 comments
Closed

services/soroban-rpc: design event streaming API interface #4676

tsachiherman opened this issue Oct 31, 2022 · 6 comments
Assignees

Comments

@tsachiherman
Copy link
Contributor

tsachiherman commented Oct 31, 2022

epic - stellar/stellar-rpc#43

related(but not blocked by), back-end data acquisition strategy for streaming - #4681

Create a detailed design document describing the intended implementation of the event stream API. The event stream API are the websocket subscription methods for the soroban-rpc service, so that clients can subscribe/unsubscribe from events.

This design should include :

  • define the WS interface - add it to existing soroban rpc api docs
  • secure wss or plain ws?
  • event endpoint - wss://<rpc_host>/contracts/{contract_id}/events
  • event filtering
  • event aggregation
  • obtain team consensus on result
@leighmcculloch
Copy link
Member

leighmcculloch commented Nov 1, 2022

What's driving the technology selection (ws/wss)? What are the use cases we're planning for? What requirements do we have for resuming when there are connectivity issues, or across restarts?

@paulbellamy
Copy link
Contributor

paulbellamy commented Nov 1, 2022

This might want to use the existing api docs https://stellarorg.atlassian.net/wiki/spaces/PJC/pages/4402151440/soroban-rpc+API+Docs#Websocket-Subscription as a starting point.

I'd suggest the desired outcome here is updating the above api docs with a more "final" design.

Nice-to-have: We might also want a new pseudo-event for contract deployment.

@sreuland sreuland changed the title services/soroban-rpc: design event streaming services/soroban-rpc: design event streaming API interface Nov 2, 2022
@paulbellamy
Copy link
Contributor

The design should consider:

  • how to deduplicate events (e.g. subscribing to multiple soroban-rpc servers)
  • How to incorporate historical replay or catch-up so clients can make sure they have received everything in spite of unreliable connections.

@paulbellamy paulbellamy self-assigned this Nov 3, 2022
@jcx120 jcx120 moved this from Next Sprint Proposal to Current Sprint in Platform Scrum Nov 4, 2022
@jcx120 jcx120 moved this from Current Sprint to In Progress in Platform Scrum Nov 4, 2022
@paulbellamy
Copy link
Contributor

@leighmcculloch

What's driving the technology selection (ws/wss)?

  • "Industry standard", it's what other chains all use alongside their jsonrpc server. Doesn't seem like a worthwhile place to innovate.
  • Websockets have (afaik) better built-in browser support (compared to server-sent-events or grpc). I expect at least some of these method will be used directly from dapps to trigger UI refreshes when things happen (e.g. balance updates after a transfer).

What are the use cases we're planning for?

  • Primary: Browsers on a dapp website listening for events and triggering UI updates based on that (e.g. balance updates after a transfer).
  • Secondly: Other backend components in the dapp streaming events to "ingest" into their own domain-specific database.

What requirements do we have for resuming when there are connectivity issues, or across restarts?

  • Restarts are indistinguishable from connectivity issues, so should be handled the same.
  • In event of a disconnect, the client should be able to esume event replay from a given ledger.
    • The client subscribes with the ledger sequence number they last saw, and replay begins from there.
    • Having the client tell us what ledger they last saw is more reliable, but also means we don't need any server-side per-client persistence (a nightmare to scale).
    • Could be limited to x days of recent ledgers to make scaling easier?
  • Idle TCP socket detection is a total pain, so we probably want to add a heartbeat to the websocket protocol, and require clients to call that periodically. However, that can be in v2 release of this.

@paulbellamy
Copy link
Contributor

paulbellamy commented Nov 14, 2022

Per the google design doc linked above, no websockets or push notifications for this. Just the request/response getEvents method, as per: https://docs.google.com/document/d/1TZUDgo_3zPz7TiPMMHVW_mtogjLyPL0plvzGMsxSz6A/edit#heading=h.t03hji406t76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants