mirror of https://github.com/oxen-io/oxen-core.git
Uptime proof timer tweak + debug option
This tweaks uptime proofs to go out on the first timer tick in the 58.5-62.5 interval (rather than 60-65) which should result in proofs usually being very close to the 60 minute mark. (Currently a fair percentage end up at the 65m mark because the timer fires just before the 60m mark). It also tweaks the first uptime proof to go out after 2 minutes instead of 5 minutes, and uses separate constants (UPTIME_PROOF_INITIAL_DELAY_SECONDS, UPTIME_PROOF_TIMER_SECONDS) for times that were previously overloading the UPTIME_PROOF_BUFFER_IN_SECONDS constant. For debugging this also adds a cmake option LOKI_DEBUG_SHORT_PROOFS that, when enabled, makes the whole proof cycle (sending and acceptance) 20x faster, which is very useful for local testnet debugging.
This commit is contained in:
parent
f7b0d212d7
commit
dd230491db
|
@ -1023,6 +1023,12 @@ if(SODIUM_LIBRARY)
|
|||
set(ZMQ_LIB "${ZMQ_LIB};${SODIUM_LIBRARY}")
|
||||
endif()
|
||||
|
||||
option(LOKI_DEBUG_SHORT_PROOFS "Developer option to substantially reduce uptime proof intervals for local test network debugging (the result lokid will not be usable on the live networks)" OFF)
|
||||
if (LOKI_DEBUG_SHORT_PROOFS)
|
||||
add_definitions(-DUPTIME_PROOF_BASE_MINUTE=3) # 20x faster uptime proofs
|
||||
endif()
|
||||
|
||||
|
||||
add_subdirectory(contrib)
|
||||
add_subdirectory(src)
|
||||
|
||||
|
|
|
@ -60,9 +60,16 @@ static_assert(STAKING_PORTIONS % 3 == 0, "Use a multiple of three, so that it di
|
|||
|
||||
#define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 11
|
||||
|
||||
// For local testnet debug purposes allow shrinking the uptime proof frequency
|
||||
#ifndef UPTIME_PROOF_BASE_MINUTE
|
||||
#define UPTIME_PROOF_BASE_MINUTE 60
|
||||
#endif
|
||||
|
||||
#define UPTIME_PROOF_BUFFER_IN_SECONDS (5*60) // The acceptable window of time to accept a peer's uptime proof from its reported timestamp
|
||||
#define UPTIME_PROOF_FREQUENCY_IN_SECONDS (60*60)
|
||||
#define UPTIME_PROOF_MAX_TIME_IN_SECONDS (UPTIME_PROOF_FREQUENCY_IN_SECONDS * 2 + UPTIME_PROOF_BUFFER_IN_SECONDS)
|
||||
#define UPTIME_PROOF_INITIAL_DELAY_SECONDS (2*UPTIME_PROOF_BASE_MINUTE) // Delay after startup before sending a proof (to allow connections to be established)
|
||||
#define UPTIME_PROOF_TIMER_SECONDS (5*UPTIME_PROOF_BASE_MINUTE) // How often we check whether we need to send an uptime proof
|
||||
#define UPTIME_PROOF_FREQUENCY_IN_SECONDS (60*UPTIME_PROOF_BASE_MINUTE) // How often we resend uptime proofs normally (i.e. after we've seen an uptime proof reply from the network)
|
||||
#define UPTIME_PROOF_MAX_TIME_IN_SECONDS (UPTIME_PROOF_FREQUENCY_IN_SECONDS * 2 + UPTIME_PROOF_BUFFER_IN_SECONDS) // How long until proofs of other network service nodes are considered expired
|
||||
|
||||
#define STORAGE_SERVER_PING_LIFETIME UPTIME_PROOF_FREQUENCY_IN_SECONDS
|
||||
#define LOKINET_PING_LIFETIME UPTIME_PROOF_FREQUENCY_IN_SECONDS
|
||||
|
|
|
@ -1876,7 +1876,11 @@ namespace cryptonote
|
|||
{
|
||||
service_nodes::service_node_info const &info = *states[0].info;
|
||||
m_check_uptime_proof_interval.do_call([&info, this]() {
|
||||
if (info.proof->timestamp <= static_cast<uint64_t>(time(nullptr) - UPTIME_PROOF_FREQUENCY_IN_SECONDS))
|
||||
// This timer is not perfectly precise and can leak seconds slightly, so send the uptime
|
||||
// proof if we are within half a tick of the target time. (Essentially our target proof
|
||||
// window becomes the first time this triggers in the 57.5-62.5 minute window).
|
||||
uint64_t threshold = static_cast<uint64_t>(time(nullptr) - UPTIME_PROOF_FREQUENCY_IN_SECONDS + UPTIME_PROOF_TIMER_SECONDS/2);
|
||||
if (info.proof->timestamp <= threshold)
|
||||
{
|
||||
if (!check_external_ping(m_last_storage_server_ping, STORAGE_SERVER_PING_LIFETIME, "the storage server"))
|
||||
{
|
||||
|
@ -1945,7 +1949,7 @@ namespace cryptonote
|
|||
m_block_rate_interval.do_call(boost::bind(&core::check_block_rate, this));
|
||||
|
||||
time_t const lifetime = time(nullptr) - get_start_time();
|
||||
if (m_service_node_keys && lifetime > DIFFICULTY_TARGET_V2) // Give us some time to connect to peers before sending uptimes
|
||||
if (m_service_node_keys && lifetime > UPTIME_PROOF_INITIAL_DELAY_SECONDS) // Give us some time to connect to peers before sending uptimes
|
||||
{
|
||||
do_uptime_proof_call();
|
||||
}
|
||||
|
|
|
@ -1085,7 +1085,7 @@ namespace cryptonote
|
|||
epee::math_helper::once_a_time_seconds<60*2, false> m_txpool_auto_relayer; //!< interval for checking re-relaying txpool transactions
|
||||
epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions
|
||||
epee::math_helper::once_a_time_seconds<60*10, true> m_check_disk_space_interval; //!< interval for checking for disk space
|
||||
epee::math_helper::once_a_time_seconds<UPTIME_PROOF_BUFFER_IN_SECONDS, true> m_check_uptime_proof_interval; //!< interval for checking our own uptime proof
|
||||
epee::math_helper::once_a_time_seconds<UPTIME_PROOF_TIMER_SECONDS, true> m_check_uptime_proof_interval; //!< interval for checking our own uptime proof
|
||||
epee::math_helper::once_a_time_seconds<90, false> m_block_rate_interval; //!< interval for checking block rate
|
||||
epee::math_helper::once_a_time_seconds<60*60*5, true> m_blockchain_pruning_interval; //!< interval for incremental blockchain pruning
|
||||
epee::math_helper::once_a_time_seconds<60*2, false> m_service_node_vote_relayer;
|
||||
|
|
Loading…
Reference in New Issue