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

Fix ledger range calculation #217

Merged
merged 77 commits into from
Jul 2, 2024
Merged

Conversation

aditya1702
Copy link
Contributor

@aditya1702 aditya1702 commented Jun 14, 2024

What

Fixes #208 , #210

  • Change GetLedgerRange function to query the meta table in an optimised way. This will be used by the rest of the endpoints to get the oldest and latest ledger details.
  • Add tests for GetLedgerRange

Why

Resolving bugs that were introduced with the new transactions db changes.

Known limitations

N/A

@aditya1702 aditya1702 changed the title [WIP] Fix GetLedgerRange [WIP] Fix ledger range calculation Jun 17, 2024
@aditya1702 aditya1702 changed the title [WIP] Fix ledger range calculation Fix ledger range calculation Jun 17, 2024
@aditya1702 aditya1702 marked this pull request as ready for review June 17, 2024 20:13
@aditya1702 aditya1702 requested a review from psheth9 June 27, 2024 19:28
Copy link
Contributor

@2opremio 2opremio left a comment

Choose a reason for hiding this comment

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

Almost there! Just a few minor things to go!

@2opremio
Copy link
Contributor

BTW, what's the benchmark result?

@aditya1702
Copy link
Contributor Author

BTW, what's the benchmark result?

@2opremio I pasted the benchmarking here - #217 (comment)

@aditya1702
Copy link
Contributor Author

Benchmarking after changing the query to use sq.Select instead of raw expression:

goos: darwin
goarch: arm64
pkg: github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/db
BenchmarkGetLedgerRange
BenchmarkGetLedgerRange-12    	   50593	     23656 ns/op

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.

I know this has gone through many many iterations but it seems we've finally landed on one that leads to quite a simple and clean implementation! LGTM from my perspective besides some tiny comments, but I'll wait for the other two to put a formal ✔️ on this one 👏

cmd/soroban-rpc/internal/db/ledger_test.go Outdated Show resolved Hide resolved
cmd/soroban-rpc/internal/db/ledger.go Show resolved Hide resolved
@aditya1702
Copy link
Contributor Author

aditya1702 commented Jul 1, 2024

@Shaptic Yeah I was also thinking of the same idea and added the ORDER BY ASC clause at the end. This just increases the query time by 0.5 microsecond (which is nothing honestly).

cc @2opremio

Copy link
Contributor

@tamirms tamirms left a comment

Choose a reason for hiding this comment

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

looks good to me, but I would wait on @2opremio feedback before merging

Copy link
Contributor

@2opremio 2opremio left a comment

Choose a reason for hiding this comment

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

Good job! I left a few extra comments, I am approving since I don't want to block the PR anymore, but please try the suggestions I added before merging.

@aditya1702 aditya1702 merged commit 44515d0 into stellar:main Jul 2, 2024
19 checks passed
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.

transactionHandler's GetLedgerRange is not accurate
5 participants