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

updates to book_changes RPC command #5096

Merged
merged 9 commits into from
Sep 19, 2024
Merged

Conversation

ckeshava
Copy link
Collaborator

High Level Overview of Change

Updates to the book_changes RPC command.
Pending clarification, I believe this PR also fixes #5033 and #5036 (improves the latency of the command)

Context of Change

  1. accepts shortcut strings (current, closed, validated) as inputs to ledger_index parameter in the RPC command.
  2. returns validated: true/false in the RPC output

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

Copy link

codecov bot commented Aug 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.2%. Comparing base (9a6af9c) to head (75cb233).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5096     +/-   ##
=========================================
+ Coverage     76.1%   76.2%   +0.1%     
=========================================
  Files          760     760             
  Lines        61548   61550      +2     
  Branches      8160    8124     -36     
=========================================
+ Hits         46834   46884     +50     
+ Misses       14714   14666     -48     
Files with missing lines Coverage Δ
src/xrpld/rpc/BookChanges.h 14.4% <100.0%> (+14.4%) ⬆️
src/xrpld/rpc/handlers/BookOffers.cpp 98.8% <100.0%> (+6.0%) ⬆️

... and 9 files with indirect coverage changes

Impacted file tree graph

@Bronek Bronek self-requested a review September 9, 2024 12:37
src/xrpld/rpc/BookChanges.h Outdated Show resolved Hide resolved
@Bronek
Copy link
Collaborator

Bronek commented Sep 13, 2024

@godexsoft you might want to test this branch with clio.

@godexsoft godexsoft self-requested a review September 13, 2024 17:15
Copy link
Collaborator

@Bronek Bronek left a comment

Choose a reason for hiding this comment

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

I love that it gets rid of getLedgerByContext call in a USER context, also the newly added unit tests seem to bump test coverage overall. Nice work !

@ckeshava
Copy link
Collaborator Author

@Bronek thanks for the quick review!

What do you mean by USER context? I feel the getLedgerByContext should only be used by the consensus mechanism (and Full History Nodes) to collect+store all ledgers. Its in-efficient for a tiny or medium resources validator to engage in acquisition of ledgers.

The getLedgerByContext method can also be removed in the ledger_request RPC call. I expect to see similar issues in that RPC call. Check my comment here: #5036 (comment)

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

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

I don't see anything that could impact Clio.
My only concern is whether the new code still does the same error handling as the old did.


if (std::holds_alternative<Json::Value>(res))
return std::get<Json::Value>(res);
Json::Value result = RPC::lookupLedger(ledger, context);
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Does this change still yield the same error from checking ledger_index etc.?
  2. Can we do the same in LedgerRequest.cpp and eliminate getLedgerByContext() entirely?

Copy link
Collaborator

@Bronek Bronek Sep 16, 2024

Choose a reason for hiding this comment

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

  1. @godexsoft the ledger_index handling (and errors) will be the same as in almost every other command, since the vast majority of commands use lookupLedger. However, since with this change, the ledger won't be requested from other nodes, if a ledger which is not in the local cache is requested, this method will fail with ledgerNotFound error (just like other methods do in such situation)
  2. No; the ADMIN method ledger_request which, with this PR, will be the only method using getLedgerByContext(), and it needs to rely on this function in order to download the ledger from other nodes.

@Bronek
Copy link
Collaborator

Bronek commented Sep 16, 2024

What do you mean by USER context? I feel the getLedgerByContext should only be used by the consensus mechanism (and Full History Nodes) to collect+store all ledgers. Its in-efficient for a tiny or medium resources validator to engage in acquisition of ledgers.

USER methods are accessible to users, ADMIN methods are accessible to admins only (i.e. they require a password and are bound to specific ip/port). The purpose of getLedgerByContext, as exposed by ledger_request is to allow downloading ledgers from other nodes, which is what InboundLedgers::acquire does. This has uses outside of consensus, e.g. replaying transactions. This is nothing to do with node size, and it will be slow by definition.

The getLedgerByContext method can also be removed in the ledger_request RPC call. I expect to see similar issues in that RPC call. Check my comment here: #5036 (comment)

Nope, it should not be removed. There is a reason why we need to be able to download ledgers from other nodes, and why we need to have an ADMIN method for this action.

@godexsoft godexsoft self-requested a review September 16, 2024 14:37
@Bronek Bronek added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Sep 16, 2024
Copy link
Collaborator

@Bronek Bronek left a comment

Choose a reason for hiding this comment

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

@ckeshava please also update API-CHANGELOG.md for release 2.3 . You need to add section for release 2.3 and list the changes in behaviour of book_changes (basically making it like all other methods, but also will now return ledgerNotFound if the ledger is very old). I suggest asking @mDuo13 for help.

API-CHANGELOG.md Outdated Show resolved Hide resolved
@Bronek Bronek removed the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Sep 17, 2024
Copy link
Collaborator

@intelliot intelliot left a comment

Choose a reason for hiding this comment

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

Suggested a rewording to the changelog for consistency. I also think it's ok to merge as-is and improve the docs later on (which is easy to do).

API-CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Elliot Lee <github.public@intelliot.com>
@Bronek Bronek added Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. and removed Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. labels Sep 18, 2024
@Bronek Bronek added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Sep 18, 2024
@Bronek Bronek mentioned this pull request Sep 19, 2024
1 task
@intelliot intelliot merged commit b6391fe into XRPLF:develop Sep 19, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid "success" response from book_changes (possible race condition)
4 participants