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

soroban-rpc: Replace getLedgerEntry with getLedgerEntries #48

Closed
6 tasks
paulbellamy opened this issue Jan 31, 2023 · 5 comments
Closed
6 tasks

soroban-rpc: Replace getLedgerEntry with getLedgerEntries #48

paulbellamy opened this issue Jan 31, 2023 · 5 comments

Comments

@paulbellamy
Copy link
Contributor

paulbellamy commented Jan 31, 2023

What problem does your feature solve?

Currently, to fetch multiple ledger entries you have to issue multiple getLedgerEntry calls, and you might get them as of multiple ledger states.

What would you like to see?

Replacing:

getLedgerEntry(key: xdr.LedgerKey): {
  xdr: xdr.LedgerEntryData,
  lastModifiedLedgerSeq: number,
  latestLedger: number,
}

with:

getLedgerEntries(keys: xdr.LedgerKey[]): {
  entries: (null | {
    xdr: xdr.LedgerEntryData,
    lastModifiedLedgerSeq: number
  })[],
  latestLedger: number,
}

If any of the keys are not found they should be put as null into the output fields. This is so the client can pair up the requested keys with their results.

We will need to:

  • Add the new method, and deprecate the old one in the first release.
  • Remove the old method in the next release.
  • Update soroban-cli
  • Update js-soroban-client
  • Update soroban-docs
  • Update system-test

What alternatives are there?

@stellarsaur
Copy link
Contributor

Have we considered adding getLedgerEntries, but keeping getLedgerEntry as-is? Saves users the effort to update how they're calling the RPC server, and makes more sense semantically to use getLedgerEntry when you only want to get a single entry.

Just a thought.

@tomerweller
Copy link

tomerweller commented Apr 19, 2023

Instead of modifying getLedgerEntry to work on multiple keys, can we have our json-rpc handler allow for a batch of requests to operate on a consistent state? Consistent state across a batch of requests can potentially have benefits beyond just batching ledger entry reads.

EDIT: I haven't gotten into the details but the json-rpc 2.0 spec does support batching and that's implemented in jrpc2. Batching is also supported by geth.

@paulbellamy
Copy link
Contributor Author

paulbellamy commented Apr 27, 2023

+1 for batching support in future, but (I'd assume) that's a bigger lift. There's no reason not to do both getLedgerEntries now, and batching later, imo.

Edit: Based on the docs for the jsonrpc server we're using, it supports batching out-of-the-box, but doesn't give any way to guarantee atomicity withing a batch. So, we would need to rework the jsonrpc server, and refactor the database transaction handling to support that.
You can see it currently supports batching with:

$ curl -X POST \
  --header "content-type: application/json" \
  https://rpc-futurenet.stellar.org:443/soroban/rpc \
  -d '[{"jsonrpc": "2.0", "id": 1, "method": "getHealth"}, {"jsonrpc": "2.0", "id": 2, "method": "getHealth"}]' \
  | jq -S .
[
  {
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
      "status": "healthy"
    }
  },
  {
    "id": 2,
    "jsonrpc": "2.0",
    "result": {
      "status": "healthy"
    }
  }
]

@paulbellamy
Copy link
Contributor Author

Created #28 to work on atomicity within batches

@stellarsaur stellarsaur transferred this issue from stellar/stellar-cli Feb 1, 2024
@mollykarcher
Copy link
Contributor

Closing in favor of #28

@github-project-automation github-project-automation bot moved this from Backlog to Done in Platform Scrum May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants