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

Change order of checks in amm_info #4924

Merged
merged 5 commits into from
Jun 18, 2024

Conversation

Bronek
Copy link
Collaborator

@Bronek Bronek commented Feb 20, 2024

High Level Overview of Change

Checking if account is well-formed currently happens before the check if asset , asset2 and amm_account are supplied, which results in an unexpected error messages if any of the fields is malformed. Swap the order of checks, so validity of fields is verified first. Since this is a breaking change, retain the existing behaviour if (apiVersion < 3) and add identical check, but after checks of assets and accounts, if (apiVersion >= 3). Also add unit tests to demonstrate the old and new behaviour.

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)

Before: sending an invalid account or asset to amm_info RPC method while other parameters are not set as expected would result in rpcINVALID_PARAMS error. This behaviour is retained in API version 2

After: sending an invalid account or asset to amm_info RPC method while other parameters are not set as expected will result in rpcISSUE_MALFORMED or rpcACT_MALFORMED error. This behaviour is new in API version 3

This resolves XRPLF/clio#1157

@Bronek Bronek marked this pull request as ready for review February 21, 2024 12:55
@Bronek Bronek force-pushed the feature/change_amm_info_error branch from 58ef31b to 99ea4fe Compare February 21, 2024 13:03
@codecov-commenter
Copy link

codecov-commenter commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.3%. Comparing base (223e6c7) to head (50e2fae).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #4924     +/-   ##
=========================================
- Coverage     71.3%   71.3%   -0.0%     
=========================================
  Files          796     796             
  Lines        66981   66987      +6     
  Branches     10871   10887     +16     
=========================================
- Hits         47774   47763     -11     
- Misses       19207   19224     +17     
Files Coverage Δ
src/ripple/rpc/handlers/AMMInfo.cpp 92.0% <100.0%> (+0.4%) ⬆️

... and 8 files with indirect coverage changes

Impacted file tree graph

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.

LGTM 👍

@intelliot intelliot added Clio Reviewed APIv3 Change does not take effect unless client opts-in to api_version 3 (currently beta) labels Feb 22, 2024
src/test/rpc/AMMInfo_test.cpp Outdated Show resolved Hide resolved
src/test/rpc/AMMInfo_test.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@gregtatcam gregtatcam left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@Bronek
Copy link
Collaborator Author

Bronek commented Feb 27, 2024

this is good to merge - note it preserves the current behaviour in API version 2 and adds a test for it.

@godexsoft
Copy link
Collaborator

Is this going to be merged soon?

@seelabs
Copy link
Collaborator

seelabs commented Jun 18, 2024

@godexsoft Yes, it should be merged today.

@seelabs seelabs merged commit c706926 into XRPLF:develop Jun 18, 2024
18 of 19 checks passed
@seelabs seelabs mentioned this pull request Jun 20, 2024
1 task
ximinez added a commit to ximinez/rippled that referenced this pull request Jul 1, 2024
* upstream/develop: (32 commits)
  fixInnerObjTemplate2 amendment (XRPLF#5047)
  Set version to 2.3.0-b1
  Ignore restructuring commits (XRPLF#4997)
  Recompute loops (XRPLF#4997)
  Rewrite includes (XRPLF#4997)
  Rearrange sources (XRPLF#4997)
  Move CMake directory (XRPLF#4997)
  Add bin/physical.sh (XRPLF#4997)
  Prepare to rearrange sources: (XRPLF#4997)
  Change order of checks in amm_info: (XRPLF#4924)
  Add the fixEnforceNFTokenTrustline amendment: (XRPLF#4946)
  Replaces the usage of boost::string_view with std::string_view (XRPLF#4509)
  docs: explain how to find a clang-format patch generated by CI (XRPLF#4521)
  XLS-52d: NFTokenMintOffer (XRPLF#4845)
  chore: remove repeat words (XRPLF#5041)
  Expose all amendments known by libxrpl (XRPLF#5026)
  fixReducedOffersV2: prevent offers from blocking order books: (XRPLF#5032)
  Additional unit tests for testing deletion of trust lines (XRPLF#4886)
  Fix conan typo: (XRPLF#5044)
  Add new command line option to make replaying transactions easier: (XRPLF#5027)
  ...
vlntb pushed a commit to vlntb/rippled that referenced this pull request Aug 23, 2024
* Change order of checks in amm_info

* Change amm_info error message in API version 3

* Change amm_info error tests
@godexsoft
Copy link
Collaborator

@Bronek this still requires [beta_rpc_api] to be set to 1 in config. Don't we want this to be enabled by default as the maximum allowed version yet? What's the plan for the switch if any?

@ximinez
Copy link
Collaborator

ximinez commented Dec 3, 2024

this still requires [beta_rpc_api] to be set to 1 in config. Don't we want this to be enabled by default as the maximum allowed version yet? What's the plan for the switch if any?

We never want [beta_rpc_api] to be 1 by default. If we want to declare a particular version of the API as done, then we make that version supported by increasing apiMaximumSupportedVersion and then we open up a "new" beta version by incrementing apiBetaVersion. apiBetaVersion should probably always be one more than apiMaximumSupportedVersion.

@godexsoft
Copy link
Collaborator

this still requires [beta_rpc_api] to be set to 1 in config. Don't we want this to be enabled by default as the maximum allowed version yet? What's the plan for the switch if any?

We never want [beta_rpc_api] to be 1 by default. If we want to declare a particular version of the API as done, then we make that version supported by increasing apiMaximumSupportedVersion and then we open up a "new" beta version by incrementing apiBetaVersion. apiBetaVersion should probably always be one more than apiMaximumSupportedVersion.

I did not mean to have the beta enabled by default, that would be silly. I mean to have v3 as the new maximum version. I guess my wording was a little off 🔢
In Clio we will start treating v3 as the maximum (but not default) version in one of the next releases just so we can forward to rippled with v3. But turns out v3 is still in beta so this fix here can't be used unless the operator enables beta or rippled moves on to v3 as the new allowed max version to request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APIv3 Change does not take effect unless client opts-in to api_version 3 (currently beta) Clio Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[amm_info] with malformed account error differs with rippled
7 participants