Skip to content

Commit ca07176

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into pr/getledger
* upstream/develop: fix: Amendment to add transaction flag checking functionality for Credentials (5250) fix: Omit superfluous setCurrentThreadName call in GRPCServer.cpp (5280)
2 parents 829e4f1 + fa5a854 commit ca07176

File tree

7 files changed

+99
-2
lines changed

7 files changed

+99
-2
lines changed

include/xrpl/protocol/Feature.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace detail {
8080
// Feature.cpp. Because it's only used to reserve storage, and determine how
8181
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
8282
// the actual number of amendments. A LogicError on startup will verify this.
83-
static constexpr std::size_t numFeatures = 87;
83+
static constexpr std::size_t numFeatures = 88;
8484

8585
/** Amendments that this server supports and the default voting behavior.
8686
Whether they are enabled depends on the Rules defined in the validated

include/xrpl/protocol/detail/features.macro

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
// If you add an amendment here, then do not forget to increment `numFeatures`
3030
// in include/xrpl/protocol/Feature.h.
3131

32+
// Check flags in Credential transactions
33+
XRPL_FIX (InvalidTxFlags, Supported::yes, VoteBehavior::DefaultNo)
3234
XRPL_FIX (FrozenLPTokenTransfer, Supported::yes, VoteBehavior::DefaultNo)
3335
XRPL_FEATURE(DeepFreeze, Supported::yes, VoteBehavior::DefaultNo)
3436
XRPL_FEATURE(PermissionedDomains, Supported::no, VoteBehavior::DefaultNo)

src/test/app/Credentials_test.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,43 @@ struct Credentials_test : public beast::unit_test::suite
10581058
}
10591059
}
10601060

1061+
void
1062+
testFlags(FeatureBitset features)
1063+
{
1064+
using namespace test::jtx;
1065+
1066+
bool const enabled = features[fixInvalidTxFlags];
1067+
testcase(
1068+
std::string("Test flag, fix ") +
1069+
(enabled ? "enabled" : "disabled"));
1070+
1071+
const char credType[] = "abcde";
1072+
Account const issuer{"issuer"};
1073+
Account const subject{"subject"};
1074+
1075+
{
1076+
using namespace jtx;
1077+
Env env{*this, features};
1078+
1079+
env.fund(XRP(5000), subject, issuer);
1080+
env.close();
1081+
1082+
{
1083+
ter const expected(
1084+
enabled ? TER(temINVALID_FLAG) : TER(tesSUCCESS));
1085+
env(credentials::create(subject, issuer, credType),
1086+
txflags(tfTransferable),
1087+
expected);
1088+
env(credentials::accept(subject, issuer, credType),
1089+
txflags(tfSellNFToken),
1090+
expected);
1091+
env(credentials::deleteCred(subject, subject, issuer, credType),
1092+
txflags(tfPassive),
1093+
expected);
1094+
}
1095+
}
1096+
}
1097+
10611098
void
10621099
run() override
10631100
{
@@ -1069,6 +1106,8 @@ struct Credentials_test : public beast::unit_test::suite
10691106
testAcceptFailed(all);
10701107
testDeleteFailed(all);
10711108
testFeatureFailed(all - featureCredentials);
1109+
testFlags(all - fixInvalidTxFlags);
1110+
testFlags(all);
10721111
testRPC();
10731112
}
10741113
};

src/test/app/MultiSign_test.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,29 @@ class MultiSign_test : public beast::unit_test::suite
16721672
BEAST_EXPECT(env.seq(alice) == aliceSeq + 1);
16731673
}
16741674

1675+
void
1676+
test_signerListSetFlags(FeatureBitset features)
1677+
{
1678+
using namespace test::jtx;
1679+
1680+
Env env{*this, features};
1681+
Account const alice{"alice"};
1682+
1683+
env.fund(XRP(1000), alice);
1684+
env.close();
1685+
1686+
bool const enabled = features[fixInvalidTxFlags];
1687+
testcase(
1688+
std::string("SignerListSet flag, fix ") +
1689+
(enabled ? "enabled" : "disabled"));
1690+
1691+
ter const expected(enabled ? TER(temINVALID_FLAG) : TER(tesSUCCESS));
1692+
env(signers(alice, 2, {{bogie, 1}, {ghost, 1}}),
1693+
expected,
1694+
txflags(tfPassive));
1695+
env.close();
1696+
}
1697+
16751698
void
16761699
testAll(FeatureBitset features)
16771700
{
@@ -1708,6 +1731,10 @@ class MultiSign_test : public beast::unit_test::suite
17081731
testAll(all - featureMultiSignReserve - featureExpandedSignerList);
17091732
testAll(all - featureExpandedSignerList);
17101733
testAll(all);
1734+
1735+
test_signerListSetFlags(all - fixInvalidTxFlags);
1736+
test_signerListSetFlags(all);
1737+
17111738
test_amendmentTransition();
17121739
}
17131740
};

src/xrpld/app/main/GRPCServer.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ GRPCServer::start()
599599
if (running_ = impl_.start(); running_)
600600
{
601601
thread_ = std::thread([this]() {
602-
beast::setCurrentThreadName("rippled : GRPCServer");
603602
// Start the event loop and begin handling requests
604603
beast::setCurrentThreadName("rippled: grpc");
605604
this->impl_.handleRpcs();

src/xrpld/app/tx/detail/Credentials.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ CredentialCreate::preflight(PreflightContext const& ctx)
6565
auto const& tx = ctx.tx;
6666
auto& j = ctx.j;
6767

68+
if (ctx.rules.enabled(fixInvalidTxFlags) &&
69+
(tx.getFlags() & tfUniversalMask))
70+
{
71+
JLOG(ctx.j.debug()) << "CredentialCreate: invalid flags.";
72+
return temINVALID_FLAG;
73+
}
74+
6875
if (!tx[sfSubject])
6976
{
7077
JLOG(j.trace()) << "Malformed transaction: Invalid Subject";
@@ -209,6 +216,13 @@ CredentialDelete::preflight(PreflightContext const& ctx)
209216
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
210217
return ret;
211218

219+
if (ctx.rules.enabled(fixInvalidTxFlags) &&
220+
(ctx.tx.getFlags() & tfUniversalMask))
221+
{
222+
JLOG(ctx.j.debug()) << "CredentialDelete: invalid flags.";
223+
return temINVALID_FLAG;
224+
}
225+
212226
auto const subject = ctx.tx[~sfSubject];
213227
auto const issuer = ctx.tx[~sfIssuer];
214228

@@ -289,6 +303,13 @@ CredentialAccept::preflight(PreflightContext const& ctx)
289303
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
290304
return ret;
291305

306+
if (ctx.rules.enabled(fixInvalidTxFlags) &&
307+
(ctx.tx.getFlags() & tfUniversalMask))
308+
{
309+
JLOG(ctx.j.debug()) << "CredentialAccept: invalid flags.";
310+
return temINVALID_FLAG;
311+
}
312+
292313
if (!ctx.tx[sfIssuer])
293314
{
294315
JLOG(ctx.j.trace()) << "Malformed transaction: Issuer field zeroed.";

src/xrpld/app/tx/detail/SetSignerList.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <xrpl/protocol/STArray.h>
2828
#include <xrpl/protocol/STObject.h>
2929
#include <xrpl/protocol/STTx.h>
30+
#include <xrpl/protocol/TxFlags.h>
31+
3032
#include <algorithm>
3133
#include <cstdint>
3234

@@ -81,6 +83,13 @@ SetSignerList::preflight(PreflightContext const& ctx)
8183
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
8284
return ret;
8385

86+
if (ctx.rules.enabled(fixInvalidTxFlags) &&
87+
(ctx.tx.getFlags() & tfUniversalMask))
88+
{
89+
JLOG(ctx.j.debug()) << "SetSignerList: invalid flags.";
90+
return temINVALID_FLAG;
91+
}
92+
8493
auto const result = determineOperation(ctx.tx, ctx.flags, ctx.j);
8594

8695
if (std::get<0>(result) != tesSUCCESS)

0 commit comments

Comments
 (0)