Skip to content

Conversation

@mvadari
Copy link
Collaborator

@mvadari mvadari commented Nov 17, 2025

High Level Overview of Change

This PR fixes some casting issues that resulted in some bad errors in the RPC CLIs, namely:

  • account_tx
  • book_offers
  • can_delete
  • connect
  • get_counts
  • tx_history

This PR also removes the proof parameter from book_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_test tests.

Context of Change

Downstream of #6043

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)

API Impact

Some bugs were fixed in the CLI API. The proof parameter was also removed, which decreases the number of CLI params in book_offers.

There are no changes to HTTPS and WS API users.

Test Plan

CI passes. Tests were adjusted.

@mvadari mvadari requested a review from vvysokikh1 November 17, 2025 12:45
@mvadari mvadari requested a review from a team as a code owner November 17, 2025 12:45
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 89.79592% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.1%. Comparing base (6c67f1f) to head (100ad8b).

Files with missing lines Patch % Lines
src/xrpld/rpc/detail/RPCCall.cpp 89.8% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           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     
Files with missing lines Coverage Δ
src/xrpld/app/misc/NetworkOPs.cpp 69.9% <ø> (ø)
src/xrpld/app/misc/NetworkOPs.h 100.0% <ø> (ø)
src/xrpld/rpc/handlers/BookOffers.cpp 98.9% <ø> (-<0.1%) ⬇️
src/xrpld/rpc/handlers/Subscribe.cpp 91.6% <ø> (ø)
src/xrpld/rpc/detail/RPCCall.cpp 93.9% <89.8%> (+0.2%) ⬆️

... and 3 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mvadari mvadari changed the title fix casting issues in RPC CLIs fix casting issues in RPC CLIs, remove proof from book_offers Nov 17, 2025
@bthomee bthomee requested a review from Tapanito November 19, 2025 22:27

while (!bDone && iParams >= 2)
{
// VFALCO Why is Json::StaticString appearing on the right side?
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

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]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be const

Suggested change
if (auto ledgerMinOpt = jvParseInt(jvParams[1u]))
if (auto const ledgerMinOpt = jvParseInt(jvParams[1u]))

Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

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]))
Copy link
Collaborator

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?


#include <array>
#include <iostream>
#include <type_traits>
Copy link
Collaborator

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.

@mvadari mvadari requested a review from Tapanito November 20, 2025 10:11
if (jvParams.size())
jvRequest[jss::min_count] = jvParams[0u].asUInt();
{
if (auto minCount = jvParseUInt(jvParams[0u]))
Copy link
Collaborator

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:

Suggested change
if (auto minCount = jvParseUInt(jvParams[0u]))
if (auto const minCount = jvParseUInt(jvParams[0u]))

{
jvRequest[jss::ip] = ip;
jvRequest[jss::port] = jvParams[1u].asUInt();
if (auto port = jvParseUInt(jvParams[1u]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I missed this too:

Suggested change
if (auto port = jvParseUInt(jvParams[1u]))
if (auto const port = jvParseUInt(jvParams[1u]))

if (input.find_first_not_of("0123456789") == std::string::npos)
jvRequest["can_delete"] = jvParams[0u].asUInt();
{
if (auto seq = jvParseUInt(jvParams[0u]))
Copy link
Collaborator

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:

Suggested change
if (auto seq = jvParseUInt(jvParams[0u]))
if (auto const seq = jvParseUInt(jvParams[0u]))

@mvadari mvadari requested a review from Tapanito November 20, 2025 12:20
Copilot AI review requested due to automatic review settings December 2, 2025 22:57
Copilot finished reviewing on behalf of mvadari December 2, 2025 22:59
Copy link

Copilot AI left a 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 proof parameter from book_offers RPC method (it was documented nowhere and had no effect)
  • Added jvParseInt and jvParseUInt helper functions for safer integer parsing from JSON values
  • Updated CLI parsing for account_tx, book_offers, can_delete, connect, get_counts, and tx_history to 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.
Copy link

Copilot AI Dec 2, 2025

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".

Suggested change
[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.

Copilot uses AI. Check for mistakes.

if (iLimit > 0)
jvRequest[jss::limit] = iLimit;
if (limit > 0)
Copy link

Copilot AI Dec 2, 2025

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:

  1. Add the limit to the request even when it's 0 (if 0 is a valid value)
  2. 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.

Suggested change
if (limit > 0)
if (limit >= 0)

Copilot uses AI. Check for mistakes.
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.

3 participants