Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow creating PDs if credentials are not enabled #5275

Conversation

Bronek
Copy link
Collaborator

@Bronek Bronek commented Feb 4, 2025

High Level Overview of Change

This solves the problem of permissioned domains dependency on credentials.

Context of Change

If the permissioned domains amendment XLS-80 were enabled before credentials XLS-70, then the permissioned domain users will not be able to match any credentials, i.e. the amendment will be useless. The simplest solution, proposed in this PR, is to prevent creation of any PD objects if credentials are not enabled.

Similarly, amendments which depend on permissioned domains (e.g. single asset vault) will have to check if permissioned domain amendment XLS-80 is enabled, and act accordingly. This is similar in spirit to how we handle addition of new optional fields to existing transactions, returning temDISABLED if the newly added features wanted by the transaction are not enabled.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

@Bronek Bronek requested review from mvadari and oleks-rip February 4, 2025 12:50
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.2%. Comparing base (d9e4009) to head (cce6ead).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5275     +/-   ##
=========================================
- Coverage     78.2%   78.2%   -0.0%     
=========================================
  Files          790     790             
  Lines        67619   67623      +4     
  Branches      8161    8163      +2     
=========================================
  Hits         52848   52848             
- Misses       14771   14775      +4     
Files with missing lines Coverage Δ
src/xrpld/app/tx/detail/PermissionedDomainSet.cpp 100.0% <100.0%> (ø)

... and 4 files with indirect coverage changes

Impacted file tree graph

env.fund(XRP(1000), alice);
pdomain::Credentials credentials{{alice, "first credential"}};
env(pdomain::setTx(alice, credentials), ter(temDISABLED));
env(pdomain::deleteTx(alice, uint256(75)), ter(tecNO_ENTRY));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this also be temDISABLED?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. The change is meant to prevent creation of PDs (if credentials cannot be used). If a PD cannot be created, then an obvious error on trying to do anything with it is tecNO_ENTRY. I do not insist this is best, but the idea is to keep coupling between different amendments to minimum - if we chose a different pattern (check every single transaction type) then I feel we might fall into ambiguities.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So your argument is that you can't create a PD because it requires credentials, but technically if PDs had other rules those would still be allowed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes - if hypothetically PD could make sense without referring to credentials (because e.g. it would refer to something else) then I think we should be able to create it; which makes me think I ought to change the check to

PermissionedDomainSet::preflight(PreflightContext const& ctx)
{
    if (!ctx.rules.enabled(featurePermissionedDomains))
        return temDISABLED;

    if (ctx.tx.isFieldPresent(sfAcceptedCredentials) &&
        !ctx.rules.enabled(featureCredentials))
        return temDISABLED;

what do you think ? This looks a bit strange, given that sfAcceptedCredentials is a required field

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that's sort of unnecessary and if we happen to make sfAcceptedCredentials optional we can make that change then.

@@ -77,6 +78,22 @@ class PermissionedDomains_test : public beast::unit_test::suite
env(pdomain::deleteTx(alice, domain));
}

// Verify that PD cannot be created or updated if credentials are disabled
void
testCredentialsDisabled()
Copy link
Collaborator

@mvadari mvadari Feb 5, 2025

Choose a reason for hiding this comment

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

nit: would prefer if this was a part of testDisabled instead of separate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the reason why this is separate is because the normal test pattern is to use one FeatureBitset per test (or per test run). I like sticking to patterns, makes things more predictable.

@mvadari mvadari added this to the 2.4.0 (Feb 2025) milestone Feb 5, 2025
Copy link
Collaborator

@oleks-rip oleks-rip left a comment

Choose a reason for hiding this comment

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

lgtm

@mvadari mvadari added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Feb 7, 2025
@bthomee bthomee merged commit 0968cdf into XRPLF:develop Feb 7, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants