refactor: Retire fixMasterKeyAsRegularKey amendment (#5959)

Amendments activated for more than 2 years can be retired. This change retires the fixMasterKeyAsRegularKey amendment.
This commit is contained in:
Jingchen
2025-10-31 21:01:44 +00:00
committed by GitHub
parent ab45a8a737
commit 50fc93f742
6 changed files with 22 additions and 144 deletions

View File

@@ -95,7 +95,6 @@ XRPL_FEATURE(HardenedValidations, Supported::yes, VoteBehavior::DefaultYe
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FIX (PayChanRecipientOwnerDir, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FIX (MasterKeyAsRegularKey, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(MultiSignReserve, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(DepositPreauth, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(Checks, Supported::yes, VoteBehavior::DefaultYes)
@@ -139,6 +138,7 @@ XRPL_RETIRE(fix1623)
XRPL_RETIRE(fix1781)
XRPL_RETIRE(fixAmendmentMajorityCalc)
XRPL_RETIRE(fixCheckThreading)
XRPL_RETIRE(fixMasterKeyAsRegularKey)
XRPL_RETIRE(fixQualityUpperBound)
XRPL_RETIRE(fixReducedOffersV1)
XRPL_RETIRE(fixRmSmallIncreasedQOffers)

View File

@@ -27,52 +27,12 @@ class SetRegularKey_test : public beast::unit_test::suite
{
public:
void
testDisableMasterKey()
testDisabledMasterKey()
{
using namespace test::jtx;
testcase("Set regular key");
Env env{*this, testable_amendments() - fixMasterKeyAsRegularKey};
Account const alice("alice");
Account const bob("bob");
env.fund(XRP(10000), alice, bob);
env(regkey(alice, bob));
auto const ar = env.le(alice);
BEAST_EXPECT(
ar->isFieldPresent(sfRegularKey) &&
(ar->getAccountID(sfRegularKey) == bob.id()));
env(noop(alice), sig(bob));
env(noop(alice), sig(alice));
testcase("Disable master key");
env(fset(alice, asfDisableMaster), sig(alice));
env(noop(alice), sig(bob));
env(noop(alice), sig(alice), ter(tefMASTER_DISABLED));
testcase("Re-enable master key");
env(fclear(alice, asfDisableMaster),
sig(alice),
ter(tefMASTER_DISABLED));
env(fclear(alice, asfDisableMaster), sig(bob));
env(noop(alice), sig(bob));
env(noop(alice), sig(alice));
testcase("Revoke regular key");
env(regkey(alice, disabled));
env(noop(alice), sig(bob), ter(tefBAD_AUTH_MASTER));
env(noop(alice), sig(alice));
}
void
testDisableMasterKeyAfterFix()
{
using namespace test::jtx;
testcase("Set regular key");
Env env{*this, testable_amendments() | fixMasterKeyAsRegularKey};
Env env{*this, testable_amendments()};
Account const alice("alice");
Account const bob("bob");
env.fund(XRP(10000), alice, bob);
@@ -106,44 +66,11 @@ public:
{
using namespace test::jtx;
// See https://ripplelabs.atlassian.net/browse/RIPD-1721.
testcase(
"Set regular key to master key (before fixMasterKeyAsRegularKey)");
Env env{*this, testable_amendments() - fixMasterKeyAsRegularKey};
testcase("Set regular key to master key");
Env env{*this, testable_amendments()};
Account const alice("alice");
env.fund(XRP(10000), alice);
// Must be possible unless amendment `fixMasterKeyAsRegularKey` enabled.
env(regkey(alice, alice), sig(alice));
env(fset(alice, asfDisableMaster), sig(alice));
// No way to sign...
env(noop(alice), ter(tefMASTER_DISABLED));
env(noop(alice), sig(alice), ter(tefMASTER_DISABLED));
// ... until now.
env.enableFeature(fixMasterKeyAsRegularKey);
env(noop(alice));
env(noop(alice), sig(alice));
env(regkey(alice, disabled), ter(tecNO_ALTERNATIVE_KEY));
env(fclear(alice, asfDisableMaster));
env(regkey(alice, disabled));
env(fset(alice, asfDisableMaster), ter(tecNO_ALTERNATIVE_KEY));
}
void
testDisableRegularKeyAfterFix()
{
using namespace test::jtx;
testcase(
"Set regular key to master key (after fixMasterKeyAsRegularKey)");
Env env{*this, testable_amendments() | fixMasterKeyAsRegularKey};
Account const alice("alice");
env.fund(XRP(10000), alice);
// Must be possible unless amendment `fixMasterKeyAsRegularKey` enabled.
env(regkey(alice, alice), ter(temBAD_REGKEY));
}
@@ -253,10 +180,8 @@ public:
void
run() override
{
testDisableMasterKey();
testDisableMasterKeyAfterFix();
testDisabledMasterKey();
testDisabledRegularKey();
testDisableRegularKeyAfterFix();
testPasswordSpent();
testUniversalMask();
testTicketRegularKey();

View File

@@ -265,7 +265,7 @@ public:
{
using namespace jtx;
Env env{*this, testable_amendments() | fixMasterKeyAsRegularKey};
Env env{*this, testable_amendments()};
Account const alice("alice", KeyType::ed25519);
Account const bob("bob", KeyType::secp256k1);
Account const carol("carol");

View File

@@ -332,23 +332,6 @@ class Feature_test : public beast::unit_test::suite
result[jss::error_message] ==
"You don't have permission for this command.");
}
{
std::string const feature =
"C4483A1896170C66C098DEA5B0E024309C60DC960DE5F01CD7AF986AA3D9AD"
"37";
Json::Value params;
params[jss::feature] = feature;
auto const result =
env.rpc("json", "feature", to_string(params))[jss::result];
BEAST_EXPECT(result.isMember(feature));
auto const amendmentResult = result[feature];
BEAST_EXPECT(amendmentResult[jss::enabled].asBool() == false);
BEAST_EXPECT(amendmentResult[jss::supported].asBool() == true);
BEAST_EXPECT(
amendmentResult[jss::name].asString() ==
"fixMasterKeyAsRegularKey");
}
}
void

View File

@@ -51,8 +51,7 @@ SetRegularKey::calculateBaseFee(ReadView const& view, STTx const& tx)
NotTEC
SetRegularKey::preflight(PreflightContext const& ctx)
{
if (ctx.rules.enabled(fixMasterKeyAsRegularKey) &&
ctx.tx.isFieldPresent(sfRegularKey) &&
if (ctx.tx.isFieldPresent(sfRegularKey) &&
(ctx.tx.getAccountID(sfRegularKey) == ctx.tx.getAccountID(sfAccount)))
{
return temBAD_REGKEY;

View File

@@ -788,55 +788,26 @@ Transactor::checkSingleSign(
{
bool const isMasterDisabled = sleAccount->isFlag(lsfDisableMaster);
if (view.rules().enabled(fixMasterKeyAsRegularKey))
// Signed with regular key.
if ((*sleAccount)[~sfRegularKey] == idSigner)
{
// Signed with regular key.
if ((*sleAccount)[~sfRegularKey] == idSigner)
{
return tesSUCCESS;
}
// Signed with enabled mater key.
if (!isMasterDisabled && idAccount == idSigner)
{
return tesSUCCESS;
}
// Signed with disabled master key.
if (isMasterDisabled && idAccount == idSigner)
{
return tefMASTER_DISABLED;
}
// Signed with any other key.
return tefBAD_AUTH;
return tesSUCCESS;
}
if (idSigner == idAccount)
// Signed with enabled master key.
if (!isMasterDisabled && idAccount == idSigner)
{
// Signing with the master key. Continue if it is not disabled.
if (isMasterDisabled)
return tefMASTER_DISABLED;
}
else if ((*sleAccount)[~sfRegularKey] == idSigner)
{
// Signing with the regular key. Continue.
}
else if (sleAccount->isFieldPresent(sfRegularKey))
{
// Signing key does not match master or regular key.
JLOG(j.trace()) << "checkSingleSign: Not authorized to use account.";
return tefBAD_AUTH;
}
else
{
// No regular key on account and signing key does not match master key.
// FIXME: Why differentiate this case from tefBAD_AUTH?
JLOG(j.trace()) << "checkSingleSign: Not authorized to use account.";
return tefBAD_AUTH_MASTER;
return tesSUCCESS;
}
return tesSUCCESS;
// Signed with disabled master key.
if (isMasterDisabled && idAccount == idSigner)
{
return tefMASTER_DISABLED;
}
// Signed with any other key.
return tefBAD_AUTH;
}
NotTEC