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

rpc: fix multi-entry responses for getLedgerEntries method #1093

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Nov 20, 2023

Closes #1084

The key->entry correspondence was broken since the code assumed a 1-to-1 match (in size and ordering) between the keys in the request and the keys in the response.

This didn't hold because:

  1. Some keys may be missing in the response (if not found in the db).
  2. The db access method (LedgerEntryReadTx.GetLedgerEntries()) returned a result whose ordering wasn't consistent with its arguments (due to traversing a map to build the result).

This change:

  1. Fixes the key->entry mapping
  2. Makes getLedgerEntries response ordering stable and consistent with the keys provided.
  3. Make a few small performance improvements (mostly allocation related) along the way.
  4. Increases test coverage.

@2opremio 2opremio requested a review from Shaptic November 20, 2023 23:02
@2opremio
Copy link
Contributor Author

Overrides #1084

The key->entry correspondence was broken since the code assumed a
1-to-1 match (in size and ordering) between the keys in the request
and the keys in the response.

This didn't hold because:

1. Some keys may be missing in the response (if not found in the db).
2. The db access method (`LedgerEntryReadTx.GetLedgerEntries()`)
   returned a result whose ordering wasn't consistent with its arguments
   (due to traversing a map to build the result).

This change:

1. Fixes the key->entry mapping
2. Makes `getLedgerEntries` response ordering stable and consistent with
   the keys provided.
3. Make a few small performance improvements (mostly allocation related) along the way.
@2opremio 2opremio force-pushed the fix-ledgerentries-keys branch from 2adf1b6 to a5710be Compare November 20, 2023 23:08
@2opremio 2opremio changed the title rpc: fix multi-entry responses for getLedger entries rpc: fix multi-entry responses for getLedgerEntries method Nov 20, 2023
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks fons 👏

Two logistical questions:

  • Do we typically add changelog entries in PRs or are they summarized as part of the release?
  • Should this be targeting rc.4.2 so we can release it to testnet?

cmd/soroban-rpc/internal/db/ledgerentry.go Show resolved Hide resolved
@2opremio
Copy link
Contributor Author

Awesome! Thanks fons 👏

Two logistical questions:

* Do we typically add changelog entries in PRs or are they summarized as part of the release?

We don't even have a CHANGELOG file. It seems tsachi has been using github releases as a changelog.

But ... we could change that if you think it's better.

* Should this be targeting `rc.4.2` so we can release it to testnet?

Uhm, we can do it if necessary.

But ... the XDR and symbol names have considerably diverged from what's on testnet since #1029 , so I am not sure it's worth it.

The bug is pretty horrible though, but I think it has gone unnoticed until because most people do single key requests.

@Shaptic
Copy link
Contributor

Shaptic commented Nov 21, 2023

@2opremio agreed with your point about divergence! Let's merge to main for now. And we can keep it in the release notes for now, but we should start a changelog once we have a stable release imo 👍

I'll look into cherry picking it afterward: this has bigger effects because of the workaround @sreuland added in stellar/js-soroban-client#161 so that users can get expiration data after it moved into its own entry, so most requests will have 2 keys 😅 if it's too messy I'll just abandon it

@2opremio 2opremio merged commit 3928c47 into stellar:main Nov 21, 2023
21 checks passed
@2opremio 2opremio deleted the fix-ledgerentries-keys branch November 21, 2023 11:16
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.

soroban-rpc: getLedgerEntries may interleave incorrect keys and values.
2 participants