diff --git a/src/blocks/checkpoints.dat b/src/blocks/checkpoints.dat index fce6c1d4d..ae1663979 100644 Binary files a/src/blocks/checkpoints.dat and b/src/blocks/checkpoints.dat differ diff --git a/src/checkpoints/checkpoints.cpp b/src/checkpoints/checkpoints.cpp index 1fb98f0a3..70a90f785 100755 --- a/src/checkpoints/checkpoints.cpp +++ b/src/checkpoints/checkpoints.cpp @@ -188,6 +188,9 @@ namespace cryptonote ADD_CHECKPOINT(50000, "5286ac2a0f39b3aefcba363cd71f2760bd1e0d763cbc81026ebdc3f80a86541f"); ADD_CHECKPOINT(53666, "3f43f56f66ef0c43cf2fd14d0d28fa2aae0ef8f40716773511345750770f1255"); //Hard fork to v9 ADD_CHECKPOINT(54500, "8ed3078b389c2b44add007803d741b58d3fbed2e1ba4139bda702152d8773c9b"); + ADD_CHECKPOINT(55000, "4b662ceccefc3247edb4d654dd610b8fb496e85b88a5de43cc2bdd28171b15ff"); + ADD_CHECKPOINT(57000, "08a79f09f12bb5d230b63963356a760d51618e526cfc636047a6f3798217c177"); + ADD_CHECKPOINT(59000, "180b51ee2c5fbcd4362eb7a29df9422481310dd77d10bccdf8930724c31e007e"); return true; } diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp index fbd97df30..5ec281d35 100644 --- a/src/cryptonote_basic/difficulty.cpp +++ b/src/cryptonote_basic/difficulty.cpp @@ -256,10 +256,14 @@ namespace cryptonote { assert(timestamps.size() == cumulative_difficulties.size() && timestamps.size() <= static_cast(N+1) ); - if ( height <= DIFFICULTY_HEIGHT ){ + if ( cryptonote::MAINNET && height <= DIFFICULTY_HEIGHT ){ return static_cast(DIFFICULTY_GUESS); } + if ( cryptonote::TESTNET && height <= DIFFICULTY_TESTNET_HEIGHT ){ + return static_cast(DIFFICULTY_TESTNET_GUESS); + } + for ( int64_t i = 1; i <= N; i++ ) { ST = static_cast(timestamps[i]) - static_cast(timestamps[i-1]); ST = std::max(-4*T, std::min(ST, 6*T)); @@ -277,50 +281,14 @@ namespace cryptonote { next_D = std::max(next_D,(prev_D*108)/100); } - if ( next_D < DIFFICULTY_MINIMUM ) { + if ( cryptonote::MAINNET && next_D < DIFFICULTY_MINIMUM ) { return static_cast(DIFFICULTY_MINIMUM); } + else if ( cryptonote::TESTNET && next_D < DIFFICULTY_TESTNET_MINIMUM ) { + return static_cast(DIFFICULTY_TESTNET_MINIMUM); + } else { return static_cast(next_D); } } - - // LWMA-3 difficulty algorithm - // Copyright (c) 2017-2018 Zawy, MIT License - difficulty_type next_difficulty_v4(std::vector timestamps, std::vector cumulative_difficulties, size_t height) { - - uint64_t T = DIFFICULTY_TARGET_V2; - uint64_t N = DIFFICULTY_WINDOW_V2; - uint64_t L(0), ST, sum_3_ST(0), next_D, prev_D, this_timestamp, previous_timestamp; - - assert(timestamps.size() == cumulative_difficulties.size() && timestamps.size() <= N+1 ); - - if ( height == DIFFICULTY_HEIGHT_V2 ){ - return static_cast(DIFFICULTY_GUESS); - } - - previous_timestamp = timestamps[0]; - for ( uint64_t i = 1; i <= N; i++) { - if ( timestamps[i] > previous_timestamp ) { - this_timestamp = timestamps[i]; - } else { this_timestamp = previous_timestamp+1; } - ST = std::min(6*T ,this_timestamp - previous_timestamp); - previous_timestamp = this_timestamp; - L += ST * i ; - if ( i > N-3 ) { sum_3_ST += ST; } - } - - next_D = ((cumulative_difficulties[N] - cumulative_difficulties[0])*T*(N+1)*99)/(100*2*L); - prev_D = cumulative_difficulties[N] - cumulative_difficulties[N-1]; - next_D = std::max((prev_D*67)/100, std::min(next_D, (prev_D*150)/100)); - - if ( sum_3_ST < (8*T)/10) { next_D = std::max(next_D,(prev_D*108)/100); } - - if ( next_D < DIFFICULTY_MINIMUM ) { - return static_cast(DIFFICULTY_MINIMUM); - } - else { - return static_cast(next_D); - } - } } diff --git a/src/cryptonote_basic/difficulty.h b/src/cryptonote_basic/difficulty.h index 550b4c164..247896e10 100644 --- a/src/cryptonote_basic/difficulty.h +++ b/src/cryptonote_basic/difficulty.h @@ -55,5 +55,4 @@ namespace cryptonote difficulty_type next_difficulty(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds); difficulty_type next_difficulty_v2(std::vector timestamps, std::vector cumulative_difficulties, size_t target_seconds); difficulty_type next_difficulty_v3(std::vector timestamps, std::vector cumulative_difficulties, size_t height); - difficulty_type next_difficulty_v4(std::vector timestamps, std::vector cumulative_difficulties, size_t height); } diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index bf446a81f..82408aab3 100755 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -48,7 +48,6 @@ #define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2 #define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 4 -#define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 11 #define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 60 // MONEY_SUPPLY - total number coins to be generated @@ -83,9 +82,11 @@ #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_HEIGHT 53666 // v9 fork height -#define DIFFICULTY_HEIGHT_V2 777777 // v10 fork height #define DIFFICULTY_GUESS 40000000 // difficulty at fork 40m #define DIFFICULTY_MINIMUM 25000000 // minimum difficulty set to 25m +#define DIFFICULTY_TESTNET_HEIGHT 100 +#define DIFFICULTY_TESTNET_GUESS 5069 +#define DIFFICULTY_TESTNET_MINIMUM 4069 #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 f5c68c64c..2181f8348 100755 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -838,11 +838,8 @@ difficulty_type Blockchain::get_difficulty_for_next_block() else if (version == 8) { return next_difficulty_v2(timestamps, difficulties, target); } - else if (version == 9) { - return next_difficulty_v3(timestamps, difficulties, height); - } else { - return next_difficulty_v4(timestamps, difficulties, height); + return next_difficulty_v3(timestamps, difficulties, height); } } //------------------------------------------------------------------ @@ -1059,12 +1056,9 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std: } else if (version == 8) { return next_difficulty_v2(timestamps, cumulative_difficulties, target); - } - else if (version == 9) { - return next_difficulty_v2(timestamps, cumulative_difficulties, height); - } + } else { - return next_difficulty_v4(timestamps, cumulative_difficulties, height); + return next_difficulty_v3(timestamps, cumulative_difficulties, height); } } @@ -1356,13 +1350,12 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m bool Blockchain::complete_timestamps_vector(uint64_t start_top_height, std::vector& timestamps) { LOG_PRINT_L3("Blockchain::" << __func__); - const uint8_t hf_version = m_hardfork->get_current_version(); - size_t blockchain_timestamp_check_window = hf_version >= 10 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; - if(timestamps.size() >= blockchain_timestamp_check_window) + + if(timestamps.size() >= BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW) return true; CRITICAL_REGION_LOCAL(m_blockchain_lock); - size_t need_elements = blockchain_timestamp_check_window - timestamps.size(); + size_t need_elements = BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW - timestamps.size(); CHECK_AND_ASSERT_MES(start_top_height < m_db->height(), false, "internal error: passed start_height not < " << " m_db->height() -- " << start_top_height << " >= " << m_db->height()); size_t stop_offset = start_top_height > need_elements ? start_top_height - need_elements : 0; while (start_top_height != stop_offset) @@ -3210,12 +3203,10 @@ bool Blockchain::check_block_timestamp(std::vector& timestamps, const { LOG_PRINT_L3("Blockchain::" << __func__); median_ts = epee::misc_utils::median(timestamps); - const uint8_t hf_version = m_hardfork->get_current_version(); - size_t blockchain_timestamp_check_window = hf_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); + 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); return false; } @@ -3233,8 +3224,6 @@ bool Blockchain::check_block_timestamp(const block& b, uint64_t& median_ts) cons { LOG_PRINT_L3("Blockchain::" << __func__); uint64_t cryptonote_block_future_time_limit = get_current_hard_fork_version() >= 8 ? CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2 : CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT; - const uint8_t hf_version = m_hardfork->get_current_version(); - size_t blockchain_timestamp_check_window = hf_version >= 10 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; if(b.timestamp > get_adjusted_time() + cryptonote_block_future_time_limit) { MERROR_VER("Timestamp of block with id: " << get_block_hash(b) << ", " << b.timestamp << ", bigger than adjusted time + 10 minutes"); @@ -3242,7 +3231,7 @@ bool Blockchain::check_block_timestamp(const block& b, uint64_t& median_ts) cons } // if not enough blocks, no proper median yet, return true - if(m_db->height() < blockchain_timestamp_check_window) + if(m_db->height() < BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW) { return true; } @@ -3251,7 +3240,7 @@ bool Blockchain::check_block_timestamp(const block& b, uint64_t& median_ts) cons auto h = m_db->height(); // need most recent 60 blocks, get index of first of those - size_t offset = h - blockchain_timestamp_check_window; + size_t offset = h - BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW; for(;offset < h; ++offset) { timestamps.push_back(m_db->get_block_timestamp(offset)); @@ -4452,7 +4441,7 @@ void Blockchain::cancel() } #if defined(PER_BLOCK_CHECKPOINT) -static const char expected_block_hashes_hash[] = "e8255f4188ddb613df2953d8ae2ed509223e432290368b0eef062f8c12da9f70"; +static const char expected_block_hashes_hash[] = "897d3ae0f3aef8ef8362b0bb3535925738414fa78d9146f8a04c60555fa5a95f"; void Blockchain::load_compiled_in_block_hashes() { const bool testnet = m_nettype == TESTNET; diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 3be08b327..044a66953 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -746,7 +746,7 @@ namespace cryptonote m_blockchain.for_all_txpool_txes([&tx_infos, key_image_infos, include_sensitive_data](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){ tx_info txi; txi.id_hash = epee::string_tools::pod_to_hex(txid); - txi.tx_blob = *bd; + txi.tx_blob = epee::string_tools::buff_to_hex_nodelimer(*bd); transaction tx; if (!parse_and_validate_tx_from_blob(*bd, tx)) { diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 635caeb16..8617c7e28 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -998,8 +998,6 @@ namespace cryptonote return r; m_core.get_pool_transactions_and_spent_keys_info(res.transactions, res.spent_key_images, !request_has_rpc_origin || !m_restricted); - for (tx_info& txi : res.transactions) - txi.tx_blob = epee::string_tools::buff_to_hex_nodelimer(txi.tx_blob); res.status = CORE_RPC_STATUS_OK; return true; } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 635f1bb41..2c741c2e5 100755 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -906,12 +906,6 @@ std::string wallet2::get_subaddress_as_str(const cryptonote::subaddress_index& i cryptonote::account_public_address address = get_subaddress(index); return cryptonote::get_account_address_as_str(m_nettype, !index.is_zero(), address); } - -//---------------------------------------------------------------------------------------------------- -std::string wallet2::get_integrated_address_as_str(const crypto::hash8& payment_id) const -{ - return cryptonote::get_account_integrated_address_as_str(m_nettype, get_address(), payment_id); -} //---------------------------------------------------------------------------------------------------- void wallet2::add_subaddress_account(const std::string& label) { diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index ed02d7a28..8e79779a2 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -629,7 +629,6 @@ namespace tools std::vector get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const; std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const; std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); } - std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const; void add_subaddress_account(const std::string& label); size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); } size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; } diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index d3491baae..8c75031a7 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1099,69 +1099,6 @@ namespace tools return true; } //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_make_integrated_address(const wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er) - { - if (!m_wallet) return not_open(er); - try - { - crypto::hash8 payment_id; - if (req.payment_id.empty()) - { - payment_id = crypto::rand(); - } - else - { - if (!tools::wallet2::parse_short_payment_id(req.payment_id,payment_id)) - { - er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID; - er.message = "Invalid payment ID"; - return false; - } - } - - res.integrated_address = m_wallet->get_integrated_address_as_str(payment_id); - res.payment_id = epee::string_tools::pod_to_hex(payment_id); - return true; - } - catch (const std::exception& e) - { - handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR); - return false; - } - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_split_integrated_address(const wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er) - { - if (!m_wallet) return not_open(er); - try - { - cryptonote::address_parse_info info; - - if(!get_account_address_from_str(info, m_wallet->nettype(), req.integrated_address)) - { - er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS; - er.message = "Invalid address"; - return false; - } - if(!info.has_payment_id) - { - er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS; - er.message = "Address is not an integrated address"; - return false; - } - res.standard_address = get_account_address_as_str(m_wallet->nettype(), info.is_subaddress, info.address); - res.payment_id = epee::string_tools::pod_to_hex(info.payment_id); - return true; - } - catch (const std::exception& e) - { - handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR); - return false; - } - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er) { if (!m_wallet) return not_open(er); diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index a68e12d97..04e57db11 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -95,8 +95,6 @@ namespace tools MAP_JON_RPC_WE("get_bulk_payments", on_get_bulk_payments, wallet_rpc::COMMAND_RPC_GET_BULK_PAYMENTS) MAP_JON_RPC_WE("incoming_transfers", on_incoming_transfers, wallet_rpc::COMMAND_RPC_INCOMING_TRANSFERS) MAP_JON_RPC_WE("query_key", on_query_key, wallet_rpc::COMMAND_RPC_QUERY_KEY) - MAP_JON_RPC_WE("make_integrated_address", on_make_integrated_address, wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS) - MAP_JON_RPC_WE("split_integrated_address", on_split_integrated_address, wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS) MAP_JON_RPC_WE("stop_wallet", on_stop_wallet, wallet_rpc::COMMAND_RPC_STOP_WALLET) MAP_JON_RPC_WE("rescan_blockchain", on_rescan_blockchain, wallet_rpc::COMMAND_RPC_RESCAN_BLOCKCHAIN) MAP_JON_RPC_WE("set_tx_notes", on_set_tx_notes, wallet_rpc::COMMAND_RPC_SET_TX_NOTES) @@ -160,8 +158,6 @@ namespace tools bool on_sweep_all(const wallet_rpc::COMMAND_RPC_SWEEP_ALL::request& req, wallet_rpc::COMMAND_RPC_SWEEP_ALL::response& res, epee::json_rpc::error& er); bool on_sweep_single(const wallet_rpc::COMMAND_RPC_SWEEP_SINGLE::request& req, wallet_rpc::COMMAND_RPC_SWEEP_SINGLE::response& res, epee::json_rpc::error& er); bool on_relay_tx(const wallet_rpc::COMMAND_RPC_RELAY_TX::request& req, wallet_rpc::COMMAND_RPC_RELAY_TX::response& res, epee::json_rpc::error& er); - bool on_make_integrated_address(const wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_MAKE_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er); - bool on_split_integrated_address(const wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS::response& res, epee::json_rpc::error& er); bool on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er); bool on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er); bool on_get_bulk_payments(const wallet_rpc::COMMAND_RPC_GET_BULK_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_BULK_PAYMENTS::response& res, epee::json_rpc::error& er); diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index f264829ad..e64f4a189 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -873,53 +873,6 @@ namespace wallet_rpc }; }; - struct COMMAND_RPC_MAKE_INTEGRATED_ADDRESS - { - struct request - { - std::string payment_id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(payment_id) - END_KV_SERIALIZE_MAP() - }; - - struct response - { - std::string integrated_address; - std::string payment_id; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(integrated_address) - KV_SERIALIZE(payment_id) - END_KV_SERIALIZE_MAP() - }; - }; - - struct COMMAND_RPC_SPLIT_INTEGRATED_ADDRESS - { - struct request - { - std::string integrated_address; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(integrated_address) - END_KV_SERIALIZE_MAP() - }; - - struct response - { - std::string standard_address; - std::string payment_id; - bool is_subaddress; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(standard_address) - KV_SERIALIZE(payment_id) - KV_SERIALIZE(is_subaddress) - END_KV_SERIALIZE_MAP() - }; - }; struct COMMAND_RPC_STOP_WALLET {