Properly handle expired validator lists when validating (RIPD-1661):

A validator that was configured to use a published validator list could
exhibit aberrent behavior if that validator list expired.

This commit introduces additional logic that makes validators operating
with an expired validator list bow out of the consensus process instead
of continuing to publish validations. Normal operation will resume once
a non-expired validator list becomes available.

This commit also enhances status reporting when using the `server_info`
and `validators` commands. Before, only the expiration time of the list
would be returned; now, its current status is also reported in a format
that is clearer.
This commit is contained in:
Nik Bougalis
2018-10-18 02:11:46 -07:00
committed by Mike Ellery
parent 63c3fc30d8
commit b36e11bc49
6 changed files with 91 additions and 26 deletions

View File

@@ -459,6 +459,13 @@ ValidatorList::removePublisherList (PublicKey const& publisherKey)
return true;
}
std::size_t
ValidatorList::count() const
{
std::shared_lock<std::shared_timed_mutex> read_lock{mutex_};
return publisherLists_.size();
}
boost::optional<TimeKeeper::time_point>
ValidatorList::expires() const
{
@@ -486,19 +493,34 @@ ValidatorList::getJson() const
res[jss::validation_quorum] = static_cast<Json::UInt>(quorum());
if (auto when = expires())
{
if (*when == TimeKeeper::time_point::max())
auto& x = (res[jss::validator_list] = Json::objectValue);
x[jss::count] = static_cast<Json::UInt>(count());
if (auto when = expires())
{
res[jss::validator_list_expires] = "never";
if (*when == TimeKeeper::time_point::max())
{
x[jss::expiration] = "never";
x[jss::status] = "active";
}
else
{
x[jss::expiration] = to_string(*when);
if (*when > timeKeeper_.now())
x[jss::status] = "active";
else
x[jss::status] = "expired";
}
}
else
{
res[jss::validator_list_expires] = to_string(*when);
x[jss::status] = "unknown";
x[jss::expiration] = "unknown";
}
}
else
res[jss::validator_list_expires] = "unknown";
// Local static keys
PublicKey local;