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

Fix tokens comparison in Payment for temREDUNDANT error #5172

Merged
merged 11 commits into from
Nov 6, 2024

Conversation

gregtatcam
Copy link
Collaborator

High Level Overview of Change

Fix semantics of tokens comparison in the payment transactor when checking for temREDUNDANT.
This check prevents an account sending tokens to self.
Current code checks for equal tokens (currency or MPTID) AND the issuers. It should only check
if currency or MPTID are equal.

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

@sgramkumar
Copy link
Collaborator

This patch fixes the test failure 👍

{
testcase("Test MPTIssue from/to Json");
MPTIssue const issue1{asset1.get<MPTIssue>()};
Json::Value const jv = to_json(issue1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we explicitly check what the contents of jv are here? Otherwise we just have confidence that to_json and mptIssueFromJson are inverse functions without knowing if the json jv was properly created


{
testcase("Test Asset from/to Json");
Json::Value jv;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think it would be more thorough to test more than just an empty json value here

Copy link
Collaborator

@kennyzlei kennyzlei left a comment

Choose a reason for hiding this comment

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

Unit tests lgtm

Comment on lines 101 to 103
/** Return true if both asset's issue (Issue or MPTIssue)
* are the same and hold the same token (currency or MPTID).
* Otherwise return false.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm suggesting a change to the whole string, but wanted to note the original string was one of the rare occasions you'd need the plural possessive "assets'" (apostrophe after the s). You'd need to pluralize "issues" too.

Suggested change
/** Return true if both asset's issue (Issue or MPTIssue)
* are the same and hold the same token (currency or MPTID).
* Otherwise return false.
/** Return true if both assets refer to the same currency (regardless of issuer) or MPT issuance.
* Otherwise return false.

include/xrpl/protocol/Asset.h Show resolved Hide resolved
src/test/app/MPToken_test.cpp Outdated Show resolved Hide resolved
src/test/app/MPToken_test.cpp Outdated Show resolved Hide resolved
src/test/app/MPToken_test.cpp Outdated Show resolved Hide resolved
src/test/app/MPToken_test.cpp Outdated Show resolved Hide resolved
@ximinez
Copy link
Collaborator

ximinez commented Nov 4, 2024

Also, I notice the linux CI builds are failing.

@kennyzlei kennyzlei added this to the 2.3.0 (Nov 2024) milestone Nov 4, 2024
@gregtatcam
Copy link
Collaborator Author

Also, I notice the linux CI builds are failing.

Thanks, I'm investigating.

@kennyzlei kennyzlei requested review from ximinez, kennyzlei and thejohnfreeman and removed request for kennyzlei November 5, 2024 19:18
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.7%. Comparing base (d6dbf0e) to head (986cc17).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5172     +/-   ##
=========================================
+ Coverage     77.5%   77.7%   +0.1%     
=========================================
  Files          777     779      +2     
  Lines        65833   65985    +152     
  Branches      8182    8152     -30     
=========================================
+ Hits         51031   51238    +207     
+ Misses       14802   14747     -55     
Files with missing lines Coverage Δ
include/xrpl/protocol/Asset.h 95.0% <100.0%> (+1.2%) ⬆️
src/libxrpl/protocol/Asset.cpp 91.3% <100.0%> (+19.9%) ⬆️
src/xrpld/app/tx/detail/Payment.cpp 90.7% <100.0%> (ø)

... and 15 files with indirect coverage changes

Impacted file tree graph

@gregtatcam gregtatcam added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Nov 5, 2024
@ximinez ximinez merged commit c5c0e70 into XRPLF:develop Nov 6, 2024
18 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.

5 participants