Don't use timestamp from proof

The timestamp inside the proof is only for signature validation, but we
were using it in some places as the uptime proof time, but not updating
it everywhere we needed to.  This fixes it by using our own timestamp
for all local timed events (e.g. when we received it, when the node is
not sending proofs, etc.) to fix the issue.
This commit is contained in:
Jason Rhinelander 2021-04-23 02:37:51 -03:00
parent fba4b9dc45
commit 208501b0d0
4 changed files with 8 additions and 8 deletions

View File

@ -6282,7 +6282,7 @@ struct service_node_proof_serialized_old
{
service_node_proof_serialized_old() = default;
service_node_proof_serialized_old(const service_nodes::proof_info &info)
: timestamp{native_to_little(info.proof->timestamp)},
: timestamp{native_to_little(info.timestamp)},
ip{native_to_little(info.proof->public_ip)},
storage_https_port{native_to_little(info.proof->storage_https_port)},
storage_omq_port{native_to_little(info.proof->storage_omq_port)},
@ -6293,9 +6293,9 @@ struct service_node_proof_serialized_old
void update(service_nodes::proof_info &info) const
{
info.proof->timestamp = little_to_native(timestamp);
if (info.proof->timestamp > info.effective_timestamp)
info.effective_timestamp = info.proof->timestamp;
info.timestamp = little_to_native(timestamp);
if (info.timestamp > info.effective_timestamp)
info.effective_timestamp = info.timestamp;
info.proof->public_ip = little_to_native(ip);
info.proof->storage_https_port = little_to_native(storage_https_port);
info.proof->storage_omq_port = little_to_native(storage_omq_port);

View File

@ -2828,7 +2828,7 @@ namespace service_nodes
proof = std::move(new_proof);
}
update_db |= update_val(timestamp, ts);
effective_timestamp = proof->timestamp;
effective_timestamp = timestamp;
pubkey_x25519 = pk_x2;
// Track an IP change (so that the obligations quorum can penalize for IP changes)
@ -2869,7 +2869,7 @@ namespace service_nodes
update_db |= update_val(proof->qnet_port, q_port);
update_db |= update_val(proof->version, ver);
update_db |= update_val(proof->pubkey_ed25519, pk_ed);
effective_timestamp = proof->timestamp;
effective_timestamp = timestamp;
pubkey_x25519 = pk_x2;
// Track an IP change (so that the obligations quorum can penalize for IP changes)

View File

@ -101,7 +101,7 @@ namespace service_nodes
m_core.get_service_node_list().access_proof(pubkey, [&](const proof_info &proof) {
ss_reachable = !proof.ss_unreachable_for(netconf.UPTIME_PROOF_VALIDITY - netconf.UPTIME_PROOF_FREQUENCY);
timestamp = std::max(proof.proof->timestamp, proof.effective_timestamp);
timestamp = std::max(proof.timestamp, proof.effective_timestamp);
ips = proof.public_ips;
checkpoint_participation = proof.checkpoint_participation;
pulse_participation = proof.pulse_participation;

View File

@ -3071,7 +3071,7 @@ namespace cryptonote { namespace rpc {
entry.quorumnet_port = proof.proof->qnet_port;
// NOTE: Service Node Testing
entry.last_uptime_proof = proof.proof->timestamp;
entry.last_uptime_proof = proof.timestamp;
auto system_now = std::chrono::system_clock::now();
auto steady_now = std::chrono::steady_clock::now();
entry.storage_server_reachable = !proof.ss_unreachable_for(netconf.UPTIME_PROOF_VALIDITY - netconf.UPTIME_PROOF_FREQUENCY, steady_now);