Skip to content

Conversation

@mvadari
Copy link
Collaborator

@mvadari mvadari commented Oct 14, 2025

High Level Overview of Change

This PR moves two functions, setVersion and getAPIVersionNumber, from RPCHelpers.h to ApiVersion.h. There are no functionality or code changes.

Context of Change

Split out of #5684 to hopefully start making that PR a bit easier to review.

Type of Change

  • Refactor (non-breaking change that only restructures code)

API Impact

N/A

Test Plan

CI passes

Future Tasks

Add another PR that creates RPCLedgerHelpers and splits out that part of #5684, leaving only the actual functionality changes in #5684

@mvadari mvadari requested a review from a team as a code owner October 14, 2025 18:47
@mvadari mvadari requested a review from godexsoft October 14, 2025 18:51
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.5%. Comparing base (a7792eb) to head (f6e46ae).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5889   +/-   ##
=======================================
  Coverage     79.5%   79.5%           
=======================================
  Files          817     816    -1     
  Lines        72209   72216    +7     
  Branches      8283    8273   -10     
=======================================
+ Hits         57395   57402    +7     
  Misses       14814   14814           
Files with missing lines Coverage Δ
include/xrpl/protocol/ApiVersion.h 100.0% <100.0%> (ø)
src/xrpld/app/main/Application.cpp 69.7% <ø> (ø)
src/xrpld/app/main/GRPCServer.h 100.0% <ø> (ø)
src/xrpld/rpc/detail/Handler.cpp 87.1% <ø> (ø)
src/xrpld/rpc/detail/Handler.h 27.8% <ø> (ø)
src/xrpld/rpc/detail/RPCHelpers.cpp 82.2% <ø> (-0.4%) ⬇️
src/xrpld/rpc/detail/ServerHandler.cpp 87.1% <ø> (ø)
src/xrpld/rpc/handlers/LedgerHandler.cpp 20.9% <ø> (ø)
src/xrpld/rpc/handlers/LedgerHandler.h 72.2% <ø> (ø)
src/xrpld/rpc/handlers/Tx.cpp 93.3% <ø> (ø)
... and 1 more

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

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.

Left a few comments

if (apiVersion == apiVersionIfUnspecified)
{
/**
* API version numbers used in API version 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is not a doxy comment that will actually work (reach documentation). You probably better use a simple comment instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

* 3) the version number is unspecified and
* APIVersionIfUnspecified is out of the supported range
*
* @param value a Json value that may or may not specifies
Copy link
Collaborator

Choose a reason for hiding this comment

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

The parameter is currently called "jv" not "value"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


Json::Value const maxVersion(
betaEnabled ? RPC::apiBetaVersion : RPC::apiMaximumSupportedVersion);
Json::Value requestedVersion(RPC::apiVersionIfUnspecified);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand this is just moving code around but consider cleaning this up (e.g. adding some whitespace where applicable)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored in a62c8e7

{
requestedVersion = jv.get(jss::api_version, requestedVersion);
}
if (!(requestedVersion.isInt() || requestedVersion.isUInt()) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This is a horrible condition. Any improvement here would be nice 🔢

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored in a62c8e7

XRPL_ASSERT(
apiVersion != apiInvalidVersion,
"ripple::RPC::setVersion : input is valid");
auto&& object = addObject(parent, jss::version);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This auto&& is a bit confusing. According to addObject signature this would call the overload which returns by value if Object is not a Value. Is it some sort of shared pointer inside? I don't understand why setting fields on object below would make sense as object is technically a temporary here.

Also, Object is a terrible name for a template parameter - I did not even notice it at first and assumed that it's the Object type from the Json library. This definitely needs renaming at the very least but also try implementing some tests that use this function with Object (template type) be actual Object from Json library and see if it even does anything useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think adding tests etc for Object is out of scope of this PR but I'll look into a separate cleanup effort. Based on some preliminary digging I think there's a good chance we can get rid of that whole Object class and only use Json::Value everywhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did switch out the && for & in 7617f1b though

@mvadari mvadari requested a review from godexsoft October 15, 2025 20:12
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.

2 participants