8000 Fix: RPC Response by dangell7 · Pull Request #5503 · XRPLF/rippled · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: RPC Response #5503

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

Merged
merged 2 commits into from
Jun 18, 2025
Merged

Fix: RPC Response #5503

merged 2 commits into from
Jun 18, 2025

Conversation

dangell7
Copy link
Collaborator
@dangell7 dangell7 commented Jun 18, 2025

High Level Overview of Change

Context of Change

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)

@dangell7 dangell7 requested a review from a team as a code owner June 18, 2025 04:11
Copy link
codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.1%. Comparing base (edb4f03) to head (5cb7014).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5503     +/-   ##
=========================================
- Coverage     79.1%   79.1%   -0.0%     
=========================================
  Files          817     817             
  Lines        71704   71703      -1     
  Branches      8261    8239     -22     
=========================================
- Hits         56725   56715     -10     
- Misses       14979   14988      +9     
Files with missing lines Coverage Δ
src/libxrpl/protocol/STTx.cpp 89.3% <100.0%> (-0.2%) ⬇️
src/xrpld/app/misc/NetworkOPs.cpp 70.5% <100.0%> (ø)
src/xrpld/app/tx/detail/Batch.cpp 98.2% <ø> (-1.8%) ⬇️

... and 5 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dangell7 dangell7 force-pushed the fix-rpc-response branch 2 times, most recently from bcd6106 to 9f961ea Compare June 18, 2025 08:17
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.

Does not look like it would impact Clio in any way 👍

@@ -61,7 +58,7 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx)

// LCOV_EXCL_START
if (baseFee > maxAmount - view.fees().base)
throw std::overflow_error("XRPAmount overflow");
return INITIAL_XRP;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's related to a bug fix and it's covered by unit tests, can we remove LCOV_EXCL_START around it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it is tested and covered yes we can remove the LCOV_EXCL_START but I believe none of these are tested except nested ttBATCH.

* transaction.
* @param view The ledger view used for fee calculations
* @param tx The batch transaction for which to calculate fees
* @return XRPAmount The total fee required for the batch transaction
*/
XRPAmount
Batch::calculateBaseFee(ReadView const& view, STTx const& tx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have two concerns about this method:

  1. We are losing the error context because all error paths with return INITIAL_XRP will be indistinguishable from each other.
  2. Returning the maximum number of XRP is a new pattern to return errors, and I haven't seen it being used anywhere else.

Copy link
Collaborator Author
@dangell7 dangell7 Jun 18, 2025

Choose a reason for hiding this comment

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

Updated back to throw

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After reviewing invoke_calculateBaseFee I don't believe it was ever meant to throw, a try was added but only for supporting a transaction.macro error. Thats why I recommended returning only an amount. The reason for INITIAL_XRP and not 0 is because if there was a bug, then 0 can make it into a ledger, INITIAL_XRP cannot.

Would you like me to add debugLog to the XRPAmount returns or throw errors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@vlntb I have changed it back to not throwing and INITIAL_XRP. This is imo how this should be handled. A zero fee here could allow a transaction into the ledger where INITIAL_XRP will not.

I also added some unit tests for calculateBaseFee.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see what you mean: 0 or -1 can be treated as a valid amount, while INITIAL_XRP is guaranteed to fail.
Added error logs will help to differentiate between different reasons for failure. LGTM

@dangell7 dangell7 force-pushed the fix-rpc-response branch 2 times, most recently from 18344d7 to 3e5adaf Compare June 18, 2025 13:17
@vlntb vlntb requested a review from godexsoft June 18, 2025 17:28
@@ -258,6 +258,11 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx)
"ripple::invoke_calculateBaseFee : unknown transaction type");
return XRPAmount{0};
}
catch (std::exception const& e)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is how we're solving the issue, should this be covered by unit tests

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 reverted to the original, returning XRPAmount. I added some unit tests.

@bthomee bthomee merged commit 8f2f531 into XRPLF:develop Jun 18, 2025
26 checks passed
@legleux legleux mentioned this pull request Jun 23, 2025
yinyiqian1 pushed a commit to yinyiqian1/rippled that referenced this pull request Jul 5, 2025
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.

5 participants
0