Enforce minimum storage server version since hardfork 13 (#811)

* Enforce minimum storage server version since hardfork 13

* Send Storage Server version as a triplet

* Send Storage Server version as a triplet of numbers, not strings

* Enforce Storage Server version immediately
This commit is contained in:
Maxim Shishmarev 2019-08-22 14:10:49 +10:00 committed by Doyle
parent 14881db565
commit 94824e3bf4
3 changed files with 25 additions and 3 deletions

View file

@ -97,6 +97,8 @@ namespace service_nodes {
// blocks out of sync and sending something that it thinks is legit.
constexpr uint64_t VOTE_OR_TX_VERIFY_HEIGHT_BUFFER = 5;
constexpr std::array<int, 3> MIN_STORAGE_SERVER_VERSION = {1, 0, 5};
using swarm_id_t = uint64_t;
constexpr swarm_id_t UNASSIGNED_SWARM_ID = UINT64_MAX;

View file

@ -2965,13 +2965,27 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_storage_server_ping(const COMMAND_RPC_STORAGE_SERVER_PING::request&,
bool core_rpc_server::on_storage_server_ping(const COMMAND_RPC_STORAGE_SERVER_PING::request& req,
COMMAND_RPC_STORAGE_SERVER_PING::response& res,
epee::json_rpc::error&,
const connection_context*)
{
m_core.m_last_storage_server_ping = time(nullptr);
res.status = "OK";
const std::array<int, 3> cur_version = { req.version_major, req.version_minor, req.version_patch };
if (cur_version < service_nodes::MIN_STORAGE_SERVER_VERSION) {
std::stringstream status;
status << "Outdated Storage Server. ";
status << "Current: " << req.version_major << "." << req.version_minor << "." << req.version_patch << ". ";
status << "Required: " << service_nodes::MIN_STORAGE_SERVER_VERSION[0] << "."
<< service_nodes::MIN_STORAGE_SERVER_VERSION[1] << "." << service_nodes::MIN_STORAGE_SERVER_VERSION[2];
res.status = status.str();
MERROR(status.str());
} else {
m_core.m_last_storage_server_ping = time(nullptr);
res.status = "OK";
}
return true;
}
//------------------------------------------------------------------------------------------------------------------------------

View file

@ -2981,7 +2981,13 @@ namespace cryptonote
{
struct request
{
int version_major; // Storage Server Major version
int version_minor; // Storage Server Minor version
int version_patch; // Storage Server Patch version
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(version_major);
KV_SERIALIZE(version_minor);
KV_SERIALIZE(version_patch);
END_KV_SERIALIZE_MAP()
};