Skip to content

retire fixXahauV1, fixXahauV2 Amendments#722

Open
tequdev wants to merge 25 commits into
Xahau:devfrom
tequdev:retire-fixXahauV1V2
Open

retire fixXahauV1, fixXahauV2 Amendments#722
tequdev wants to merge 25 commits into
Xahau:devfrom
tequdev:retire-fixXahauV1V2

Conversation

@tequdev

@tequdev tequdev commented Mar 17, 2026

Copy link
Copy Markdown
Member

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)

RichardAH and others added 19 commits February 24, 2026 16:07
* Add AMM bid/create/deposit/swap/withdraw/vote invariants:
  - Deposit, Withdrawal invariants: `sqrt(asset1Balance * asset2Balance) >= LPTokens`.
  - Bid: `sqrt(asset1Balance * asset2Balance) > LPTokens` and the pool balances don't change.
  - Create: `sqrt(asset1Balance * assetBalance2) == LPTokens`.
  - Swap: `asset1BalanceAfter * asset2BalanceAfter >= asset1BalanceBefore * asset2BalanceBefore`
     and `LPTokens` don't change.
  - Vote: `LPTokens` and pool balances don't change.
  - All AMM and swap transactions: amounts and tokens are greater than zero, except on withdrawal if all tokens
    are withdrawn.
* Add AMM deposit and withdraw rounding to ensure AMM invariant:
  - On deposit, tokens out are rounded downward and deposit amount is rounded upward.
  - On withdrawal, tokens in are rounded upward and withdrawal amount is rounded downward.
* Add Order Book Offer invariant to verify consumed amounts. Consumed amounts are less than the offer.
* Fix Bid validation. `AuthAccount` can't have duplicate accounts or the submitter account.
Due to rounding, the LPTokenBalance of the last LP might not match the LP's trustline balance. This was fixed for `AMMWithdraw` in `fixAMMv1_1` by adjusting the LPTokenBalance to be the same as the trustline balance. Since `AMMClawback` is also performing a withdrawal, we need to adjust LPTokenBalance as well in `AMMClawback.`

This change includes:
1. Refactored `verifyAndAdjustLPTokenBalance` function in `AMMUtils`, which both`AMMWithdraw` and `AMMClawback` call to adjust LPTokenBalance.
2. Added the unit test `testLastHolderLPTokenBalance` to test the scenario.
3. Modify the existing unit tests for `fixAMMClawbackRounding`.
Backport of XRPLF/rippled#6325. The python version runs ~80x faster.
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.39073% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.2%. Comparing base (c55420b) to head (dd1d4a6).

Files with missing lines Patch % Lines
src/xrpld/app/tx/detail/URIToken.cpp 86.5% 12 Missing ⚠️
src/xrpld/app/hook/detail/applyHook.cpp 97.1% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             dev    #722     +/-   ##
=======================================
- Coverage   77.3%   77.2%   -0.1%     
=======================================
  Files        837     837             
  Lines      78575   78272    -303     
  Branches   11551   11528     -23     
=======================================
- Hits       60747   60463    -284     
+ Misses     17818   17799     -19     
  Partials      10      10             
Files with missing lines Coverage Δ
src/xrpld/app/hook/detail/HookAPI.cpp 88.3% <100.0%> (-<0.1%) ⬇️
src/xrpld/app/tx/detail/CancelOffer.cpp 81.6% <100.0%> (-2.0%) ⬇️
src/xrpld/app/tx/detail/Escrow.cpp 84.3% <100.0%> (-0.6%) ⬇️
src/xrpld/app/tx/detail/GenesisMint.cpp 82.3% <ø> (-1.5%) ⬇️
src/xrpld/app/tx/detail/Import.cpp 75.9% <100.0%> (-0.1%) ⬇️
src/xrpld/app/tx/detail/Invoke.cpp 96.9% <ø> (-0.9%) ⬇️
src/xrpld/app/tx/detail/SetHook.cpp 81.1% <100.0%> (-0.4%) ⬇️
src/xrpld/app/tx/detail/Transactor.cpp 85.4% <100.0%> (-<0.1%) ⬇️
src/xrpld/ledger/detail/ApplyStateTable.cpp 93.2% <100.0%> (-<0.1%) ⬇️
src/xrpld/app/hook/detail/applyHook.cpp 85.3% <97.1%> (-0.2%) ⬇️
... and 1 more

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

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.

6 participants