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

[Prototype/Spike] soroban-rpc: Design Data Backend #4681

Closed
Tracked by #43
paulbellamy opened this issue Nov 1, 2022 · 7 comments
Closed
Tracked by #43

[Prototype/Spike] soroban-rpc: Design Data Backend #4681

paulbellamy opened this issue Nov 1, 2022 · 7 comments
Assignees

Comments

@paulbellamy
Copy link
Contributor

paulbellamy commented Nov 1, 2022

epic - stellar/stellar-rpc#43

To serve contract events to clients, we need to get the events from somewhere. The events are in the ledger close metas. But where should we get those from?

Assumption: Let's ignore historical replay for now (but consider how we would do it in future).

There are a few potential options here to evaluate:

  • Implement Zenith Data Backend flow: TX Meta -> Index by Contract: AccountID, ingest, serve stream
    • Paul: Probably the one we want to go for, but needs proving/testing.
  • Use the core buckets, and grab the current state directly from core
    • Paul: Definitely a terrible idea. But technically possible.
  • Or use custom ingestion
    • Paul: is this just captive core? I'm not sure I fully understand the suggestion here. The upside here, is that we don't need persistence, so it could just ingest the ledgers, and emit events. Is there really much to test here?

Understand:

  • Ease of use (deployment/runtime reqs/etc)
  • Performance
  • Running cost
  • Any gotcha’s / tradeoff's

Desired outcome is a decision about which approach we want to take.

[12/16/22] - Soroban RPC design discussion today ended with consensus from group to take Option 0.5 first, as part of that design it proposes soroban rpc will use captive core and run it's own custom ingestion against that which would then be persisted into the data backend decided here.

Timebox to ?

@paulbellamy paulbellamy changed the title Spike: Design backend data pattern for event streaming [Prototype/Spike] soroban-rpc: Design backend data pattern for event streaming Nov 1, 2022
@paulbellamy paulbellamy moved this to Backlog in Platform Scrum Nov 1, 2022
@paulbellamy paulbellamy moved this from Backlog to Next Sprint Proposal in Platform Scrum Nov 1, 2022
@paulbellamy paulbellamy changed the title [Prototype/Spike] soroban-rpc: Design backend data pattern for event streaming [Prototype/Spike] soroban-rpc: Design Data Backend for event streaming Nov 1, 2022
@sreuland
Copy link
Contributor

sreuland commented Nov 2, 2022

@sreuland
Copy link
Contributor

sreuland commented Nov 2, 2022

maybe consider mq brokers, some discussion here on hot vs cold subscriptions for durable messages - https://stellarorg.atlassian.net/wiki/spaces/PLAT/pages/4434690049/soroban-rpc%3A+grpc+and+json-rpc+comparison?focusedCommentId=4447240228

some options on how Zenith may look if it published to mq broker as on alternate store rather than s3/f/s, then soroban rpc could potentially subscribe to mq topics and use offsets in the subscription to achieve replay scenarios or forward-only type streams, depends on the broker used:

https://stellarorg.atlassian.net/wiki/spaces/HOR/pages/4340678664/Zenith

@tamirms tamirms self-assigned this Nov 3, 2022
@jcx120 jcx120 moved this from Next Sprint Proposal to Current Sprint in Platform Scrum Nov 4, 2022
@tamirms tamirms moved this from Current Sprint to In Progress in Platform Scrum Nov 14, 2022
@paulbellamy paulbellamy changed the title [Prototype/Spike] soroban-rpc: Design Data Backend for event streaming [Prototype/Spike] soroban-rpc: Design Data Backend for events Nov 14, 2022
@tamirms
Copy link
Contributor

tamirms commented Dec 6, 2022

https://docs.google.com/document/d/1F60xINIbfKrdnGeBBxygeHU3ZlgthRJw8DLXaYDakl0/edit?usp=sharing analyzes the different database options for storing events. SQLite appears to be the most promising option. We can ingest the events from TX Meta (either coming from captive core or a TX Meta stored on s3 via ledger exporter) into a SQLite database.

@tamirms
Copy link
Contributor

tamirms commented Dec 6, 2022

One important gotcah regarding SQLite:

simulateTransaction will require soroban-rpc to look up ledger entries while executing a smart contract invocation. These look-ups need to be consistent to a single ledger sequence. This can be implemented using repeatable read transactions in Postgres or read-only transactions in BadgerDB. However, SQLite does not support repeatable read transactions so we will need to introduce a read-write lock to ensure that ingestion cannot operate simultaneously with simulateTransaction requests.

@sreuland
Copy link
Contributor

@tamirms , I updated description/scope, mentioned the agreement that was reached to follow the 0.5 RPC design option, which would be a part of this back-end context.

@sreuland sreuland changed the title [Prototype/Spike] soroban-rpc: Design Data Backend for events [Prototype/Spike] soroban-rpc: Design Data Backend Dec 16, 2022
@sreuland
Copy link
Contributor

@tamirms , is this complete, seems like it's wrapped up as work has started on #4682, if so, please move this to done and set CompletedSprint, thx!

@mollykarcher
Copy link
Contributor

Closing this in favor of #4682 and #4731

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

4 participants