提交 1efaeafa 编写于 作者: K Khaled Al-Hassanieh

Prevent name auctions from closing until 14 days after min_stake_activated - #3209

上级 de54bb5e
......@@ -260,6 +260,7 @@
{"name":"savings", "type":"int64"},
{"name":"total_unpaid_blocks", "type":"uint32"},
{"name":"total_activated_stake", "type":"int64"},
{"name":"thresh_activated_stake_time", "type":"uint64"},
{"name":"last_producer_schedule_id", "type":"checksum160"},
{"name":"total_producer_vote_weight", "type":"float64"},
{"name":"last_name_close", "type":"block_timestamp_type"}
......
......@@ -57,6 +57,7 @@ namespace eosiosystem {
int64_t savings = 0;
uint32_t total_unpaid_blocks = 0; /// all blocks which have been produced but not paid
int64_t total_activated_stake = 0;
uint64_t thresh_activated_stake_time = 0;
checksum160 last_producer_schedule_id;
double total_producer_vote_weight = 0; /// the sum of all producer votes
block_timestamp last_name_close;
......@@ -65,7 +66,8 @@ namespace eosiosystem {
EOSLIB_SERIALIZE_DERIVED( eosio_global_state, eosio_parameters, (total_ram_bytes_reserved)(total_ram_stake)
(last_producer_schedule_update)
(last_pervote_bucket_fill)
(pervote_bucket)(perblock_bucket)(savings)(total_unpaid_blocks)(total_activated_stake)(last_producer_schedule_id)(total_producer_vote_weight)(last_name_close) )
(pervote_bucket)(perblock_bucket)(savings)(total_unpaid_blocks)(total_activated_stake)(thresh_activated_stake_time)
(last_producer_schedule_id)(total_producer_vote_weight)(last_name_close) )
};
struct producer_info {
......
......@@ -4,17 +4,17 @@
namespace eosiosystem {
const int64_t min_daily_tokens = 100;
const int64_t min_activated_stake = 150'000'000'0000;
const double continuous_rate = 0.04879; // 5% annual rate
const double perblock_rate = 0.0025; // 0.25%
const double standby_rate = 0.0075; // 0.75%
const uint32_t blocks_per_year = 52*7*24*2*3600; // half seconds per year
const uint32_t seconds_per_year = 52*7*24*3600;
const uint32_t blocks_per_day = 2 * 24 * 3600;
const uint32_t blocks_per_hour = 2 * 3600;
const uint64_t useconds_per_day = 24 * 3600 * uint64_t(1000000);
const uint64_t useconds_per_year = seconds_per_year*1000000ll;
const int64_t min_pervote_daily_pay = 100'0000;
const int64_t min_activated_stake = 150'000'000'0000;
const double continuous_rate = 0.04879; // 5% annual rate
const double perblock_rate = 0.0025; // 0.25%
const double standby_rate = 0.0075; // 0.75%
const uint32_t blocks_per_year = 52*7*24*2*3600; // half seconds per year
const uint32_t seconds_per_year = 52*7*24*3600;
const uint32_t blocks_per_day = 2 * 24 * 3600;
const uint32_t blocks_per_hour = 2 * 3600;
const uint64_t useconds_per_day = 24 * 3600 * uint64_t(1000000);
const uint64_t useconds_per_year = seconds_per_year*1000000ll;
void system_contract::onblock( block_timestamp timestamp, account_name producer ) {
......@@ -49,12 +49,15 @@ namespace eosiosystem {
print( "maybe update bids \n" );
if( (timestamp.slot - _gstate.last_name_close.slot) > (2*60*60*24ll)/*timeslots_per_day*/ ) {
if( (timestamp.slot - _gstate.last_name_close.slot) > blocks_per_day ) {
print( "update bids" );
name_bid_table bids(_self,_self);
auto idx = bids.get_index<N(highbid)>();
auto highest = idx.begin();
if( highest != idx.end() && highest->high_bid > 0 && highest->last_bid_time < (current_time() - useconds_per_day) ) {
if( highest != idx.end() &&
highest->high_bid > 0 &&
highest->last_bid_time < (current_time() - useconds_per_day) &&
(current_time() - _gstate.thresh_activated_stake_time) > 14 * useconds_per_day ){
_gstate.last_name_close = timestamp;
idx.modify( highest, 0, [&]( auto& b ){
b.high_bid = -b.high_bid;
......@@ -106,7 +109,7 @@ namespace eosiosystem {
if( _gstate.total_producer_vote_weight > 0 ) {
producer_per_vote_pay = int64_t((_gstate.pervote_bucket * prod.total_votes ) / _gstate.total_producer_vote_weight);
}
if( producer_per_vote_pay < 100'0000 ) {
if( producer_per_vote_pay < min_pervote_daily_pay ) {
producer_per_vote_pay = 0;
}
int64_t total_pay = producer_per_block_pay + producer_per_vote_pay;
......
......@@ -167,6 +167,9 @@ namespace eosiosystem {
*/
if( voter->last_vote_weight <= 0.0 ) {
_gstate.total_activated_stake += voter->staked;
if( _gstate.total_activated_stake >= min_activated_stake ) {
_gstate.thresh_activated_stake_time = current_time();
}
}
auto new_vote_weight = stake2vote( voter->staked );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册