Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1077 from GolosChain/1074-fix-delegators-overflow
Browse files Browse the repository at this point in the history
Fix delegator's interest overflow #1074
  • Loading branch information
afalaleev authored Jan 17, 2019
2 parents 34b76bb + 9b2d6d6 commit 824cab7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2290,8 +2290,11 @@ namespace golos { namespace chain {
uint64_t delegators_reward = 0;
const auto& vdo_idx = get_index<vesting_delegation_index>().indices().get<by_received>();
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;
}
Expand Down
9 changes: 7 additions & 2 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,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.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 {
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));
Expand Down
4 changes: 4 additions & 0 deletions libraries/protocol/include/golos/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion libraries/protocol/steem_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 0 additions & 4 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 824cab7

Please sign in to comment.