Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rippled Server Software Upgrade Notification #3447

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions src/ripple/app/ledger/impl/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,45 +1042,45 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> const& ledger)

if (ledger->seq() % 256 == 0)
{
/*
* Check if the majority of validators run a higher version rippled
* software. If so print a warning.
*
* Once the HardenedValidations amendment is enabled, validators include
* their rippled software version in the validation messages of every
* (flag - 1) ledger. We wait for one ledger time before checking the
* version information to accumulate more validation messages.
*/
auto const& patentHash = ledger->info().parentHash;
auto const parentLedger = getLedgerByHash(patentHash);
// Check if the majority of validators run a higher version rippled
// software. If so print a warning.
//
// Once the HardenedValidations amendment is enabled, validators include
// their rippled software version in the validation messages of every
// (flag - 1) ledger. We wait for one ledger time before checking the
// version information to accumulate more validation messages.

auto const& parentHash = ledger->info().parentHash;
auto const parentLedger = getLedgerByHash(parentHash);
if (parentLedger &&
parentLedger->rules().enabled(featureHardenedValidations))
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
{
auto const vals =
app_.getValidations().getTrustedForLedger(patentHash);
auto higherVersionCount = std::count_if(
vals.begin(), vals.end(), [](auto const& v) -> bool {
if (v->isFieldPresent(sfServerVersion))
return BuildInfo::localVersionLow(
v->getFieldU64(sfServerVersion));
else
return false;
});
auto const threshold = static_cast<std::size_t>(std::ceil(
app_.validators().getQuorumKeys().second.size() *
BuildInfo::versionUpgradeWarningThreshold));
if (higherVersionCount >= threshold)
// To throttle the warning messages, instead of printing a warning
// every flag ledger, we print every week.
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
static TimeKeeper::time_point lastTime{};
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
auto currentTime = app_.timeKeeper().now();
if (currentTime - lastTime >= weeks{1})
{
std::cerr << "***********************************************"
<< std::endl;
std::cerr << "* Majority of your trusted validators run a *"
<< std::endl;
std::cerr << "* higher version of rippled server software. *"
<< std::endl;
std::cerr << "* Please upgrade your rippled server software.*"
<< std::endl;
std::cerr << "***********************************************"
<< std::endl;
auto const vals =
app_.getValidations().getTrustedForLedger(parentHash);
auto higherVersionCount = std::count_if(
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
vals.begin(), vals.end(), [](auto const& v) -> bool {
if (v->isFieldPresent(sfServerVersion))
return BuildInfo::isNewerVersion(
v->getFieldU64(sfServerVersion));
else
return false;
});
// We set the threshold of majority to be 60% of the UNL
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
auto const threshold =
app_.validators().getQuorumKeys().second.size() * 60 / 100;
if (higherVersionCount >= threshold)
{
lastTime = currentTime;
std::cerr << "Check for upgrade: "
"A majority of trusted validators are "
"running a newer version.\n";
}
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/ripple/protocol/BuildInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ getFullVersionString();
std::uint64_t
getEncodedVersion();

/** Compare the local node's rippled server software version with the given one.
/** Check if the version is newer than the local node's rippled software
version.

@note We only compare the major version, minor version, and patch version.
@param othersVersion another node's rippled server software version
@return true if local node's rippled server software version is lower,
false otherwise.
@param version another node's rippled software version
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
@return true if the version is newer than the local node's rippled software
version, false otherwise.

@note This function only understands version numbers that are generated by
rippled. Please see the getEncodedVersion() function for detail.
*/
bool
localVersionLow(std::uint64_t othersVersion);

static constexpr float versionUpgradeWarningThreshold = 0.6;
isNewerVersion(std::uint64_t version);

} // namespace BuildInfo

Expand Down
8 changes: 5 additions & 3 deletions src/ripple/protocol/impl/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,12 @@ getEncodedVersion()
}

bool
localVersionLow(std::uint64_t othersVersion)
isNewerVersion(std::uint64_t version)
{
static std::uint64_t const mask = 0x0000ffffff000000;
return (getEncodedVersion() & mask) < (othersVersion & mask);
std::uint64_t constexpr mask = 0x183B000000000000;
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
if ((version & mask) == mask)
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
return version > getEncodedVersion();
return false;
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
}
pwang200 marked this conversation as resolved.
Show resolved Hide resolved

} // namespace BuildInfo
Expand Down