Skip to content

refactor: Use PermissionedDomainEntry everywhere - #8367

Open
mvadari wants to merge 7 commits into
developfrom
mvadari/rearch/permissioneddomain-entry
Open

mvadari wants to merge 7 commits into
developfrom
mvadari/rearch/permissioneddomain-entry

Conversation

@mvadari

@mvadari mvadari commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Migrates every raw PermissionedDomain SLE pointer to PermissionedDomainEntryR/PermissionedDomainEntryW across the transactors and helpers that read or peek this ledger entry: PermissionedDomainSet, PermissionedDomainDelete, Payment, OfferCreate, VaultCreate, VaultSet, MPTokenIssuanceSet, plus the Credential/Vault/DEX helper functions that operate on it. credentials::validDomain and verifyValidDomain now take PermissionedDomainEntryR const& instead of a raw domain ID, since every call site already has (or can cheaply build) the entry.

Context of Change

Part of the Wrapped SLEs migration (design: step 2/3 of #7886). Wrapping SLE access in a typed entry lets the compiler enforce read/write access instead of relying on convention. Pure refactor: no amendment, no behavior change; any observable difference is a bug.

permissioned_dex::accountInDomain keeps its uint256 domain ID parameter rather than moving to the entry type: it has a defensive pre-fetch check against a zero-key domain (guarded by fixCleanup3_2_0) that cannot be replicated once a caller has already constructed the entry, since a non-existent read-only entry cannot recover the key it was built from. Changing its signature for a pointer-only PR risked losing that safety net for no behavior change, so it was left as-is; only its internal view.read call was migrated to the wrapper.

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

Compile-checked (clang++ -fsyntax-only) every changed file and every file that includes CredentialHelpers.h (27 files total, transactors, helpers, the RPC handlers and gtests that pull it in) — all passed. Ran pre-commit (clang-format, include-style, spelling) and clang-tidy (misc-include-cleaner) on every changed .cpp — clean. No new tests added; a signature change in credentials::verifyValidDomain forced one existing call site update in src/test/app/Credentials_test.cpp. 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 mechanical, well-scoped refactor swapping raw PermissionedDomain SLE pointers for the typed PermissionedDomainEntryR/PermissionedDomainEntryW wrappers across the affected transactors and helpers. I traced each call site (PermissionedDomainSet, PermissionedDomainDelete, Payment, OfferCreate, VaultCreate, VaultSet, MPTokenIssuanceSet, and the Credential/Vault/DEX/MPToken helpers) against the pre-refactor logic and did not find any behavioral divergence: existence checks, ordering of mutations (setAccountID → setFieldU32 → peekFieldArray → dirInsert → setFieldU64 → increaseOwnerCount → insert in PermissionedDomainSet's create path), and the view instances passed into validDomain/verifyValidDomain are consistent with the originals at every call site. The accountInDomain exception noted in the description (keeping the raw uint256 parameter for the zero-key defensive check) is correctly reflected in the diff. No new resource leaks, null-deref changes, or cross-view mismatches were found.

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

@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-scoped refactor migrating raw PermissionedDomain SLE pointers to the typed PermissionedDomainEntryR/W wrapper across transactors and helpers. I traced every call site of the changed validDomain/verifyValidDomain signatures and the new entry-construction patterns in PermissionedDomainSet/Delete, and each substitution is a faithful 1:1 mapping of the prior raw-pointer logic (same view used to build the entry as is used at the call site, same null checks, same ordering of insert/dirInsert/increaseOwnerCount operations). The one intentionally-unchanged function (permissioned_dex::accountInDomain) is well-justified in the description due to its defensive zero-key pre-check. I did not find any correctness, security, or resource-management issues introduced by this diff.

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

🟡 Changes recommended

The new validation API permits a domain entry and mutable view from different ledger states.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Migrates permissioned-domain ledger access to typed SLE wrappers as part of the Wrapped SLEs initiative.

Changes:

  • Replaces raw permissioned-domain SLE reads and writes with typed entries.
  • Updates credential helper APIs and callers.
  • Adapts the existing credential test.
File Description
src/​test/​app/​Credentials_test.cpp Adapts helper invocation to the wrapper API.
src/​libxrpl/​tx/​transactors/​vault/​VaultSet.cpp Uses a typed domain read.
src/​libxrpl/​tx/​transactors/​vault/​VaultCreate.cpp Uses a typed domain read.
src/​libxrpl/​tx/​transactors/​token/​MPTokenIssuanceSet.cpp Uses a typed domain read.
src/​libxrpl/​tx/​transactors/​permissioned_domain/​PermissionedDomainSet.cpp Uses typed domain creation and updates.
src/​libxrpl/​tx/​transactors/​permissioned_domain/​PermissionedDomainDelete.cpp Uses typed domain deletion.
src/​libxrpl/​tx/​transactors/​payment/​Payment.cpp Passes typed domains through authorization checks.
src/​libxrpl/​tx/​transactors/​dex/​OfferCreate.cpp Migrates domain authorization access.
src/​libxrpl/​ledger/​helpers/​VaultHelpers.cpp Uses typed domains for vault authorization.
src/​libxrpl/​ledger/​helpers/​PermissionedDEXHelpers.cpp Migrates domain membership reads.
src/​libxrpl/​ledger/​helpers/​MPTokenHelpers.cpp Uses typed domains for token authorization.
src/​libxrpl/​ledger/​helpers/​CredentialHelpers.cpp Refactors domain validation around wrappers.
include/​xrpl/​ledger/​helpers/​CredentialHelpers.h Updates public helper signatures.

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

Comment on lines +72 to +76
verifyValidDomain(
ApplyView& view,
AccountID const& account,
PermissionedDomainEntryR const& domain,
beast::Journal j);

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.

Is this something we should address @mvadari ?

@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/permissioneddomain-entry branch from 29b5354 to 200c531 Compare September 30, 2026 17:47
@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.

Clean, mechanical refactor migrating raw PermissionedDomain SLE access to the typed PermissionedDomainEntryR/W wrapper across transactors and helpers. Traced every call site (Payment, OfferCreate, VaultCreate/Set, MPTokenIssuanceSet, PermissionedDomainSet/Delete, and the Credential/Vault/DEX/MPToken helpers) and the argument order/types line up with the new validDomain/verifyValidDomain signatures in every case; no swapped params, no stale-entry reuse across mutations, and the deliberate exception for permissioned_dex::accountInDomain (kept as a raw uint256 to preserve the fixCleanup3_2_0 zero-key pre-fetch check) is reasonable given only its internal read call needed to change. Reusing a single PermissionedDomainEntryR across multiple verifyValidDomain calls in Payment.cpp::doApply (for sender/destination cleanup) is safe because verifyValidDomain only deletes separate Credential SLEs, not the domain's own AcceptedCredentials field. No behavior-changing issues found in the diff.

Migrate every raw PermissionedDomain SLE pointer to
PermissionedDomainEntryR/PermissionedDomainEntryW across the
transactors and helpers that read or peek this ledger entry:
PermissionedDomainSet, PermissionedDomainDelete, Payment, OfferCreate,
VaultCreate, VaultSet, MPTokenIssuanceSet, and the Credential/Vault/DEX
helper functions.

credentials::validDomain and verifyValidDomain now take
PermissionedDomainEntryR const& instead of a raw domainID, since every
call site already has (or can cheaply build) the entry; this also
removes a few duplicate re-fetches of the same domain SLE in Payment
and OfferCreate. permissioned_dex::accountInDomain keeps its uint256
domainID parameter: it has a defensive pre-fetch check against a
zero-key domain that cannot be replicated once the caller has already
constructed the entry, so changing its signature risked losing that
safety net for a signature-only refactor.

Pure pointer migration: no helper moved onto the wrapper, and
Credential/Offer/Vault SLE pointers are untouched.
@mvadari
mvadari force-pushed the mvadari/rearch/permissioneddomain-entry branch from 200c531 to d4e470a Compare October 5, 2026 12:45

@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 migrating raw PermissionedDomain SLE pointers to the PermissionedDomainEntryR/W wrapper types across all the listed transactors and helpers. I traced every call site change (CredentialHelpers, MPTokenHelpers, PermissionedDEXHelpers, VaultHelpers, OfferCreate, Payment, PermissionedDomainSet/Delete, MPTokenIssuanceSet, VaultCreate, VaultSet, and the test update) against the pre-refactor logic and each one preserves identical read/write semantics, control flow, and error codes — no behavior changes are evident. The documented exception (accountInDomain keeping a raw uint256 param due to the fixCleanup3_2_0 zero-key pre-check) is reasonable and clearly explained. No correctness, security, or consistency issues found in the diff.

@github-actions

Copy link
Copy Markdown

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

…ermissioneddomain-entry

# Conflicts:
#	src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.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.

This is a mechanical, well-scoped refactor migrating raw PermissionedDomain SLE access to the typed PermissionedDomainEntryR/PermissionedDomainEntryW wrappers across transactors and helpers. I traced each call site (CredentialHelpers, MPTokenHelpers, PermissionedDEXHelpers, VaultHelpers, OfferCreate, Payment, LoanSet, PermissionedDomainSet/Delete, MPTokenIssuanceSet, VaultCreate/Set) and the substitutions are consistent with the pre-refactor logic: same checks (!domain -> tecOBJECT_NOT_FOUND/tecNO_ENTRY), same field access patterns, and the same view/journal threading. The one intentionally-preserved exception (accountInDomain keeping a raw domain ID for its zero-key pre-fetch guard) is explained in the description and matches what's in the diff. I did not find any lines where the new entry-based call uses a stale view, swaps argument order, or drops a null-check that existed before. No behavior-changing issues identified.

@github-actions

Copy link
Copy Markdown

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

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

This is a mechanical, well-scoped refactor replacing raw view.read/peek(keylet::permissionedDomain(...)) calls with the typed PermissionedDomainEntryR/PermissionedDomainEntryW wrapper across all the listed transactors and helpers, plus updating credentials::validDomain/verifyValidDomain to take the entry instead of a raw domain ID. I traced every call site (OfferCreate, Payment, PermissionedDomainSet/Delete, VaultCreate/Set, MPTokenIssuanceSet, MPTokenHelpers, VaultHelpers, PermissionedDEXHelpers, LoanSet, and the test update) and the constructor argument order, read/write semantics, and control flow (null checks, update()/insert()/erase() calls, owner-count bookkeeping) all match the pre-refactor behavior exactly — just rerouted through the wrapper. The one intentionally-unchanged signature (accountInDomain keeping uint256) is explained in the PR description and consistent with the diff. I found no logic changes, resource-handling bugs, or missed call sites in the diff provided; this looks like a faithful, low-risk pure refactor.

@github-actions

Copy link
Copy Markdown

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

…ermissioneddomain-entry

# Conflicts:
#	src/libxrpl/tx/transactors/vault/VaultSet.cpp
@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.

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

3 participants