Skip to content

Commit 6e4fe66

Browse files
committed
Update self_stake_boost to use uint64_t and add self_stake_boost_multiplier to votingconfig. Implement setselfstake action to modify the multiplier and adjust voting logic to utilize the new multiplier for vote weight calculations.
1 parent 6a6d4d8 commit 6e4fe66

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

contracts/eosio.system/include/eosio.system/eosio.system.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ namespace eosiosystem {
457457
eosio::asset reserved3;
458458

459459
// TELOS BEGIN
460-
eosio::binary_extension<uint32_t> self_stake_boost = 0;
460+
eosio::binary_extension<uint64_t> self_stake_boost = 0;
461461
// TELOS END
462462

463463
uint64_t primary_key()const { return owner.value; }
@@ -535,7 +535,8 @@ namespace eosiosystem {
535535
eosio::checksum160 evm_voting_contract;
536536
uint64_t decay_start_epoch;
537537
uint64_t decay_increase_yearly;
538-
EOSLIB_SERIALIZE(votingconfig, (evm_voting_contract)(decay_start_epoch)(decay_increase_yearly))
538+
uint64_t self_stake_boost_multiplier;
539+
EOSLIB_SERIALIZE(votingconfig, (evm_voting_contract)(decay_start_epoch)(decay_increase_yearly)(self_stake_boost_multiplier))
539540
};
540541
// TELOS END
541542

@@ -1710,6 +1711,9 @@ namespace eosiosystem {
17101711
[[eosio::action]]
17111712
void setbpevmstat( eosio::name bp );
17121713

1714+
[[eosio::action]]
1715+
void setselfstake( uint64_t self_stake_boost_multiplier );
1716+
17131717
using unregreason_action = eosio::action_wrapper<"unregreason"_n, &system_contract::unregreason>;
17141718
using votebpout_action = eosio::action_wrapper<"votebpout"_n, &system_contract::votebpout>;
17151719
using setpayrates_action = eosio::action_wrapper<"setpayrates"_n, &system_contract::setpayrates>;
@@ -1719,6 +1723,7 @@ namespace eosiosystem {
17191723
using setvotecontr_action = eosio::action_wrapper<"setvotecontr"_n, &system_contract::setvotecontr>;
17201724
using getevmvote_action = eosio::action_wrapper<"getevmvote"_n, &system_contract::getevmvote>;
17211725
using setbpevmstat_action = eosio::action_wrapper<"setbpevmstat"_n, &system_contract::setbpevmstat>;
1726+
using setselfstake_action = eosio::action_wrapper<"setselfstake"_n, &system_contract::setselfstake>;
17221727
// TELOS END
17231728

17241729
private:

contracts/eosio.system/src/eosio.system.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace eosiosystem {
5656
_gschedule_metrics = _schedule_metrics.get_or_create(_self, schedule_metrics_state{ name(0), 0, std::vector<producer_metric>() });
5757
_grotation = _rotation.get_or_create(_self, rotation_state{ name(0), name(0), 21, 75, block_timestamp(), block_timestamp() });
5858
_gpayrate = _payrate.get_or_create(_self, payrates{ max_bpay_rate, max_worker_monthly_amount });
59-
_gvoting_config = _voting_config.get_or_create(_self, votingconfig{ eosio::checksum160(), 0, 0 });
59+
_gvoting_config = _voting_config.get_or_create(_self, votingconfig{ eosio::checksum160(), 0, 0, 0 });
6060
// TELOS END
6161
}
6262

@@ -798,5 +798,10 @@ namespace eosiosystem {
798798
).send();
799799

800800
}
801+
802+
void system_contract::setselfstake( uint64_t self_stake_boost_multiplier ) {
803+
require_auth(_self);
804+
_gvoting_config.self_stake_boost_multiplier = self_stake_boost_multiplier;
805+
}
801806
// TELOS END
802807
} /// eosio.system

contracts/eosio.system/src/voting.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ namespace eosiosystem {
438438
d.first -= voter->last_vote_weight;
439439
d.second = false;
440440
if (p == voter_name) {
441-
d.first -= self_stake_boost*voter->last_vote_weight;
441+
d.first -= (self_stake_boost/100.0)*voter->last_vote_weight;
442442
self_stake_boost = 0;
443443
}
444444
}
@@ -465,9 +465,8 @@ namespace eosiosystem {
465465
d.first += new_vote_weight;
466466
d.second = true;
467467
if (p == voter_name) {
468-
// TODO: self stake boost multiplier should be retrieved from the votingconfig table
469-
self_stake_boost = 10;
470-
d.first += self_stake_boost*new_vote_weight;
468+
self_stake_boost = _gvoting_config.self_stake_boost_multiplier;
469+
d.first += (self_stake_boost/100.0)*new_vote_weight;
471470
}
472471
}
473472
}

0 commit comments

Comments
 (0)