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

Rename eos_bucket to pervote_bucket

上级 53b5dc0c
......@@ -126,7 +126,7 @@
{"name":"total_ram_stake", "type":"asset"},
{"name":"last_producer_schedule_update", "type":"time"},
{"name":"last_pervote_bucket_fill", "type":"uint64"},
{"name":"eos_bucket", "type":"asset"},
{"name":"pervote_bucket", "type":"asset"},
{"name":"savings", "type":"asset"},
{"name":"last_producer_schedule_id", "type":"checksum160"},
{"name":"total_activatied_stake", "type":"int64"}
......
......@@ -33,7 +33,7 @@ namespace eosiosystem {
block_timestamp last_producer_schedule_update = 0;
uint64_t last_pervote_bucket_fill = 0;
eosio::asset eos_bucket;
eosio::asset pervote_bucket;
eosio::asset savings;
checksum160 last_producer_schedule_id;
......@@ -43,7 +43,7 @@ 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)
(eos_bucket)(savings)(last_producer_schedule_id)(total_activated_stake) )
(pervote_bucket)(savings)(last_producer_schedule_id)(total_activated_stake) )
};
struct producer_info {
......@@ -191,7 +191,7 @@ namespace eosiosystem {
private:
eosio::asset payment_per_block( double rate, const eosio::asset& token_supply, uint32_t num_blocks );
eosio::asset payment_per_vote( const account_name& owner, double owners_votes, const eosio::asset& eos_bucket );
eosio::asset payment_per_vote( const account_name& owner, double owners_votes, const eosio::asset& pervote_bucket );
eosio::asset supply_growth( double rate, const eosio::asset& token_supply, time seconds );
......
......@@ -29,7 +29,7 @@ namespace eosiosystem {
using namespace eosio;
/** until activated stake crosses this threshold no new rewards are paid */
if( _gstate.total_activated_stake < 1500000000000 /* 150'000'000'0000 */ )
if( _gstate.total_activated_stake < 150'000'000'0000 )
return;
if( _gstate.last_pervote_bucket_fill == 0 ) /// start the presses
......@@ -50,10 +50,10 @@ namespace eosiosystem {
}
eosio::asset system_contract::payment_per_vote( const account_name& owner, double owners_votes, const eosio::asset& eos_bucket ) {
eosio::asset system_contract::payment_per_vote( const account_name& owner, double owners_votes, const eosio::asset& pervote_bucket ) {
eosio::asset payment(0, S(4,EOS));
const int64_t min_daily_amount = 100 * 10000;
if ( eos_bucket.amount < min_daily_tokens ) {
if ( pervote_bucket.amount < min_daily_tokens ) {
return payment;
}
......@@ -75,7 +75,7 @@ namespace eosiosystem {
}
total_producer_votes += itr->total_votes;
running_payment_amount = (itr->total_votes) * double(eos_bucket.amount) / total_producer_votes;
running_payment_amount = (itr->total_votes) * double(pervote_bucket.amount) / total_producer_votes;
if ( running_payment_amount < min_daily_amount ) {
if ( itr->owner == owner ) {
to_be_payed = false;
......@@ -86,7 +86,7 @@ namespace eosiosystem {
}
if ( to_be_payed ) {
payment.amount = static_cast<int64_t>( (double(eos_bucket.amount) * owners_votes) / total_producer_votes );
payment.amount = static_cast<int64_t>( (double(pervote_bucket.amount) * owners_votes) / total_producer_votes );
}
return payment;
......@@ -106,12 +106,12 @@ namespace eosiosystem {
const asset token_supply = token( N(eosio.token)).get_supply(symbol_type(system_token_symbol).name() );
const uint32_t secs_since_last_fill = static_cast<uint32_t>( (current_time() - _gstate.last_pervote_bucket_fill) / 1000000 );
const asset to_eos_bucket = supply_growth( standby_rate, token_supply, secs_since_last_fill );
const asset to_pervote_bucket = supply_growth( standby_rate, token_supply, secs_since_last_fill );
const asset to_savings = supply_growth( continuous_rate - (perblock_rate + standby_rate), token_supply, secs_since_last_fill );
const asset perblock_pay = payment_per_block( perblock_rate, token_supply, prod->produced_blocks );
const asset issue_amount = to_eos_bucket + to_savings + perblock_pay;
const asset issue_amount = to_pervote_bucket + to_savings + perblock_pay;
const asset pervote_pay = payment_per_vote( owner, prod->total_votes, to_eos_bucket + _gstate.eos_bucket );
const asset pervote_pay = payment_per_vote( owner, prod->total_votes, to_pervote_bucket + _gstate.pervote_bucket );
if ( perblock_pay.amount + pervote_pay.amount == 0 ) {
_producers.modify( prod, 0, [&](auto& p) {
......@@ -123,7 +123,7 @@ namespace eosiosystem {
INLINE_ACTION_SENDER(eosio::token, issue)( N(eosio.token), {{N(eosio),N(active)}},
{N(eosio), issue_amount, std::string("issue tokens for producer pay and savings")} );
_gstate.eos_bucket += ( to_eos_bucket - pervote_pay );
_gstate.pervote_bucket += ( to_pervote_bucket - pervote_pay );
_gstate.last_pervote_bucket_fill = current_time();
_gstate.savings += to_savings;
......
......@@ -1261,10 +1261,11 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
{
produce_blocks(50);
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_eos_bucket = initial_global_state["eos_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_pervote_bucket = initial_global_state["pervote_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
prod = get_producer_info("inita");
const uint32_t produced_blocks = prod["produced_blocks"].as<uint32_t>();
BOOST_REQUIRE(1 < produced_blocks);
......@@ -1274,10 +1275,10 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL(success(), push_action(N(inita), N(claimrewards), mvo()("owner", "inita")));
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset eos_bucket = global_state["eos_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset pervote_bucket = global_state["pervote_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
prod = get_producer_info("inita");
BOOST_REQUIRE_EQUAL(1, prod["produced_blocks"].as<uint32_t>());
const asset supply = get_token_supply();
......@@ -1286,20 +1287,20 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL(claim_time, prod["last_claim_time"].as<uint64_t>());
const int32_t secs_between_fills = static_cast<int32_t>((claim_time - initial_claim_time) / 1000000);
BOOST_REQUIRE_EQUAL(0, initial_eos_bucket.amount);
BOOST_REQUIRE_EQUAL(0, initial_pervote_bucket.amount);
BOOST_REQUIRE_EQUAL(int64_t( (initial_supply.amount * secs_between_fills * ((4.879-1.0)/100.0)) / (52*7*24*3600) ),
savings.amount - initial_savings.amount);
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * (0.25/100.0) / (52*7*24*3600*2) );
int64_t from_eos_bucket = int64_t( initial_supply.amount * secs_between_fills * (0.75/100.0) / (52*7*24*3600) );
int64_t from_pervote_bucket = int64_t( initial_supply.amount * secs_between_fills * (0.75/100.0) / (52*7*24*3600) );
if (from_eos_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_eos_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(0, eos_bucket.amount);
if (from_pervote_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_pervote_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(0, pervote_bucket.amount);
} else {
BOOST_REQUIRE_EQUAL(block_payments, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(from_eos_bucket, eos_bucket.amount);
BOOST_REQUIRE_EQUAL(from_pervote_bucket, pervote_bucket.amount);
}
const int64_t max_supply_growth = int64_t( (initial_supply.amount * secs_between_fills * (4.879/100.0)) / (52*7*24*3600) );
......@@ -1321,10 +1322,10 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
// wait 5 more minutes, inita can now claim rewards again
{
produce_block(fc::seconds(5 * 60));
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_eos_bucket = initial_global_state["eos_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_pervote_bucket = initial_global_state["pervote_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
prod = get_producer_info("inita");
const uint32_t produced_blocks = prod["produced_blocks"].as<uint32_t>();
......@@ -1336,10 +1337,11 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL(success(),
push_action(N(inita), N(claimrewards), mvo()("owner", "inita")));
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset eos_bucket = global_state["eos_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset pervote_bucket = global_state["pervote_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
prod = get_producer_info("inita");
BOOST_REQUIRE_EQUAL(1, prod["produced_blocks"].as<uint32_t>());
const asset supply = get_token_supply();
......@@ -1351,15 +1353,15 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester) try {
BOOST_REQUIRE_EQUAL(int64_t( (initial_supply.amount * secs_between_fills * ((4.879-1.0)/100.0)) / (52*7*24*3600) ),
savings.amount - initial_savings.amount);
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * (0.25/100.0) / (52*7*24*3600*2) );
int64_t from_eos_bucket = int64_t( initial_eos_bucket.amount + initial_supply.amount * secs_between_fills * (0.75/100.0) / (52*7*24*3600) );
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * (0.25/100.0) / (52*7*24*3600*2) );
int64_t from_pervote_bucket = int64_t( initial_pervote_bucket.amount + initial_supply.amount * secs_between_fills * (0.75/100.0) / (52*7*24*3600) );
if (from_eos_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_eos_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(0, eos_bucket.amount);
if (from_pervote_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_pervote_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(0, pervote_bucket.amount);
} else {
BOOST_REQUIRE_EQUAL(block_payments, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(from_eos_bucket, eos_bucket.amount);
BOOST_REQUIRE_EQUAL(from_pervote_bucket, pervote_bucket.amount);
}
const int64_t max_supply_growth = int64_t( (initial_supply.amount * secs_between_fills * (4.879/100.0)) / (52*7*24*3600) );
......@@ -1490,37 +1492,37 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester) try {
const auto prod_name = producer_names[prod_index];
const auto produced_blocks = get_producer_info(prod_name)["produced_blocks"].as<uint32_t>();
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_eos_bucket = initial_global_state["eos_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
const asset initial_supply = get_token_supply();
const asset initial_balance = get_balance(prod_name);
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_pervote_bucket = initial_global_state["pervote_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
const asset initial_supply = get_token_supply();
const asset initial_balance = get_balance(prod_name);
BOOST_REQUIRE_EQUAL(success(), push_action(prod_name, N(claimrewards), mvo()("owner", prod_name)));
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset eos_bucket = global_state["eos_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
const asset supply = get_token_supply();
const asset balance = get_balance(prod_name);
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset pervote_bucket = global_state["pervote_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
const asset supply = get_token_supply();
const asset balance = get_balance(prod_name);
const int32_t secs_between_fills = static_cast<int32_t>((claim_time - initial_claim_time) / 1000000);
BOOST_REQUIRE_EQUAL(int64_t( (initial_supply.amount * secs_between_fills * (cont_rate - standby_rate - block_rate)) / secs_per_year ),
savings.amount - initial_savings.amount);
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * block_rate / blocks_per_year );
int64_t expected_eos_bucket = int64_t( initial_eos_bucket.amount + initial_supply.amount * secs_between_fills * standby_rate / secs_per_year );
int64_t from_eos_bucket = int64_t( vote_shares[prod_index] * expected_eos_bucket );
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * block_rate / blocks_per_year );
int64_t expected_pervote_bucket = int64_t( initial_pervote_bucket.amount + initial_supply.amount * secs_between_fills * standby_rate / secs_per_year );
int64_t from_pervote_bucket = int64_t( vote_shares[prod_index] * expected_pervote_bucket );
if (from_eos_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_eos_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(expected_eos_bucket - from_eos_bucket, eos_bucket.amount);
if (from_pervote_bucket >= 100 * 10000) {
BOOST_REQUIRE_EQUAL(block_payments + from_pervote_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(expected_pervote_bucket - from_pervote_bucket, pervote_bucket.amount);
} else {
BOOST_REQUIRE_EQUAL(block_payments, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(expected_eos_bucket, eos_bucket.amount);
BOOST_REQUIRE_EQUAL(expected_pervote_bucket, pervote_bucket.amount);
}
produce_blocks(5);
......@@ -1550,33 +1552,33 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester) try {
const auto prod_name = producer_names[prod_index];
const auto produced_blocks = get_producer_info(prod_name)["produced_blocks"].as<uint32_t>();
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_eos_bucket = initial_global_state["eos_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
const asset initial_supply = get_token_supply();
const asset initial_balance = get_balance(prod_name);
const auto initial_global_state = get_global_state();
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const asset initial_pervote_bucket = initial_global_state["pervote_bucket"].as<asset>();
const asset initial_savings = initial_global_state["savings"].as<asset>();
const asset initial_supply = get_token_supply();
const asset initial_balance = get_balance(prod_name);
BOOST_REQUIRE_EQUAL(success(), push_action(prod_name, N(claimrewards), mvo()("owner", prod_name)));
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset eos_bucket = global_state["eos_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
const asset supply = get_token_supply();
const asset balance = get_balance(prod_name);
const auto global_state = get_global_state();
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const asset pervote_bucket = global_state["pervote_bucket"].as<asset>();
const asset savings = global_state["savings"].as<asset>();
const asset supply = get_token_supply();
const asset balance = get_balance(prod_name);
const int32_t secs_between_fills = static_cast<int32_t>((claim_time - initial_claim_time) / 1000000);
BOOST_REQUIRE_EQUAL(int64_t( (initial_supply.amount * secs_between_fills * (cont_rate - standby_rate - block_rate)) / secs_per_year ),
savings.amount - initial_savings.amount);
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * block_rate / blocks_per_year );
int64_t expected_eos_bucket = int64_t( initial_eos_bucket.amount + initial_supply.amount * secs_between_fills * standby_rate / secs_per_year );
int64_t from_eos_bucket = int64_t( vote_shares[prod_index] * expected_eos_bucket );
int64_t block_payments = int64_t( initial_supply.amount * produced_blocks * block_rate / blocks_per_year );
int64_t expected_pervote_bucket = int64_t( initial_pervote_bucket.amount + initial_supply.amount * secs_between_fills * standby_rate / secs_per_year );
int64_t from_pervote_bucket = int64_t( vote_shares[prod_index] * expected_pervote_bucket );
BOOST_REQUIRE_EQUAL(block_payments + from_eos_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(expected_eos_bucket - from_eos_bucket, eos_bucket.amount);
BOOST_REQUIRE_EQUAL(block_payments + from_pervote_bucket, balance.amount - initial_balance.amount);
BOOST_REQUIRE_EQUAL(expected_pervote_bucket - from_pervote_bucket, pervote_bucket.amount);
produce_blocks(5);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册