feat: Remove pseudo account field filter - #8042
Conversation
There was a problem hiding this comment.
Clean, behavior-preserving simplification of isPseudoAccount: drops the now-redundant filter parameter and switches to std::ranges::any_of. All three migrated call sites pass the same field set that was previously hardcoded, so semantics are preserved. No issues found on the changed lines.
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.
Clean, well-scoped refactor that collapses isPseudoAccount to a single no-filter overload and updates the three internal call sites to match. The filter previously passed at each call site ({&sfVaultID, &sfLoanBrokerID, &sfAMMID}) is exactly equal to getPseudoAccountFields(), so the migration is behavior-preserving as described. The std::count_if > 0 -> std::ranges::any_of simplification is a correct, equivalent transformation and matches existing codebase style. No security, correctness, or resource issues found in the changed lines.
High Level Overview of Change
Collapse
isPseudoAccountto a single no-filter function and migrate the internal call sites.API change
bool isPseudoAccount(SLE::const_pointer sleAcct)now returns true iffsleAcctis anltACCOUNT_ROOTand carries at least one field flagged withSField::kSmdPseudoAccount.Migrations (behaviour-preserving)
MPTokenHelpers::requireAuth- pseudo-account exemption uses the no-filter check.MPTokenAuthorize::preclaim- refuses to (un)authorize a pseudo-account holder via the no-filter check.MPTInvariant::ValidMPTTransfer::isAuthorized- pseudo-account exemption uses the no-filter check.Simpler
any_ofThe implementation moves from
std::count_if(...) > 0tostd::ranges::any_of(...), matching the style used elsewhere in the codebase (MPTokenHelpers,PermissionedDEXHelpers,TokenHelpers, etc).Context of Change
isPseudoAccountchecks whether anACCOUNT_ROOTSLE is a pseudo-account. It has offered two overloads:std::set<SField const*>filter to restrict the match to specific pseudo-account designator fields;Auditing every internal call site of the filter-taking overload showed that all three callers passed the complete set of pseudo-account designator fields:
MPTokenHelpers.cpp- MPTrequireAuthexemptionMPTokenAuthorize.cpp- rejectMPTokenAuthorizetargeting a pseudo-accountMPTInvariant.cpp- invariant-check exemptionThe set
{&sfVaultID, &sfLoanBrokerID, &sfAMMID}they passed is exactly the value returned bygetPseudoAccountFields(), so passing the filter was behaviourally equivalent to passing no filter. The filter overload therefore added an API surface with no internal justification and a subtle forward-compatibility hazard: if a new pseudo-account designator field is introduced later (a newSFieldflagged withSField::kSmdPseudoAccount), any hardcoded filter list would silently miss it, whereas the no-filter form derives its check directly fromgetPseudoAccountFields()and picks up new types automatically.API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)