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:
Peng Wang
2020-03-01 21:03:19 -05:00
committed by manojsdoshi
parent 51bd4626b1
commit 706ca874b0
41 changed files with 4344 additions and 73 deletions

View File

@@ -485,6 +485,36 @@ populateFlags(T& to, STObject const& from)
[&to]() { return to.mutable_flags(); }, from, sfFlags);
}
template <class T>
void
populateFirstLedgerSequence(T& to, STObject const& from)
{
populateProtoPrimitive(
[&to]() { return to.mutable_ledger_sequence(); },
from,
sfFirstLedgerSequence);
}
template <class T>
void
populateNegativeUNLToDisable(T& to, STObject const& from)
{
populateProtoPrimitive(
[&to]() { return to.mutable_validator_to_disable(); },
from,
sfNegativeUNLToDisable);
}
template <class T>
void
populateNegativeUNLToReEnable(T& to, STObject const& from)
{
populateProtoPrimitive(
[&to]() { return to.mutable_validator_to_re_enable(); },
from,
sfNegativeUNLToReEnable);
}
template <class T>
void
populateLastLedgerSequence(T& to, STObject const& from)
@@ -846,6 +876,21 @@ populateSignerEntries(T& to, STObject const& from)
sfSignerEntry);
}
template <class T>
void
populateNegativeUNLEntries(T& to, STObject const& from)
{
populateProtoArray(
[&to]() { return to.add_negative_unl_entries(); },
[](auto& innerObj, auto& innerProto) {
populatePublicKey(innerProto, innerObj);
populateFirstLedgerSequence(innerProto, innerObj);
},
from,
sfNegativeUNL,
sfNegativeUNLEntry);
}
template <class T>
void
populateMemos(T& to, STObject const& from)
@@ -1417,6 +1462,16 @@ convert(org::xrpl::rpc::v1::SignerList& to, STObject const& from)
populateSignerListID(to, from);
}
void
convert(org::xrpl::rpc::v1::NegativeUnl& to, STObject const& from)
{
populateNegativeUNLEntries(to, from);
populateNegativeUNLToDisable(to, from);
populateNegativeUNLToReEnable(to, from);
}
void
setLedgerEntryType(
org::xrpl::rpc::v1::AffectedNode& proto,
@@ -1472,6 +1527,10 @@ setLedgerEntryType(
proto.set_ledger_entry_type(
org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_DEPOSIT_PREAUTH);
break;
case ltNEGATIVE_UNL:
proto.set_ledger_entry_type(
org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_NEGATIVE_UNL);
break;
}
}
@@ -1517,6 +1576,9 @@ convert(T& to, STObject& from, std::uint16_t type)
case ltDEPOSIT_PREAUTH:
RPC::convert(*to.mutable_deposit_preauth(), from);
break;
case ltNEGATIVE_UNL:
RPC::convert(*to.mutable_negative_unl(), from);
break;
}
}