lokinet/SS minimum proof versions; 9.2.0 version bump

Remove support for old (non-bt) proofs with the 9.2.0 snode revision
block (I'm not 100% sure on what to call this; "snode revision"? "soft
fork"? "spork"?).

Also bumps the working version to 9.2.0; this likely isn't release
ready, but allows for testing of this on testnet.
This commit is contained in:
Jason Rhinelander 2021-06-17 20:47:00 -03:00
parent ead4819fec
commit 3644861971
4 changed files with 33 additions and 25 deletions

View File

@ -51,7 +51,7 @@ message(STATUS "CMake version ${CMAKE_VERSION}")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)")
project(oxen
VERSION 9.1.3
VERSION 9.2.0
LANGUAGES CXX C)
set(OXEN_RELEASE_CODENAME "Audacious Aurochs")

View File

@ -2747,7 +2747,7 @@ namespace service_nodes
return true;
}
//TODO: remove after HF18
//TODO: remove after HF18, snode revision 1
crypto::hash service_node_list::hash_uptime_proof(const cryptonote::NOTIFY_UPTIME_PROOF::request &proof) const
{
size_t buf_size;
@ -2850,7 +2850,7 @@ namespace service_nodes
};
//TODO remove after HF18
//TODO remove after HF18, snode revision 1
bool proof_info::update(uint64_t ts,
uint32_t ip,
uint16_t s_https_port,
@ -2904,10 +2904,13 @@ namespace service_nodes
#define REJECT_PROOF(log) do { LOG_PRINT_L2("Rejecting uptime proof from " << proof.pubkey << ": " log); return false; } while (0)
//TODO remove after HF18
//TODO remove after HF18, snode revision 1
bool service_node_list::handle_uptime_proof(cryptonote::NOTIFY_UPTIME_PROOF::request const &proof, bool &my_uptime_proof_confirmation, crypto::x25519_public_key &x25519_pkey)
{
uint8_t const hf_version = m_blockchain.get_network_version();
auto vers = get_network_version_revision(m_blockchain.nettype(), m_blockchain.get_current_blockchain_height());
if (vers >= std::pair<uint8_t, uint8_t>{cryptonote::network_version_18, 1})
REJECT_PROOF("Old format (non-bt) proofs are not acceptable from v18+1 onwards");
auto& netconf = get_config(m_blockchain.nettype());
auto now = std::chrono::system_clock::now();
@ -2917,8 +2920,8 @@ namespace service_nodes
REJECT_PROOF("timestamp is too far from now");
for (auto const &min : MIN_UPTIME_PROOF_VERSIONS)
if (hf_version >= min.hardfork && proof.snode_version < min.version)
REJECT_PROOF("v" << min.version[0] << "." << min.version[1] << "." << min.version[2] << "+ oxen version is required for v" << std::to_string(hf_version) << "+ network proofs");
if (vers >= min.hardfork_revision && proof.snode_version < min.oxend)
REJECT_PROOF("v" << tools::join(".", min.oxend) << "+ oxend version is required for v" << +vers.first << "." << +vers.second << "+ network proofs");
if (!debug_allow_local_ips && !epee::net_utils::is_ip_public(proof.public_ip))
REJECT_PROOF("public_ip is not actually public");
@ -3000,7 +3003,7 @@ namespace service_nodes
bool service_node_list::handle_btencoded_uptime_proof(std::unique_ptr<uptime_proof::Proof> proof, bool &my_uptime_proof_confirmation, crypto::x25519_public_key &x25519_pkey)
{
uint8_t const hf_version = m_blockchain.get_network_version();
auto vers = get_network_version_revision(m_blockchain.nettype(), m_blockchain.get_current_blockchain_height());
auto& netconf = get_config(m_blockchain.nettype());
auto now = std::chrono::system_clock::now();
@ -3009,9 +3012,16 @@ namespace service_nodes
if (time_deviation > netconf.UPTIME_PROOF_TOLERANCE || time_deviation < -netconf.UPTIME_PROOF_TOLERANCE)
REJECT_PROOF("timestamp is too far from now");
for (auto const &min : MIN_UPTIME_PROOF_VERSIONS)
if (hf_version >= min.hardfork && proof->version < min.version)
REJECT_PROOF("v" << min.version[0] << "." << min.version[1] << "." << min.version[2] << "+ oxen version is required for v" << std::to_string(hf_version) << "+ network proofs");
for (auto const &min : MIN_UPTIME_PROOF_VERSIONS) {
if (vers >= min.hardfork_revision) {
if (proof->version < min.oxend)
REJECT_PROOF("v" << tools::join(".", min.oxend) << "+ oxend version is required for v" << +vers.first << "." << +vers.second << "+ network proofs");
if (proof->lokinet_version < min.lokinet)
REJECT_PROOF("v" << tools::join(".", min.lokinet) << "+ lokinet version is required for v" << +vers.first << "." << +vers.second << "+ network proofs");
if (proof->storage_server_version < min.storage_server)
REJECT_PROOF("v" << tools::join(".", min.storage_server) << "+ storage server version is required for v" << +vers.first << "." << +vers.second << "+ network proofs");
}
}
if (!debug_allow_local_ips && !epee::net_utils::is_ip_public(proof->public_ip))
REJECT_PROOF("public_ip is not actually public");

View File

@ -211,23 +211,21 @@ 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<uint16_t, 3> MIN_STORAGE_SERVER_VERSION{{2, 1, 1}};
constexpr std::array<uint16_t, 3> MIN_LOKINET_VERSION{{0, 9, 3}};
constexpr std::array<uint16_t, 3> MIN_STORAGE_SERVER_VERSION{{2, 2, 0}};
constexpr std::array<uint16_t, 3> MIN_LOKINET_VERSION{{0, 9, 4}};
// The minimum accepted version number, broadcasted by Service Nodes via uptime proofs for each hardfork
struct proof_version
{
uint8_t hardfork;
std::array<uint16_t, 3> version;
std::pair<uint8_t, uint8_t> hardfork_revision;
std::array<uint16_t, 3> oxend;
std::array<uint16_t, 3> lokinet;
std::array<uint16_t, 3> storage_server;
};
constexpr proof_version MIN_UPTIME_PROOF_VERSIONS[] = {
{cryptonote::network_version_18, {9,1,0}},
{cryptonote::network_version_16_pulse, {8,1,0}},
{cryptonote::network_version_15_ons, {7,1,2}},
{cryptonote::network_version_14_blink, {6,1,0}},
{cryptonote::network_version_13_enforce_checkpoints, {5,1,0}},
{cryptonote::network_version_12_checkpointing, {4,0,3}},
constexpr std::array MIN_UPTIME_PROOF_VERSIONS = {
proof_version{{cryptonote::network_version_18, 1}, {9,2,0}, {0,9,4}, {2,2,0}},
proof_version{{cryptonote::network_version_18, 0}, {9,1,0}, {0,9,0}, {2,1,0}},
};
using swarm_id_t = uint64_t;

View File

@ -30,10 +30,10 @@ Proof::Proof(
qnet_port{quorumnet_port},
storage_https_port{sn_storage_https_port},
storage_omq_port{sn_storage_omq_port},
storage_server_version{ss_version}
storage_server_version{ss_version},
lokinet_version{lokinet_version}
{
this->lokinet_version = lokinet_version;
crypto::hash hash = this->hash_uptime_proof();
crypto::hash hash = hash_uptime_proof();
crypto::generate_signature(hash, keys.pub, keys.key, sig);
crypto_sign_detached(sig_ed25519.data, NULL, reinterpret_cast<unsigned char *>(hash.data), sizeof(hash.data), keys.key_ed25519.data);