diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp index d51653e89..dc7396ac1 100644 --- a/src/cryptonote_basic/difficulty.cpp +++ b/src/cryptonote_basic/difficulty.cpp @@ -214,6 +214,7 @@ namespace cryptonote { return 1; } if (HEIGHT < 200 && HEIGHT > 2 && m_nettype == TESTNET) { return 500; } + if (HEIGHT <= DIFFICULTY_RESET_HEIGHT + DIFFICULTY_WINDOW && HEIGHT >= DIFFICULTY_RESET_HEIGHT && m_nettype == MAINNET) { return DIFFICULTY_RESET_LEVEL; } static_assert(DIFFICULTY_WINDOW >= 2, "Window is too small"); assert(length <= DIFFICULTY_WINDOW); sort(timestamps.begin(), timestamps.end()); diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 7d7fb84c6..245f7a959 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -87,6 +87,8 @@ #define DIFFICULTY_BLOCKS_COUNT_V3 DIFFICULTY_WINDOW_V3 + 1 // added +1 to make N=N #define DIFFICULTY_BLOCKS_COUNT_V2 DIFFICULTY_WINDOW_V2 + 1 // added +1 to make N=N #define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG +#define DIFFICULTY_RESET_HEIGHT 331519 // ~July 4, 2021 Pool Independence Day +#define DIFFICULTY_RESET_LEVEL 100000000 // 100 mill #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 DIFFICULTY_TARGET_V1 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 DIFFICULTY_TARGET_V2 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index e067f2dde..91c4f58d5 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -948,7 +948,7 @@ start: difficulty_type diff = next_difficulty(timestamps, m_nettype, difficulties, target, HEIGHT); - if (version >= 11) { + if (version <= 17 && version >= 11) { diff = next_difficulty_v5(timestamps, m_nettype, difficulties, T, N, HEIGHT); } else if (version == 10) { diff = next_difficulty_v4(timestamps, m_nettype, difficulties, HEIGHT); @@ -1043,7 +1043,7 @@ size_t Blockchain::recalculate_difficulties(boost::optional start_heig size_t target = get_ideal_hard_fork_version(height) < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2; difficulty_type recalculated_diff = next_difficulty(timestamps, m_nettype, difficulties, target, HEIGHT); - if (version >= 11) { + if (version <= 17 && version >= 11) { recalculated_diff = next_difficulty_v5(timestamps, m_nettype, difficulties, T, N, HEIGHT); } else if (version == 10) { recalculated_diff = next_difficulty_v4(timestamps, m_nettype, difficulties, HEIGHT); @@ -1357,7 +1357,7 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std: uint64_t HEIGHT = m_db->height(); // calculate the difficulty target for the block and return it - if (version >= 11) { + if (version <= 17 && version >= 11) { return next_difficulty_v5(timestamps, m_nettype, cumulative_difficulties, T, N, HEIGHT); } else if (version == 10) { return next_difficulty_v4(timestamps, m_nettype, cumulative_difficulties, HEIGHT); diff --git a/src/hardforks/hardforks.cpp b/src/hardforks/hardforks.cpp index 3554bde2e..59cf8c4a5 100644 --- a/src/hardforks/hardforks.cpp +++ b/src/hardforks/hardforks.cpp @@ -43,6 +43,7 @@ const hardfork_t mainnet_hard_forks[] = { { 15, 160777, 0, 1573280497 }, { 16, 253999, 0, 1600576508 }, { 17, 254287, 0, 1600576524 }, + { 18, 331519, 0, 1623245591 }, }; const size_t num_mainnet_hard_forks = sizeof(mainnet_hard_forks) / sizeof(mainnet_hard_forks[0]);