Skip to content

refactor: Move checkReserve onto AccountRootEntry - #8406

Open
mvadari wants to merge 4 commits into
mvadari/rearch/accountroot-ownerCountfrom
mvadari/rearch/accountroot-checkReserve
Open

mvadari wants to merge 4 commits into
mvadari/rearch/accountroot-ownerCountfrom
mvadari/rearch/accountroot-checkReserve

Conversation

@mvadari

@mvadari mvadari commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Replaces both entry-taking checkReserve free functions with const members of AccountRootEntry: checkReserve(ctx, accBalance, sponsorSle, adj, insufReserveCode) and checkReserve(ctx, accBalance, adj). The members keep the ApplyViewContext parameter, because the check needs the transaction. The journal parameter goes away: call sites pass their journal to the entry constructor instead.

Context of Change

Part of the Wrapped SLEs migration (design: step 2/3 of #7886). The reserve check now lives on the typed entry, so it cannot be called with an SLE of the wrong type. Pure refactor: no amendment, no behavior change; any observable difference is a bug.

Stacked on #8387; review only the last commit.

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 project flags) every changed .cpp and every .cpp that includes AccountRootEntry.h or AccountRootHelpers.h (98/98 passed). clang-tidy clean on all changed files and headers; pre-commit clean. No new tests. CI runs the full unit test suite.

🤖 Generated with Claude Code

@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 clean, mechanical refactor moving checkReserve from free functions to const members of AccountRootEntry. I traced every call site against the two new member overload signatures (with-sponsor+insufReserveCode, and derive-sponsor-internally) and found the parameter mapping consistent everywhere — no argument-order swaps, no dropped sponsor/insufReserveCode arguments relative to the original behavior, and the journal is correctly threaded into entry constructors instead of the removed function parameter. No new correctness, security, or resource-management issues were introduced by the changed (+) lines.

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mvadari
mvadari force-pushed the mvadari/rearch/accountroot-checkReserve branch from 4a22287 to 0a8f1ea Compare September 30, 2026 14:29

@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 mechanical, well-executed refactor moving the two checkReserve free functions onto AccountRootEntry as const member functions. I traced every changed call site against its prior free-function invocation (EscrowHelpers, MPTokenHelpers, RippleStateHelpers, SignerListSet, CheckCash, CheckCreate, CredentialAccept, CredentialCreate, DelegateSet, EscrowCreate, DepositPreauth, PaymentChannelCreate/Fund, TransactionProposalCreate, SponsorshipSet/Transfer, MPTokenIssuanceCreate, TrustSet) and the argument lists line up 1:1 with the removed calls (accSle/journal args dropped, remaining args and defaults preserved). The new AccountRootEntry.cpp implementation is a verbatim copy of the old AccountRootHelpers.cpp body, and the second overload correctly derives the sponsor via getEffectiveTxReserveSponsor(ctx, *this) exactly as before. Entry constructions that gained an explicit journal argument are consistent with entries that are later used for checkReserve or other journal-consuming operations. No behavioral divergence, resource leak, or logic error was found in the changed (+) lines.

@mvadari
mvadari force-pushed the mvadari/rearch/accountroot-checkReserve branch from 0a8f1ea to 2da8ca1 Compare September 30, 2026 17:58
@mvadari
mvadari added this pull request to stack #8448 September 30, 2026 17:59
@mvadari
mvadari force-pushed the mvadari/rearch/accountroot-checkReserve branch from 2da8ca1 to a7ec004 Compare October 5, 2026 13:58
Replace both entry-taking checkReserve free functions with const members
of AccountRootEntry. The members keep the ApplyViewContext parameter,
because the check needs the transaction, and drop the journal parameter:
call sites pass their journal to the entry constructor instead.
@mvadari
mvadari force-pushed the mvadari/rearch/accountroot-checkReserve branch from a7ec004 to 654edc9 Compare October 5, 2026 14:51
@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.

@github-actions

github-actions Bot commented Oct 5, 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.

This is a mechanical, well-executed refactor moving checkReserve from free functions onto AccountRootEntry as member functions. I traced every call site update against the original free-function invocation (argument order, default insufReserveCode handling, sponsor-explicit vs sponsor-implicit overload selection, and the journal param moving from checkReserve to the entry constructor) and found them all consistent with the pre-refactor behavior. No logic changes, no argument-order mix-ups, no dropped parameters. The author's claim of 'no behavior change' holds up under review.

…rch/accountroot-checkReserve

# Conflicts:
#	src/libxrpl/tx/transactors/check/CheckCash.cpp
#	src/libxrpl/tx/transactors/escrow/EscrowCreate.cpp
#	src/libxrpl/tx/transactors/payment_channel/PaymentChannelFund.cpp
#	src/libxrpl/tx/transactors/token/MPTokenIssuanceCreate.cpp

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

1 participant