mirror of https://github.com/oxen-io/oxen-core.git
Added versions for SS and lokinet to be saved to core, generate_uptime_proof adds them to the proof
This commit is contained in:
parent
049de234e0
commit
c0de851d1d
|
@ -194,6 +194,7 @@ constexpr uint64_t BLOCKS_EXPECTED_IN_YEARS(int years) { return BLOCKS_EXPECTED_
|
|||
#define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY cryptonote::network_version_16_pulse
|
||||
#define HF_VERSION_PULSE cryptonote::network_version_16_pulse
|
||||
#define HF_VERSION_CLSAG cryptonote::network_version_16_pulse
|
||||
#define HF_VERSION_PROOF_VERSION cryptonote::network_version_17
|
||||
|
||||
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
||||
|
||||
|
|
|
@ -1930,7 +1930,7 @@ namespace cryptonote
|
|||
if (!m_service_node)
|
||||
return true;
|
||||
|
||||
NOTIFY_UPTIME_PROOF::request req = m_service_node_list.generate_uptime_proof(m_sn_public_ip, m_storage_port, m_storage_lmq_port, m_quorumnet_port);
|
||||
NOTIFY_UPTIME_PROOF::request req = m_service_node_list.generate_uptime_proof(m_sn_public_ip, m_storage_port, m_storage_lmq_port, ss_version, m_quorumnet_port, lokinet_version);
|
||||
|
||||
cryptonote_connection_context fake_context{};
|
||||
bool relayed = get_protocol()->relay_uptime_proof(req, fake_context);
|
||||
|
|
|
@ -1163,6 +1163,10 @@ namespace cryptonote
|
|||
std::unordered_map<crypto::x25519_public_key, oxenmq::AuthLevel>& _lmq_auth_level_map() { return m_lmq_auth; }
|
||||
oxenmq::TaggedThreadID const &pulse_thread_id() const { return *m_pulse_thread_id; }
|
||||
|
||||
/// Service Node's storage server and lokinet version
|
||||
std::array<uint16_t, 3> ss_version;
|
||||
std::array<uint16_t, 3> lokinet_version;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
|
@ -2745,11 +2745,12 @@ namespace service_nodes
|
|||
|
||||
static crypto::hash hash_uptime_proof(const cryptonote::NOTIFY_UPTIME_PROOF::request &proof, uint8_t hf_version)
|
||||
{
|
||||
auto buf = tools::memcpy_le(proof.pubkey.data, proof.timestamp, proof.public_ip, proof.storage_port, proof.pubkey_ed25519.data, proof.qnet_port, proof.storage_lmq_port);
|
||||
auto buf = tools::memcpy_le(proof.pubkey.data, proof.timestamp, proof.public_ip, proof.storage_port, proof.pubkey_ed25519.data, proof.qnet_port, proof.storage_lmq_port, proof.storage_version, proof.lokinet_version);
|
||||
size_t buf_size = buf.size();
|
||||
|
||||
if (hf_version < cryptonote::network_version_15_lns) // TODO - can be removed post-HF15
|
||||
buf_size -= sizeof(proof.storage_lmq_port);
|
||||
//TODO - Can be removed post-HF17
|
||||
if (hf_version < HF_VERSION_PROOF_VERSION)
|
||||
buf_size -= (sizeof(proof.storage_version) + sizeof(proof.lokinet_version));
|
||||
|
||||
crypto::hash result;
|
||||
crypto::cn_fast_hash(buf.data(), buf_size, result);
|
||||
|
@ -2757,7 +2758,7 @@ namespace service_nodes
|
|||
}
|
||||
|
||||
cryptonote::NOTIFY_UPTIME_PROOF::request service_node_list::generate_uptime_proof(
|
||||
uint32_t public_ip, uint16_t storage_port, uint16_t storage_lmq_port, uint16_t quorumnet_port) const
|
||||
uint32_t public_ip, uint16_t storage_port, uint16_t storage_lmq_port, std::array<uint16_t, 3> ss_version, uint16_t quorumnet_port, std::array<uint16_t, 3> lokinet_version) const
|
||||
{
|
||||
assert(m_service_node_keys);
|
||||
const auto& keys = *m_service_node_keys;
|
||||
|
@ -2771,6 +2772,10 @@ namespace service_nodes
|
|||
result.qnet_port = quorumnet_port;
|
||||
result.pubkey_ed25519 = keys.pub_ed25519;
|
||||
|
||||
result.storage_version = ss_version;
|
||||
result.lokinet_version = lokinet_version;
|
||||
|
||||
|
||||
crypto::hash hash = hash_uptime_proof(result, m_blockchain.get_current_hard_fork_version());
|
||||
crypto::generate_signature(hash, keys.pub, keys.key, result.sig);
|
||||
crypto_sign_detached(result.sig_ed25519.data, NULL, reinterpret_cast<unsigned char *>(hash.data), sizeof(hash.data), keys.key_ed25519.data);
|
||||
|
|
|
@ -515,7 +515,9 @@ namespace service_nodes
|
|||
cryptonote::NOTIFY_UPTIME_PROOF::request generate_uptime_proof(uint32_t public_ip,
|
||||
uint16_t storage_port,
|
||||
uint16_t storage_lmq_port,
|
||||
uint16_t quorumnet_port) const;
|
||||
std::array<uint16_t, 3> ss_version,
|
||||
uint16_t quorumnet_port,
|
||||
std::array<uint16_t, 3> lokinet_version) const;
|
||||
bool handle_uptime_proof(cryptonote::NOTIFY_UPTIME_PROOF::request const &proof, bool &my_uptime_proof_confirmation, crypto::x25519_public_key &x25519_pkey);
|
||||
|
||||
void record_checkpoint_participation(crypto::public_key const &pubkey, uint64_t height, bool participated);
|
||||
|
|
|
@ -224,6 +224,7 @@ namespace service_nodes {
|
|||
};
|
||||
|
||||
constexpr proof_version MIN_UPTIME_PROOF_VERSIONS[] = {
|
||||
{cryptonote::network_version_17, {8,1,5}},
|
||||
{cryptonote::network_version_16_pulse, {8,1,0}},
|
||||
{cryptonote::network_version_15_lns, {7,1,2}},
|
||||
{cryptonote::network_version_14_blink, {6,1,0}},
|
||||
|
|
|
@ -252,6 +252,8 @@ namespace cryptonote
|
|||
struct request
|
||||
{
|
||||
std::array<uint16_t, 3> snode_version;
|
||||
std::array<uint16_t, 3> storage_version;
|
||||
std::array<uint16_t, 3> lokinet_version;
|
||||
|
||||
uint64_t timestamp;
|
||||
crypto::public_key pubkey;
|
||||
|
|
|
@ -3301,6 +3301,7 @@ namespace cryptonote { namespace rpc {
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
STORAGE_SERVER_PING::response core_rpc_server::invoke(STORAGE_SERVER_PING::request&& req, rpc_context context)
|
||||
{
|
||||
m_core.ss_version = {req.version_major, req.version_minor, req.version_patch};
|
||||
return handle_ping<STORAGE_SERVER_PING>(
|
||||
{req.version_major, req.version_minor, req.version_patch}, service_nodes::MIN_STORAGE_SERVER_VERSION,
|
||||
"Storage Server", m_core.m_last_storage_server_ping, STORAGE_SERVER_PING_LIFETIME,
|
||||
|
@ -3313,6 +3314,7 @@ namespace cryptonote { namespace rpc {
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
LOKINET_PING::response core_rpc_server::invoke(LOKINET_PING::request&& req, rpc_context context)
|
||||
{
|
||||
std::copy(req.version.begin(),req.version.end(),m_core.lokinet_version.begin());
|
||||
return handle_ping<LOKINET_PING>(
|
||||
req.version, service_nodes::MIN_LOKINET_VERSION,
|
||||
"Lokinet", m_core.m_last_lokinet_ping, LOKINET_PING_LIFETIME,
|
||||
|
|
Loading…
Reference in New Issue