From 12e64bf462d9cafd9fbe6785c5ea39a1bd28f781 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Mon, 8 Apr 2019 20:28:11 +0200 Subject: [PATCH 1/5] changed to wildprog --- contrib/ethereum/libethash/progpow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/ethereum/libethash/progpow.cpp b/contrib/ethereum/libethash/progpow.cpp index fd709e8f..a7b85c0e 100644 --- a/contrib/ethereum/libethash/progpow.cpp +++ b/contrib/ethereum/libethash/progpow.cpp @@ -117,9 +117,9 @@ inline uint32_t random_math(uint32_t a, uint32_t b, uint32_t selector) noexcept { default: case 0: - return a + b; - case 1: return a * b; + case 1: + return a + b; case 2: return mul_hi32(a, b); case 3: From 534d649466f4ddb43cc6b356a06b193675c65f3a Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 10 Apr 2019 03:00:29 +0200 Subject: [PATCH 2/5] implemented 128 bit coin supply --- .../epee/include/print_fixed_point_helper.h | 5 ++- src/currency_core/blockchain_storage.cpp | 8 ++-- src/currency_core/blockchain_storage.h | 6 +-- src/currency_core/blockchain_storage_basic.h | 11 ++---- src/currency_core/currency_format_utils.cpp | 38 ++++++++----------- src/currency_core/currency_format_utils.h | 28 +++++++++----- src/currency_core/tx_pool.cpp | 2 +- src/currency_core/tx_pool.h | 2 +- src/rpc/core_rpc_server.cpp | 10 +++-- src/rpc/core_rpc_server_commands_defs.h | 4 +- tests/core_tests/block_reward.cpp | 2 +- tests/core_tests/chain_switch_pow_pos.cpp | 1 - tests/core_tests/chaingen_helpers.h | 2 +- tests/core_tests/pos_block_builder.cpp | 4 +- tests/core_tests/pos_block_builder.h | 4 +- 15 files changed, 65 insertions(+), 62 deletions(-) diff --git a/contrib/epee/include/print_fixed_point_helper.h b/contrib/epee/include/print_fixed_point_helper.h index 43843618..c652f601 100644 --- a/contrib/epee/include/print_fixed_point_helper.h +++ b/contrib/epee/include/print_fixed_point_helper.h @@ -31,9 +31,10 @@ namespace epee { namespace string_tools { - inline std::string print_fixed_decimal_point(uint64_t amount, size_t decimal_point) + template + inline std::string print_fixed_decimal_point(t_number amount, size_t decimal_point) { - std::string s = std::to_string(amount); + std::string s = boost::lexical_cast(amount); if (s.size() < decimal_point + 1) { s.insert(0, decimal_point + 1 - s.size(), '0'); diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 19b29ebb..a24d6b47 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1029,7 +1029,7 @@ bool blockchain_storage::validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, - uint64_t already_generated_coins) const + const boost::multiprecision::uint128_t& already_generated_coins) const { CRITICAL_REGION_LOCAL(m_read_lock); //validate reward @@ -1128,7 +1128,7 @@ bool blockchain_storage::create_block_template(block& b, fill_block_template_func_t custom_fill_block_template_func /* = nullptr */) const { size_t median_size; - uint64_t already_generated_coins; + boost::multiprecision::uint128_t already_generated_coins; CRITICAL_REGION_BEGIN(m_read_lock); b.major_version = CURRENT_BLOCK_MAJOR_VERSION; b.minor_version = CURRENT_BLOCK_MINOR_VERSION; @@ -2107,7 +2107,7 @@ bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDO return true; } //------------------------------------------------------------------ -uint64_t blockchain_storage::total_coins() const +boost::multiprecision::uint128_t blockchain_storage::total_coins() const { CRITICAL_REGION_LOCAL(m_read_lock); if (!m_db_blocks.size()) @@ -4423,7 +4423,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt } uint64_t base_reward = 0; - uint64_t already_generated_coins = m_db_blocks.size() ? m_db_blocks.back()->already_generated_coins:0; + boost::multiprecision::uint128_t already_generated_coins = m_db_blocks.size() ? m_db_blocks.back()->already_generated_coins:0; if (!validate_miner_transaction(bl, cumulative_block_size, fee_summary, base_reward, already_generated_coins)) { LOG_PRINT_L0("Block with id: " << id diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index adfddb91..960b288b 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -230,7 +230,7 @@ namespace currency wide_difficulty_type get_next_diff_conditional2(bool pos, const alt_chain_type& alt_chain, uint64_t split_height) const; wide_difficulty_type get_cached_next_difficulty(bool pos) const; - typedef bool fill_block_template_func_t(block &bl, bool pos, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height); + typedef bool fill_block_template_func_t(block &bl, bool pos, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height); bool create_block_template(block& b, const account_public_address& miner_address, const account_public_address& stakeholder_address, wide_difficulty_type& di, uint64_t& height, const blobdata& ex_nonce, bool pos, const pos_entry& pe, fill_block_template_func_t custom_fill_block_template_func = nullptr) const; bool create_block_template(block& b, const account_public_address& miner_address, wide_difficulty_type& di, uint64_t& height, const blobdata& ex_nonce) const; @@ -270,7 +270,7 @@ namespace currency uint64_t get_seconds_between_last_n_block(size_t n)const; bool has_multisig_output(const crypto::hash& multisig_id) const; bool is_multisig_output_spent(const crypto::hash& multisig_id) const; - uint64_t total_coins()const; + boost::multiprecision::uint128_t total_coins()const; bool is_pos_allowed()const; uint64_t get_tx_fee_median()const; uint64_t get_tx_expiration_median() const; @@ -280,7 +280,7 @@ namespace currency uint64_t get_last_timestamps_check_window_median() const; uint64_t get_last_n_blocks_timestamps_median(size_t n) const; bool prevalidate_alias_info(const transaction& tx, extra_alias_entry& eae); - bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins) const; + bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, const boost::multiprecision::uint128_t& already_generated_coins) const; performnce_data& get_performnce_data()const; bool validate_instance(const std::string& path); bool is_tx_expired(const transaction& tx) const; diff --git a/src/currency_core/blockchain_storage_basic.h b/src/currency_core/blockchain_storage_basic.h index d29afc8c..05709aef 100644 --- a/src/currency_core/blockchain_storage_basic.h +++ b/src/currency_core/blockchain_storage_basic.h @@ -48,13 +48,13 @@ namespace currency wide_difficulty_type cumulative_diff_adjusted; wide_difficulty_type cumulative_diff_precise; wide_difficulty_type difficulty; - uint64_t already_generated_coins; + boost::multiprecision::uint128_t already_generated_coins; crypto::hash stake_hash; //TODO: unused field for PoW blocks, subject for refactoring uint32_t version; uint64_t this_block_tx_fee_median; //tx fee median for current block transactions uint64_t effective_tx_fee_median; //current fee median which applied for current block's alias registrations - DEFINE_SERIALIZATION_VERSION(2); + DEFINE_SERIALIZATION_VERSION(1); BEGIN_SERIALIZE_OBJECT() VERSION_ENTRY(version) FIELDS(bl) @@ -65,11 +65,8 @@ namespace currency FIELD(difficulty) FIELD(already_generated_coins) FIELD(stake_hash) - if (version >= 2) - { - FIELD(this_block_tx_fee_median) - FIELD(effective_tx_fee_median) - } + FIELD(this_block_tx_fee_median) + FIELD(effective_tx_fee_median) END_SERIALIZE() }; diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index b644fc56..8dff4880 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -40,7 +40,7 @@ namespace currency //--------------------------------------------------------------- /* - bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, + bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, @@ -76,7 +76,7 @@ namespace currency return diff; } //------------------------------------------------------------------ - bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, + bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, @@ -122,7 +122,7 @@ namespace currency return construct_miner_tx(height, median_size, already_generated_coins, current_block_size, fee, destinations, tx, extra_nonce, max_outs, pos, pe); } //------------------------------------------------------------------ - bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, + bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, const std::vector& destinations, @@ -1604,15 +1604,7 @@ namespace currency } - std::string print_fixed_decimal_point(uint64_t amount, size_t decimal_point) - { - return epee::string_tools::print_fixed_decimal_point(amount, decimal_point); - } - //--------------------------------------------------------------- - std::string print_money(uint64_t amount) - { - return print_fixed_decimal_point(amount, CURRENCY_DISPLAY_DECIMAL_POINT); - } + //--------------------------------------------------------------- std::string print_money_brief(uint64_t amount) { @@ -1713,10 +1705,10 @@ namespace currency std::cout << std::endl << "Reward change for 10 years:" << std::endl; std::cout << std::setw(10) << std::left << "day" << std::setw(19) << "block reward" << std::setw(19) << "generated coins" << std::endl; - uint64_t already_generated_coins = PREMINE_AMOUNT; - uint64_t money_was_at_begining_of_year = already_generated_coins; - uint64_t total_generated_in_year_by_pos = 0; - uint64_t total_generated_in_year_by_pow = 0; + boost::multiprecision::uint128_t already_generated_coins = PREMINE_AMOUNT; + boost::multiprecision::uint128_t money_was_at_begining_of_year = already_generated_coins; + boost::multiprecision::uint128_t total_generated_in_year_by_pos = 0; + boost::multiprecision::uint128_t total_generated_in_year_by_pow = 0; //uint64_t total_money_supply = TOTAL_MONEY_SUPPLY; uint64_t h = 0; for (uint64_t day = 0; day != 365 * 10; ++day) @@ -1730,8 +1722,8 @@ namespace currency << std::setw(10) << day << std::setw(19) << print_money(emission_reward) << std::setw(4) << print_money(already_generated_coins) - << "(POS: " << std::to_string(GET_PERECENTS_BIG_NUMBERS(total_generated_in_year_by_pos, money_was_at_begining_of_year)) << "%" - << ", POW: " << std::to_string(GET_PERECENTS_BIG_NUMBERS(total_generated_in_year_by_pow, money_was_at_begining_of_year)) << "%)" + << "(POS: " << boost::lexical_cast(GET_PERECENTS_BIG_NUMBERS(total_generated_in_year_by_pos, money_was_at_begining_of_year)) << "%" + << ", POW: " << boost::lexical_cast(GET_PERECENTS_BIG_NUMBERS(total_generated_in_year_by_pow, money_was_at_begining_of_year)) << "%)" << std::setw(19) << ",PoS coins/year: " << print_money(total_generated_in_year_by_pos) << std::setw(19) << ",PoW coins/year:" << print_money(total_generated_in_year_by_pow) @@ -1765,7 +1757,7 @@ namespace currency // std::cout << std::endl << "Reward change for 20 days:" << std::endl; // std::cout << std::setw(10) << std::left << "day" << std::setw(19) << "block reward" << std::setw(19) << "generated coins" << std::endl; // -// uint64_t already_generated_coins = PREMINE_AMOUNT; +// const boost::multiprecision::uint128_t& already_generated_coins = PREMINE_AMOUNT; // //uint64_t total_money_supply = TOTAL_MONEY_SUPPLY; // uint64_t h = 0; // for (uint64_t day = 0; day != 20; ++day) @@ -1798,7 +1790,7 @@ namespace currency ss << std::endl << "Reward change for the first " << n_of_first_blocks << " blocks:" << std::endl; ss << std::setw(10) << std::left << "block #" << std::setw(20) << "block reward" << std::setw(20) << "generated coins" << std::setw(8) << "type" << std::endl; - uint64_t already_generated_coins = 0; + boost::multiprecision::uint128_t already_generated_coins = 0; uint64_t total_generated_pos = 0; uint64_t total_generated_pow = 0; @@ -2296,7 +2288,7 @@ namespace currency pei_rpc.prev_id = epee::string_tools::pod_to_hex(bei_chain.bl.prev_id); pei_rpc.actual_timestamp = get_actual_timestamp(bei_chain.bl); pei_rpc.type = is_pos_block(bei_chain.bl) ? 0 : 1; - pei_rpc.already_generated_coins = bei_chain.already_generated_coins; + pei_rpc.already_generated_coins = boost::lexical_cast(bei_chain.already_generated_coins); pei_rpc.this_block_fee_median = bei_chain.this_block_tx_fee_median; pei_rpc.effective_fee_median = bei_chain.effective_tx_fee_median; pei_rpc.height = bei_chain.height; @@ -2380,7 +2372,7 @@ namespace currency return CURRENCY_MAX_TRANSACTION_BLOB_SIZE; } //----------------------------------------------------------------------------------------------- - uint64_t get_base_block_reward(bool is_pos, uint64_t already_generated_coins, uint64_t height) + uint64_t get_base_block_reward(bool is_pos, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t height) { if (!height) return PREMINE_AMOUNT; @@ -2388,7 +2380,7 @@ namespace currency return CURRENCY_TESTNET_CONST_REWARD; } //----------------------------------------------------------------------------------------------- - bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint64_t height) + bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t &reward, uint64_t height) { uint64_t base_reward = get_base_block_reward(is_pos, already_generated_coins, height); diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index a984233f..59ffa4c3 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -163,7 +163,7 @@ namespace currency //--------------------------------------------------------------- - bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, + bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, @@ -174,7 +174,7 @@ namespace currency bool pos = false, const pos_entry& pe = pos_entry()); - bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, + bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, const std::vector& destinations, @@ -309,9 +309,7 @@ namespace currency uint64_t get_block_height(const block& b); std::vector relative_output_offsets_to_absolute(const std::vector& off); std::vector absolute_output_offsets_to_relative(const std::vector& off); - // prints amount in format "3.14000000", "0.00000000" - std::string print_money(uint64_t amount); - std::string print_fixed_decimal_point(uint64_t amount, size_t decimal_point); + // prints amount in format "3.14", "0.0" std::string print_money_brief(uint64_t amount); uint64_t get_actual_timestamp(const block& b); @@ -382,8 +380,8 @@ namespace currency /************************************************************************/ size_t get_max_block_size(); size_t get_max_tx_size(); - bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint64_t height); - uint64_t get_base_block_reward(bool is_pos, uint64_t already_generated_coins, uint64_t height); + bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t &reward, uint64_t height); + uint64_t get_base_block_reward(bool is_pos, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t height); bool is_payment_id_size_ok(const std::string& payment_id); std::string get_account_address_as_str(const account_public_address& addr); std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const std::string& payment_id); @@ -440,7 +438,7 @@ namespace currency { return alias_info_to_rpc_alias_info(ai.m_alias, ai, ari); } - + //--------------------------------------------------------------- template bool alias_info_to_rpc_alias_info(const std::string& alias, const currency::extra_alias_entry_base& aib, alias_rpc_details_t& ari) { @@ -452,7 +450,19 @@ namespace currency return true; } - + //--------------------------------------------------------------- + template + std::string print_fixed_decimal_point(t_number amount, size_t decimal_point) + { + return epee::string_tools::print_fixed_decimal_point(amount, decimal_point); + } + //--------------------------------------------------------------- + template + std::string print_money(t_number amount) + { + return print_fixed_decimal_point(amount, CURRENCY_DISPLAY_DECIMAL_POINT); + } + //--------------------------------------------------------------- template bool alias_rpc_details_to_alias_info(const alias_rpc_details_t& ard, currency::extra_alias_entry& ai) { diff --git a/src/currency_core/tx_pool.cpp b/src/currency_core/tx_pool.cpp index 665e9e92..817f2a55 100644 --- a/src/currency_core/tx_pool.cpp +++ b/src/currency_core/tx_pool.cpp @@ -1046,7 +1046,7 @@ namespace currency bool tx_memory_pool::fill_block_template(block &bl, bool pos, size_t median_size, - uint64_t already_generated_coins, + const boost::multiprecision::uint128_t& already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height) diff --git a/src/currency_core/tx_pool.h b/src/currency_core/tx_pool.h index 22dd9948..9e524b43 100644 --- a/src/currency_core/tx_pool.h +++ b/src/currency_core/tx_pool.h @@ -116,7 +116,7 @@ namespace currency // load/store operations bool init(const std::string& config_folder); bool deinit(); - bool fill_block_template(block &bl, bool pos, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height); + bool fill_block_template(block &bl, bool pos, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height); bool get_transactions(std::list& txs) const; bool get_all_transactions_details(std::list& txs)const; bool get_all_transactions_brief_details(std::list& txs)const; diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index bf9c8994..5089f054 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -131,8 +131,12 @@ namespace currency if (pow_bl_ptr) res.last_pow_timestamp = pow_bl_ptr->bl.timestamp; } + boost::multiprecision::uint128_t total_coins = 0; if (req.flags&COMMAND_RPC_GET_INFO_FLAG_TOTAL_COINS) - res.total_coins = m_core.get_blockchain_storage().total_coins(); + { + total_coins = m_core.get_blockchain_storage().total_coins(); + res.total_coins = boost::lexical_cast(total_coins); + } if (req.flags&COMMAND_RPC_GET_INFO_FLAG_LAST_BLOCK_SIZE) { std::vector sz; @@ -151,11 +155,11 @@ namespace currency res.pow_sequence_factor = m_core.get_blockchain_storage().get_current_sequence_factor(false); if (req.flags&(COMMAND_RPC_GET_INFO_FLAG_POS_DIFFICULTY | COMMAND_RPC_GET_INFO_FLAG_TOTAL_COINS)) { - res.block_reward = currency::get_base_block_reward(true, res.total_coins, res.height); + res.block_reward = currency::get_base_block_reward(true, total_coins, res.height); currency::block b = AUTO_VAL_INIT(b); m_core.get_blockchain_storage().get_top_block(b); res.last_block_total_reward = currency::get_reward_from_miner_tx(b.miner_tx); - res.pos_diff_total_coins_rate = (pos_diff / (res.total_coins - PREMINE_AMOUNT + 1)).convert_to(); + res.pos_diff_total_coins_rate = (pos_diff / (total_coins - PREMINE_AMOUNT + 1)).convert_to(); res.last_block_timestamp = b.timestamp; res.last_block_hash = string_tools::pod_to_hex(get_block_hash(b)); } diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index a2a2c47b..b27d7ddb 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -645,7 +645,7 @@ namespace currency uint64_t pow_sequence_factor; uint64_t last_pow_timestamp; uint64_t last_pos_timestamp; - uint64_t total_coins; + std::string total_coins; uint64_t block_reward; uint64_t last_block_total_reward; uint64_t pos_diff_total_coins_rate; @@ -1234,7 +1234,7 @@ namespace currency std::string pow_seed; uint64_t type; bool is_orphan; - uint64_t already_generated_coins; + std::string already_generated_coins; uint64_t this_block_fee_median; uint64_t effective_fee_median; std::list transactions_details; diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp index a7d01fd8..8a5771de 100644 --- a/tests/core_tests/block_reward.cpp +++ b/tests/core_tests/block_reward.cpp @@ -31,7 +31,7 @@ bool block_template_against_txs_size::generate(std::vector& ev static size_t g_block_txs_total_size = 0; static uint64_t g_block_txs_fee = 0; -bool custom_fill_block_template_func(block &bl, bool pos, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height) +bool custom_fill_block_template_func(block &bl, bool pos, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height) { total_size = g_block_txs_total_size; fee = g_block_txs_fee; diff --git a/tests/core_tests/chain_switch_pow_pos.cpp b/tests/core_tests/chain_switch_pow_pos.cpp index cf6ec48b..e199ee11 100644 --- a/tests/core_tests/chain_switch_pow_pos.cpp +++ b/tests/core_tests/chain_switch_pow_pos.cpp @@ -29,7 +29,6 @@ gen_chain_switch_pow_pos::gen_chain_switch_pow_pos() bool gen_chain_switch_pow_pos::generate(std::vector& events) const { - return false; // TODO: for test check only, remove pls uint64_t ts_start = 1420000000; std::list miner_stake_sources, alice_stake_sources, bob_stake_sources; diff --git a/tests/core_tests/chaingen_helpers.h b/tests/core_tests/chaingen_helpers.h index 00b193dd..fcd77038 100644 --- a/tests/core_tests/chaingen_helpers.h +++ b/tests/core_tests/chaingen_helpers.h @@ -44,7 +44,7 @@ inline bool mine_next_pow_block_in_playtime_with_given_txs(const currency::accou { struct loc_helper { - static bool fill_block_template_func(currency::block &bl, bool pos, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height) + static bool fill_block_template_func(currency::block &bl, bool pos, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t height) { fee = 0; total_size = 0; diff --git a/tests/core_tests/pos_block_builder.cpp b/tests/core_tests/pos_block_builder.cpp index 3e854636..95b281a9 100644 --- a/tests/core_tests/pos_block_builder.cpp +++ b/tests/core_tests/pos_block_builder.cpp @@ -106,7 +106,7 @@ void pos_block_builder::step3_build_stake_kernel( } void pos_block_builder::step4_generate_coinbase_tx(size_t median_size, - uint64_t already_generated_coins, + const boost::multiprecision::uint128_t& already_generated_coins, const account_public_address &reward_receiver_address, const blobdata& extra_nonce, size_t max_outs, @@ -165,7 +165,7 @@ void pos_block_builder::step5_sign(const crypto::public_key& stake_tx_pub_key, s m_step = 5; } -bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, +bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, uint64_t pos_stake_amount, diff --git a/tests/core_tests/pos_block_builder.h b/tests/core_tests/pos_block_builder.h index 29b070fc..62d2a9b5 100644 --- a/tests/core_tests/pos_block_builder.h +++ b/tests/core_tests/pos_block_builder.h @@ -25,7 +25,7 @@ struct pos_block_builder uint64_t timestamp_step = POS_SCAN_STEP); void step4_generate_coinbase_tx(size_t median_size, - uint64_t already_generated_coins, + const boost::multiprecision::uint128_t& already_generated_coins, const currency::account_public_address &reward_receiver_address, const currency::blobdata& extra_nonce = currency::blobdata(), size_t max_outs = CURRENCY_MINER_TX_MAX_OUTS, @@ -44,7 +44,7 @@ struct pos_block_builder uint64_t m_pos_stake_amount; }; -bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, +bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins, size_t current_block_size, uint64_t fee, uint64_t pos_stake_amount, From 1cf1425fb036dfef3612fc3cc0f70c97cba62bc2 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 10 Apr 2019 22:44:57 +0200 Subject: [PATCH 3/5] fixed connectivity tool --- src/connectivity_tool/conn_tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index e29adcf2..381c2c07 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -540,7 +540,7 @@ bool handle_get_daemon_info(po::variables_map& vm) << "pow_sequence_factor: " << res.pow_sequence_factor << ENDL << "last_pos_timestamp: " << res.last_pos_timestamp << ENDL << "last_pow_timestamp: " << res.last_pow_timestamp << ENDL - << "total_coins: " << res.total_coins / COIN << ENDL + << "total_coins: " << res.total_coins << ENDL << "pos_difficulty_in_coins: " << currency::wide_difficulty_type(res.pos_difficulty) / COIN << ENDL << "block_reward: " << res.block_reward << ENDL << "last_block_total_reward: " << res.last_block_total_reward << ENDL From 17f9e9d40f7d0ced7d5155eb83aff66c73bff532 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 10 Apr 2019 23:05:26 +0200 Subject: [PATCH 4/5] changed genesis and emission set for check coinsupply 64bit overflow --- src/currency_core/currency_config.h | 4 ++-- src/currency_core/genesis.cpp | 2 +- src/currency_core/genesis.h | 2 +- src/currency_core/genesis_acc.cpp | 29 ++++++++++++++++------------- src/currency_core/genesis_acc.h | 2 +- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 86e04f95..be3a4b6c 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -53,7 +53,7 @@ // #define CURRENCY_FIXED_REWARD_ZONE_REWARD_AMOUNT ((uint64_t)100000000) // should be TX_MINIMUM_FEE * CURRENCY_FIXED_REWARD_ZONE_FEE_MULTIPLIER // #define CURRENCY_FIXED_REWARD_ZONE_FEE_MULTIPLIER 1000 // reward in minimum fees for a block in the zone -#define CURRENCY_TESTNET_CONST_REWARD 1000000000 +#define CURRENCY_TESTNET_CONST_REWARD 100000000000000 #define WALLET_MAX_ALLOWED_OUTPUT_AMOUNT ((uint64_t)0xffffffffffffffffLL) @@ -174,7 +174,7 @@ #endif //premine -#define PREMINE_AMOUNT (2000000000000000000) +#define PREMINE_AMOUNT (17517203000000000000) // 13827203.0 reserved for coinswap, 3690000.0 - premine //alias registration wallet #define ALIAS_REWARDS_ACCOUNT_SPEND_PUB_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money diff --git a/src/currency_core/genesis.cpp b/src/currency_core/genesis.cpp index 1ae251af..fba792a8 100644 --- a/src/currency_core/genesis.cpp +++ b/src/currency_core/genesis.cpp @@ -8,7 +8,7 @@ namespace currency { const genesis_tx_raw_data ggenesis_tx_raw = { { - 0xd080800a00000101,0xd20302e3a2de8bd8,0xa4c656f120022dac,0x6e2f69c4efec713d,0x1dab067faa99d2b0,0x004bc2ed989554f5,0xe3a2de8bd8d08080,0x0c893e3c11110302,0x923c676c08c3b3da,0x9d5f9bab3c153f86,0xceec49611dbff8fa,0x8bd8d0808000a087,0xda75030302e3a2de,0x9c6c996e44fb4fa8,0x57da9b191a0ea5e5,0x8300d36ad5146cb0,0x808000f70b26fb7c,0x0302e3a2de8bd8d0,0x0d971710a6f965c0,0x712f15d0c23ca097,0xab0cccfcffca2772,0x4d79952b97b321f0,0xa2de8bd8d0808000,0x6e95a338730302e3,0x699ed30d4fe42200,0x44acb4ec1910cbae,0xac396ca4d07c6032,0xd8d08080007ca3ab,0xf16e0302e3a2de8b,0xa51960554838e739,0x9e49a3a3891d8589,0xfdec3d1c43ce6c6a,0x8000e9d451bab45d,0x02e3a2de8bd8d080,0x441f83683012d103,0xfe5af148188baa39,0x9a6f3f19372b9a63,0xa3af018f526dbcd0,0xde8bd8d0808000fa,0x3002d9a70302e3a2,0x9f8afd984e34d469,0xb839504b8be18512,0x9d6e2d8197e5347e,0xd0808000321a67f6,0x770302e3a2de8bd8,0x13c5c72e5040ae82,0xd3430b8a3a8b8f3e,0x345f656308d8200e,0x008b35ba6c7ac665,0xe3a2de8bd8d08080,0xf47aaa9ee2230302,0x8c75dbd4e43c096d,0xa8479951e6621d52,0x4614fba0a021d84d,0x7b8b69160d00fb3b,0xb9579673ea1bfcd6,0xe6caa4a7a54184fa,0xe460fcdea2efb79c,0x170015f4099060c6,0x627a17ad0517f176,0x4f17b84817ad0717,0x179de517114f17b9,0x000a0e9f2a177c9f }, + 0xa080800e00000101,0x800326b0b4a0f2fd,0x46f236cb0efcd16c,0x547fbb0ff9468d85,0x1da1229cbceeeddf,0x00509f1127de5f6d,0xb0b4a0f2fda08080,0x19fbc70d41860326,0xb0afa73cfe1209ca,0x0d299d4e62aa2f1f,0x7071d8e322c2ebfc,0xf2fda0808000ed15,0x9e5a660326b0b4a0,0x2928590bf14c0f33,0x3dfd3f48e046a8c2,0xfa969b2fa09ad0ed,0x808000acfcbb24be,0x0326b0b4a0f2fda0,0x682ecad7a79177d8,0xc9e501939827d6ec,0x7f55e8f25beacf76,0xc3a22fd82ddcb367,0xb4f89aecdce08000,0x6aeaf9b0de0326b0,0x631393eedf0fc04d,0x8ed9b961192f541a,0x5088f34df1470474,0x93dc80800011241e,0x30b80307d0ffc2e0,0xdcf3a14a0ac108e5,0xd508a0ec648f342d,0x0c1ac8310dcce994,0x8000346b43733822,0x05c6c5bc97b1a080,0x44663811c2802f03,0x5456a1cc803e5b0c,0x9a7c995f82c5bb18,0xe95939d19b769901,0xbc97b1a0808000e9,0xb0624da20305c6c5,0xe7921e8df615d26f,0x27abce5d4d975bc6,0xecb92e6224ce0952,0xa080800085eb1099,0xb10305c6c5bc97b1,0xea6de475ef2cdaaf,0xa47b3fe828343c89,0x8ec5057c0bf7dd44,0x000f2403abe0ade8,0xc6c5bc97b1a08080,0x60e1a72d445b0305,0x8bb2fc2bfd63e41b,0x7772ae843713073b,0xe1c2db8d00c414ff,0x97b1a0808000b5c2,0xd69ad60305c6c5bc,0x8b0b54a7a541d22c,0x312a3c33f20800c1,0xe401b39ce755f512,0x808000d176bfb84a,0x0305c6c5bc97b1a0,0x7711834fbded84b6,0x1d4dca20946a1b23,0x80bfed89b730469e,0x641a20bd14e5d7cf,0xc5bc97b1a0808000,0xca32ddfd2c0305c6,0xf662200d93c916ca,0x0ca700521b6ece14,0x1a14d2365bb10a8e,0xbd88808000fd386e,0xc6e40304dbfb86ad,0xaba7f00aede6da7a,0xc5a36eac7d327196,0x5237aa32dafc085e,0x11003545013f1ed3,0xbd65d3fbab8aa616,0xb8c69175919e298e,0xe4fe3762fd534801,0xba7de375298d061d,0xf917cbb4170015e4,0x1747ce171e061770,0x05d7177e6b170d69,0x69170e891774ff17,0x17882e17c3621765,0x000a0ec1de17d7e4 }, { 0x00 } }; } diff --git a/src/currency_core/genesis.h b/src/currency_core/genesis.h index 3cd77089..73f8f942 100644 --- a/src/currency_core/genesis.h +++ b/src/currency_core/genesis.h @@ -11,7 +11,7 @@ namespace currency #pragma pack(push, 1) struct genesis_tx_raw_data { - uint64_t const v[63]; + uint64_t const v[86]; uint8_t const r[1]; }; #pragma pack(pop) diff --git a/src/currency_core/genesis_acc.cpp b/src/currency_core/genesis_acc.cpp index 50460c4b..aac46ed6 100644 --- a/src/currency_core/genesis_acc.cpp +++ b/src/currency_core/genesis_acc.cpp @@ -9,20 +9,23 @@ namespace currency { - const std::string ggenesis_tx_pub_key_str = "698b7bd6fc1bea739657b9fa8441a5a7a4cae69cb7efa2defc60e4c6609009f4"; + const std::string ggenesis_tx_pub_key_str = "a68aabfbd365bd8e299e917591c6b8014853fd6237fee41d068d2975e37dbae4"; const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string(ggenesis_tx_pub_key_str); - - const genesis_tx_dictionary_entry ggenesis_dict[10] = { - { 690562910953636312ULL,5 }, - { 940036618224342135ULL,3 }, - { 1343336992873709805ULL,9 }, - { 2417587344126263675ULL,7 }, - { 2976852013260878279ULL,8 }, - { 9662281438621735689ULL,4 }, - { 14708441932961059072ULL,6 }, - { 15678994962012632719ULL,1 }, - { 17191212896741366274ULL,2 }, - { 18291644074790683797ULL,0 } + const genesis_tx_dictionary_entry ggenesis_dict[14] = { + { 898363347618325980ULL,7 }, + { 1234271292339965434ULL,1 }, + { 2785329203593578547ULL,12 }, + { 4955366495399988463ULL,11 }, + { 5233257582118330150ULL,5 }, + { 6604452700210763953ULL,13 }, + { 8712326356392296687ULL,9 }, + { 8863158309745010598ULL,4 }, + { 9527474759752332295ULL,2 }, + { 9921730437908704447ULL,8 }, + { 11109691972771859220ULL,0 }, + { 14297297752337562678ULL,3 }, + { 15951161519112687845ULL,6 }, + { 17472133472787764818ULL,10 } }; } diff --git a/src/currency_core/genesis_acc.h b/src/currency_core/genesis_acc.h index 49af5cce..628c7256 100644 --- a/src/currency_core/genesis_acc.h +++ b/src/currency_core/genesis_acc.h @@ -24,7 +24,7 @@ namespace currency } }; #pragma pack(pop) - extern const genesis_tx_dictionary_entry ggenesis_dict[10]; + extern const genesis_tx_dictionary_entry ggenesis_dict[14]; extern const crypto::public_key ggenesis_tx_pub_key; From d977521c17217d7de18a30cd7c3758e51153661e Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 11 Apr 2019 00:12:32 +0200 Subject: [PATCH 5/5] fixed checkpoints in coretests --- src/currency_core/currency_config.h | 4 ++-- tests/core_tests/checkpoints_tests.cpp | 2 +- tests/core_tests/multisig_wallet_tests.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index be3a4b6c..1fc59d5d 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -7,7 +7,7 @@ #pragma once -#define CURRENCY_FORMATION_VERSION 78 +#define CURRENCY_FORMATION_VERSION 79 #define CURRENCY_MAX_BLOCK_NUMBER 500000000 @@ -15,7 +15,7 @@ #define CURRENCY_TX_MAX_ALLOWED_OUTS 2000 #define CURRENCY_PUBLIC_ADDRESS_TEXTBLOB_VER 0 #define CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX 197 // addresses start with 'Z' -#define CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX 0x3678 // addresses start with 'iZ' +#define CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX 0x3678 // integrated addresses start with 'iZ' #define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10 #define CURRENT_TRANSACTION_VERSION 1 #define CURRENT_BLOCK_MAJOR_VERSION 1 diff --git a/tests/core_tests/checkpoints_tests.cpp b/tests/core_tests/checkpoints_tests.cpp index 2275b884..a7405288 100644 --- a/tests/core_tests/checkpoints_tests.cpp +++ b/tests/core_tests/checkpoints_tests.cpp @@ -628,7 +628,7 @@ bool gen_no_attchments_in_coinbase::init_config_set_cp(currency::core& c, size_t crc.pos_minimum_heigh = 1; c.get_blockchain_storage().set_core_runtime_config(crc); - m_checkpoints.add_checkpoint(12, "b28d40aa02b30d1f0e807147151b5073dc8dc930414cbbdbde11a9502f9c6936"); + m_checkpoints.add_checkpoint(12, "446b25ca3816e36df92745ea91c3c54a8745db565bafd4d2aa7df9da49220a19"); c.set_checkpoints(currency::checkpoints(m_checkpoints)); return true; diff --git a/tests/core_tests/multisig_wallet_tests.cpp b/tests/core_tests/multisig_wallet_tests.cpp index fee3ea47..b37b2498 100644 --- a/tests/core_tests/multisig_wallet_tests.cpp +++ b/tests/core_tests/multisig_wallet_tests.cpp @@ -1625,7 +1625,7 @@ multisig_and_checkpoints::multisig_and_checkpoints() bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector& events) { currency::checkpoints checkpoints; - checkpoints.add_checkpoint(15, "b9adef016fc8de02ad6d0db526e536a3c2211ee23a2d906f56989465c3e38602"); + checkpoints.add_checkpoint(15, "37da2a30fd8cf1daa05ba11cb2ac5f7a3cc998bce56e4b575fbbea58f0592f5b"); c.set_checkpoints(std::move(checkpoints)); return true;