Repository navigation
Conversation
There was a problem hiding this comment.
This is a large, mechanical refactor swapping raw AMM SLE pointers for the AMMEntryR/AMMEntryW wrapper types across the AMM transactors, AMMHelpers, BookStep, StepChecks, TrustSet, and the LPToken checks in View.cpp/TokenHelpers.cpp. I checked every changed call site for argument-order swaps (asset vs asset2), lost update()/insert()/erase() calls, wrong AMMEntryR/AMMEntryW construction overloads, and lifetime issues with the if-init-statement patterns (BookStep, AMMCreate) — all are consistent 1:1 replacements of the prior SLE-based logic. Field access (ammSle[sfX] -> (*ammSle)[sfX]) and mutation flows (setField... followed by .update()) match the original control flow exactly. No behavioral divergence was found in the visible diff; the mechanical nature of the change and the author's stated compile/clang-tidy verification are consistent with what I observed.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The broad refactor touches consensus-critical AMM transaction and payment-path processing and warrants final human validation.
Review effort: Balanced
Findings: None
What changed in this PR
Refactors AMM ledger access to use typed AMMEntryR/AMMEntryW wrappers across transaction processing, payment paths, ledger helpers, RPC, and tests.
Changes:
- Replaces raw AMM SLE reads and writes with typed wrappers.
- Updates AMM helper and transactor interfaces accordingly.
- Adjusts test and RPC call sites for the new interfaces.
| File | Description |
|---|---|
src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp |
Wraps AMM entries for LP balance lookup. |
src/test/jtx/impl/AMM.cpp |
Updates AMM test helpers. |
src/test/app/TheoreticalQuality_test.cpp |
Makes the sandbox mutable for wrapper reads. |
src/libxrpl/tx/transactors/token/TrustSet.cpp |
Uses typed AMM lookup. |
src/libxrpl/tx/transactors/dex/AMMWithdraw.cpp |
Migrates withdrawal processing to typed entries. |
src/libxrpl/tx/transactors/dex/AMMVote.cpp |
Migrates voting reads and updates. |
src/libxrpl/tx/transactors/dex/AMMDeposit.cpp |
Migrates deposit reads and updates. |
src/libxrpl/tx/transactors/dex/AMMDelete.cpp |
Uses typed AMM lookup. |
src/libxrpl/tx/transactors/dex/AMMCreate.cpp |
Uses typed AMM creation and insertion. |
src/libxrpl/tx/transactors/dex/AMMClawback.cpp |
Migrates clawback processing. |
src/libxrpl/tx/transactors/dex/AMMBid.cpp |
Migrates bidding reads and updates. |
src/libxrpl/tx/paths/BookStep.cpp |
Uses typed AMM access during path construction. |
src/libxrpl/ledger/View.cpp |
Uses typed AMM lookup for LP transfers. |
src/libxrpl/ledger/helpers/TokenHelpers.cpp |
Uses typed AMM lookup for token checks. |
src/libxrpl/ledger/helpers/AMMHelpers.cpp |
Updates helper implementations and mutations. |
include/xrpl/tx/transactors/dex/AMMWithdraw.h |
Updates withdrawal interfaces. |
include/xrpl/tx/transactors/dex/AMMClawback.h |
Updates clawback interfaces. |
include/xrpl/tx/paths/detail/StepChecks.h |
Uses typed AMM lookup in freeze checks. |
include/xrpl/ledger/helpers/AMMHelpers.h |
Exposes typed helper signatures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
b8ef34e to
c46c5c8
Compare
There was a problem hiding this comment.
This is a mechanical, well-scoped refactor swapping raw AMM SLE pointers for AMMEntryR/AMMEntryW across the AMM transactors, AMMHelpers, BookStep, StepChecks.h, TrustSet, and the LPToken checks in View.cpp/TokenHelpers.cpp. All the dereference/access patterns ((*ammSle)[...], ammSle->...) are used consistently with the new wrapper types, and the changed call sites line up with the updated header signatures (ammHolds, ammLPHolds, getTradingFee, initializeFeeAuctionVote, verifyAndAdjustLPTokenBalance, and the AMMWithdraw/AMMClawback private helpers). No SQL/command injection, hardcoded secrets, or obvious logic inversions were found in the added lines. The one spot worth a second look is the new mutableRawSle() / dirLink interaction in AMMCreate.cpp, flagged below as a low-confidence note rather than a confirmed bug, since AMMEntryW's internals aren't part of this diff.
c46c5c8 to
f0c32fa
Compare
There was a problem hiding this comment.
This is a careful, mechanical refactor swapping raw AMM SLE pointers for the typed AMMEntryR/AMMEntryW wrapper across the AMM transactors, AMMHelpers, BookStep, StepChecks, TrustSet, and the LP-token checks in View.cpp/TokenHelpers.cpp. Call sites consistently preserve existing control flow (null checks, update()/insert()/erase() calls map 1:1 to the old sb.update/insert/erase calls), and the signature changes (SLE const& -> AMMEntryR const&, SLE::pointer& -> AMMEntryW&) are threaded consistently through headers and .cpp files with no mismatched overloads spotted. The one place worth a sanity check (not flagged as a confident bug) is AMMCreate.cpp's new ammSle.mutableRawSle() copy passed into dirLink, which the author already called out in a comment as relying on shared_ptr aliasing rather than pointer reseating — worth confirming dirLink's actual signature doesn't reassign the pointer, but given the explicit comment and the author's stated compile/clang-tidy verification, I don't have enough signal to assert this is wrong. No changed line otherwise shows a logic inversion, resource leak, or security issue; the diff reads as behavior-preserving as claimed.
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
Replace raw AMM SLE pointers with AMMEntryR/AMMEntryW in the AMM transactors, AMMHelpers, the payment path steps, TrustSet, and the LPToken checks in View.cpp and TokenHelpers.cpp. Helpers that take an AMM SLE (ammHolds, ammLPHolds, getTradingFee, initializeFeeAuctionVote, verifyAndAdjustLPTokenBalance, and the AMMWithdraw/AMMClawback private members) now take AMMEntryR const& or AMMEntryW& and stay where they are. AMMInfo and the jtx AMM helper wrap their existing SLE to match the new ammLPHolds signature. TheoreticalQuality_test no longer uses a const PaymentSandbox, because read-only entries peek() through an ApplyView. No behavior change.
f0c32fa to
b255632
Compare
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
There was a problem hiding this comment.
🔵 Needs a closer look
Read-only AMM lookups now inherit SLEBase’s const_cast-based ApplyView::peek resolution, requiring human validation of const-view usage and behavior equivalence in public helpers and consensus path construction.
No open issues 🎉
Review effort: Balanced
High Level Overview of Change
Replace raw AMM SLE pointers with
AMMEntryR/AMMEntryWin the AMM transactors,AMMHelpers,BookStep,StepChecks.h,TrustSet, and the LPToken checks inView.cppandTokenHelpers.cpp. Helpers that take an AMM SLE (ammHolds,ammLPHolds,getTradingFee,initializeFeeAuctionVote,verifyAndAdjustLPTokenBalance, and the privateAMMWithdraw/AMMClawbackmembers) now takeAMMEntryR const&orAMMEntryW&. No helper moves onto the wrapper in this PR.Context of Change
Part of the Wrapped SLEs migration (design: step 2/3 of #7886). The AMM parameters are now typed, so the compiler rejects an SLE of the wrong type and enforces read-only vs. writable access. Pure refactor: no amendment, no behavior change; any observable difference is a bug.
AMMInfoand the jtxAMMhelper wrap their existing SLE to match the newammLPHoldssignature.TheoreticalQuality_testno longer uses aconst PaymentSandbox, because read-only entriespeek()through anApplyView(seeSLEBase.h);BookStepnow reads the AMM throughAMMEntryR.This PR was fully written by AI (Claude Code) under human direction; the human author reviewed the diff.
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)Test Plan
Compile-checked (
clang++ -fsyntax-only) every changed .cpp and every includer of the changed headers (26 files), ran clang-tidy on the changed .cpp files, and ran pre-commit. No new tests. CI runs the full unit test suite.🤖 Generated with Claude Code