mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-04 01:06:48 +00:00
Implement negative UNL functionality:
This change can help improve the liveness of the network during periods of network instability, by allowing the network to track which validators are presently not online and to disregard them for the purposes of quorum calculations.
This commit is contained in:
@@ -134,6 +134,39 @@ public:
|
||||
auto const jrr = env.rpc("validator_list_sites")[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::validator_sites].size() == 0);
|
||||
}
|
||||
// Negative UNL empty
|
||||
{
|
||||
auto const jrr = env.rpc("validators")[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::NegativeUNL].isNull());
|
||||
}
|
||||
// Negative UNL update
|
||||
{
|
||||
hash_set<PublicKey> disabledKeys;
|
||||
auto k1 = randomKeyPair(KeyType::ed25519).first;
|
||||
auto k2 = randomKeyPair(KeyType::ed25519).first;
|
||||
disabledKeys.insert(k1);
|
||||
disabledKeys.insert(k2);
|
||||
env.app().validators().setNegativeUnl(disabledKeys);
|
||||
|
||||
auto const jrr = env.rpc("validators")[jss::result];
|
||||
auto& jrrnUnl = jrr[jss::NegativeUNL];
|
||||
auto jrrnUnlSize = jrrnUnl.size();
|
||||
BEAST_EXPECT(jrrnUnlSize == 2);
|
||||
for (std::uint32_t x = 0; x < jrrnUnlSize; ++x)
|
||||
{
|
||||
auto parsedKey = parseBase58<PublicKey>(
|
||||
TokenType::NodePublic, jrrnUnl[x].asString());
|
||||
BEAST_EXPECT(parsedKey);
|
||||
if (parsedKey)
|
||||
BEAST_EXPECT(
|
||||
disabledKeys.find(*parsedKey) != disabledKeys.end());
|
||||
}
|
||||
|
||||
disabledKeys.clear();
|
||||
env.app().validators().setNegativeUnl(disabledKeys);
|
||||
auto const jrrUpdated = env.rpc("validators")[jss::result];
|
||||
BEAST_EXPECT(jrrUpdated[jss::NegativeUNL].isNull());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user