From fbc506b1f55826e3ef4ec3bb32fc76cc2810d847 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 11 Dec 2018 23:09:02 +0800 Subject: [PATCH 1/3] fix logic for choosing timestamp-check-window-version --- src/cryptonote_core/blockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index dc62118d2..0154391ce 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1443,7 +1443,7 @@ bool Blockchain::complete_timestamps_vector(uint64_t start_top_height, std::vect { LOG_PRINT_L3("Blockchain::" << __func__); uint8_t version = get_current_hard_fork_version(); - size_t blockchain_timestamp_check_window = version >= 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 : version == 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; + size_t blockchain_timestamp_check_window = version >= 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 : version == 10 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; if(timestamps.size() >= blockchain_timestamp_check_window) return true; @@ -3183,7 +3183,7 @@ bool Blockchain::check_block_timestamp(std::vector& timestamps, const LOG_PRINT_L3("Blockchain::" << __func__); median_ts = epee::misc_utils::median(timestamps); uint8_t version = get_current_hard_fork_version(); - size_t blockchain_timestamp_check_window = version >= 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 : version == 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; + size_t blockchain_timestamp_check_window = version >= 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 : version == 10 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; if(b.timestamp < median_ts) { MERROR_VER("Timestamp of block with id: " << get_block_hash(b) << ", " << b.timestamp << ", less than median of last " << blockchain_timestamp_check_window << " blocks, " << median_ts); @@ -3205,7 +3205,7 @@ bool Blockchain::check_block_timestamp(const block& b, uint64_t& median_ts) cons LOG_PRINT_L3("Blockchain::" << __func__); uint8_t version = get_current_hard_fork_version(); uint64_t cryptonote_block_future_time_limit = version >= 8 ? CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2 : CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT; - size_t blockchain_timestamp_check_window = version >= 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 : version == 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; + size_t blockchain_timestamp_check_window = version >= 11 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 : version == 10 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; if(b.timestamp > get_adjusted_time() + cryptonote_block_future_time_limit) { From 65d056aeae45edc166363a2b002244d792959e44 Mon Sep 17 00:00:00 2001 From: fuwa Date: Wed, 12 Dec 2018 18:31:32 +0800 Subject: [PATCH 2/3] use the predefined diff variable for next-diff --- src/cryptonote_core/blockchain.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 0154391ce..f061909ce 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -879,15 +879,15 @@ difficulty_type Blockchain::get_difficulty_for_next_block() difficulty_type diff = next_difficulty(timestamps, difficulties, target); if (version >= 11) { - difficulty_type diff = next_difficulty_v5(timestamps, difficulties, target); + diff = next_difficulty_v5(timestamps, difficulties, target); } else if (version == 10) { - difficulty_type diff = next_difficulty_v4(timestamps, difficulties, height); + diff = next_difficulty_v4(timestamps, difficulties, height); } else if (version == 9) { - difficulty_type diff = next_difficulty_v3(timestamps, difficulties); + diff = next_difficulty_v3(timestamps, difficulties); } else if (version == 8) { - difficulty_type diff = next_difficulty_v2(timestamps, difficulties, target); + diff = next_difficulty_v2(timestamps, difficulties, target); } else { - difficulty_type diff = next_difficulty(timestamps, difficulties, target); + diff = next_difficulty(timestamps, difficulties, target); } CRITICAL_REGION_LOCAL1(m_difficulty_lock); From 72904ee10706e15a74ae974ecba08566db1db3eb Mon Sep 17 00:00:00 2001 From: wowario Date: Sat, 15 Dec 2018 00:15:15 +0300 Subject: [PATCH 3/3] update difficulty --- src/cryptonote_config.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 31388ac66..ae158f86c 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -49,7 +49,7 @@ #define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2 #define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 4 -#define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 24 +#define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V3 12 #define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 11 #define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 60 @@ -80,12 +80,12 @@ #define DIFFICULTY_TARGET_V2 300 #define DIFFICULTY_TARGET_V1 300 -#define DIFFICULTY_WINDOW_V3 288 +#define DIFFICULTY_WINDOW_V3 144 #define DIFFICULTY_WINDOW_V2 60 #define DIFFICULTY_WINDOW 720 // blocks -#define DIFFICULTY_LAG_V2 6 +#define DIFFICULTY_LAG_V2 3 #define DIFFICULTY_LAG 15 // !!! -#define DIFFICULTY_CUT_V2 24 +#define DIFFICULTY_CUT_V2 12 #define DIFFICULTY_CUT 60 // timestamps to cut after sorting #define DIFFICULTY_BLOCKS_COUNT_V3 DIFFICULTY_WINDOW_V3 + DIFFICULTY_LAG_V2 #define DIFFICULTY_BLOCKS_COUNT_V2 DIFFICULTY_WINDOW_V2 + 1 // added +1 to make N=N