From 1e5fb36f9559255079ad1b041dc748e0abf720e8 Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Fri, 18 Jan 2019 01:53:41 +0700 Subject: [PATCH 1/8] Initial commit for HF 0.20.0 --- libraries/chain/database.cpp | 5 +++++ libraries/chain/hardfork.d/0-preamble.hf | 2 +- libraries/chain/hardfork.d/0_20.hf | 13 +++++++++++++ .../protocol/include/golos/protocol/config.hpp | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 libraries/chain/hardfork.d/0_20.hf diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 273e0ddc1a..99b5ffacb7 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -4506,6 +4506,9 @@ namespace golos { namespace chain { FC_ASSERT(STEEMIT_HARDFORK_0_19 == 19, "Invalid hardfork configuration"); _hardfork_times[STEEMIT_HARDFORK_0_19] = fc::time_point_sec(STEEMIT_HARDFORK_0_19_TIME); _hardfork_versions[STEEMIT_HARDFORK_0_19] = STEEMIT_HARDFORK_0_19_VERSION; + FC_ASSERT(STEEMIT_HARDFORK_0_20 == 20, "Invalid hardfork configuration"); + _hardfork_times[STEEMIT_HARDFORK_0_20] = fc::time_point_sec(STEEMIT_HARDFORK_0_20_TIME); + _hardfork_versions[STEEMIT_HARDFORK_0_20] = STEEMIT_HARDFORK_0_20_VERSION; const auto &hardforks = get_hardfork_property_object(); FC_ASSERT( @@ -4761,6 +4764,8 @@ namespace golos { namespace chain { break; case STEEMIT_HARDFORK_0_19: break; + case STEEMIT_HARDFORK_0_20: + break; default: break; } diff --git a/libraries/chain/hardfork.d/0-preamble.hf b/libraries/chain/hardfork.d/0-preamble.hf index 540ba568b1..703cb09f2a 100644 --- a/libraries/chain/hardfork.d/0-preamble.hf +++ b/libraries/chain/hardfork.d/0-preamble.hf @@ -51,4 +51,4 @@ FC_REFLECT((golos::chain::hardfork_property_object), (next_hardfork)(next_hardfork_time)) CHAINBASE_SET_INDEX_TYPE( golos::chain::hardfork_property_object, golos::chain::hardfork_property_index) -#define STEEMIT_NUM_HARDFORKS 19 +#define STEEMIT_NUM_HARDFORKS 20 diff --git a/libraries/chain/hardfork.d/0_20.hf b/libraries/chain/hardfork.d/0_20.hf new file mode 100644 index 0000000000..bf3d487fe1 --- /dev/null +++ b/libraries/chain/hardfork.d/0_20.hf @@ -0,0 +1,13 @@ +#ifndef STEEMIT_HARDFORK_0_20 +#define STEEMIT_HARDFORK_0_20 20 +#define STEEMIT_HARDFORK_0_20__1074 (STEEMIT_HARDFORK_0_20) // Blockchain stopped due to negative payment of curator reward + +#ifdef STEEMIT_BUILD_TESTNET +#define STEEMIT_HARDFORK_0_20_TIME 1547701200 // 17 jan 2019 12:00:00 MSK +#else +#define STEEMIT_HARDFORK_0_20_TIME 1547787600 // 18 jan 2019 12:00:00 MSK +#endif + +#define STEEMIT_HARDFORK_0_20_VERSION hardfork_version( 0, 20 ) + +#endif diff --git a/libraries/protocol/include/golos/protocol/config.hpp b/libraries/protocol/include/golos/protocol/config.hpp index 8d06a5f53a..e3289635f0 100644 --- a/libraries/protocol/include/golos/protocol/config.hpp +++ b/libraries/protocol/include/golos/protocol/config.hpp @@ -3,7 +3,7 @@ */ #pragma once -#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 19, 1)) +#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 20, 0)) #define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION (hardfork_version(STEEMIT_BLOCKCHAIN_VERSION)) #ifdef STEEMIT_BUILD_TESTNET From 6fff0b6180bd6b2ceca00aa1374930a2a59fd9ab Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Fri, 18 Jan 2019 03:15:05 +0700 Subject: [PATCH 2/8] Disable change curation percent by author after voting on post #1075 --- libraries/chain/hardfork.d/0_20.hf | 1 + libraries/chain/steem_evaluator.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/libraries/chain/hardfork.d/0_20.hf b/libraries/chain/hardfork.d/0_20.hf index bf3d487fe1..8f055a5e88 100644 --- a/libraries/chain/hardfork.d/0_20.hf +++ b/libraries/chain/hardfork.d/0_20.hf @@ -1,6 +1,7 @@ #ifndef STEEMIT_HARDFORK_0_20 #define STEEMIT_HARDFORK_0_20 20 #define STEEMIT_HARDFORK_0_20__1074 (STEEMIT_HARDFORK_0_20) // Blockchain stopped due to negative payment of curator reward +#define STEEMIT_HARDFORK_0_20__1075 (STEEMIT_HARDFORK_0_20) // Author can change curation percent after voting on post #ifdef STEEMIT_BUILD_TESTNET #define STEEMIT_HARDFORK_0_20_TIME 1547701200 // 17 jan 2019 12:00:00 MSK diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 2ff393f8d8..86b8d41f64 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -543,6 +543,12 @@ namespace golos { namespace chain { const auto& mprops = _db.get_witness_schedule_object().median_props; + if (db.has_hardfork(STEEMIT_HARDFORK_0_20__1075)) { + GOLOS_CHECK_LOGIC(_c.abs_rshares == 0, + logic_exception::comment_must_not_have_been_voted, + "Comment must not have been voted on changing auction window reward destination."); + } + GOLOS_CHECK_PARAM(cawrd.destination, { GOLOS_CHECK_VALUE(cawrd.destination != to_reward_fund || mprops.allow_return_auction_reward_to_fund, "Returning to reward fund is disallowed." @@ -566,6 +572,12 @@ namespace golos { namespace chain { const auto& mprops = _db.get_witness_schedule_object().median_props; auto percent = ccrp.percent; // Workaround for correct param name in GOLOS_CHECK_PARAM + + if (db.has_hardfork(STEEMIT_HARDFORK_0_20__1075)) { + GOLOS_CHECK_LOGIC(_c.abs_rshares == 0, + logic_exception::comment_must_not_have_been_voted, + "Comment must not have been voted on changing curation rewards percent."); + } GOLOS_CHECK_PARAM(percent, { GOLOS_CHECK_VALUE(mprops.min_curation_percent <= ccrp.percent && ccrp.percent <= mprops.max_curation_percent, From f03736703d9143891657c9731b44beb78a6cfef8 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 3/8] 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 65a8d72ad0d07915e50ec54966e3959bf59dd73f Mon Sep 17 00:00:00 2001 From: zxcat <550974+zxcat@users.noreply.github.com> Date: Thu, 17 Jan 2019 23:26:03 +0300 Subject: [PATCH 4/8] Revert "Fix delegator's interest overflow #1074" This reverts commit f03736703d9143891657c9731b44beb78a6cfef8. --- libraries/chain/database.cpp | 5 +---- libraries/chain/steem_evaluator.cpp | 9 ++------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index cb999b7fb0..99b5ffacb7 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -2290,11 +2290,8 @@ 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 5c852afe8d..2ff393f8d8 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -1516,13 +1516,8 @@ 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)) { - 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.interest_rate = vdo_itr->vesting_shares.amount.value * vdo_itr->interest_rate + / voter.effective_vesting_shares().amount.value; dvir.payout_strategy = vdo_itr->payout_strategy; if (dvir.interest_rate > 0) { delegator_vote_interest_rates.emplace_back(std::move(dvir)); 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 5/8] 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 5ee3537fe23a5adcadf4d6fe623b5c84203c003f Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Fri, 18 Jan 2019 03:33:11 +0700 Subject: [PATCH 6/8] Typo fix #1075 --- libraries/chain/steem_evaluator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 86b8d41f64..bdeef5c258 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -543,7 +543,7 @@ namespace golos { namespace chain { const auto& mprops = _db.get_witness_schedule_object().median_props; - if (db.has_hardfork(STEEMIT_HARDFORK_0_20__1075)) { + if (_db.has_hardfork(STEEMIT_HARDFORK_0_20__1075)) { GOLOS_CHECK_LOGIC(_c.abs_rshares == 0, logic_exception::comment_must_not_have_been_voted, "Comment must not have been voted on changing auction window reward destination."); @@ -573,7 +573,7 @@ namespace golos { namespace chain { auto percent = ccrp.percent; // Workaround for correct param name in GOLOS_CHECK_PARAM - if (db.has_hardfork(STEEMIT_HARDFORK_0_20__1075)) { + if (_db.has_hardfork(STEEMIT_HARDFORK_0_20__1075)) { GOLOS_CHECK_LOGIC(_c.abs_rshares == 0, logic_exception::comment_must_not_have_been_voted, "Comment must not have been voted on changing curation rewards percent."); 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 7/8] 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 8/8] 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"