Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 11 additions & 5 deletions src/main/ApplicationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,16 +1180,22 @@ publish(Application::pointer app)
return 0;
}

// Returns the major release version extracted from the git tag _if_ this is a
// release-tagged version of stellar core (one that looks like vNN.X.Y or
// vNN.X.YrcZ or vNN.X.YHOTZ). If its version has some other name structure
// Returns the major release version extracted from a release-version string if
// it matches one of the supported release formats, such as vNN.X.Y,
// vNN.X.YrcZ, vNN.X.YHOTZ, or the packaged form
// `stellar-core NN.X.Y (<commit-hash>)`. If its version has some other name
// structure, return std::nullopt.
std::optional<uint32_t>
getStellarCoreMajorReleaseVersion(std::string const& vstr)
{
std::regex re("^v([0-9]+)\\.[0-9]+\\.[0-9]+(rc[0-9]+|HOT[0-9]+)?$");
std::regex releaseTagRe(
"^v([0-9]+)\\.[0-9]+\\.[0-9]+(rc[0-9]+|HOT[0-9]+)?$");
std::regex packagedReleaseRe(
"^stellar-core ([0-9]+)\\.[0-9]+\\.[0-9]+(rc[0-9]+|HOT[0-9]+)? "
"\\([0-9a-fA-F]+\\)$");
std::smatch match;
if (std::regex_match(vstr, match, re))
if (std::regex_match(vstr, match, releaseTagRe) ||
std::regex_match(vstr, match, packagedReleaseRe))
{
uint32_t vers = stoi(match.str(1));
return std::make_optional<uint32_t>(vers);
Comment on lines +1197 to 1201
Expand Down
21 changes: 11 additions & 10 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,12 @@ checkXDRFileIdentity()
void
checkStellarCoreMajorVersionProtocolIdentity()
{
// This extracts a major version number from the git version string embedded
// in the binary if, and only if, that version string has the form of a
// release tag: specifically vX.Y.Z, or vX.Y.ZrcN, or vX.Y.ZHOTN. Other
// version strings return nullopt, for example non-release-tagged versions
// that typically look more like `v21.0.0rc1-84-g08d89bb4a`
// This extracts a major version number from the version string embedded in
// the binary if, and only if, it identifies a release build. Supported
// formats include source builds like vX.Y.Z, vX.Y.ZrcN, vX.Y.ZHOTN, and
// packaged builds like `stellar-core X.Y.Z (<commit-hash>)`. Other version
// strings return nullopt, for example git-describe versions that typically
// look more like `v21.0.0rc1-84-g08d89bb4a`.
auto major_release_version =
stellar::getStellarCoreMajorReleaseVersion(STELLAR_CORE_VERSION);
if (major_release_version)
Expand Down Expand Up @@ -274,11 +275,11 @@ checkStellarCoreMajorVersionProtocolIdentity()
}
else
{
// If we are running a version that does not look exactly like vX.Y.Z or
// vX.Y.ZrcN or vX.Y.ZHOTN, then we are running a non-release version of
// stellar-core and we relax the check above and just warn.
std::cerr << "Warning: running non-release version "
<< STELLAR_CORE_VERSION << " of stellar-core" << std::endl;
// If we are running a version that does not match a recognized release
// version string format, then we relax the check above and just warn.
LOG_WARNING(DEFAULT_LOG, "Running non-release version {} of "
"stellar-core",
Comment on lines +280 to +281
STELLAR_CORE_VERSION);
}
}
} // namespace
Expand Down
6 changes: 6 additions & 0 deletions src/main/test/ApplicationUtilsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ TEST_CASE("application major version numbers", "[applicationutils]")
std::make_optional<uint32_t>(20));
CHECK(getStellarCoreMajorReleaseVersion("v20.0.0HOT4") ==
std::make_optional<uint32_t>(20));
CHECK(getStellarCoreMajorReleaseVersion(
"stellar-core 23.0.0 "
"(d5cbc0793d6eab25eac886969c5bc0f7da69d6ea)") ==
std::make_optional<uint32_t>(23));
CHECK(getStellarCoreMajorReleaseVersion("v19.1.2-10") == std::nullopt);
CHECK(getStellarCoreMajorReleaseVersion("v23.0.0-1-gd5cbc0793d6e") ==
std::nullopt);
CHECK(getStellarCoreMajorReleaseVersion("v19.9.0-30-g726eabdea-dirty") ==
std::nullopt);
}
Expand Down
Loading