-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix casting issues in RPC CLIs, remove proof from book_offers
#6044
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6044 +/- ##
=======================================
Coverage 79.0% 79.1%
=======================================
Files 839 839
Lines 71377 71400 +23
Branches 8339 8333 -6
=======================================
+ Hits 56422 56451 +29
+ Misses 14955 14949 -6
🚀 New features to boost your workflow:
|
proof from book_offers
|
|
||
| while (!bDone && iParams >= 2) | ||
| { | ||
| // VFALCO Why is Json::StaticString appearing on the right side? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a flyby, does this comment still make sense? It's seems a little pointless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still factually correct (jss is Json::StaticString). Not sure why it's a problem though.
src/xrpld/rpc/detail/RPCCall.cpp
Outdated
| std::int64_t uLedgerMin = jvParams[1u].asInt(); | ||
| std::int64_t uLedgerMax = jvParams[2u].asInt(); | ||
| std::int32_t ledgerMin, ledgerMax; | ||
| if (auto ledgerMinOpt = jvParseInt(jvParams[1u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be const
| if (auto ledgerMinOpt = jvParseInt(jvParams[1u])) | |
| if (auto const ledgerMinOpt = jvParseInt(jvParams[1u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, shouldn't we parse the ledgerMin as uint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, -1 is a valid value. https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_tx
A value of -1 instructs the server to use the most recent validated ledger version available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks! Might be worth adding a blurb in the comments though, explaining that.
src/xrpld/rpc/detail/RPCCall.cpp
Outdated
| std::int64_t uLedgerMin = jvParams[1u].asInt(); | ||
| std::int64_t uLedgerMax = jvParams[2u].asInt(); | ||
| std::int32_t ledgerMin, ledgerMax; | ||
| if (auto ledgerMinOpt = jvParseInt(jvParams[1u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, shouldn't we parse the ledgerMin as uint?
src/xrpld/rpc/detail/RPCCall.cpp
Outdated
|
|
||
| #include <array> | ||
| #include <iostream> | ||
| #include <type_traits> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: (driveby) This include isn't used.
src/xrpld/rpc/detail/RPCCall.cpp
Outdated
| if (jvParams.size()) | ||
| jvRequest[jss::min_count] = jvParams[0u].asUInt(); | ||
| { | ||
| if (auto minCount = jvParseUInt(jvParams[0u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I missed this:
| if (auto minCount = jvParseUInt(jvParams[0u])) | |
| if (auto const minCount = jvParseUInt(jvParams[0u])) |
src/xrpld/rpc/detail/RPCCall.cpp
Outdated
| { | ||
| jvRequest[jss::ip] = ip; | ||
| jvRequest[jss::port] = jvParams[1u].asUInt(); | ||
| if (auto port = jvParseUInt(jvParams[1u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this too:
| if (auto port = jvParseUInt(jvParams[1u])) | |
| if (auto const port = jvParseUInt(jvParams[1u])) |
src/xrpld/rpc/detail/RPCCall.cpp
Outdated
| if (input.find_first_not_of("0123456789") == std::string::npos) | ||
| jvRequest["can_delete"] = jvParams[0u].asUInt(); | ||
| { | ||
| if (auto seq = jvParseUInt(jvParams[0u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I missed this too:
| if (auto seq = jvParseUInt(jvParams[0u])) | |
| if (auto const seq = jvParseUInt(jvParams[0u])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes casting issues in RPC command-line interfaces and removes the unused proof parameter from book_offers. The changes improve error handling by replacing unsafe type casts with proper validation using new helper functions jvParseInt and jvParseUInt.
Key Changes
- Removed the
proofparameter frombook_offersRPC method (it was documented nowhere and had no effect) - Added
jvParseIntandjvParseUInthelper functions for safer integer parsing from JSON values - Updated CLI parsing for
account_tx,book_offers,can_delete,connect,get_counts, andtx_historyto use the new helpers - Simplified test infrastructure by removing exception-based test expectations
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/xrpld/rpc/handlers/BookOffers.cpp | Removed bProof variable and parameter from doBookOffers function |
| src/xrpld/rpc/handlers/Subscribe.cpp | Removed false (proof) parameter from getBookPage call |
| src/xrpld/app/misc/NetworkOPs.h | Removed bProof parameter from getBookPage signature |
| src/xrpld/app/misc/NetworkOPs.cpp | Removed bProof parameter from both getBookPage implementations |
| src/xrpld/rpc/detail/RPCCall.cpp | Added parsing helpers, updated CLI parsers for better error handling, removed proof handling from book_offers, changed max params from 7 to 6 |
| src/test/rpc/RPCCall_test.cpp | Removed exception-based test structure, updated test expectations for commands that now return errors instead of throwing |
| include/xrpl/protocol/jss.h | Removed proof constant declaration |
| API-CHANGELOG.md | Added entry documenting the removal of proof parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ## XRP Ledger server version 2.5.0 | ||
|
|
||
| As of 2025-04-04, version 2.5.0 is in development. You can use a pre-release version by building from source or [using the `nightly` package](https://xrpl.org/docs/infrastructure/installation/install-rippled-on-ubuntu). | ||
| [Version 2.4.0](https://github.com/XRPLF/rippled/releases/tag/2.5.0) was released on June 24, 2025. |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version number in the link does not match the section heading. The link says "2.4.0" but should say "2.5.0" to match the section title "XRP Ledger server version 2.5.0".
| [Version 2.4.0](https://github.com/XRPLF/rippled/releases/tag/2.5.0) was released on June 24, 2025. | |
| [Version 2.5.0](https://github.com/XRPLF/rippled/releases/tag/2.5.0) was released on June 24, 2025. |
|
|
||
| if (iLimit > 0) | ||
| jvRequest[jss::limit] = iLimit; | ||
| if (limit > 0) |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition if (limit > 0) means that a limit value of 0 will be silently ignored and not added to the request. However, based on the comment "limit: 0 = no limit", a limit of 0 appears to have special meaning. The code should either:
- Add the limit to the request even when it's 0 (if 0 is a valid value)
- Return an error if the limit is <= 0 (if 0 is not valid)
The current implementation silently ignores limit=0, which could be confusing to users.
| if (limit > 0) | |
| if (limit >= 0) |
High Level Overview of Change
This PR fixes some casting issues that resulted in some bad errors in the RPC CLIs, namely:
account_txbook_offerscan_deleteconnectget_countstx_historyThis PR also removes the
proofparameter frombook_offers, which isn't documented anywhere and also doesn't do anything (there will be no change in behavior except in the CLI, since rippled just ignores other parameters).This also results in some serious simplification opportunities in the
RPCCall_testtests.Context of Change
Downstream of #6043
Type of Change
API Impact
Some bugs were fixed in the CLI API. The
proofparameter was also removed, which decreases the number of CLI params inbook_offers.There are no changes to HTTPS and WS API users.
Test Plan
CI passes. Tests were adjusted.