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 3 commits
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
3 changes: 3 additions & 0 deletions src/ripple/app/ledger/LedgerMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ class LedgerMaster : public Stoppable, public AbstractFetchPackContainer
// without first wiping the database.
LedgerIndex const max_ledger_difference_{1000000};

// Time of printing the upgrade warning message previously
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
TimeKeeper::time_point upgradeWarningPrevTime_{};

private:
struct Stats
{
Expand Down
49 changes: 49 additions & 0 deletions src/ripple/app/ledger/impl/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include <ripple/nodestore/DatabaseShard.h>
#include <ripple/overlay/Overlay.h>
#include <ripple/overlay/Peer.h>
#include <ripple/protocol/BuildInfo.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/HashPrefix.h>
#include <ripple/protocol/digest.h>
#include <ripple/resource/Fees.h>
Expand Down Expand Up @@ -1037,6 +1039,53 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> const& ledger)
app_.getFeeTrack().setRemoteFee(fee);

tryAdvance();

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& 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
{
// 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
auto currentTime = app_.timeKeeper().now();
if (currentTime - upgradeWarningPrevTime_ >= weeks{1})
pwang200 marked this conversation as resolved.
Show resolved Hide resolved
{
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)
{
upgradeWarningPrevTime_ = currentTime;
auto const upgradeMsg =
"Check for upgrade: "
"A majority of trusted validators are "
"running a newer version.";
std::cerr << upgradeMsg << std::endl;
JLOG(m_journal.error()) << upgradeMsg;
}
}
}
}
}

/** Report that the consensus process built a particular ledger */
Expand Down
13 changes: 13 additions & 0 deletions src/ripple/protocol/BuildInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ getFullVersionString();
std::uint64_t
getEncodedVersion();

/** Check if the version is newer than the local node's rippled software
version.

@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
isNewerVersion(std::uint64_t version);

} // namespace BuildInfo

} // namespace ripple
Expand Down
9 changes: 9 additions & 0 deletions src/ripple/protocol/impl/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ getEncodedVersion()
return cookie;
}

bool
isNewerVersion(std::uint64_t version)
{
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

} // namespace ripple