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

Commit 824cab7

Browse files
authored
Merge pull request #1077 from GolosChain/1074-fix-delegators-overflow
Fix delegator's interest overflow #1074
2 parents 34b76bb + 9b2d6d6 commit 824cab7

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

libraries/chain/database.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,8 +2290,11 @@ namespace golos { namespace chain {
22902290
uint64_t delegators_reward = 0;
22912291
const auto& vdo_idx = get_index<vesting_delegation_index>().indices().get<by_received>();
22922292
for (auto& dvir : cvo.delegator_vote_interest_rates) {
2293+
if (dvir.interest_rate > STEEMIT_100_PERCENT) {
2294+
wlog("Skip bad delegator's interest rate: ${r}", ("r", dvir.interest_rate));
2295+
continue;
2296+
}
22932297
auto delegator_claim = claim * dvir.interest_rate / STEEMIT_100_PERCENT;
2294-
22952298
if (delegator_claim == 0) {
22962299
continue;
22972300
}

libraries/chain/steem_evaluator.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,8 +1528,13 @@ namespace golos { namespace chain {
15281528
for (; vdo_itr != vdo_idx.end() && vdo_itr->delegatee == voter.name; ++vdo_itr) {
15291529
delegator_vote_interest_rate dvir;
15301530
dvir.account = vdo_itr->delegator;
1531-
dvir.interest_rate = vdo_itr->vesting_shares.amount.value * vdo_itr->interest_rate
1532-
/ voter.effective_vesting_shares().amount.value;
1531+
if (_db.head_block_num() < GOLOS_BUG1074_BLOCK && !_db.has_hardfork(STEEMIT_HARDFORK_0_20__1074)) {
1532+
dvir.interest_rate = vdo_itr->vesting_shares.amount.value * vdo_itr->interest_rate /
1533+
voter.effective_vesting_shares().amount.value;
1534+
} else {
1535+
dvir.interest_rate = (uint128_t(vdo_itr->vesting_shares.amount.value) *
1536+
vdo_itr->interest_rate / voter.effective_vesting_shares().amount.value).to_uint64();
1537+
}
15331538
dvir.payout_strategy = vdo_itr->payout_strategy;
15341539
if (dvir.interest_rate > 0) {
15351540
delegator_vote_interest_rates.emplace_back(std::move(dvir));

libraries/protocol/include/golos/protocol/config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
*/
44
#pragma once
55

6+
67
#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 20, 0))
78
#define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION (hardfork_version(STEEMIT_BLOCKCHAIN_VERSION))
89

10+
11+
#define GOLOS_BUG1074_BLOCK 23569125
12+
913
#ifdef STEEMIT_BUILD_TESTNET
1014
#define BLOCKCHAIN_NAME "GOLOSTEST"
1115

libraries/protocol/steem_operations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ namespace golos { namespace protocol {
276276

277277
void chain_properties_19::validate() const {
278278
chain_properties_18::validate();
279-
GOLOS_CHECK_VALUE_LE(auction_window_size, STEEMIT_MAX_AUCTION_WINDOW_SIZE_SECONDS);
279+
// GOLOS_CHECK_VALUE_LE(auction_window_size, STEEMIT_MAX_AUCTION_WINDOW_SIZE_SECONDS); // auction_window_size is limited by 16bit
280280
GOLOS_CHECK_VALUE_LE(max_referral_interest_rate, GOLOS_MAX_REFERRAL_INTEREST_RATE);
281281
GOLOS_CHECK_VALUE_LE(max_referral_term_sec, GOLOS_MAX_REFERRAL_TERM_SEC);
282282

libraries/wallet/wallet.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,12 +2204,8 @@ fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_st
22042204
) {
22052205
WALLET_CHECK_UNLOCKED();
22062206

2207-
const auto hf = my->_remote_database_api->get_hardfork_version();
2208-
const auto has_hf18 = hf >= hardfork_version(0, STEEMIT_HARDFORK_0_18__673);
2209-
22102207
signed_transaction tx;
22112208
witness_update_operation op;
2212-
22132209
if (url.empty()) {
22142210
auto wit = my->_remote_witness_api->get_witness_by_account(witness_account_name);
22152211
if (wit.valid()) {

0 commit comments

Comments
 (0)