diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 431bd71a..a498ec18 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -302,6 +302,7 @@ namespace currency res.status = API_RETURN_CODE_FAIL; return false; } + res.current_hardfork = m_core.get_blockchain_storage().get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height); for(auto& b: bs) { @@ -339,6 +340,7 @@ namespace currency res.status = API_RETURN_CODE_FAIL; return false; } + res.current_hardfork = m_core.get_blockchain_storage().get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height); LOG_PRINT_L2("[on_get_blocks]: Enumerating over blocks ...."); for (auto& b : bs) @@ -357,6 +359,8 @@ namespace currency i++; } } + + LOG_PRINT_L2("[on_get_blocks]: Finished"); res.status = API_RETURN_CODE_OK; return true; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 8953df4e..72b2a298 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -274,12 +274,14 @@ namespace currency std::list blocks; uint64_t start_height; uint64_t current_height; + uint64_t current_hardfork; std::string status; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(blocks) DOC_DSCR("Bunch of blocks") DOC_EXMP_AUTO(1) DOC_END KV_SERIALIZE(start_height) DOC_DSCR("Starting height of the resulting bunch of blocks.") DOC_EXMP(2000000) DOC_END KV_SERIALIZE(current_height) DOC_DSCR("Current height of the blockchain.") DOC_EXMP(2555000) DOC_END + KV_SERIALIZE(current_hardfork) DOC_DSCR("Current hardfork, used for wallet <-> version verification") DOC_EXMP(4) DOC_END KV_SERIALIZE(status) DOC_DSCR("Status of the call.") DOC_EXMP(API_RETURN_CODE_OK) DOC_END END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 0115c334..8d1630ca 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2019,6 +2019,16 @@ void wallet2::pull_blocks(size_t& blocks_added, std::atomic& stop, bool& f "wrong daemon response: m_start_height=" + std::to_string(res.start_height) + " not less than local blockchain size=" + std::to_string(get_blockchain_current_size())); + //check if wallet are "on the same hardfork" with daemon with latest height of daemon + if (res.current_hardfork != 0 && res.current_hardfork != get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height)) + { + LOG_ERROR("Daemon currently on the hardfork (" << res.current_hardfork + << ") at heigh (" << res.current_height << "), while wallet think it's hardfork (" << get_core_runtime_config().hard_forks.get_the_most_recent_hardfork_id_for_height(res.current_height) << ") at a given height"); + THROW_IF_TRUE_WALLET_EX(true, error::wallet_internal_error, "Daemon and wallet ver validation failed, hardforks missmatch"); + } + + + try { handle_pulled_blocks(blocks_added, stop, res, full_reset_needed);