refactor: Remove support for protocol version 2.1 (#7432)

Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Bart
2026-08-14 15:36:47 +00:00
committed by GitHub
parent bd87edfc75
commit 2adffaef72
13 changed files with 114 additions and 437 deletions

View File

@@ -33,22 +33,30 @@ public:
void
run() override
{
testcase("Convert protocol version to string");
BEAST_EXPECT(to_string(makeProtocol(1, 3)) == "XRPL/1.3");
BEAST_EXPECT(to_string(makeProtocol(2, 0)) == "XRPL/2.0");
BEAST_EXPECT(to_string(makeProtocol(2, 1)) == "XRPL/2.1");
BEAST_EXPECT(to_string(makeProtocol(10, 10)) == "XRPL/10.10");
{
testcase("Convert protocol version to string");
BEAST_EXPECT(to_string(makeProtocol(0, 0)) == "XRPL/0.0");
BEAST_EXPECT(to_string(makeProtocol(0, 1)) == "XRPL/0.1");
BEAST_EXPECT(to_string(makeProtocol(1, 3)) == "XRPL/1.3");
BEAST_EXPECT(to_string(makeProtocol(2, 0)) == "XRPL/2.0");
BEAST_EXPECT(to_string(makeProtocol(2, 1)) == "XRPL/2.1");
BEAST_EXPECT(to_string(makeProtocol(10, 10)) == "XRPL/10.10");
BEAST_EXPECT(to_string(makeProtocol(65535, 65535)) == "XRPL/65535.65535");
}
{
testcase("Convert strings to protocol versions");
// Empty string
// Invalid versions, either they do not parse as XRPL/N.M or are unsupported.
check("", "");
check("RTXP/1.1,RTXP/1.2,RTXP/1.3", "");
check("XRPL/-2.1,XRPL/0.3,XRPL/2,XRPL/2.01,websocket", "");
check("RTXP/1.1,RTXP/1.2,RTXP/1.3,XRPL/2.1,XRPL/2.0,/XRPL/3.0", "XRPL/2.0,XRPL/2.1");
check("RTXP/0.9,RTXP/1.01,XRPL/0.3,XRPL/2.01,websocket", "");
// Mixture of valid, duplicate, and invalid versions.
check("RTXP/1.3,XRPL/2.1,XRPL/2.0,/XRPL/3.0", "XRPL/2.0,XRPL/2.1");
check(
"XRPL/2.0,XRPL/2.0,XRPL/19.4,XRPL/7.89,XRPL/XRPL/3.0,XRPL/2.01",
"XRPL/2.0,XRPL/2.0,XRPL/19.4,XRPL/7.89,XRPL/XRPL/3.0,XRPL/2.01,XRPL/-65535.65535",
"XRPL/2.0,XRPL/7.89,XRPL/19.4");
check(
"XRPL/2.0,XRPL/3.0,XRPL/4,XRPL/,XRPL,OPT XRPL/2.2,XRPL/5.67",
@@ -58,15 +66,17 @@ public:
{
testcase("Protocol version negotiation");
BEAST_EXPECT(negotiateProtocolVersion("RTXP/1.2") == std::nullopt);
// Only the highest supported protocol version, if any, is returned.
BEAST_EXPECT(negotiateProtocolVersion("") == std::nullopt);
BEAST_EXPECT(negotiateProtocolVersion("XRPL/0.0") == std::nullopt);
BEAST_EXPECT(negotiateProtocolVersion("RTXP/1.2,XRPL/0.1") == std::nullopt);
BEAST_EXPECT(
negotiateProtocolVersion("RTXP/1.2, XRPL/2.0, XRPL/2.1") == makeProtocol(2, 1));
negotiateProtocolVersion("XRPL/999.999, XRPL/-2.2,WebSocket/1.0") == std::nullopt);
BEAST_EXPECT(negotiateProtocolVersion("XRPL/2.2") == makeProtocol(2, 2));
BEAST_EXPECT(
negotiateProtocolVersion("RTXP/1.2, XRPL/2.3, XRPL/2.4, XRPL/999.999") ==
negotiateProtocolVersion(
"RTXP/1.2, XRPL/2.1, XRPL/2.2, XRPL/2.3, XRPL/2.4, XRPL/999.999") ==
makeProtocol(2, 3));
BEAST_EXPECT(negotiateProtocolVersion("XRPL/999.999, WebSocket/1.0") == std::nullopt);
BEAST_EXPECT(negotiateProtocolVersion("") == std::nullopt);
}
}
};

View File

@@ -292,33 +292,6 @@ public:
return getObject;
}
static std::shared_ptr<protocol::TMValidatorList>
buildValidatorList()
{
auto list = std::make_shared<protocol::TMValidatorList>();
auto master = randomKeyPair(KeyType::Ed25519);
auto signing = randomKeyPair(KeyType::Ed25519);
STObject st(sfGeneric);
st[sfSequence] = 0;
st[sfPublicKey] = std::get<0>(master);
st[sfSigningPubKey] = std::get<0>(signing);
st[sfDomain] = makeSlice(std::string("example.com"));
sign(st, HashPrefix::Manifest, KeyType::Ed25519, std::get<1>(master), sfMasterSignature);
sign(st, HashPrefix::Manifest, KeyType::Ed25519, std::get<1>(signing));
Serializer s;
st.add(s);
list->set_manifest(s.data(), s.size());
list->set_version(3);
STObject const signature(sfSignature);
xrpl::sign(st, HashPrefix::Manifest, KeyType::Ed25519, std::get<1>(signing));
Serializer s1;
st.add(s1);
list->set_signature(s1.data(), s1.size());
list->set_blob(strHex(s.slice()));
return list;
}
static std::shared_ptr<protocol::TMValidatorListCollection>
buildValidatorListCollection()
{
@@ -359,7 +332,6 @@ public:
protocol::TMGetLedger const getLedger;
protocol::TMLedgerData const ledgerData;
protocol::TMGetObjectByHash const getObject;
protocol::TMValidatorList const validatorList;
protocol::TMValidatorListCollection const validatorListCollection;
// 4.5KB
@@ -386,8 +358,6 @@ public:
doTest(buildLedgerData(500000, *logs), protocol::mtLEDGER_DATA, 100, "TMLedgerData500000");
// 7.7KB
doTest(buildGetObjectByHash(), protocol::mtGET_OBJECTS, 4, "TMGetObjectByHash");
// 895B
doTest(buildValidatorList(), protocol::mtVALIDATOR_LIST, 4, "TMValidatorList");
doTest(
buildValidatorListCollection(),
protocol::mtVALIDATOR_LIST_COLLECTION,