Skip to content

Commit

Permalink
fix: Do not allow creating Permissioned Domains if credentials are no…
Browse files Browse the repository at this point in the history
…t enabled (#5275)

If the permissioned domains amendment XLS-80 is enabled before credentials XLS-70, then the permissioned domain users will not be able to match any credentials. The changes here prevent the creation of any permissioned domain objects if credentials are not enabled.
  • Loading branch information
Bronek authored Feb 7, 2025
1 parent d9e4009 commit 0968cdf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/test/app/PermissionedDomains_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ exceptionExpected(Env& env, Json::Value const& jv)

class PermissionedDomains_test : public beast::unit_test::suite
{
FeatureBitset withFeature_{
supported_amendments() | featurePermissionedDomains};
FeatureBitset withoutFeature_{supported_amendments()};
FeatureBitset withFeature_{
supported_amendments() //
| featurePermissionedDomains | featureCredentials};

// Verify that each tx type can execute if the feature is enabled.
void
Expand All @@ -77,6 +78,21 @@ 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()
{
auto amendments = supported_amendments();
amendments.set(featurePermissionedDomains);
amendments.reset(featureCredentials);
testcase("Credentials disabled");
Account const alice("alice");
Env env(*this, amendments);
env.fund(XRP(1000), alice);
pdomain::Credentials credentials{{alice, "first credential"}};
env(pdomain::setTx(alice, credentials), ter(temDISABLED));
}

// Verify that each tx does not execute if feature is disabled
void
testDisabled()
Expand Down Expand Up @@ -556,6 +572,7 @@ class PermissionedDomains_test : public beast::unit_test::suite
run() override
{
testEnabled();
testCredentialsDisabled();
testDisabled();
testSet();
testDelete();
Expand Down
4 changes: 3 additions & 1 deletion src/xrpld/app/tx/detail/PermissionedDomainSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ namespace ripple {
NotTEC
PermissionedDomainSet::preflight(PreflightContext const& ctx)
{
if (!ctx.rules.enabled(featurePermissionedDomains))
if (!ctx.rules.enabled(featurePermissionedDomains) ||
!ctx.rules.enabled(featureCredentials))
return temDISABLED;

if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;

Expand Down

0 comments on commit 0968cdf

Please sign in to comment.