未验证 提交 433dda1e 编写于 作者: A arhag 提交者: GitHub

Merge pull request #3619 from EOSIO/k-system

Cancel producer deactivation, add rmvproducer system contract action
......@@ -253,11 +253,9 @@
{"name":"last_pervote_bucket_fill", "type":"uint64"},
{"name":"pervote_bucket", "type":"int64"},
{"name":"perblock_bucket", "type":"int64"},
{"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":"last_producer_schedule_size", "type":"uint16"},
{"name":"total_producer_vote_weight", "type":"float64"},
{"name":"last_name_close", "type":"block_timestamp_type"}
......@@ -266,16 +264,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",
......@@ -341,6 +337,12 @@
{"name":"account", "type":"account_name"},
{"name":"is_priv", "type":"int8"}
]
},{
"name": "rmvproducer",
"base": "",
"fields": [
{"name":"producer", "type":"account_name"}
]
},{
"name": "set_account_limits",
"base": "",
......@@ -475,6 +477,10 @@
"name": "setpriv",
"type": "setpriv",
"ricardian_contract": ""
},{
"name": "rmvproducer",
"type": "rmvproducer",
"ricardian_contract": ""
},{
"name": "setalimits",
"type": "set_account_limits",
......
......@@ -85,6 +85,15 @@ namespace eosiosystem {
set_privileged( account, ispriv );
}
void system_contract::rmvproducer( account_name producer ) {
require_auth( _self );
auto prod = _producers.find( producer );
eosio_assert( prod != _producers.end(), "producer not found" );
_producers.modify( prod, 0, [&](auto& p) {
p.deactivate();
});
}
void system_contract::bidname( account_name bidder, account_name newname, asset bid ) {
require_auth( bidder );
eosio_assert( eosio::name_suffix(newname) == newname, "you can only bid on top-level suffix" );
......@@ -179,7 +188,7 @@ EOSIO_ABI( eosiosystem::system_contract,
// native.hpp (newaccount definition is actually in eosio.system.cpp)
(newaccount)(updateauth)(deleteauth)(linkauth)(unlinkauth)(canceldelay)(onerror)
// eosio.system.cpp
(setram)(setparams)(setpriv)(bidname)
(setram)(setparams)(setpriv)(rmvproducer)(bidname)
// delegate_bandwidth.cpp
(buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund)
// voting.cpp
......
......@@ -46,11 +46,9 @@ namespace eosiosystem {
uint64_t last_pervote_bucket_fill = 0;
int64_t pervote_bucket = 0;
int64_t perblock_bucket = 0;
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;
uint16_t last_producer_schedule_size = 0;
double total_producer_vote_weight = 0; /// the sum of all producer votes
block_timestamp last_name_close;
......@@ -59,8 +57,8 @@ namespace eosiosystem {
EOSLIB_SERIALIZE_DERIVED( eosio_global_state, eosio::blockchain_parameters,
(max_ram_size)(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)(thresh_activated_stake_time)
(last_producer_schedule_id)(last_producer_schedule_size)(total_producer_vote_weight)(last_name_close) )
(pervote_bucket)(perblock_bucket)(total_unpaid_blocks)(total_activated_stake)(thresh_activated_stake_time)
(last_producer_schedule_size)(total_producer_vote_weight)(last_name_close) )
};
struct producer_info {
......@@ -72,8 +70,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; }
......@@ -82,8 +78,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 {
......@@ -217,6 +212,8 @@ namespace eosiosystem {
void setpriv( account_name account, uint8_t ispriv );
void rmvproducer( account_name producer );
void bidname( account_name bidder, account_name newname, asset bid );
private:
void update_elected_producers( block_timestamp timestamp );
......
......@@ -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;
});
}
......@@ -103,7 +102,6 @@ namespace eosiosystem {
_gstate.pervote_bucket += to_per_vote_pay;
_gstate.perblock_bucket += to_per_block_pay;
_gstate.savings += to_savings;
_gstate.last_pervote_bucket_fill = ct;
}
......
......@@ -80,30 +80,7 @@ namespace eosiosystem {
std::vector< std::pair<eosio::producer_key,uint16_t> > top_producers;
top_producers.reserve(21);
std::vector<decltype(idx.cbegin())> 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<eosio::producer_key,uint16_t>({{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() );
......@@ -128,15 +98,10 @@ namespace eosiosystem {
producers.push_back(item.first);
bytes packed_schedule = pack(producers);
checksum160 new_id;
sha1( packed_schedule.data(), packed_schedule.size(), &new_id );
if( new_id != _gstate.last_producer_schedule_id ) {
_gstate.last_producer_schedule_id = new_id;
set_proposed_producers( packed_schedule.data(), packed_schedule.size() );
if( set_proposed_producers( packed_schedule.data(), packed_schedule.size() ) >= 0 ) {
_gstate.last_producer_schedule_size = top_producers.size();
}
_gstate.last_producer_schedule_update = block_time;
}
double stake2vote( int64_t staked ) {
......
......@@ -117,6 +117,9 @@ BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try {
BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {
cross_15_percent_threshold();
produce_blocks( 10 );
produce_block( fc::hours(3*24) );
BOOST_REQUIRE_EQUAL( core_from_string("0.0000"), get_balance( "alice1111111" ) );
transfer( "eosio", "alice1111111", core_from_string("1000.0000"), "eosio" );
......@@ -127,18 +130,22 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL( core_from_string("210.0000"), total["net_weight"].as<asset>());
BOOST_REQUIRE_EQUAL( core_from_string("110.0000"), total["cpu_weight"].as<asset>());
const auto init_eosio_stake_balance = get_balance( N(eosio.stake) );
BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", core_from_string("200.0000"), core_from_string("100.0000") ) );
BOOST_REQUIRE_EQUAL( core_from_string("700.0000"), get_balance( "alice1111111" ) );
BOOST_REQUIRE_EQUAL( init_eosio_stake_balance + core_from_string("300.0000"), get_balance( N(eosio.stake) ) );
BOOST_REQUIRE_EQUAL( success(), unstake( "alice1111111", "alice1111111", core_from_string("200.0000"), core_from_string("100.0000") ) );
BOOST_REQUIRE_EQUAL( core_from_string("700.0000"), get_balance( "alice1111111" ) );
produce_block( fc::hours(3*24-1) );
produce_blocks(1);
BOOST_REQUIRE_EQUAL( core_from_string("700.0000"), get_balance( "alice1111111" ) );
BOOST_REQUIRE_EQUAL( init_eosio_stake_balance + core_from_string("300.0000"), get_balance( N(eosio.stake) ) );
//after 3 days funds should be released
produce_block( fc::hours(1) );
produce_blocks(1);
BOOST_REQUIRE_EQUAL( core_from_string("1000.0000"), get_balance( "alice1111111" ) );
BOOST_REQUIRE_EQUAL( init_eosio_stake_balance, get_balance( N(eosio.stake) ) );
BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "bob111111111", core_from_string("200.0000"), core_from_string("100.0000") ) );
BOOST_REQUIRE_EQUAL( core_from_string("700.0000"), get_balance( "alice1111111" ) );
......@@ -1145,7 +1152,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t initial_pervote_bucket = initial_global_state["pervote_bucket"].as<int64_t>();
const int64_t initial_perblock_bucket = initial_global_state["perblock_bucket"].as<int64_t>();
const int64_t initial_savings = initial_global_state["savings"].as<int64_t>();
const int64_t initial_savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t initial_tot_unpaid_blocks = initial_global_state["total_unpaid_blocks"].as<uint32_t>();
prod = get_producer_info("defproducera");
......@@ -1164,7 +1171,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t pervote_bucket = global_state["pervote_bucket"].as<int64_t>();
const int64_t perblock_bucket = global_state["perblock_bucket"].as<int64_t>();
const int64_t savings = global_state["savings"].as<int64_t>();
const int64_t savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t tot_unpaid_blocks = global_state["total_unpaid_blocks"].as<uint32_t>();
......@@ -1223,7 +1230,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t initial_pervote_bucket = initial_global_state["pervote_bucket"].as<int64_t>();
const int64_t initial_perblock_bucket = initial_global_state["perblock_bucket"].as<int64_t>();
const int64_t initial_savings = initial_global_state["savings"].as<int64_t>();
const int64_t initial_savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t initial_tot_unpaid_blocks = initial_global_state["total_unpaid_blocks"].as<uint32_t>();
const double initial_tot_vote_weight = initial_global_state["total_producer_vote_weight"].as<double>();
......@@ -1247,7 +1254,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t pervote_bucket = global_state["pervote_bucket"].as<int64_t>();
const int64_t perblock_bucket = global_state["perblock_bucket"].as<int64_t>();
const int64_t savings = global_state["savings"].as<int64_t>();
const int64_t savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t tot_unpaid_blocks = global_state["total_unpaid_blocks"].as<uint32_t>();
......@@ -1289,7 +1296,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
regproducer(N(defproducerb));
regproducer(N(defproducerc));
const asset initial_supply = get_token_supply();
const int64_t initial_savings = get_global_state()["savings"].as<int64_t>();
const int64_t initial_savings = get_balance(N(eosio.saving)).get_amount();
for (uint32_t i = 0; i < 7 * 52; ++i) {
produce_block(fc::seconds(8 * 3600));
BOOST_REQUIRE_EQUAL(success(), push_action(N(defproducerc), N(claimrewards), mvo()("owner", "defproducerc")));
......@@ -1299,7 +1306,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
BOOST_REQUIRE_EQUAL(success(), push_action(N(defproducera), N(claimrewards), mvo()("owner", "defproducera")));
}
const asset supply = get_token_supply();
const int64_t savings = get_global_state()["savings"].as<int64_t>();
const int64_t savings = get_balance(N(eosio.saving)).get_amount();
// Amount issued per year is very close to the 5% inflation target. Small difference (500 tokens out of 50'000'000 issued)
// is due to compounding every 8 hours in this test as opposed to theoretical continuous compounding
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.05)) - (supply.get_amount() - initial_supply.get_amount()));
......@@ -1447,10 +1454,9 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t initial_pervote_bucket = initial_global_state["pervote_bucket"].as<int64_t>();
const int64_t initial_perblock_bucket = initial_global_state["perblock_bucket"].as<int64_t>();
const int64_t initial_savings = initial_global_state["savings"].as<int64_t>();
const int64_t initial_savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t initial_tot_unpaid_blocks = initial_global_state["total_unpaid_blocks"].as<uint32_t>();
const asset initial_supply = get_token_supply();
const asset initial_saving_balance = get_balance(N(eosio.saving));
const asset initial_bpay_balance = get_balance(N(eosio.bpay));
const asset initial_vpay_balance = get_balance(N(eosio.vpay));
const asset initial_balance = get_balance(prod_name);
......@@ -1462,10 +1468,9 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t pervote_bucket = global_state["pervote_bucket"].as<int64_t>();
const int64_t perblock_bucket = global_state["perblock_bucket"].as<int64_t>();
const int64_t savings = global_state["savings"].as<int64_t>();
const int64_t savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t tot_unpaid_blocks = global_state["total_unpaid_blocks"].as<uint32_t>();
const asset supply = get_token_supply();
const asset saving_balance = get_balance(N(eosio.saving));
const asset bpay_balance = get_balance(N(eosio.bpay));
const asset vpay_balance = get_balance(N(eosio.vpay));
const asset balance = get_balance(prod_name);
......@@ -1478,8 +1483,6 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth), supply.get_amount() - initial_supply.get_amount() );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - int64_t(expected_supply_growth)/5, savings - initial_savings );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - int64_t(expected_supply_growth)/5,
saving_balance.get_amount() - initial_saving_balance.get_amount() );
const int64_t expected_perblock_bucket = int64_t( double(initial_supply.get_amount()) * double(usecs_between_fills) * (0.25 * cont_rate/ 5.) / usecs_per_year );
const int64_t expected_pervote_bucket = int64_t( double(initial_supply.get_amount()) * double(usecs_between_fills) * (0.75 * cont_rate/ 5.) / usecs_per_year );
......@@ -1515,9 +1518,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));
{
......@@ -1528,10 +1530,9 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const uint64_t initial_claim_time = initial_global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t initial_pervote_bucket = initial_global_state["pervote_bucket"].as<int64_t>();
const int64_t initial_perblock_bucket = initial_global_state["perblock_bucket"].as<int64_t>();
const int64_t initial_savings = initial_global_state["savings"].as<int64_t>();
const int64_t initial_savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t initial_tot_unpaid_blocks = initial_global_state["total_unpaid_blocks"].as<uint32_t>();
const asset initial_supply = get_token_supply();
const asset initial_saving_balance = get_balance(N(eosio.saving));
const asset initial_bpay_balance = get_balance(N(eosio.bpay));
const asset initial_vpay_balance = get_balance(N(eosio.vpay));
const asset initial_balance = get_balance(prod_name);
......@@ -1543,10 +1544,9 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const uint64_t claim_time = global_state["last_pervote_bucket_fill"].as_uint64();
const int64_t pervote_bucket = global_state["pervote_bucket"].as<int64_t>();
const int64_t perblock_bucket = global_state["perblock_bucket"].as<int64_t>();
const int64_t savings = global_state["savings"].as<int64_t>();
const int64_t savings = get_balance(N(eosio.saving)).get_amount();
const uint32_t tot_unpaid_blocks = global_state["total_unpaid_blocks"].as<uint32_t>();
const asset supply = get_token_supply();
const asset saving_balance = get_balance(N(eosio.saving));
const asset bpay_balance = get_balance(N(eosio.bpay));
const asset vpay_balance = get_balance(N(eosio.vpay));
const asset balance = get_balance(prod_name);
......@@ -1557,8 +1557,6 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const double expected_supply_growth = initial_supply.get_amount() * double(usecs_between_fills) * cont_rate / usecs_per_year;
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth), supply.get_amount() - initial_supply.get_amount() );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - int64_t(expected_supply_growth)/5, savings - initial_savings );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - int64_t(expected_supply_growth)/5,
saving_balance.get_amount() - initial_saving_balance.get_amount() );
const int64_t expected_perblock_bucket = int64_t( double(initial_supply.get_amount()) * double(usecs_between_fills) * (0.25 * cont_rate/ 5.) / usecs_per_year )
+ initial_perblock_bucket;
......@@ -1595,54 +1593,29 @@ 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<account_name>(producer_names.begin(), producer_names.begin()+21))
)
);
{
const uint32_t rmv_index = 5;
account_name prod_name = producer_names[rmv_index];
produce_block(fc::hours(9));
produce_blocks(8 * 21 * 12);
auto info = get_producer_info(prod_name);
BOOST_REQUIRE( info["is_active"].as<bool>() );
BOOST_REQUIRE( fc::crypto::public_key() != fc::crypto::public_key(info["producer_key"].as_string()) );
{
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<uint32_t>()) {
all_newly_elected_produced = false;
}
}
BOOST_REQUIRE(all_newly_elected_produced);
}
BOOST_REQUIRE_EQUAL( error("missing authority of eosio"),
push_action(prod_name, N(rmvproducer), mvo()("producer", prod_name)));
BOOST_REQUIRE_EQUAL( error("missing authority of eosio"),
push_action(producer_names[rmv_index + 2], N(rmvproducer), mvo()("producer", prod_name) ) );
BOOST_REQUIRE_EQUAL( success(),
push_action(config::system_account_name, N(rmvproducer), mvo()("producer", prod_name) ) );
{
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;
}
}
info = get_producer_info(prod_name);
BOOST_REQUIRE( !info["is_active"].as<bool>() );
BOOST_REQUIRE( fc::crypto::public_key() == fc::crypto::public_key(info["producer_key"].as_string()) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("producer does not have an active key"),
push_action(prod_name, N(claimrewards), mvo()("owner", prod_name) ) );
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<uint32_t>());
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<uint32_t>();
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<uint32_t>();
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])));
BOOST_REQUIRE_EQUAL( wasm_assert_msg("producer not found"),
push_action( config::system_account_name, N(rmvproducer), mvo()("producer", "nonexistingp") ) );
}
} FC_LOG_AND_RETHROW()
......@@ -2513,7 +2486,7 @@ BOOST_FIXTURE_TEST_CASE( vote_producers_in_and_out, eosio_system_tester ) try {
);
BOOST_REQUIRE_EQUAL(0, get_producer_info(producer_names[new_prod_index])["unpaid_blocks"].as<uint32_t>());
produce_blocks(4 * 12 * 21);
BOOST_REQUIRE(0 < get_producer_info(producer_names[new_prod_index])["unpaid_blocks"]);
BOOST_REQUIRE(0 < get_producer_info(producer_names[new_prod_index])["unpaid_blocks"].as<uint32_t>());
const uint32_t initial_unpaid_blocks = get_producer_info(producer_names[voted_out_index])["unpaid_blocks"].as<uint32_t>();
produce_blocks(2 * 12 * 21);
BOOST_REQUIRE_EQUAL(initial_unpaid_blocks, get_producer_info(producer_names[voted_out_index])["unpaid_blocks"].as<uint32_t>());
......@@ -2658,6 +2631,8 @@ BOOST_FIXTURE_TEST_CASE( setram_effect, eosio_system_tester ) try {
// increase max_ram_size, ram bought by name_b loses part of its value
BOOST_REQUIRE_EQUAL( wasm_assert_msg("ram may only be increased"),
push_action(config::system_account_name, N(setram), mvo()("max_ram_size", 64ll*1024 * 1024 * 1024)) );
BOOST_REQUIRE_EQUAL( error("missing authority of eosio"),
push_action(name_b, N(setram), mvo()("max_ram_size", 80ll*1024 * 1024 * 1024)) );
BOOST_REQUIRE_EQUAL( success(),
push_action(config::system_account_name, N(setram), mvo()("max_ram_size", 80ll*1024 * 1024 * 1024)) );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册