diff --git a/contracts/eosio.system/eosio.system.abi b/contracts/eosio.system/eosio.system.abi index 39c095a127adf8c2ee9edec9b70062aa71908806..a0c9d5ca9ce843874eb93113f8d5d86651f65246 100644 --- a/contracts/eosio.system/eosio.system.abi +++ b/contracts/eosio.system/eosio.system.abi @@ -270,16 +270,14 @@ "name": "producer_info", "base": "", "fields": [ - {"name":"owner", "type":"account_name"}, - {"name":"total_votes", "type":"float64"}, - {"name":"producer_key", "type":"public_key"}, - {"name":"is_active", "type":"bool"}, - {"name":"url", "type":"string"}, - {"name":"unpaid_blocks", "type":"uint32"}, - {"name":"last_claim_time", "type":"uint64"}, - {"name":"location", "type":"uint16"}, - {"name":"time_became_active", "type":"uint32"}, - {"name":"last_produced_block_time", "type":"uint32"} + {"name":"owner", "type":"account_name"}, + {"name":"total_votes", "type":"float64"}, + {"name":"producer_key", "type":"public_key"}, + {"name":"is_active", "type":"bool"}, + {"name":"url", "type":"string"}, + {"name":"unpaid_blocks", "type":"uint32"}, + {"name":"last_claim_time", "type":"uint64"}, + {"name":"location", "type":"uint16"} ] },{ "name": "regproducer", diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index 2916d03ae685f6a223fd2453546117b3fce69764..6edfd1350a79791c888a77e47b78ceb8a1f7c415 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -78,8 +78,6 @@ namespace eosiosystem { uint32_t unpaid_blocks = 0; uint64_t last_claim_time = 0; uint16_t location = 0; - block_timestamp time_became_active; - block_timestamp last_produced_block_time; uint64_t primary_key()const { return owner; } double by_votes()const { return is_active ? -total_votes : total_votes; } @@ -88,8 +86,7 @@ namespace eosiosystem { // explicit serialization macro is not necessary, used here only to improve compilation time EOSLIB_SERIALIZE( producer_info, (owner)(total_votes)(producer_key)(is_active)(url) - (unpaid_blocks)(last_claim_time)(location) - (time_became_active)(last_produced_block_time) ) + (unpaid_blocks)(last_claim_time)(location) ) }; struct voter_info { diff --git a/contracts/eosio.system/producer_pay.cpp b/contracts/eosio.system/producer_pay.cpp index c2fc7c9664b6e01c6723231bde4b48a5935252ac..f9d9bedb50575b76878d4c7e223746acc0b052fe 100644 --- a/contracts/eosio.system/producer_pay.cpp +++ b/contracts/eosio.system/producer_pay.cpp @@ -39,7 +39,6 @@ namespace eosiosystem { _gstate.total_unpaid_blocks++; _producers.modify( prod, 0, [&](auto& p ) { p.unpaid_blocks++; - p.last_produced_block_time = timestamp; }); } diff --git a/contracts/eosio.system/voting.cpp b/contracts/eosio.system/voting.cpp index ae3f40d5a292425bc31e50cfbbd9634c2ebaf226..4fe7a5e04bae62f673f0f96d1c399c9121369f2a 100644 --- a/contracts/eosio.system/voting.cpp +++ b/contracts/eosio.system/voting.cpp @@ -80,30 +80,7 @@ namespace eosiosystem { std::vector< std::pair > top_producers; top_producers.reserve(21); - std::vector inactive_iters; for ( auto it = idx.cbegin(); it != idx.cend() && top_producers.size() < 21 && 0 < it->total_votes && it->active(); ++it ) { - - /** - If it's the first time or it's been over a day since a producer was last voted in, - update his info. Otherwise, a producer gets a grace period of 7 hours after which - he gets deactivated if he hasn't produced in 24 hours. - */ - if ( it->time_became_active.slot == 0 || - block_time.slot > it->time_became_active.slot + 23 * blocks_per_hour ) { - _producers.modify( *it, 0, [&](auto& p) { - p.time_became_active = block_time; - }); - } else if ( block_time.slot > (2 * 21 * 12 * 100) + it->time_became_active.slot && - block_time.slot > it->last_produced_block_time.slot + blocks_per_day ) { - // save producers that will be deactivated - inactive_iters.push_back(it); - continue; - } else { - _producers.modify( *it, 0, [&](auto& p) { - p.time_became_active = block_time; - }); - } - top_producers.emplace_back( std::pair({{it->owner, it->producer_key}, it->location}) ); } @@ -111,13 +88,6 @@ namespace eosiosystem { return; } - for ( const auto& it: inactive_iters ) { - _producers.modify( *it, 0, [&](auto& p) { - p.deactivate(); - p.time_became_active.slot = 0; - }); - } - /// sort by producer name std::sort( top_producers.begin(), top_producers.end() ); diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index 04c14e47ea25968ab4414fbd1aaed3a1aa762fef..3a2aeb67f5e634e6e1b864f7a574c941d2160263 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -1517,9 +1517,8 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni push_action(prod_name, N(claimrewards), mvo()("owner", prod_name))); } - // wait for 23 hours which is not enough for producers to get deactivated - // payment calculations don't change. By now, pervote_bucket has grown enough - // that a producer's share is more than 100 tokens + // Wait for 23 hours. By now, pervote_bucket has grown enough + // that a producer's share is more than 100 tokens. produce_block(fc::seconds(23 * 3600)); { @@ -1593,56 +1592,6 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni push_action(prod_name, N(claimrewards), mvo()("owner", prod_name))); } - // wait two more hours, now most producers haven't produced in a day and will - // be deactivated - BOOST_REQUIRE_EQUAL(success(), push_action(N(producvotera), N(voteproducer), mvo() - ("voter", "producvotera") - ("proxy", name(0).to_string()) - ("producers", vector(producer_names.begin(), producer_names.begin()+21)) - ) - ); - - produce_block(fc::hours(9)); - produce_blocks(8 * 21 * 12); - - { - bool all_newly_elected_produced = true; - for (uint32_t i = 21; i < producer_names.size(); ++i) { - if (0 == get_producer_info(producer_names[i])["unpaid_blocks"].as()) { - all_newly_elected_produced = false; - } - } - BOOST_REQUIRE(all_newly_elected_produced); - } - - { - uint32_t survived_active_producers = 0; - uint32_t one_inactive_index = 0; - for (uint32_t i = 0; i < 21; ++i) { - if (fc::crypto::public_key() != fc::crypto::public_key(get_producer_info(producer_names[i])["producer_key"].as_string())) { - ++survived_active_producers; - } else { - one_inactive_index = i; - } - } - - BOOST_REQUIRE(3 >= survived_active_producers); - - auto inactive_prod_info = get_producer_info(producer_names[one_inactive_index]); - BOOST_REQUIRE_EQUAL(0, inactive_prod_info["time_became_active"].as()); - BOOST_REQUIRE_EQUAL(wasm_assert_msg("producer does not have an active key"), - push_action(producer_names[one_inactive_index], N(claimrewards), mvo()("owner", producer_names[one_inactive_index]))); - // re-register deactivated producer and let him produce blocks again - const uint32_t initial_unpaid_blocks = inactive_prod_info["unpaid_blocks"].as(); - regproducer(producer_names[one_inactive_index]); - produce_blocks(8 * 21 * 12); - auto reactivated_prod_info = get_producer_info(producer_names[one_inactive_index]); - const uint32_t unpaid_blocks = reactivated_prod_info["unpaid_blocks"].as(); - BOOST_REQUIRE(initial_unpaid_blocks + 12 <= unpaid_blocks); - BOOST_REQUIRE_EQUAL(success(), - push_action(producer_names[one_inactive_index], N(claimrewards), mvo()("owner", producer_names[one_inactive_index]))); - } - } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester) try {