Skip to content

refactor: Use MPTokenIssuanceEntry everywhere - #8359

Open
mvadari wants to merge 4 commits into
developfrom
mvadari/rearch/mptokenissuance-entry
Open

mvadari wants to merge 4 commits into
developfrom
mvadari/rearch/mptokenissuance-entry

Conversation

@mvadari

@mvadari mvadari commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Replaces raw MPTokenIssuance SLE pointers with MPTokenIssuanceEntryR / MPTokenIssuanceEntryW in the ledger helpers, transactors, and payment paths (58 read/peek/make_shared sites in 28 source files). Helpers that take an issuance SLE (isGlobalFrozen, assetOfHolding issuance parameter, availableMPTAmount, isVaultPseudoAccountFrozen, assetsToShares*/sharesToAssets*, isSoleShareholder, checkVaultDomain, and some file-local helpers) now take MPTokenIssuanceEntryR const& and stay free functions. No helper moves onto the wrapper in this PR.

maxMPTAmount keeps its SLE const& parameter because ValidMPTBalanceChanges::visitEntry calls it and has no view to build an entry. Code that branches on MPToken vs. MPTokenIssuance (isFrozen(view, account, SLE const&, depth), MPTokenIssuanceSet::doApply) keeps the generic SLE. MPToken (holder) pointers are not touched.

Context of Change

Part of the Wrapped SLEs migration (design: step 2/3 of #7886). The entry type is now part of the signature, so the compiler rejects passing a different ledger object type, and read-only vs. writable access is enforced at compile time. Pure refactor: no amendment, no behavior change; any observable difference is a bug.

This PR was fully written by AI (Claude Code) under human direction; the human author reviewed the diff.

API Impact

  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)

Test Plan

  • Syntax-checked (clang++ -fsyntax-only with the project flags) every changed .cpp and every .cpp that includes a changed header, directly or transitively: 92/92 passed.
  • clang-tidy (incl. misc-include-cleaner) clean on all 28 changed .cpp files; pre-commit clean.
  • No new tests. VaultBugs_test.cpp has a one-line edit because assetsToSharesWithdraw now takes an entry.
  • CI runs the full unit test suite.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.07407% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/libxrpl/ledger/helpers/TokenHelpers.cpp 88.9% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a large, mechanical refactor swapping raw SLE pointers for MPTokenIssuanceEntryR/W wrappers across 28 files. The signature changes and call-site updates are consistent and match up correctly throughout (constructors, operator-> usage, .update()/.erase()/.insert() replacing view calls, and the aliasing-shared_ptr trick in View.cpp's isFrozen are all internally consistent). The one recurring gap I found is that most call sites forward the enclosing function's beast::Journal into the new MPTokenIssuanceEntryW constructor (3-arg form), but three free-function call sites in MPTokenHelpers.cpp (addEmptyHolding, lockEscrowMPT, unlockEscrowMPT) construct the writable entry with the 2-arg form even though a Journal (journal/j) is already in scope and used for JLOG right next to the construction. Given the PR's explicit "no behavior change" bar, this looks like an unintentional omission rather than an intentional design choice, and would silently drop any diagnostic logging the entry wrapper does internally for these three code paths.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The consensus-sensitive migration changes read-only lookup behavior across payment and transaction paths and needs final human review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

This PR advances the wrapped-ledger-entry migration by replacing raw MPTokenIssuance SLE pointers with typed read-only and writable entries across ledger helpers, transaction processing, and payment paths.

Changes:

  • Converts issuance lookups, creation, updates, and deletion to typed wrappers.
  • Updates helper signatures and their callers.
  • Adapts one vault test call to the new signature.
File Description
src/​test/​app/​vault/​VaultBugs_test.cpp Adapts a vault helper test call.
src/​libxrpl/​tx/​transactors/​vault/​VaultWithdraw.cpp Wraps vault share issuance reads.
src/​libxrpl/​tx/​transactors/​vault/​VaultSet.cpp Wraps issuance reads and updates.
src/​libxrpl/​tx/​transactors/​vault/​VaultDeposit.cpp Wraps vault share issuance reads.
src/​libxrpl/​tx/​transactors/​vault/​VaultDelete.cpp Wraps share issuance deletion.
src/​libxrpl/​tx/​transactors/​vault/​VaultClawback.cpp Wraps issuance reads and helper input.
src/​libxrpl/​tx/​transactors/​token/​MPTokenIssuanceSet.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​token/​MPTokenIssuanceDestroy.cpp Wraps issuance lookup and deletion.
src/​libxrpl/​tx/​transactors/​token/​MPTokenIssuanceCreate.cpp Creates and inserts a wrapped issuance.
src/​libxrpl/​tx/​transactors/​token/​MPTokenAuthorize.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​token/​ConfidentialMPTSend.cpp Wraps issuance reads and proof input.
src/​libxrpl/​tx/​transactors/​token/​ConfidentialMPTMirrorUpdate.cpp Wraps issuance reads.
src/​libxrpl/​tx/​transactors/​token/​ConfidentialMPTMergeInbox.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​token/​ConfidentialMPTConvertBack.cpp Wraps issuance reads and update.
src/​libxrpl/​tx/​transactors/​token/​ConfidentialMPTConvert.cpp Wraps issuance reads and update.
src/​libxrpl/​tx/​transactors/​token/​ConfidentialMPTClawback.cpp Wraps issuance reads and update.
src/​libxrpl/​tx/​transactors/​token/​Clawback.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​lending/​LoanBrokerCoverClawback.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​escrow/​EscrowFinish.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​escrow/​EscrowCreate.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​escrow/​EscrowCancel.cpp Wraps issuance preclaim read.
src/​libxrpl/​tx/​transactors/​dex/​AMMCreate.cpp Wraps issuance clawback-flag read.
src/​libxrpl/​tx/​transactors/​dex/​AMMClawback.cpp Wraps issuance authorization read.
src/​libxrpl/​tx/​paths/​MPTEndpointStep.cpp Wraps payment-path issuance read.
src/​libxrpl/​ledger/​View.cpp Passes typed issuance to freeze helpers.
src/​libxrpl/​ledger/​helpers/​VaultHelpers.cpp Accepts typed issuance in vault helpers.
src/​libxrpl/​ledger/​helpers/​TokenHelpers.cpp Wraps issuance reads and balance updates.
src/​libxrpl/​ledger/​helpers/​MPTokenHelpers.cpp Wraps issuance reads and helper inputs.
include/​xrpl/​tx/​transactors/​vault/​VaultClawback.h Updates clawback helper signature.
include/​xrpl/​ledger/​View.h Updates freeze helper signature.
include/​xrpl/​ledger/​helpers/​VaultHelpers.h Updates vault helper signatures.
include/​xrpl/​ledger/​helpers/​MPTokenHelpers.h Updates issuance helper signatures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

{
if (auto const sle = view.read(keylet::mptokenIssuance(mptIssue.getMptID())))
return isGlobalFrozen(*sle);
if (auto const sle = MPTokenIssuanceEntryR(mptIssue.getMptID(), view))
// if the account is the issuer, and the issuance exists, their limit is
// the issuance limit minus the outstanding value
auto const issuance = view.read(keylet::mptokenIssuance(mptIssue.getMptID()));
MPTokenIssuanceEntryR const issuance(mptIssue.getMptID(), view);
@github-actions

Copy link
Copy Markdown

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

@mvadari
mvadari force-pushed the mvadari/rearch/mptokenissuance-entry branch from eb0ddd1 to 0687c18 Compare September 30, 2026 17:59
@github-actions

Copy link
Copy Markdown

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

@mvadari
mvadari added this pull request to stack #8451 September 30, 2026 18:03
@mvadari
mvadari force-pushed the mvadari/rearch/mptokenissuance-entry branch from 0687c18 to aad945f Compare October 5, 2026 13:18

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a large, mechanical refactor swapping raw SLE pointers for MPTokenIssuanceEntryR/W wrappers across ~28 files. I traced each changed call site back to its original view.read/view.peek/keylet construction and the new entry-wrapper constructors line up 1:1 in every case I checked (VaultClawback, VaultDelete, VaultSet, VaultWithdraw, VaultDeposit, all the Confidential* transactors, MPTokenAuthorize, MPTokenIssuanceCreate/Destroy/Set, escrow preclaim helpers, AMMClawback/AMMCreate, MPTEndpointStep). Null/existence checks (!sleIssuance, == nullptr) are preserved with equivalent operator!/bool semantics, and .update()/.insert()/.erase() wrapper calls replace the corresponding view.update/insert/erase(sle) calls at the same points in control flow. I did not find a case where the wrong ID/keylet is passed into a wrapper, where a null check was dropped, or where read vs. write access was swapped. The one spot worth a second pair of eyes is the aliasing-shared_ptr construction in MPTokenHelpers.cpp's isFrozen (building a non-owning MPTokenIssuanceEntryR directly from the SLE const& parameter) — it's a well-known, standard-sanctioned idiom and is clearly commented, so I'm not flagging it as a bug, just noting it's the least conventional change in the diff and deserves a close look during review since its correctness depends on the Entry wrapper's constructor not assuming real ownership.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

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

Replace raw MPTokenIssuance SLE pointers with MPTokenIssuanceEntryR
(read-only) and MPTokenIssuanceEntryW (writable) in the ledger
helpers, transactors, and payment paths. view.read()/peek() become
entry constructors, and insert/update/erase go through the entry.

Helpers that take an issuance SLE now take MPTokenIssuanceEntryR:
isGlobalFrozen, assetOfHolding (issuance parameter only),
availableMPTAmount, isVaultPseudoAccountFrozen, the vault share
conversion helpers, isSoleShareholder, checkVaultDomain, and a few
file-local helpers. They stay free functions.

maxMPTAmount keeps its SLE parameter because an invariant calls it
from visitEntry(), where no view exists to build an entry. Code that
branches on MPToken vs. MPTokenIssuance keeps its generic SLE.

Pure refactor: no behavior change.
Develop added the ConfidentialMPTHolderKeyUpdate transactor (#8266),
which reads the issuance with a raw view.read(). Use
MPTokenIssuanceEntryR there too, so that this PR still covers every
MPTokenIssuance read.
@mvadari
mvadari force-pushed the mvadari/rearch/mptokenissuance-entry branch from aad945f to 21d6386 Compare November 9, 2026 22:28
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found.

@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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found.

This branch has not been deployed

No deployments
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.

2 participants