From f20692d2fbba8ea2123cc803d1890cd2681556d8 Mon Sep 17 00:00:00 2001 From: zxcat <550974+zxcat@users.noreply.github.com> Date: Thu, 17 Jan 2019 23:22:43 +0300 Subject: [PATCH 1/3] Fix delegator's interest overflow #1074 --- libraries/chain/database.cpp | 5 ++++- libraries/chain/steem_evaluator.cpp | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 99b5ffacb7..cb999b7fb0 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -2290,8 +2290,11 @@ namespace golos { namespace chain { uint64_t delegators_reward = 0; const auto& vdo_idx = get_index().indices().get(); for (auto& dvir : cvo.delegator_vote_interest_rates) { + if (dvir.interest_rate > STEEMIT_100_PERCENT) { + wlog("Skip bad delegator's interest rate: ${r}", ("r", dvir.interest_rate)); + continue; + } auto delegator_claim = claim * dvir.interest_rate / STEEMIT_100_PERCENT; - if (delegator_claim == 0) { continue; } diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 2ff393f8d8..5c852afe8d 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -1516,8 +1516,13 @@ namespace golos { namespace chain { for (; vdo_itr != vdo_idx.end() && vdo_itr->delegatee == voter.name; ++vdo_itr) { delegator_vote_interest_rate dvir; dvir.account = vdo_itr->delegator; - dvir.interest_rate = vdo_itr->vesting_shares.amount.value * vdo_itr->interest_rate - / voter.effective_vesting_shares().amount.value; + if (!_db.has_hardfork(STEEMIT_HARDFORK_0_20__1074)) { + dvir.interest_rate = vdo_itr->vesting_shares.amount.value * vdo_itr->interest_rate / + voter.effective_vesting_shares().amount.value; + } else { + dvir.interest_rate = (uint128_t(vdo_itr->vesting_shares.amount.value) * + vdo_itr->interest_rate / voter.effective_vesting_shares().amount.value).to_uint64(); + } dvir.payout_strategy = vdo_itr->payout_strategy; if (dvir.interest_rate > 0) { delegator_vote_interest_rates.emplace_back(std::move(dvir)); From fcf26d8149ca3477ff4713222ce378b6af6d8d2b Mon Sep 17 00:00:00 2001 From: zxcat <550974+zxcat@users.noreply.github.com> Date: Fri, 18 Jan 2019 00:19:44 +0300 Subject: [PATCH 2/3] Fix compilation warnings --- libraries/protocol/steem_operations.cpp | 2 +- libraries/wallet/wallet.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/protocol/steem_operations.cpp b/libraries/protocol/steem_operations.cpp index acc7d4849e..ca2fa538a8 100644 --- a/libraries/protocol/steem_operations.cpp +++ b/libraries/protocol/steem_operations.cpp @@ -276,7 +276,7 @@ namespace golos { namespace protocol { void chain_properties_19::validate() const { chain_properties_18::validate(); - GOLOS_CHECK_VALUE_LE(auction_window_size, STEEMIT_MAX_AUCTION_WINDOW_SIZE_SECONDS); + // GOLOS_CHECK_VALUE_LE(auction_window_size, STEEMIT_MAX_AUCTION_WINDOW_SIZE_SECONDS); // auction_window_size is limited by 16bit GOLOS_CHECK_VALUE_LE(max_referral_interest_rate, GOLOS_MAX_REFERRAL_INTEREST_RATE); GOLOS_CHECK_VALUE_LE(max_referral_term_sec, GOLOS_MAX_REFERRAL_TERM_SEC); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 7be689c481..d0914b7ad9 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2204,12 +2204,8 @@ fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_st ) { WALLET_CHECK_UNLOCKED(); - const auto hf = my->_remote_database_api->get_hardfork_version(); - const auto has_hf18 = hf >= hardfork_version(0, STEEMIT_HARDFORK_0_18__673); - signed_transaction tx; witness_update_operation op; - if (url.empty()) { auto wit = my->_remote_witness_api->get_witness_by_account(witness_account_name); if (wit.valid()) { From 9b2d6d6f8f4fdebb19eda83e766eef13695390b0 Mon Sep 17 00:00:00 2001 From: zxcat <550974+zxcat@users.noreply.github.com> Date: Fri, 18 Jan 2019 00:59:22 +0300 Subject: [PATCH 3/3] Avoid new overwlows after 23569125 block #1074 --- libraries/chain/steem_evaluator.cpp | 2 +- libraries/protocol/include/golos/protocol/config.hpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 5c852afe8d..c96b521d3b 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -1516,7 +1516,7 @@ namespace golos { namespace chain { for (; vdo_itr != vdo_idx.end() && vdo_itr->delegatee == voter.name; ++vdo_itr) { delegator_vote_interest_rate dvir; dvir.account = vdo_itr->delegator; - if (!_db.has_hardfork(STEEMIT_HARDFORK_0_20__1074)) { + if (_db.head_block_num() < GOLOS_BUG1074_BLOCK && !_db.has_hardfork(STEEMIT_HARDFORK_0_20__1074)) { dvir.interest_rate = vdo_itr->vesting_shares.amount.value * vdo_itr->interest_rate / voter.effective_vesting_shares().amount.value; } else { diff --git a/libraries/protocol/include/golos/protocol/config.hpp b/libraries/protocol/include/golos/protocol/config.hpp index e3289635f0..40de245187 100644 --- a/libraries/protocol/include/golos/protocol/config.hpp +++ b/libraries/protocol/include/golos/protocol/config.hpp @@ -3,9 +3,13 @@ */ #pragma once + #define STEEMIT_BLOCKCHAIN_VERSION (version(0, 20, 0)) #define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION (hardfork_version(STEEMIT_BLOCKCHAIN_VERSION)) + +#define GOLOS_BUG1074_BLOCK 23569125 + #ifdef STEEMIT_BUILD_TESTNET #define BLOCKCHAIN_NAME "GOLOSTEST"