Compare commits
4 commits
master
...
sons_gpos_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1691bcfa55 | ||
|
|
4b6305952f | ||
|
|
598ee95621 | ||
|
|
39e4ebe92e |
3 changed files with 163 additions and 87 deletions
|
|
@ -558,100 +558,97 @@ void database::update_active_sons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//restrict below code snippet to sons functionality
|
if (son_sets_equal) {
|
||||||
if(cur_active_sons.size() || new_active_sons.size())
|
ilog( "Active SONs set NOT CHANGED" );
|
||||||
{
|
} else {
|
||||||
if (son_sets_equal) {
|
ilog( "Active SONs set CHANGED" );
|
||||||
ilog( "Active SONs set NOT CHANGED" );
|
|
||||||
} else {
|
|
||||||
ilog( "Active SONs set CHANGED" );
|
|
||||||
|
|
||||||
bool should_recreate_pw = true;
|
bool should_recreate_pw = true;
|
||||||
|
|
||||||
// Expire for current son_wallet_object wallet, if exists
|
// Expire for current son_wallet_object wallet, if exists
|
||||||
const auto& idx_swi = get_index_type<son_wallet_index>().indices().get<by_id>();
|
const auto& idx_swi = get_index_type<son_wallet_index>().indices().get<by_id>();
|
||||||
auto obj = idx_swi.rbegin();
|
auto obj = idx_swi.rbegin();
|
||||||
if (obj != idx_swi.rend()) {
|
if (obj != idx_swi.rend()) {
|
||||||
// Compare current wallet SONs and to-be lists of active sons
|
// Compare current wallet SONs and to-be lists of active sons
|
||||||
auto cur_wallet_sons = (*obj).sons;
|
auto cur_wallet_sons = (*obj).sons;
|
||||||
|
|
||||||
bool wallet_son_sets_equal = (cur_wallet_sons.size() == new_active_sons.size());
|
bool wallet_son_sets_equal = (cur_wallet_sons.size() == new_active_sons.size());
|
||||||
if (wallet_son_sets_equal) {
|
if (wallet_son_sets_equal) {
|
||||||
for( size_t i = 0; i < cur_wallet_sons.size(); i++ ) {
|
for( size_t i = 0; i < cur_wallet_sons.size(); i++ ) {
|
||||||
wallet_son_sets_equal = wallet_son_sets_equal && cur_wallet_sons.at(i) == new_active_sons.at(i);
|
wallet_son_sets_equal = wallet_son_sets_equal && cur_wallet_sons.at(i) == new_active_sons.at(i);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
should_recreate_pw = !wallet_son_sets_equal;
|
|
||||||
|
|
||||||
if (should_recreate_pw) {
|
|
||||||
modify(*obj, [&, obj](son_wallet_object &swo) {
|
|
||||||
swo.expires = head_block_time();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
should_recreate_pw = !wallet_son_sets_equal;
|
||||||
|
|
||||||
if (should_recreate_pw) {
|
if (should_recreate_pw) {
|
||||||
// Create new son_wallet_object, to initiate wallet recreation
|
modify(*obj, [&, obj](son_wallet_object &swo) {
|
||||||
create<son_wallet_object>( [&]( son_wallet_object& obj ) {
|
swo.expires = head_block_time();
|
||||||
obj.valid_from = head_block_time();
|
|
||||||
obj.expires = time_point_sec::maximum();
|
|
||||||
obj.sons.insert(obj.sons.end(), new_active_sons.begin(), new_active_sons.end());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vector<son_info> sons_to_remove;
|
if (should_recreate_pw) {
|
||||||
// find all cur_active_sons members that is not in new_active_sons
|
// Create new son_wallet_object, to initiate wallet recreation
|
||||||
for_each(cur_active_sons.begin(), cur_active_sons.end(),
|
create<son_wallet_object>( [&]( son_wallet_object& obj ) {
|
||||||
[&sons_to_remove, &new_active_sons](const son_info& si)
|
obj.valid_from = head_block_time();
|
||||||
|
obj.expires = time_point_sec::maximum();
|
||||||
|
obj.sons.insert(obj.sons.end(), new_active_sons.begin(), new_active_sons.end());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<son_info> sons_to_remove;
|
||||||
|
// find all cur_active_sons members that is not in new_active_sons
|
||||||
|
for_each(cur_active_sons.begin(), cur_active_sons.end(),
|
||||||
|
[&sons_to_remove, &new_active_sons](const son_info& si)
|
||||||
|
{
|
||||||
|
if(std::find(new_active_sons.begin(), new_active_sons.end(), si) ==
|
||||||
|
new_active_sons.end())
|
||||||
{
|
{
|
||||||
if(std::find(new_active_sons.begin(), new_active_sons.end(), si) ==
|
sons_to_remove.push_back(si);
|
||||||
new_active_sons.end())
|
|
||||||
{
|
|
||||||
sons_to_remove.push_back(si);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
|
);
|
||||||
for( const son_info& si : sons_to_remove )
|
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
|
||||||
|
for( const son_info& si : sons_to_remove )
|
||||||
|
{
|
||||||
|
auto son = idx.find( si.son_id );
|
||||||
|
if(son == idx.end()) // SON is deleted already
|
||||||
|
continue;
|
||||||
|
// keep maintenance status for nodes becoming inactive
|
||||||
|
if(son->status == son_status::active)
|
||||||
{
|
{
|
||||||
auto son = idx.find( si.son_id );
|
modify( *son, [&]( son_object& obj ){
|
||||||
if(son == idx.end()) // SON is deleted already
|
obj.status = son_status::inactive;
|
||||||
continue;
|
});
|
||||||
// keep maintenance status for nodes becoming inactive
|
|
||||||
if(son->status == son_status::active)
|
|
||||||
{
|
|
||||||
modify( *son, [&]( son_object& obj ){
|
|
||||||
obj.status = son_status::inactive;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vector<son_info> sons_to_add;
|
|
||||||
// find all new_active_sons members that is not in cur_active_sons
|
|
||||||
for_each(new_active_sons.begin(), new_active_sons.end(),
|
|
||||||
[&sons_to_add, &cur_active_sons](const son_info& si)
|
|
||||||
{
|
|
||||||
if(std::find(cur_active_sons.begin(), cur_active_sons.end(), si) ==
|
|
||||||
cur_active_sons.end())
|
|
||||||
{
|
|
||||||
sons_to_add.push_back(si);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
for( const son_info& si : sons_to_add )
|
|
||||||
{
|
|
||||||
auto son = idx.find( si.son_id );
|
|
||||||
FC_ASSERT(son != idx.end(), "Invalid SON in active list, id={sonid}.", ("sonid", si.son_id));
|
|
||||||
// keep maintenance status for new nodes
|
|
||||||
if(son->status == son_status::inactive)
|
|
||||||
{
|
|
||||||
modify( *son, [&]( son_object& obj ){
|
|
||||||
obj.status = son_status::active;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
vector<son_info> sons_to_add;
|
||||||
|
// find all new_active_sons members that is not in cur_active_sons
|
||||||
|
for_each(new_active_sons.begin(), new_active_sons.end(),
|
||||||
|
[&sons_to_add, &cur_active_sons](const son_info& si)
|
||||||
|
{
|
||||||
|
if(std::find(cur_active_sons.begin(), cur_active_sons.end(), si) ==
|
||||||
|
cur_active_sons.end())
|
||||||
|
{
|
||||||
|
sons_to_add.push_back(si);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
for( const son_info& si : sons_to_add )
|
||||||
|
{
|
||||||
|
auto son = idx.find( si.son_id );
|
||||||
|
FC_ASSERT(son != idx.end(), "Invalid SON in active list, id={sonid}.", ("sonid", si.son_id));
|
||||||
|
// keep maintenance status for new nodes
|
||||||
|
if(son->status == son_status::inactive)
|
||||||
|
{
|
||||||
|
modify( *son, [&]( son_object& obj ){
|
||||||
|
obj.status = son_status::active;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
modify(gpo, [&]( global_property_object& gp ){
|
modify(gpo, [&]( global_property_object& gp ){
|
||||||
gp.active_sons.clear();
|
gp.active_sons.clear();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"initial_timestamp": "2020-01-13T06:03:15",
|
"initial_timestamp": "2020-03-16T20:35:24",
|
||||||
"max_core_supply": "1000000000000000",
|
"max_core_supply": "1000000000000000",
|
||||||
"initial_parameters": {
|
"initial_parameters": {
|
||||||
"current_fees": {
|
"current_fees": {
|
||||||
|
|
@ -328,6 +328,78 @@
|
||||||
81,{
|
81,{
|
||||||
"fee": 2000000
|
"fee": 2000000
|
||||||
}
|
}
|
||||||
|
],[
|
||||||
|
82,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
83,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
84,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
85,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
86,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
87,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
88,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
89,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
90,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
91,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
92,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
93,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
94,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
95,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
96,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
97,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
98,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
|
],[
|
||||||
|
99,{
|
||||||
|
"fee": 0
|
||||||
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"scale": 10000
|
"scale": 10000
|
||||||
|
|
@ -344,6 +416,7 @@
|
||||||
"maximum_asset_feed_publishers": 10,
|
"maximum_asset_feed_publishers": 10,
|
||||||
"maximum_witness_count": 1001,
|
"maximum_witness_count": 1001,
|
||||||
"maximum_committee_count": 1001,
|
"maximum_committee_count": 1001,
|
||||||
|
"maximum_son_count": 15,
|
||||||
"maximum_authority_membership": 10,
|
"maximum_authority_membership": 10,
|
||||||
"reserve_percent_of_fee": 2000,
|
"reserve_percent_of_fee": 2000,
|
||||||
"network_percent_of_fee": 2000,
|
"network_percent_of_fee": 2000,
|
||||||
|
|
@ -374,17 +447,20 @@
|
||||||
"maximum_tournament_start_delay": 604800,
|
"maximum_tournament_start_delay": 604800,
|
||||||
"maximum_tournament_number_of_wins": 100,
|
"maximum_tournament_number_of_wins": 100,
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"min_bet_multiplier": 10100,
|
|
||||||
"max_bet_multiplier": 10000000,
|
|
||||||
"betting_rake_fee_percentage": 300,
|
|
||||||
"live_betting_delay_time": 5,
|
|
||||||
"sweeps_distribution_percentage": 200,
|
"sweeps_distribution_percentage": 200,
|
||||||
"sweeps_distribution_asset": "1.3.0",
|
"sweeps_distribution_asset": "1.3.0",
|
||||||
"sweeps_vesting_accumulator_account": "1.2.0",
|
"sweeps_vesting_accumulator_account": "1.2.0",
|
||||||
"gpos_period": 15552000,
|
"gpos_period": 15552000,
|
||||||
"gpos_subperiod": 2592000,
|
"gpos_subperiod": 2592000,
|
||||||
"gpos_period_start": 1601528400,
|
"gpos_period_start": 1584385200,
|
||||||
"gpos_vesting_lockin_period": 2592000
|
"gpos_vesting_lockin_period": 2592000,
|
||||||
|
"son_vesting_amount": 5000000,
|
||||||
|
"son_vesting_period": 172800,
|
||||||
|
"son_pay_daily_max": 20000000,
|
||||||
|
"son_pay_time": 86400,
|
||||||
|
"son_deregister_time": 43200,
|
||||||
|
"son_heartbeat_frequency": 180,
|
||||||
|
"son_down_time": 360
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"initial_bts_accounts": [],
|
"initial_bts_accounts": [],
|
||||||
|
|
@ -523,7 +599,8 @@
|
||||||
"immutable_parameters": {
|
"immutable_parameters": {
|
||||||
"min_committee_member_count": 11,
|
"min_committee_member_count": 11,
|
||||||
"min_witness_count": 11,
|
"min_witness_count": 11,
|
||||||
|
"min_son_count": 5,
|
||||||
"num_special_accounts": 0,
|
"num_special_accounts": 0,
|
||||||
"num_special_assets": 0
|
"num_special_assets": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,7 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
||||||
BOOST_TEST_MESSAGE("Voting for SONs");
|
BOOST_TEST_MESSAGE("Voting for SONs");
|
||||||
for(unsigned int i = 0; i < son_number + 1; i++)
|
for(unsigned int i = 0; i < son_number + 1; i++)
|
||||||
{
|
{
|
||||||
|
// It is mandatory to vest balance under GPOS policy to vote for SON account
|
||||||
con.wallet_api_ptr->transfer(
|
con.wallet_api_ptr->transfer(
|
||||||
"nathan", "sonaccount" + fc::to_pretty_string(i), "1000", "1.3.0", "Here are some CORE tokens for your new account", true );
|
"nathan", "sonaccount" + fc::to_pretty_string(i), "1000", "1.3.0", "Here are some CORE tokens for your new account", true );
|
||||||
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
||||||
|
|
@ -626,6 +627,7 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
||||||
"http://son" + fc::to_pretty_string(i),
|
"http://son" + fc::to_pretty_string(i),
|
||||||
sidechain_public_keys,
|
sidechain_public_keys,
|
||||||
false);
|
false);
|
||||||
|
// It is mandatory to vest balance under GPOS policy to vote for SON account
|
||||||
con.wallet_api_ptr->transfer(
|
con.wallet_api_ptr->transfer(
|
||||||
"nathan", "sonaccount" + fc::to_pretty_string(i), "1000", "1.3.0", "Here are some CORE tokens for your new account", true );
|
"nathan", "sonaccount" + fc::to_pretty_string(i), "1000", "1.3.0", "Here are some CORE tokens for your new account", true );
|
||||||
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue