Skip to content

fix: Move AMMInvariant weakInvariantCheck logic into the transaction#7032

Open
Kassaking7 wants to merge 6 commits intoXRPLF:developfrom
Kassaking7:DEFI-664
Open

fix: Move AMMInvariant weakInvariantCheck logic into the transaction#7032
Kassaking7 wants to merge 6 commits intoXRPLF:developfrom
Kassaking7:DEFI-664

Conversation

@Kassaking7
Copy link
Copy Markdown
Collaborator

High Level Overview of Change

Move AMMInvariant weakInvariantCheck logic into the transaction to mitigate the error code to tecPRECISSION_LOSS instead of tecINVARIANT_FAILED.

Context of Change

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)

@Tapanito Tapanito self-requested a review April 27, 2026 16:52
@Kassaking7 Kassaking7 changed the title Fix: move AMMInvariant weakInvariantCheck logic into the transaction fix: move AMMInvariant weakInvariantCheck logic into the transaction Apr 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.1%. Comparing base (46b997b) to head (32ccbf6).
⚠️ Report is 11 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7032     +/-   ##
=========================================
- Coverage     82.1%   82.1%   -0.0%     
=========================================
  Files         1010    1010             
  Lines        75961   75986     +25     
  Branches      7392    7382     -10     
=========================================
+ Hits         62330   62348     +18     
- Misses       13631   13638      +7     
Files with missing lines Coverage Δ
include/xrpl/ledger/helpers/AMMHelpers.h 96.1% <ø> (ø)
src/libxrpl/ledger/helpers/AMMHelpers.cpp 95.7% <100.0%> (+0.1%) ⬆️
src/libxrpl/tx/invariants/AMMInvariant.cpp 95.0% <ø> (ø)
src/libxrpl/tx/transactors/dex/AMMClawback.cpp 98.7% <100.0%> (+<0.1%) ⬆️
src/libxrpl/tx/transactors/dex/AMMDeposit.cpp 96.1% <100.0%> (+<0.1%) ⬆️
src/libxrpl/tx/transactors/dex/AMMWithdraw.cpp 94.6% <100.0%> (+0.1%) ⬆️

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

@Tapanito
Copy link
Copy Markdown
Collaborator

/ai-review

Copy link
Copy Markdown
Contributor

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@Tapanito Tapanito removed their request for review April 28, 2026 09:35
@github-actions
Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions
Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@Kassaking7 Kassaking7 changed the title fix: move AMMInvariant weakInvariantCheck logic into the transaction fix: Move AMMInvariant weakInvariantCheck logic into the transaction Apr 28, 2026
@Kassaking7 Kassaking7 requested a review from shawnxie999 May 1, 2026 17:42
@Kassaking7
Copy link
Copy Markdown
Collaborator Author

/ai-review

Copy link
Copy Markdown
Contributor

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Choose a reason for hiding this comment

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

No issues.

Review by Claude Opus 4.6 · Prompt: V15

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@godexsoft
Copy link
Copy Markdown
Contributor

We recently merged a refactor to develop that enables clang-tidy's readability-identifier-naming. Your branch now has heavy conflicts that are largely mechanical. Below is a workflow that aligns your branch's naming with develop before merging, which should minimize the merge conflicts.

One-time setup

If you don't already have clang-tidy working in your env, on macOS:

brew install llvm@21
# Follow brew's hint to put $(brew --prefix llvm@21)/bin on PATH so run-clang-tidy is found.

Workflow on your branch (before merging develop)

1. Grab the new .clang-tidy from develop without pulling anything else. Sync your fork on GitHub first, then:

git remote -v   # should show 'upstream' among others; if not:
# git remote set-url upstream git@github.com:XRPLF/rippled.git
git fetch upstream
git checkout upstream/develop -- .clang-tidy

2. Reconfigure conan/cmake so compile_commands.json is fresh.

3. Apply renames for the files modified in your PR:

git diff --name-only $(git merge-base HEAD upstream/develop) HEAD \
  | grep -E '\.(cpp|h|hpp|ipp)$' \
  | xargs run-clang-tidy -p build -fix -allow-no-checks
# or -p .build, or whatever your build dir is called

4. Build + test, then commit as a single dedicated commit:

cmake --build build -j8
git commit -am "refactor: Align identifier naming with develop"

5. Now merge develop:

git merge upstream/develop

Extra

Run clang-tidy once more after the merge to catch any stragglers introduced from develop's side:

run-clang-tidy -p build -fix -allow-no-checks src tests
# or -p .build, or whatever your build dir is called

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants