diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 54b45be9..17f635c9 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1055,7 +1055,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con wide_difficulty_type& dif = pos ? m_cached_next_pos_difficulty : m_cached_next_pow_difficulty; TIME_MEASURE_FINISH_PD(target_calculating_enum_blocks); TIME_MEASURE_START_PD(target_calculating_calc); - if (m_db_blocks.size() > m_core_runtime_config.hard_fork1_starts_after_height) + if (m_db_blocks.size() > m_core_runtime_config.hard_fork_01_starts_after_height) { dif = next_difficulty_2(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET); } @@ -1094,7 +1094,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional2(bool pos, co enum_blockchain(cb, alt_chain, split_height); wide_difficulty_type diff = 0; - if(abei.height > m_core_runtime_config.hard_fork1_starts_after_height) + if(abei.height > m_core_runtime_config.hard_fork_01_starts_after_height) diff = next_difficulty_2(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET); else diff = next_difficulty_1(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET); @@ -1174,7 +1174,7 @@ bool blockchain_storage::prevalidate_miner_transaction(const block& b, uint64_t CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(txin_to_key), false, "coinstake transaction in the block has the wrong type"); } - if (height > m_core_runtime_config.hard_fork1_starts_after_height) + if (height > m_core_runtime_config.hard_fork_01_starts_after_height) { // new rules that allow different unlock time in coinbase outputs uint64_t max_unlock_time = 0; @@ -1345,7 +1345,7 @@ bool blockchain_storage::create_block_template(const create_block_template_param boost::multiprecision::uint128_t already_generated_coins; CRITICAL_REGION_BEGIN(m_read_lock); height = m_db_blocks.size(); - if(height <= m_core_runtime_config.hard_fork1_starts_after_height) + if(height <= m_core_runtime_config.hard_fork_01_starts_after_height) b.major_version = BLOCK_MAJOR_VERSION_INITAL; else b.major_version = CURRENT_BLOCK_MAJOR_VERSION; @@ -1713,7 +1713,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto:: if (abei.height >= m_core_runtime_config.pos_minimum_heigh) cumulative_diff_delta = correct_difficulty_with_sequence_factor(sequence_factor, cumulative_diff_delta); - if (abei.height > BLOCKCHAIN_HEIGHT_FOR_POS_STRICT_SEQUENCE_LIMITATION && abei.height <= m_core_runtime_config.hard_fork1_starts_after_height && pos_block && sequence_factor > BLOCK_POS_STRICT_SEQUENCE_LIMIT) + if (abei.height > BLOCKCHAIN_HEIGHT_FOR_POS_STRICT_SEQUENCE_LIMITATION && abei.height <= m_core_runtime_config.hard_fork_01_starts_after_height && pos_block && sequence_factor > BLOCK_POS_STRICT_SEQUENCE_LIMIT) { LOG_PRINT_RED_L0("Alternative block " << id << " @ " << abei.height << " has too big sequence factor: " << sequence_factor << ", rejected"); bvc.m_verification_failed = true; @@ -1838,7 +1838,7 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_ const block_extended_info& alt_chain_bei = alt_chain.back()->second; const block_extended_info& connection_point = alt_chain.front()->second; - if (connection_point.height <= m_core_runtime_config.hard_fork1_starts_after_height) + if (connection_point.height <= m_core_runtime_config.hard_fork_01_starts_after_height) { //use pre-hard fork, old-style comparing if (main_chain_bei.cumulative_diff_adjusted < alt_chain_bei.cumulative_diff_adjusted) @@ -1859,7 +1859,7 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_ return true; } } - else if (alt_chain_bei.height > m_core_runtime_config.hard_fork1_starts_after_height) + else if (alt_chain_bei.height > m_core_runtime_config.hard_fork_01_starts_after_height) { //new rules, applied after HARD_FORK_1 //to learn this algo please read https://github.com/hyle-team/docs/blob/master/zano/PoS_Analysis_and_improvements_proposal.pdf @@ -4501,7 +4501,7 @@ void blockchain_storage::get_pos_mining_estimate(uint64_t amount_coins, //------------------------------------------------------------------ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transaction& tx, const crypto::hash& tx_id, uint64_t block_height) const { - if (block_height <= m_core_runtime_config.hard_fork1_starts_after_height) + if (block_height <= m_core_runtime_config.hard_fork_01_starts_after_height) { // before hardfork 1 @@ -4528,7 +4528,7 @@ bool blockchain_storage::validate_pos_coinbase_outs_unlock_time(const transactio return true; } - CHECK_AND_ASSERT_MES(get_block_height(miner_tx) > m_core_runtime_config.hard_fork1_starts_after_height, false, "error in block [" << get_block_height(miner_tx) << "] etc_tx_details_unlock_time2 can exist only after hard fork point : " << m_core_runtime_config.hard_fork1_starts_after_height); + CHECK_AND_ASSERT_MES(get_block_height(miner_tx) > m_core_runtime_config.hard_fork_01_starts_after_height, false, "error in block [" << get_block_height(miner_tx) << "] etc_tx_details_unlock_time2 can exist only after hard fork point : " << m_core_runtime_config.hard_fork_01_starts_after_height); //etc_tx_details_unlock_time2 can be kept only after hard_fork_1 point etc_tx_details_unlock_time2 ut2 = AUTO_VAL_INIT(ut2); @@ -4633,7 +4633,7 @@ bool blockchain_storage::validate_pos_block(const block& b, r = check_tx_input(b.miner_tx, 1, coinstake_in, id, b.miner_tx.signatures[0], max_related_block_height, source_max_unlock_time_for_pos_coinbase); CHECK_AND_ASSERT_MES(r, false, "Failed to validate coinstake input in miner tx, block_id = " << get_block_hash(b)); - if (get_block_height(b) > m_core_runtime_config.hard_fork1_starts_after_height) + if (get_block_height(b) > m_core_runtime_config.hard_fork_01_starts_after_height) { uint64_t last_pow_h = get_last_x_block_height(false); CHECK_AND_ASSERT_MES(max_related_block_height <= last_pow_h, false, "Failed to validate coinbase in PoS block, condition failed: max_related_block_height(" << max_related_block_height << ") <= last_pow_h(" << last_pow_h << ")"); @@ -5263,7 +5263,7 @@ bool blockchain_storage::update_next_comulative_size_limit() //------------------------------------------------------------------ bool blockchain_storage::prevalidate_block(const block& bl) { - if (bl.major_version == BLOCK_MAJOR_VERSION_INITAL && get_block_height(bl) <= m_core_runtime_config.hard_fork1_starts_after_height) + if (bl.major_version == BLOCK_MAJOR_VERSION_INITAL && get_block_height(bl) <= m_core_runtime_config.hard_fork_01_starts_after_height) return true; if (bl.major_version != CURRENT_BLOCK_MAJOR_VERSION) { diff --git a/src/currency_core/core_runtime_config.h b/src/currency_core/core_runtime_config.h index 8e9d94b0..283d3efb 100644 --- a/src/currency_core/core_runtime_config.h +++ b/src/currency_core/core_runtime_config.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Zano Project +// Copyright (c) 2014-2020 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Boolberry developers // Distributed under the MIT/X11 software license, see the accompanying @@ -18,11 +18,13 @@ namespace currency uint64_t pos_minimum_heigh; //height uint64_t tx_pool_min_fee; uint64_t tx_default_fee; - uint64_t hard_fork1_starts_after_height; uint64_t max_alt_blocks; crypto::public_key alias_validation_pubkey; core_time_func_t get_core_time; - + + uint64_t hard_fork_01_starts_after_height; + uint64_t hard_fork_02_starts_after_height; + static uint64_t _default_core_time_function() { return time(NULL); @@ -37,7 +39,10 @@ namespace currency pc.tx_pool_min_fee = TX_MINIMUM_FEE; pc.tx_default_fee = TX_DEFAULT_FEE; pc.max_alt_blocks = CURRENCY_ALT_BLOCK_MAX_COUNT; - pc.hard_fork1_starts_after_height = ZANO_HARDFORK_1_AFTER_HEIGHT; + + pc.hard_fork_01_starts_after_height = ZANO_HARDFORK_01_AFTER_HEIGHT; + pc.hard_fork_02_starts_after_height = ZANO_HARDFORK_02_AFTER_HEIGHT; + pc.get_core_time = &core_runtime_config::_default_core_time_function; bool r = epee::string_tools::hex_to_pod(ALIAS_SHORT_NAMES_VALIDATION_PUB_KEY, pc.alias_validation_pubkey); CHECK_AND_ASSERT_THROW_MES(r, "failed to parse alias_validation_pub_key"); diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 8de1ee32..95eee0db 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -224,9 +224,11 @@ #define BLOCK_MINOR_VERSION_GENESIS 0 #define BLOCK_MAJOR_VERSION_INITAL 0 #ifndef TESTNET -#define ZANO_HARDFORK_1_AFTER_HEIGHT 194624 +#define ZANO_HARDFORK_01_AFTER_HEIGHT 194624 +#define ZANO_HARDFORK_02_AFTER_HEIGHT 999999 #else -#define ZANO_HARDFORK_1_AFTER_HEIGHT 1440 +#define ZANO_HARDFORK_01_AFTER_HEIGHT 1440 +#define ZANO_HARDFORK_02_AFTER_HEIGHT 999999 #endif diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 5aaf395f..768a2e6b 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2951,7 +2951,7 @@ bool wallet2::is_transfer_unlocked(const transfer_details& td, bool for_pos_mini uint64_t unlock_time = get_tx_unlock_time(td.m_ptx_wallet_info->m_tx, td.m_internal_output_index); - if (for_pos_mining && m_blockchain.size() > m_core_runtime_config.hard_fork1_starts_after_height) + if (for_pos_mining && m_blockchain.size() > m_core_runtime_config.hard_fork_01_starts_after_height) { //allowed of staking locked coins with stake_lock_time = unlock_time;