Improve naming of fields associated with the NegativeUNL

This commit is contained in:
Peng Wang
2020-08-03 00:02:45 -04:00
committed by Nik Bougalis
parent 72a9a2bdbb
commit 12c0e8148b
19 changed files with 201 additions and 194 deletions

View File

@@ -600,13 +600,13 @@ Ledger::peek(Keylet const& k) const
} }
hash_set<PublicKey> hash_set<PublicKey>
Ledger::negativeUnl() const Ledger::negativeUNL() const
{ {
hash_set<PublicKey> negUnl; hash_set<PublicKey> negUnl;
if (auto sle = read(keylet::negativeUNL()); if (auto sle = read(keylet::negativeUNL());
sle && sle->isFieldPresent(sfNegativeUNL)) sle && sle->isFieldPresent(sfDisabledValidators))
{ {
auto const& nUnlData = sle->getFieldArray(sfNegativeUNL); auto const& nUnlData = sle->getFieldArray(sfDisabledValidators);
for (auto const& n : nUnlData) for (auto const& n : nUnlData)
{ {
if (n.isFieldPresent(sfPublicKey)) if (n.isFieldPresent(sfPublicKey))
@@ -626,12 +626,12 @@ Ledger::negativeUnl() const
} }
boost::optional<PublicKey> boost::optional<PublicKey>
Ledger::negativeUnlToDisable() const Ledger::validatorToDisable() const
{ {
if (auto sle = read(keylet::negativeUNL()); if (auto sle = read(keylet::negativeUNL());
sle && sle->isFieldPresent(sfNegativeUNLToDisable)) sle && sle->isFieldPresent(sfValidatorToDisable))
{ {
auto d = sle->getFieldVL(sfNegativeUNLToDisable); auto d = sle->getFieldVL(sfValidatorToDisable);
auto s = makeSlice(d); auto s = makeSlice(d);
if (publicKeyType(s)) if (publicKeyType(s))
return PublicKey(s); return PublicKey(s);
@@ -641,12 +641,12 @@ Ledger::negativeUnlToDisable() const
} }
boost::optional<PublicKey> boost::optional<PublicKey>
Ledger::negativeUnlToReEnable() const Ledger::validatorToReEnable() const
{ {
if (auto sle = read(keylet::negativeUNL()); if (auto sle = read(keylet::negativeUNL());
sle && sle->isFieldPresent(sfNegativeUNLToReEnable)) sle && sle->isFieldPresent(sfValidatorToReEnable))
{ {
auto d = sle->getFieldVL(sfNegativeUNLToReEnable); auto d = sle->getFieldVL(sfValidatorToReEnable);
auto s = makeSlice(d); auto s = makeSlice(d);
if (publicKeyType(s)) if (publicKeyType(s))
return PublicKey(s); return PublicKey(s);
@@ -662,21 +662,21 @@ Ledger::updateNegativeUNL()
if (!sle) if (!sle)
return; return;
bool const hasToDisable = sle->isFieldPresent(sfNegativeUNLToDisable); bool const hasToDisable = sle->isFieldPresent(sfValidatorToDisable);
bool const hasToReEnable = sle->isFieldPresent(sfNegativeUNLToReEnable); bool const hasToReEnable = sle->isFieldPresent(sfValidatorToReEnable);
if (!hasToDisable && !hasToReEnable) if (!hasToDisable && !hasToReEnable)
return; return;
STArray newNUnl; STArray newNUnl;
if (sle->isFieldPresent(sfNegativeUNL)) if (sle->isFieldPresent(sfDisabledValidators))
{ {
auto const& oldNUnl = sle->getFieldArray(sfNegativeUNL); auto const& oldNUnl = sle->getFieldArray(sfDisabledValidators);
for (auto v : oldNUnl) for (auto v : oldNUnl)
{ {
if (hasToReEnable && v.isFieldPresent(sfPublicKey) && if (hasToReEnable && v.isFieldPresent(sfPublicKey) &&
v.getFieldVL(sfPublicKey) == v.getFieldVL(sfPublicKey) ==
sle->getFieldVL(sfNegativeUNLToReEnable)) sle->getFieldVL(sfValidatorToReEnable))
continue; continue;
newNUnl.push_back(v); newNUnl.push_back(v);
} }
@@ -684,19 +684,19 @@ Ledger::updateNegativeUNL()
if (hasToDisable) if (hasToDisable)
{ {
newNUnl.emplace_back(sfNegativeUNLEntry); newNUnl.emplace_back(sfDisabledValidator);
newNUnl.back().setFieldVL( newNUnl.back().setFieldVL(
sfPublicKey, sle->getFieldVL(sfNegativeUNLToDisable)); sfPublicKey, sle->getFieldVL(sfValidatorToDisable));
newNUnl.back().setFieldU32(sfFirstLedgerSequence, seq()); newNUnl.back().setFieldU32(sfFirstLedgerSequence, seq());
} }
if (!newNUnl.empty()) if (!newNUnl.empty())
{ {
sle->setFieldArray(sfNegativeUNL, newNUnl); sle->setFieldArray(sfDisabledValidators, newNUnl);
if (hasToReEnable) if (hasToReEnable)
sle->makeFieldAbsent(sfNegativeUNLToReEnable); sle->makeFieldAbsent(sfValidatorToReEnable);
if (hasToDisable) if (hasToDisable)
sle->makeFieldAbsent(sfNegativeUNLToDisable); sle->makeFieldAbsent(sfValidatorToDisable);
rawReplace(sle); rawReplace(sle);
} }
else else

View File

@@ -335,7 +335,7 @@ public:
* @return the public keys * @return the public keys
*/ */
hash_set<PublicKey> hash_set<PublicKey>
negativeUnl() const; negativeUNL() const;
/** /**
* get the to be disabled validator's master public key if any * get the to be disabled validator's master public key if any
@@ -343,7 +343,7 @@ public:
* @return the public key if any * @return the public key if any
*/ */
boost::optional<PublicKey> boost::optional<PublicKey>
negativeUnlToDisable() const; validatorToDisable() const;
/** /**
* get the to be re-enabled validator's master public key if any * get the to be re-enabled validator's master public key if any
@@ -351,7 +351,7 @@ public:
* @return the public key if any * @return the public key if any
*/ */
boost::optional<PublicKey> boost::optional<PublicKey>
negativeUnlToReEnable() const; validatorToReEnable() const;
/** /**
* update the Negative UNL ledger component. * update the Negative UNL ledger component.

View File

@@ -57,9 +57,9 @@ NegativeUNLVote::doVoting(
buildScoreTable(prevLedger, unlNodeIDs, validations)) buildScoreTable(prevLedger, unlNodeIDs, validations))
{ {
// build next negUnl // build next negUnl
auto negUnlKeys = prevLedger->negativeUnl(); auto negUnlKeys = prevLedger->negativeUNL();
auto negUnlToDisable = prevLedger->negativeUnlToDisable(); auto negUnlToDisable = prevLedger->validatorToDisable();
auto negUnlToReEnable = prevLedger->negativeUnlToReEnable(); auto negUnlToReEnable = prevLedger->validatorToReEnable();
if (negUnlToDisable) if (negUnlToDisable)
negUnlKeys.insert(*negUnlToDisable); negUnlKeys.insert(*negUnlToDisable);
if (negUnlToReEnable) if (negUnlToReEnable)
@@ -211,7 +211,7 @@ NegativeUNLVote::buildScoreTable(
return it->second; return it->second;
return 0; return 0;
}(); }();
if (myValidationCount < negativeUnlMinLocalValsToVote) if (myValidationCount < negativeUNLMinLocalValsToVote)
{ {
JLOG(j_.debug()) << "N-UNL: ledger " << seq JLOG(j_.debug()) << "N-UNL: ledger " << seq
<< ". Local node only issued " << myValidationCount << ". Local node only issued " << myValidationCount
@@ -221,7 +221,7 @@ NegativeUNLVote::buildScoreTable(
return {}; return {};
} }
else if ( else if (
myValidationCount > negativeUnlMinLocalValsToVote && myValidationCount > negativeUNLMinLocalValsToVote &&
myValidationCount <= FLAG_LEDGER_INTERVAL) myValidationCount <= FLAG_LEDGER_INTERVAL)
{ {
return scoreTable; return scoreTable;
@@ -246,7 +246,7 @@ NegativeUNLVote::findAllCandidates(
// Compute if need to find more validators to disable // Compute if need to find more validators to disable
auto const canAdd = [&]() -> bool { auto const canAdd = [&]() -> bool {
auto const maxNegativeListed = static_cast<std::size_t>( auto const maxNegativeListed = static_cast<std::size_t>(
std::ceil(unl.size() * negativeUnlMaxListed)); std::ceil(unl.size() * negativeUNLMaxListed));
std::size_t negativeListed = 0; std::size_t negativeListed = 0;
for (auto const& n : unl) for (auto const& n : unl)
{ {
@@ -255,8 +255,8 @@ NegativeUNLVote::findAllCandidates(
} }
bool const result = negativeListed < maxNegativeListed; bool const result = negativeListed < maxNegativeListed;
JLOG(j_.trace()) << "N-UNL: nodeId " << myId_ << " lowWaterMark " JLOG(j_.trace()) << "N-UNL: nodeId " << myId_ << " lowWaterMark "
<< negativeUnlLowWaterMark << " highWaterMark " << negativeUNLLowWaterMark << " highWaterMark "
<< negativeUnlHighWaterMark << " canAdd " << result << negativeUNLHighWaterMark << " canAdd " << result
<< " negativeListed " << negativeListed << " negativeListed " << negativeListed
<< " maxNegativeListed " << maxNegativeListed; << " maxNegativeListed " << maxNegativeListed;
return result; return result;
@@ -269,10 +269,10 @@ NegativeUNLVote::findAllCandidates(
// Find toDisable Candidates: check if // Find toDisable Candidates: check if
// (1) canAdd, // (1) canAdd,
// (2) has less than negativeUnlLowWaterMark validations, // (2) has less than negativeUNLLowWaterMark validations,
// (3) is not in negUnl, and // (3) is not in negUnl, and
// (4) is not a new validator. // (4) is not a new validator.
if (canAdd && score < negativeUnlLowWaterMark && if (canAdd && score < negativeUNLLowWaterMark &&
!negUnl.count(nodeId) && !newValidators_.count(nodeId)) !negUnl.count(nodeId) && !newValidators_.count(nodeId))
{ {
JLOG(j_.trace()) << "N-UNL: toDisable candidate " << nodeId; JLOG(j_.trace()) << "N-UNL: toDisable candidate " << nodeId;
@@ -280,9 +280,9 @@ NegativeUNLVote::findAllCandidates(
} }
// Find toReEnable Candidates: check if // Find toReEnable Candidates: check if
// (1) has more than negativeUnlHighWaterMark validations, // (1) has more than negativeUNLHighWaterMark validations,
// (2) is in negUnl // (2) is in negUnl
if (score > negativeUnlHighWaterMark && negUnl.count(nodeId)) if (score > negativeUNLHighWaterMark && negUnl.count(nodeId))
{ {
JLOG(j_.trace()) << "N-UNL: toReEnable candidate " << nodeId; JLOG(j_.trace()) << "N-UNL: toReEnable candidate " << nodeId;
candidates.toReEnableCandidates.push_back(nodeId); candidates.toReEnableCandidates.push_back(nodeId);

View File

@@ -48,23 +48,23 @@ class NegativeUNLVote final
public: public:
/** /**
* A validator is considered unreliable if its validations is less than * A validator is considered unreliable if its validations is less than
* negativeUnlLowWaterMark in the last flag ledger period. * negativeUNLLowWaterMark in the last flag ledger period.
* An unreliable validator is a candidate to be disabled by the NegativeUNL * An unreliable validator is a candidate to be disabled by the NegativeUNL
* protocol. * protocol.
*/ */
static constexpr size_t negativeUnlLowWaterMark = static constexpr size_t negativeUNLLowWaterMark =
FLAG_LEDGER_INTERVAL * 50 / 100; FLAG_LEDGER_INTERVAL * 50 / 100;
/** /**
* An unreliable validator must have more than negativeUnlHighWaterMark * An unreliable validator must have more than negativeUNLHighWaterMark
* validations in the last flag ledger period to be re-enabled. * validations in the last flag ledger period to be re-enabled.
*/ */
static constexpr size_t negativeUnlHighWaterMark = static constexpr size_t negativeUNLHighWaterMark =
FLAG_LEDGER_INTERVAL * 80 / 100; FLAG_LEDGER_INTERVAL * 80 / 100;
/** /**
* The minimum number of validations of the local node for it to * The minimum number of validations of the local node for it to
* participate in the voting. * participate in the voting.
*/ */
static constexpr size_t negativeUnlMinLocalValsToVote = static constexpr size_t negativeUNLMinLocalValsToVote =
FLAG_LEDGER_INTERVAL * 90 / 100; FLAG_LEDGER_INTERVAL * 90 / 100;
/** /**
* We don't want to disable new validators immediately after adding them. * We don't want to disable new validators immediately after adding them.
@@ -74,7 +74,7 @@ public:
/** /**
* We only want to put 25% of the UNL on the NegativeUNL. * We only want to put 25% of the UNL on the NegativeUNL.
*/ */
static constexpr float negativeUnlMaxListed = 0.25; static constexpr float negativeUNLMaxListed = 0.25;
/** /**
* A flag indicating whether a UNLModify Tx is to disable or to re-enable * A flag indicating whether a UNLModify Tx is to disable or to re-enable

View File

@@ -1751,7 +1751,7 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed)
m_ledgerMaster.getClosedLedger()->info().hash); m_ledgerMaster.getClosedLedger()->info().hash);
if (prevLedger->rules().enabled(featureNegativeUNL)) if (prevLedger->rules().enabled(featureNegativeUNL))
app_.validators().setNegativeUnl(prevLedger->negativeUnl()); app_.validators().setNegativeUNL(prevLedger->negativeUNL());
TrustChanges const changes = app_.validators().updateTrusted( TrustChanges const changes = app_.validators().updateTrusted(
app_.getValidations().getCurrentNodeIDs()); app_.getValidations().getCurrentNodeIDs());

View File

@@ -161,7 +161,7 @@ class ValidatorList
PublicKey localPubKey_; PublicKey localPubKey_;
// The master public keys of the current negative UNL // The master public keys of the current negative UNL
hash_set<PublicKey> negativeUnl_; hash_set<PublicKey> negativeUNL_;
// Currently supported version of publisher list format // Currently supported version of publisher list format
static constexpr std::uint32_t requiredListVersion = 1; static constexpr std::uint32_t requiredListVersion = 1;
@@ -521,14 +521,14 @@ public:
* @return the master public keys * @return the master public keys
*/ */
hash_set<PublicKey> hash_set<PublicKey>
getNegativeUnl() const; getNegativeUNL() const;
/** /**
* set the Negative UNL with validators' master public keys * set the Negative UNL with validators' master public keys
* @param negUnl the public keys * @param negUnl the public keys
*/ */
void void
setNegativeUnl(hash_set<PublicKey> const& negUnl); setNegativeUNL(hash_set<PublicKey> const& negUnl);
/** /**
* Remove validations that are from validators on the negative UNL. * Remove validations that are from validators on the negative UNL.

View File

@@ -748,10 +748,10 @@ ValidatorList::getJson() const
}); });
// Negative UNL // Negative UNL
if (!negativeUnl_.empty()) if (!negativeUNL_.empty())
{ {
Json::Value& jNegativeUNL = (res[jss::NegativeUNL] = Json::arrayValue); Json::Value& jNegativeUNL = (res[jss::NegativeUNL] = Json::arrayValue);
for (auto const& k : negativeUnl_) for (auto const& k : negativeUNL_)
{ {
jNegativeUNL.append(toBase58(TokenType::NodePublic, k)); jNegativeUNL.append(toBase58(TokenType::NodePublic, k));
} }
@@ -944,15 +944,15 @@ ValidatorList::updateTrusted(hash_set<NodeID> const& seenValidators)
auto unlSize = trustedMasterKeys_.size(); auto unlSize = trustedMasterKeys_.size();
auto effectiveUnlSize = unlSize; auto effectiveUnlSize = unlSize;
auto seenSize = seenValidators.size(); auto seenSize = seenValidators.size();
if (!negativeUnl_.empty()) if (!negativeUNL_.empty())
{ {
for (auto const& k : trustedMasterKeys_) for (auto const& k : trustedMasterKeys_)
{ {
if (negativeUnl_.count(k)) if (negativeUNL_.count(k))
--effectiveUnlSize; --effectiveUnlSize;
} }
hash_set<NodeID> negUnlNodeIDs; hash_set<NodeID> negUnlNodeIDs;
for (auto const& k : negativeUnl_) for (auto const& k : negativeUNL_)
{ {
negUnlNodeIDs.emplace(calcNodeID(k)); negUnlNodeIDs.emplace(calcNodeID(k));
} }
@@ -987,17 +987,17 @@ ValidatorList::getTrustedMasterKeys() const
} }
hash_set<PublicKey> hash_set<PublicKey>
ValidatorList::getNegativeUnl() const ValidatorList::getNegativeUNL() const
{ {
std::shared_lock lock{mutex_}; std::shared_lock lock{mutex_};
return negativeUnl_; return negativeUNL_;
} }
void void
ValidatorList::setNegativeUnl(hash_set<PublicKey> const& negUnl) ValidatorList::setNegativeUNL(hash_set<PublicKey> const& negUnl)
{ {
std::lock_guard lock{mutex_}; std::lock_guard lock{mutex_};
negativeUnl_ = negUnl; negativeUNL_ = negUnl;
} }
std::vector<std::shared_ptr<STValidation>> std::vector<std::shared_ptr<STValidation>>
@@ -1008,7 +1008,7 @@ ValidatorList::negativeUNLFilter(
auto ret = std::move(validations); auto ret = std::move(validations);
std::shared_lock lock{mutex_}; std::shared_lock lock{mutex_};
if (!negativeUnl_.empty()) if (!negativeUNL_.empty())
{ {
ret.erase( ret.erase(
std::remove_if( std::remove_if(
@@ -1019,7 +1019,7 @@ ValidatorList::negativeUNLFilter(
getTrustedKey(v->getSignerPublic()); getTrustedKey(v->getSignerPublic());
masterKey) masterKey)
{ {
return negativeUnl_.count(*masterKey); return negativeUNL_.count(*masterKey);
} }
else else
{ {

View File

@@ -290,9 +290,10 @@ Change::applyUNLModify()
} }
bool const found = [&] { bool const found = [&] {
if (negUnlObject->isFieldPresent(sfNegativeUNL)) if (negUnlObject->isFieldPresent(sfDisabledValidators))
{ {
auto const& negUnl = negUnlObject->getFieldArray(sfNegativeUNL); auto const& negUnl =
negUnlObject->getFieldArray(sfDisabledValidators);
for (auto const& v : negUnl) for (auto const& v : negUnl)
{ {
if (v.isFieldPresent(sfPublicKey) && if (v.isFieldPresent(sfPublicKey) &&
@@ -306,16 +307,16 @@ Change::applyUNLModify()
if (disabling) if (disabling)
{ {
// cannot have more than one toDisable // cannot have more than one toDisable
if (negUnlObject->isFieldPresent(sfNegativeUNLToDisable)) if (negUnlObject->isFieldPresent(sfValidatorToDisable))
{ {
JLOG(j_.warn()) << "N-UNL: applyUNLModify, already has ToDisable"; JLOG(j_.warn()) << "N-UNL: applyUNLModify, already has ToDisable";
return tefFAILURE; return tefFAILURE;
} }
// cannot be the same as toReEnable // cannot be the same as toReEnable
if (negUnlObject->isFieldPresent(sfNegativeUNLToReEnable)) if (negUnlObject->isFieldPresent(sfValidatorToReEnable))
{ {
if (negUnlObject->getFieldVL(sfNegativeUNLToReEnable) == validator) if (negUnlObject->getFieldVL(sfValidatorToReEnable) == validator)
{ {
JLOG(j_.warn()) JLOG(j_.warn())
<< "N-UNL: applyUNLModify, ToDisable is same as ToReEnable"; << "N-UNL: applyUNLModify, ToDisable is same as ToReEnable";
@@ -331,21 +332,21 @@ Change::applyUNLModify()
return tefFAILURE; return tefFAILURE;
} }
negUnlObject->setFieldVL(sfNegativeUNLToDisable, validator); negUnlObject->setFieldVL(sfValidatorToDisable, validator);
} }
else else
{ {
// cannot have more than one toReEnable // cannot have more than one toReEnable
if (negUnlObject->isFieldPresent(sfNegativeUNLToReEnable)) if (negUnlObject->isFieldPresent(sfValidatorToReEnable))
{ {
JLOG(j_.warn()) << "N-UNL: applyUNLModify, already has ToReEnable"; JLOG(j_.warn()) << "N-UNL: applyUNLModify, already has ToReEnable";
return tefFAILURE; return tefFAILURE;
} }
// cannot be the same as toDisable // cannot be the same as toDisable
if (negUnlObject->isFieldPresent(sfNegativeUNLToDisable)) if (negUnlObject->isFieldPresent(sfValidatorToDisable))
{ {
if (negUnlObject->getFieldVL(sfNegativeUNLToDisable) == validator) if (negUnlObject->getFieldVL(sfValidatorToDisable) == validator)
{ {
JLOG(j_.warn()) JLOG(j_.warn())
<< "N-UNL: applyUNLModify, ToReEnable is same as ToDisable"; << "N-UNL: applyUNLModify, ToReEnable is same as ToDisable";
@@ -361,7 +362,7 @@ Change::applyUNLModify()
return tefFAILURE; return tefFAILURE;
} }
negUnlObject->setFieldVL(sfNegativeUNLToReEnable, validator); negUnlObject->setFieldVL(sfValidatorToReEnable, validator);
} }
view().update(negUnlObject); view().update(negUnlObject);

View File

@@ -356,12 +356,12 @@ message TransactionSignature
bytes value = 1; bytes value = 1;
} }
message NegativeUnlToDisable message ValidatorToDisable
{ {
bytes value = 1; bytes value = 1;
} }
message NegativeUnlToReEnable message ValidatorToReEnable
{ {
bytes value = 1; bytes value = 1;
} }
@@ -490,7 +490,7 @@ message SignerEntry
} }
// Next field: 3 // Next field: 3
message NegativeUnlEntry message DisabledValidator
{ {
PublicKey public_key = 1; PublicKey public_key = 1;

View File

@@ -23,7 +23,7 @@ message LedgerObject
PayChannel pay_channel = 10; PayChannel pay_channel = 10;
RippleState ripple_state = 11; RippleState ripple_state = 11;
SignerList signer_list = 12; SignerList signer_list = 12;
NegativeUnl negative_unl = 13; NegativeUNL negative_unl = 13;
} }
} }
@@ -332,12 +332,14 @@ message SignerList
SignerQuorum signer_quorum = 7; SignerQuorum signer_quorum = 7;
} }
// Next field: 4 // Next field: 5
message NegativeUnl message NegativeUNL
{ {
repeated NegativeUnlEntry negative_unl_entries = 1; repeated DisabledValidator disabled_validators = 1;
NegativeUnlToDisable validator_to_disable = 2; ValidatorToDisable validator_to_disable = 2;
NegativeUnlToReEnable validator_to_re_enable = 3; ValidatorToReEnable validator_to_re_enable = 3;
Flags flags = 4;
} }

View File

@@ -85,7 +85,7 @@ skip(LedgerIndex ledger) noexcept;
Keylet const& Keylet const&
fees() noexcept; fees() noexcept;
/** The (fixed) index of the object containing the ledger negativeUnl. */ /** The (fixed) index of the object containing the ledger negativeUNL. */
Keylet const& Keylet const&
negativeUNL() noexcept; negativeUNL() noexcept;

View File

@@ -473,8 +473,8 @@ extern SF_Blob const sfFulfillment;
extern SF_Blob const sfCondition; extern SF_Blob const sfCondition;
extern SF_Blob const sfMasterSignature; extern SF_Blob const sfMasterSignature;
extern SF_Blob const sfUNLModifyValidator; extern SF_Blob const sfUNLModifyValidator;
extern SF_Blob const sfNegativeUNLToDisable; extern SF_Blob const sfValidatorToDisable;
extern SF_Blob const sfNegativeUNLToReEnable; extern SF_Blob const sfValidatorToReEnable;
// account // account
extern SF_Account const sfAccount; extern SF_Account const sfAccount;
@@ -508,7 +508,7 @@ extern SField const sfMemo;
extern SField const sfSignerEntry; extern SField const sfSignerEntry;
extern SField const sfSigner; extern SField const sfSigner;
extern SField const sfMajority; extern SField const sfMajority;
extern SField const sfNegativeUNLEntry; extern SField const sfDisabledValidator;
// array of objects // array of objects
// ARRAY/1 is reserved for end of array // ARRAY/1 is reserved for end of array
@@ -521,7 +521,7 @@ extern SField const sfSufficient;
extern SField const sfAffectedNodes; extern SField const sfAffectedNodes;
extern SField const sfMemos; extern SField const sfMemos;
extern SField const sfMajorities; extern SField const sfMajorities;
extern SField const sfNegativeUNL; extern SField const sfDisabledValidators;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
} // namespace ripple } // namespace ripple

View File

@@ -228,9 +228,9 @@ LedgerFormats::LedgerFormats()
add(jss::NegativeUNL, add(jss::NegativeUNL,
ltNEGATIVE_UNL, ltNEGATIVE_UNL,
{ {
{sfNegativeUNL, soeOPTIONAL}, {sfDisabledValidators, soeOPTIONAL},
{sfNegativeUNLToDisable, soeOPTIONAL}, {sfValidatorToDisable, soeOPTIONAL},
{sfNegativeUNLToReEnable, soeOPTIONAL}, {sfValidatorToReEnable, soeOPTIONAL},
}, },
commonFields); commonFields);
} }

View File

@@ -224,9 +224,8 @@ SF_Blob const sfMasterSignature(
SField::sMD_Default, SField::sMD_Default,
SField::notSigning); SField::notSigning);
SF_Blob const sfUNLModifyValidator(access, STI_VL, 19, "UNLModifyValidator"); SF_Blob const sfUNLModifyValidator(access, STI_VL, 19, "UNLModifyValidator");
SF_Blob const sfNegativeUNLToDisable(access, STI_VL, 20, "ValidatorToDisable"); SF_Blob const sfValidatorToDisable(access, STI_VL, 20, "ValidatorToDisable");
SF_Blob const SF_Blob const sfValidatorToReEnable(access, STI_VL, 21, "ValidatorToReEnable");
sfNegativeUNLToReEnable(access, STI_VL, 21, "ValidatorToReEnable");
// account // account
SF_Account const sfAccount(access, STI_ACCOUNT, 1, "Account"); SF_Account const sfAccount(access, STI_ACCOUNT, 1, "Account");
@@ -265,7 +264,7 @@ SField const sfSignerEntry(access, STI_OBJECT, 11, "SignerEntry");
SField const sfSigner(access, STI_OBJECT, 16, "Signer"); SField const sfSigner(access, STI_OBJECT, 16, "Signer");
// 17 has not been used yet... // 17 has not been used yet...
SField const sfMajority(access, STI_OBJECT, 18, "Majority"); SField const sfMajority(access, STI_OBJECT, 18, "Majority");
SField const sfNegativeUNLEntry(access, STI_OBJECT, 19, "DisabledValidator"); SField const sfDisabledValidator(access, STI_OBJECT, 19, "DisabledValidator");
// array of objects // array of objects
// ARRAY/1 is reserved for end of array // ARRAY/1 is reserved for end of array
@@ -287,7 +286,7 @@ SField const sfMemos(access, STI_ARRAY, 9, "Memos");
// array of objects (uncommon) // array of objects (uncommon)
SField const sfMajorities(access, STI_ARRAY, 16, "Majorities"); SField const sfMajorities(access, STI_ARRAY, 16, "Majorities");
SField const sfNegativeUNL(access, STI_ARRAY, 17, "NegativeUNL"); SField const sfDisabledValidators(access, STI_ARRAY, 17, "DisabledValidators");
SField::SField( SField::SField(
private_access_tag_t, private_access_tag_t,

View File

@@ -497,22 +497,22 @@ populateFirstLedgerSequence(T& to, STObject const& from)
template <class T> template <class T>
void void
populateNegativeUNLToDisable(T& to, STObject const& from) populateValidatorToDisable(T& to, STObject const& from)
{ {
populateProtoPrimitive( populateProtoPrimitive(
[&to]() { return to.mutable_validator_to_disable(); }, [&to]() { return to.mutable_validator_to_disable(); },
from, from,
sfNegativeUNLToDisable); sfValidatorToDisable);
} }
template <class T> template <class T>
void void
populateNegativeUNLToReEnable(T& to, STObject const& from) populateValidatorToReEnable(T& to, STObject const& from)
{ {
populateProtoPrimitive( populateProtoPrimitive(
[&to]() { return to.mutable_validator_to_re_enable(); }, [&to]() { return to.mutable_validator_to_re_enable(); },
from, from,
sfNegativeUNLToReEnable); sfValidatorToReEnable);
} }
template <class T> template <class T>
@@ -878,17 +878,17 @@ populateSignerEntries(T& to, STObject const& from)
template <class T> template <class T>
void void
populateNegativeUNLEntries(T& to, STObject const& from) populateDisabledValidators(T& to, STObject const& from)
{ {
populateProtoArray( populateProtoArray(
[&to]() { return to.add_negative_unl_entries(); }, [&to]() { return to.add_disabled_validators(); },
[](auto& innerObj, auto& innerProto) { [](auto& innerObj, auto& innerProto) {
populatePublicKey(innerProto, innerObj); populatePublicKey(innerProto, innerObj);
populateFirstLedgerSequence(innerProto, innerObj); populateFirstLedgerSequence(innerProto, innerObj);
}, },
from, from,
sfNegativeUNL, sfDisabledValidators,
sfNegativeUNLEntry); sfDisabledValidator);
} }
template <class T> template <class T>
@@ -1463,13 +1463,15 @@ convert(org::xrpl::rpc::v1::SignerList& to, STObject const& from)
} }
void void
convert(org::xrpl::rpc::v1::NegativeUnl& to, STObject const& from) convert(org::xrpl::rpc::v1::NegativeUNL& to, STObject const& from)
{ {
populateNegativeUNLEntries(to, from); populateDisabledValidators(to, from);
populateNegativeUNLToDisable(to, from); populateValidatorToDisable(to, from);
populateNegativeUNLToReEnable(to, from); populateValidatorToReEnable(to, from);
populateFlags(to, from);
} }
void void

View File

@@ -59,7 +59,7 @@ void
convert(org::xrpl::rpc::v1::SignerList& to, STObject const& from); convert(org::xrpl::rpc::v1::SignerList& to, STObject const& from);
void void
convert(org::xrpl::rpc::v1::NegativeUnl& to, STObject const& from); convert(org::xrpl::rpc::v1::NegativeUNL& to, STObject const& from);
template <class T> template <class T>
void void

View File

@@ -1342,7 +1342,7 @@ private:
nUnl.insert(*it); nUnl.insert(*it);
++it; ++it;
} }
validators->setNegativeUnl(nUnl); validators->setNegativeUNL(nUnl);
validators->updateTrusted(activeValidators); validators->updateTrusted(activeValidators);
BEAST_EXPECT( BEAST_EXPECT(
validators->quorum() == validators->quorum() ==
@@ -1374,8 +1374,8 @@ private:
nUnl.insert(*it); nUnl.insert(*it);
++it; ++it;
} }
validators->setNegativeUnl(nUnl); validators->setNegativeUNL(nUnl);
auto nUnl_temp = validators->getNegativeUnl(); auto nUnl_temp = validators->getNegativeUNL();
if (nUnl_temp.size() == nUnl.size()) if (nUnl_temp.size() == nUnl.size())
{ {
for (auto& n : nUnl_temp) for (auto& n : nUnl_temp)
@@ -1396,7 +1396,7 @@ private:
{ {
// nUNL overlap: |nUNL - UNL| = 5, with nUNL size: 18 // nUNL overlap: |nUNL - UNL| = 5, with nUNL size: 18
auto nUnl = validators->getNegativeUnl(); auto nUnl = validators->getNegativeUNL();
BEAST_EXPECT(nUnl.size() == 12); BEAST_EXPECT(nUnl.size() == 12);
std::size_t ss = 33; std::size_t ss = 33;
std::vector<uint8_t> data(ss, 0); std::vector<uint8_t> data(ss, 0);
@@ -1407,7 +1407,7 @@ private:
data[1]++; data[1]++;
nUnl.emplace(s); nUnl.emplace(s);
} }
validators->setNegativeUnl(nUnl); validators->setNegativeUNL(nUnl);
validators->updateTrusted(activeValidators); validators->updateTrusted(activeValidators);
BEAST_EXPECT(validators->quorum() == 39); BEAST_EXPECT(validators->quorum() == 39);
} }
@@ -1439,7 +1439,7 @@ private:
nUnl.insert(*it); nUnl.insert(*it);
++it; ++it;
} }
validators->setNegativeUnl(nUnl); validators->setNegativeUNL(nUnl);
validators->updateTrusted(activeValidators); validators->updateTrusted(activeValidators);
BEAST_EXPECT(validators->quorum() == 30); BEAST_EXPECT(validators->quorum() == 30);
} }

View File

@@ -282,7 +282,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnlToDisable() == publicKeys[0]); BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
//++ first ToDisable Tx in ledger's TxSet //++ first ToDisable Tx in ledger's TxSet
uint256 txID = txDisable_0.getTransactionID(); uint256 txID = txDisable_0.getTransactionID();
BEAST_EXPECT(l->txExists(txID)); BEAST_EXPECT(l->txExists(txID));
@@ -296,7 +296,7 @@ class NegativeUNL_test : public beast::unit_test::suite
auto good_size = negUnlSizeTest(l, 0, true, false); auto good_size = negUnlSizeTest(l, 0, true, false);
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
BEAST_EXPECT(l->negativeUnlToDisable() == publicKeys[0]); BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
l = std::make_shared<Ledger>( l = std::make_shared<Ledger>(
*l, env.app().timeKeeper().closeTime()); *l, env.app().timeKeeper().closeTime());
} }
@@ -309,7 +309,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(*(l->negativeUnl().begin()) == publicKeys[0]); BEAST_EXPECT(*(l->negativeUNL().begin()) == publicKeys[0]);
nUnlLedgerSeq.emplace(publicKeys[0], l->seq()); nUnlLedgerSeq.emplace(publicKeys[0], l->seq());
} }
@@ -330,9 +330,9 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[0])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[0]));
BEAST_EXPECT(l->negativeUnlToDisable() == publicKeys[1]); BEAST_EXPECT(l->validatorToDisable() == publicKeys[1]);
BEAST_EXPECT(l->negativeUnlToReEnable() == publicKeys[0]); BEAST_EXPECT(l->validatorToReEnable() == publicKeys[0]);
// test sfFirstLedgerSequence // test sfFirstLedgerSequence
BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq)); BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq));
} }
@@ -346,9 +346,9 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[0])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[0]));
BEAST_EXPECT(l->negativeUnlToDisable() == publicKeys[1]); BEAST_EXPECT(l->validatorToDisable() == publicKeys[1]);
BEAST_EXPECT(l->negativeUnlToReEnable() == publicKeys[0]); BEAST_EXPECT(l->validatorToReEnable() == publicKeys[0]);
} }
l = std::make_shared<Ledger>( l = std::make_shared<Ledger>(
*l, env.app().timeKeeper().closeTime()); *l, env.app().timeKeeper().closeTime());
@@ -362,7 +362,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
} }
auto txDisable_0 = createTx(true, l->seq(), publicKeys[0]); auto txDisable_0 = createTx(true, l->seq(), publicKeys[0]);
@@ -374,8 +374,8 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->negativeUnlToDisable() == publicKeys[0]); BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
nUnlLedgerSeq.emplace(publicKeys[1], l->seq()); nUnlLedgerSeq.emplace(publicKeys[1], l->seq());
nUnlLedgerSeq.erase(publicKeys[0]); nUnlLedgerSeq.erase(publicKeys[0]);
BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq)); BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq));
@@ -390,8 +390,8 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->negativeUnlToDisable() == publicKeys[0]); BEAST_EXPECT(l->validatorToDisable() == publicKeys[0]);
} }
l = std::make_shared<Ledger>( l = std::make_shared<Ledger>(
*l, env.app().timeKeeper().closeTime()); *l, env.app().timeKeeper().closeTime());
@@ -405,8 +405,8 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[0])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[0]));
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
nUnlLedgerSeq.emplace(publicKeys[0], l->seq()); nUnlLedgerSeq.emplace(publicKeys[0], l->seq());
BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq)); BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq));
} }
@@ -424,9 +424,9 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[0])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[0]));
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->negativeUnlToReEnable() == publicKeys[0]); BEAST_EXPECT(l->validatorToReEnable() == publicKeys[0]);
BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq)); BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq));
} }
} }
@@ -439,9 +439,9 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[0])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[0]));
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->negativeUnlToReEnable() == publicKeys[0]); BEAST_EXPECT(l->validatorToReEnable() == publicKeys[0]);
} }
l = std::make_shared<Ledger>( l = std::make_shared<Ledger>(
*l, env.app().timeKeeper().closeTime()); *l, env.app().timeKeeper().closeTime());
@@ -455,7 +455,7 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
nUnlLedgerSeq.erase(publicKeys[0]); nUnlLedgerSeq.erase(publicKeys[0]);
BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq)); BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq));
} }
@@ -469,8 +469,8 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->negativeUnlToReEnable() == publicKeys[1]); BEAST_EXPECT(l->validatorToReEnable() == publicKeys[1]);
BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq)); BEAST_EXPECT(VerifyPubKeyAndSeq(l, nUnlLedgerSeq));
} }
} }
@@ -483,8 +483,8 @@ class NegativeUNL_test : public beast::unit_test::suite
BEAST_EXPECT(good_size); BEAST_EXPECT(good_size);
if (good_size) if (good_size)
{ {
BEAST_EXPECT(l->negativeUnl().count(publicKeys[1])); BEAST_EXPECT(l->negativeUNL().count(publicKeys[1]));
BEAST_EXPECT(l->negativeUnlToReEnable() == publicKeys[1]); BEAST_EXPECT(l->validatorToReEnable() == publicKeys[1]);
} }
l = std::make_shared<Ledger>( l = std::make_shared<Ledger>(
*l, env.app().timeKeeper().closeTime()); *l, env.app().timeKeeper().closeTime());
@@ -633,14 +633,14 @@ struct NetworkHistory
{ {
l->updateNegativeUNL(); l->updateNegativeUNL();
OpenView accum(&*l); OpenView accum(&*l);
if (l->negativeUnl().size() < param.negUNLSize) if (l->negativeUNL().size() < param.negUNLSize)
{ {
auto tx = createTx(true, l->seq(), UNLKeys[nidx]); auto tx = createTx(true, l->seq(), UNLKeys[nidx]);
if (!applyAndTestResult(env, accum, tx, true)) if (!applyAndTestResult(env, accum, tx, true))
break; break;
++nidx; ++nidx;
} }
else if (l->negativeUnl().size() == param.negUNLSize) else if (l->negativeUNL().size() == param.negUNLSize)
{ {
if (param.hasToDisable) if (param.hasToDisable)
{ {
@@ -1030,7 +1030,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// build a good scoreTable to use, or copy and modify // build a good scoreTable to use, or copy and modify
hash_map<NodeID, std::uint32_t> goodScoreTable; hash_map<NodeID, std::uint32_t> goodScoreTable;
for (auto const& n : history.UNLNodeIDs) for (auto const& n : history.UNLNodeIDs)
goodScoreTable[n] = NegativeUNLVote::negativeUnlHighWaterMark + 1; goodScoreTable[n] = NegativeUNLVote::negativeUNLHighWaterMark + 1;
NegativeUNLVote vote(history.UNLNodeIDs[0], history.env.journal); NegativeUNLVote vote(history.UNLNodeIDs[0], history.env.journal);
@@ -1043,7 +1043,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// all bad scores // all bad scores
hash_map<NodeID, std::uint32_t> scoreTable; hash_map<NodeID, std::uint32_t> scoreTable;
for (auto& n : history.UNLNodeIDs) for (auto& n : history.UNLNodeIDs)
scoreTable[n] = NegativeUNLVote::negativeUnlLowWaterMark - 1; scoreTable[n] = NegativeUNLVote::negativeUNLLowWaterMark - 1;
BEAST_EXPECT(checkCandidateSizes( BEAST_EXPECT(checkCandidateSizes(
vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 35 - 3, 0)); vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 35 - 3, 0));
} }
@@ -1051,7 +1051,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// all between watermarks // all between watermarks
hash_map<NodeID, std::uint32_t> scoreTable; hash_map<NodeID, std::uint32_t> scoreTable;
for (auto& n : history.UNLNodeIDs) for (auto& n : history.UNLNodeIDs)
scoreTable[n] = NegativeUNLVote::negativeUnlLowWaterMark + 1; scoreTable[n] = NegativeUNLVote::negativeUNLLowWaterMark + 1;
BEAST_EXPECT(checkCandidateSizes( BEAST_EXPECT(checkCandidateSizes(
vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 0, 0)); vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 0, 0));
} }
@@ -1060,7 +1060,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// 2 good scorers in negUnl // 2 good scorers in negUnl
auto scoreTable = goodScoreTable; auto scoreTable = goodScoreTable;
scoreTable[*negUnl_012.begin()] = scoreTable[*negUnl_012.begin()] =
NegativeUNLVote::negativeUnlLowWaterMark + 1; NegativeUNLVote::negativeUNLLowWaterMark + 1;
BEAST_EXPECT(checkCandidateSizes( BEAST_EXPECT(checkCandidateSizes(
vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 0, 2)); vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 0, 2));
} }
@@ -1069,9 +1069,9 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// 2 bad scorers not in negUnl // 2 bad scorers not in negUnl
auto scoreTable = goodScoreTable; auto scoreTable = goodScoreTable;
scoreTable[history.UNLNodeIDs[11]] = scoreTable[history.UNLNodeIDs[11]] =
NegativeUNLVote::negativeUnlLowWaterMark - 1; NegativeUNLVote::negativeUNLLowWaterMark - 1;
scoreTable[history.UNLNodeIDs[12]] = scoreTable[history.UNLNodeIDs[12]] =
NegativeUNLVote::negativeUnlLowWaterMark - 1; NegativeUNLVote::negativeUNLLowWaterMark - 1;
BEAST_EXPECT(checkCandidateSizes( BEAST_EXPECT(checkCandidateSizes(
vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 2, 3)); vote, history.UNLNodeIDSet, negUnl_012, scoreTable, 2, 3));
} }
@@ -1092,7 +1092,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
scoreTable.erase(history.UNLNodeIDs[0]); scoreTable.erase(history.UNLNodeIDs[0]);
scoreTable.erase(history.UNLNodeIDs[1]); scoreTable.erase(history.UNLNodeIDs[1]);
scoreTable[history.UNLNodeIDs[2]] = scoreTable[history.UNLNodeIDs[2]] =
NegativeUNLVote::negativeUnlLowWaterMark + 1; NegativeUNLVote::negativeUNLLowWaterMark + 1;
hash_set<NodeID> UNL_temp = history.UNLNodeIDSet; hash_set<NodeID> UNL_temp = history.UNLNodeIDSet;
UNL_temp.erase(history.UNLNodeIDs[0]); UNL_temp.erase(history.UNLNodeIDs[0]);
UNL_temp.erase(history.UNLNodeIDs[1]); UNL_temp.erase(history.UNLNodeIDs[1]);
@@ -1113,9 +1113,9 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
// 2 new validators have good scores, already in negUnl // 2 new validators have good scores, already in negUnl
auto scoreTable = goodScoreTable; auto scoreTable = goodScoreTable;
scoreTable[new_1] = scoreTable[new_1] =
NegativeUNLVote::negativeUnlHighWaterMark + 1; NegativeUNLVote::negativeUNLHighWaterMark + 1;
scoreTable[new_2] = scoreTable[new_2] =
NegativeUNLVote::negativeUnlHighWaterMark + 1; NegativeUNLVote::negativeUNLHighWaterMark + 1;
hash_set<NodeID> negUnl_temp = negUnl_012; hash_set<NodeID> negUnl_temp = negUnl_012;
negUnl_temp.insert(new_1); negUnl_temp.insert(new_1);
negUnl_temp.insert(new_2); negUnl_temp.insert(new_2);
@@ -1151,16 +1151,16 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
* == combination 1: * == combination 1:
* -- unl size: 34, 35, 80 * -- unl size: 34, 35, 80
* -- nUnl size: 0, 50%, all * -- nUnl size: 0, 50%, all
* -- score pattern: all 0, all negativeUnlLowWaterMark & +1 & -1, all * -- score pattern: all 0, all negativeUNLLowWaterMark & +1 & -1, all
* negativeUnlHighWaterMark & +1 & -1, all 100% * negativeUNLHighWaterMark & +1 & -1, all 100%
* *
* == combination 2: * == combination 2:
* -- unl size: 34, 35, 80 * -- unl size: 34, 35, 80
* -- negativeUnl size: 0, all * -- negativeUNL size: 0, all
* -- nUnl size: one on, one off, one on, one off, * -- nUnl size: one on, one off, one on, one off,
* -- score pattern: 2*(negativeUnlLowWaterMark, +1, -1) & * -- score pattern: 2*(negativeUNLLowWaterMark, +1, -1) &
* 2*(negativeUnlHighWaterMark, +1, -1) & rest * 2*(negativeUNLHighWaterMark, +1, -1) & rest
* negativeUnlMinLocalValsToVote * negativeUNLMinLocalValsToVote
*/ */
jtx::Env env(*this); jtx::Env env(*this);
@@ -1172,13 +1172,13 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
std::array<std::uint32_t, 3> nUnlPercent = {0, 50, 100}; std::array<std::uint32_t, 3> nUnlPercent = {0, 50, 100};
std::array<std::uint32_t, 8> scores = { std::array<std::uint32_t, 8> scores = {
0, 0,
NegativeUNLVote::negativeUnlLowWaterMark - 1, NegativeUNLVote::negativeUNLLowWaterMark - 1,
NegativeUNLVote::negativeUnlLowWaterMark, NegativeUNLVote::negativeUNLLowWaterMark,
NegativeUNLVote::negativeUnlLowWaterMark + 1, NegativeUNLVote::negativeUNLLowWaterMark + 1,
NegativeUNLVote::negativeUnlHighWaterMark - 1, NegativeUNLVote::negativeUNLHighWaterMark - 1,
NegativeUNLVote::negativeUnlHighWaterMark, NegativeUNLVote::negativeUNLHighWaterMark,
NegativeUNLVote::negativeUnlHighWaterMark + 1, NegativeUNLVote::negativeUNLHighWaterMark + 1,
NegativeUNLVote::negativeUnlMinLocalValsToVote}; NegativeUNLVote::negativeUNLMinLocalValsToVote};
//== combination 1: //== combination 1:
{ {
@@ -1221,7 +1221,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
if (np == 0) if (np == 0)
{ {
if (score < if (score <
NegativeUNLVote::negativeUnlLowWaterMark) NegativeUNLVote::negativeUNLLowWaterMark)
{ {
toDisable_expect = us; toDisable_expect = us;
} }
@@ -1229,7 +1229,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
else if (np == 50) else if (np == 50)
{ {
if (score > if (score >
NegativeUNLVote::negativeUnlHighWaterMark) NegativeUNLVote::negativeUNLHighWaterMark)
{ {
toReEnable_expect = us * np / 100; toReEnable_expect = us * np / 100;
} }
@@ -1237,7 +1237,7 @@ class NegativeUNLVoteInternal_test : public beast::unit_test::suite
else else
{ {
if (score > if (score >
NegativeUNLVote::negativeUnlHighWaterMark) NegativeUNLVote::negativeUNLHighWaterMark)
{ {
toReEnable_expect = us; toReEnable_expect = us;
} }
@@ -1523,7 +1523,7 @@ class NegativeUNLVoteScoreTable_test : public beast::unit_test::suite
* *
* == 2 nodes offline including me, not in nUnl * == 2 nodes offline including me, not in nUnl
* -- txSet.size = 0 * -- txSet.size = 0
* == 2 nodes offline, not in negativeUnl, but I'm not a validator * == 2 nodes offline, not in negativeUNL, but I'm not a validator
* -- txSet.size = 0 * -- txSet.size = 0
* == 2 in nUnl, but not in unl, no other remove candidates * == 2 in nUnl, but not in unl, no other remove candidates
* -- txSet.size = 1 * -- txSet.size = 1
@@ -1542,7 +1542,7 @@ class NegativeUNLVoteGoodScore_test : public beast::unit_test::suite
testcase("Do Voting"); testcase("Do Voting");
{ {
//== all good score, negativeUnl empty //== all good score, negativeUNL empty
//-- txSet.size = 0 //-- txSet.size = 0
NetworkHistory history = {*this, {51, 0, false, false, {}}}; NetworkHistory history = {*this, {51, 0, false, false, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1556,7 +1556,7 @@ class NegativeUNLVoteGoodScore_test : public beast::unit_test::suite
} }
{ {
// all good score, negativeUnl not empty (use hasToDisable) // all good score, negativeUNL not empty (use hasToDisable)
//-- txSet.size = 1 //-- txSet.size = 1
NetworkHistory history = {*this, {37, 0, true, false, {}}}; NetworkHistory history = {*this, {37, 0, true, false, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1585,7 +1585,7 @@ class NegativeUNLVoteOffline_test : public beast::unit_test::suite
testcase("Do Voting"); testcase("Do Voting");
{ {
//== 2 nodes offline, negativeUnl empty (use hasToReEnable) //== 2 nodes offline, negativeUNL empty (use hasToReEnable)
//-- txSet.size = 1 //-- txSet.size = 1
NetworkHistory history = {*this, {29, 1, false, true, {}}}; NetworkHistory history = {*this, {29, 1, false, true, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1603,16 +1603,16 @@ class NegativeUNLVoteOffline_test : public beast::unit_test::suite
} }
{ {
// 2 nodes offline, in negativeUnl // 2 nodes offline, in negativeUNL
//-- txSet.size = 0 //-- txSet.size = 0
NetworkHistory history = {*this, {30, 1, true, false, {}}}; NetworkHistory history = {*this, {30, 1, true, false, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
if (history.goodHistory) if (history.goodHistory)
{ {
NodeID n1 = NodeID n1 =
calcNodeID(*history.lastLedger()->negativeUnl().begin()); calcNodeID(*history.lastLedger()->negativeUNL().begin());
NodeID n2 = NodeID n2 =
calcNodeID(*history.lastLedger()->negativeUnlToDisable()); calcNodeID(*history.lastLedger()->validatorToDisable());
history.walkHistoryAndAddValidations( history.walkHistoryAndAddValidations(
[&](std::shared_ptr<Ledger const> const& l, [&](std::shared_ptr<Ledger const> const& l,
std::size_t idx) -> bool { std::size_t idx) -> bool {
@@ -1641,7 +1641,7 @@ class NegativeUNLVoteMaxListed_test : public beast::unit_test::suite
testcase("Do Voting"); testcase("Do Voting");
{ {
// 2 nodes offline, not in negativeUnl, but maxListed // 2 nodes offline, not in negativeUNL, but maxListed
//-- txSet.size = 0 //-- txSet.size = 0
NetworkHistory history = {*this, {32, 8, true, true, {}}}; NetworkHistory history = {*this, {32, 8, true, true, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1674,7 +1674,7 @@ class NegativeUNLVoteRetiredValidator_test : public beast::unit_test::suite
testcase("Do Voting"); testcase("Do Voting");
{ {
//== 2 nodes offline including me, not in negativeUnl //== 2 nodes offline including me, not in negativeUNL
//-- txSet.size = 0 //-- txSet.size = 0
NetworkHistory history = {*this, {35, 0, false, false, {}}}; NetworkHistory history = {*this, {35, 0, false, false, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1688,7 +1688,7 @@ class NegativeUNLVoteRetiredValidator_test : public beast::unit_test::suite
} }
{ {
// 2 nodes offline, not in negativeUnl, but I'm not a validator // 2 nodes offline, not in negativeUNL, but I'm not a validator
//-- txSet.size = 0 //-- txSet.size = 0
NetworkHistory history = {*this, {40, 0, false, false, {}}}; NetworkHistory history = {*this, {40, 0, false, false, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1702,7 +1702,7 @@ class NegativeUNLVoteRetiredValidator_test : public beast::unit_test::suite
} }
{ {
//== 2 in negativeUnl, but not in unl, no other remove candidates //== 2 in negativeUNL, but not in unl, no other remove candidates
//-- txSet.size = 1 //-- txSet.size = 1
NetworkHistory history = {*this, {25, 2, false, false, {}}}; NetworkHistory history = {*this, {25, 2, false, false, {}}};
BEAST_EXPECT(history.goodHistory); BEAST_EXPECT(history.goodHistory);
@@ -1862,8 +1862,8 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite
validators.load(local, cfgKeys, cfgPublishers); validators.load(local, cfgKeys, cfgPublishers);
validators.updateTrusted(activeValidators); validators.updateTrusted(activeValidators);
BEAST_EXPECT(validators.getTrustedMasterKeys().size() == numNodes); BEAST_EXPECT(validators.getTrustedMasterKeys().size() == numNodes);
validators.setNegativeUnl(nUnlKeys); validators.setNegativeUNL(nUnlKeys);
BEAST_EXPECT(validators.getNegativeUnl().size() == negUnlSize); BEAST_EXPECT(validators.getNegativeUNL().size() == negUnlSize);
// test the filter // test the filter
BEAST_EXPECT(vals.size() == numNodes); BEAST_EXPECT(vals.size() == numNodes);
@@ -1909,9 +1909,13 @@ class NegativeUNLgRPC_test : public beast::unit_test::suite
if (!negUnlObject) if (!negUnlObject)
return false; return false;
org::xrpl::rpc::v1::NegativeUnl to; org::xrpl::rpc::v1::NegativeUNL to;
ripple::RPC::convert(to, *negUnlObject); ripple::RPC::convert(to, *negUnlObject);
bool goodSize = to.negative_unl_entries_size() == negUnlSize && if (!to.has_flags() ||
to.flags().value() != negUnlObject->getFlags())
return false;
bool goodSize = to.disabled_validators_size() == negUnlSize &&
to.has_validator_to_disable() == hasToDisable && to.has_validator_to_disable() == hasToDisable &&
to.has_validator_to_re_enable() == hasToReEnable; to.has_validator_to_re_enable() == hasToReEnable;
if (!goodSize) if (!goodSize)
@@ -1919,10 +1923,10 @@ class NegativeUNLgRPC_test : public beast::unit_test::suite
if (negUnlSize) if (negUnlSize)
{ {
if (!negUnlObject->isFieldPresent(sfNegativeUNL)) if (!negUnlObject->isFieldPresent(sfDisabledValidators))
return false; return false;
auto const& nUnlData = auto const& nUnlData =
negUnlObject->getFieldArray(sfNegativeUNL); negUnlObject->getFieldArray(sfDisabledValidators);
if (nUnlData.size() != negUnlSize) if (nUnlData.size() != negUnlSize)
return false; return false;
int idx = 0; int idx = 0;
@@ -1932,17 +1936,16 @@ class NegativeUNLgRPC_test : public beast::unit_test::suite
!n.isFieldPresent(sfFirstLedgerSequence)) !n.isFieldPresent(sfFirstLedgerSequence))
return false; return false;
if (!to.negative_unl_entries(idx).has_ledger_sequence() || if (!to.disabled_validators(idx).has_ledger_sequence() ||
!to.negative_unl_entries(idx).has_public_key()) !to.disabled_validators(idx).has_public_key())
return false; return false;
if (to.negative_unl_entries(idx).public_key().value() != if (to.disabled_validators(idx).public_key().value() !=
toByteString(n.getFieldVL(sfPublicKey))) toByteString(n.getFieldVL(sfPublicKey)))
return false; return false;
if (to.negative_unl_entries(idx) if (to.disabled_validators(idx).ledger_sequence().value() !=
.ledger_sequence() n.getFieldU32(sfFirstLedgerSequence))
.value() != n.getFieldU32(sfFirstLedgerSequence))
return false; return false;
++idx; ++idx;
@@ -1951,21 +1954,21 @@ class NegativeUNLgRPC_test : public beast::unit_test::suite
if (hasToDisable) if (hasToDisable)
{ {
if (!negUnlObject->isFieldPresent(sfNegativeUNLToDisable)) if (!negUnlObject->isFieldPresent(sfValidatorToDisable))
return false; return false;
if (to.validator_to_disable().value() != if (to.validator_to_disable().value() !=
toByteString( toByteString(
negUnlObject->getFieldVL(sfNegativeUNLToDisable))) negUnlObject->getFieldVL(sfValidatorToDisable)))
return false; return false;
} }
if (hasToReEnable) if (hasToReEnable)
{ {
if (!negUnlObject->isFieldPresent(sfNegativeUNLToReEnable)) if (!negUnlObject->isFieldPresent(sfValidatorToReEnable))
return false; return false;
if (to.validator_to_re_enable().value() != if (to.validator_to_re_enable().value() !=
toByteString( toByteString(
negUnlObject->getFieldVL(sfNegativeUNLToReEnable))) negUnlObject->getFieldVL(sfValidatorToReEnable)))
return false; return false;
} }
@@ -2010,11 +2013,11 @@ negUnlSizeTest(
bool hasToDisable, bool hasToDisable,
bool hasToReEnable) bool hasToReEnable)
{ {
bool sameSize = l->negativeUnl().size() == size; bool sameSize = l->negativeUNL().size() == size;
bool sameToDisable = bool sameToDisable =
(l->negativeUnlToDisable() != boost::none) == hasToDisable; (l->validatorToDisable() != boost::none) == hasToDisable;
bool sameToReEnable = bool sameToReEnable =
(l->negativeUnlToReEnable() != boost::none) == hasToReEnable; (l->validatorToReEnable() != boost::none) == hasToReEnable;
return sameSize && sameToDisable && sameToReEnable; return sameSize && sameToDisable && sameToReEnable;
} }
@@ -2037,10 +2040,10 @@ VerifyPubKeyAndSeq(
auto sle = l->read(keylet::negativeUNL()); auto sle = l->read(keylet::negativeUNL());
if (!sle) if (!sle)
return false; return false;
if (!sle->isFieldPresent(sfNegativeUNL)) if (!sle->isFieldPresent(sfDisabledValidators))
return false; return false;
auto const& nUnlData = sle->getFieldArray(sfNegativeUNL); auto const& nUnlData = sle->getFieldArray(sfDisabledValidators);
if (nUnlData.size() != nUnlLedgerSeq.size()) if (nUnlData.size() != nUnlLedgerSeq.size())
return false; return false;

View File

@@ -146,7 +146,7 @@ public:
auto k2 = randomKeyPair(KeyType::ed25519).first; auto k2 = randomKeyPair(KeyType::ed25519).first;
disabledKeys.insert(k1); disabledKeys.insert(k1);
disabledKeys.insert(k2); disabledKeys.insert(k2);
env.app().validators().setNegativeUnl(disabledKeys); env.app().validators().setNegativeUNL(disabledKeys);
auto const jrr = env.rpc("validators")[jss::result]; auto const jrr = env.rpc("validators")[jss::result];
auto& jrrnUnl = jrr[jss::NegativeUNL]; auto& jrrnUnl = jrr[jss::NegativeUNL];
@@ -163,7 +163,7 @@ public:
} }
disabledKeys.clear(); disabledKeys.clear();
env.app().validators().setNegativeUnl(disabledKeys); env.app().validators().setNegativeUNL(disabledKeys);
auto const jrrUpdated = env.rpc("validators")[jss::result]; auto const jrrUpdated = env.rpc("validators")[jss::result];
BEAST_EXPECT(jrrUpdated[jss::NegativeUNL].isNull()); BEAST_EXPECT(jrrUpdated[jss::NegativeUNL].isNull());
} }