Fix update son parameters on maintenance
This commit is contained in:
parent
237889f621
commit
d1e425e3c9
4 changed files with 52 additions and 14 deletions
|
|
@ -2034,18 +2034,11 @@ void database::perform_son_tasks()
|
|||
|
||||
void update_son_params(database& db)
|
||||
{
|
||||
if( db.head_block_time() >= HARDFORK_SON2_TIME )
|
||||
if( (db.head_block_time() >= HARDFORK_SON2_TIME) && (db.head_block_time() < HARDFORK_SON3_TIME) )
|
||||
{
|
||||
const auto& gpo = db.get_global_properties();
|
||||
const asset_object& btc_asset = gpo.parameters.btc_asset()(db);
|
||||
if( btc_asset.is_transfer_restricted() ) {
|
||||
db.modify( btc_asset, []( asset_object& ao ) {
|
||||
ao.options.flags = asset_issuer_permission_flags::charge_market_fee |
|
||||
asset_issuer_permission_flags::override_authority;
|
||||
});
|
||||
}
|
||||
db.modify( gpo, []( global_property_object& gpo ) {
|
||||
gpo.parameters.extensions.value.maximum_son_count = 7;
|
||||
gpo.parameters.extensions.value.maximum_son_count = 7;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
libraries/chain/hardfork.d/SON3.hf
Normal file
7
libraries/chain/hardfork.d/SON3.hf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef HARDFORK_SON3_TIME
|
||||
#ifdef BUILD_PEERPLAYS_TESTNET
|
||||
#define HARDFORK_SON3_TIME (fc::time_point_sec::from_iso_string("2022-05-31T00:00:00"))
|
||||
#else
|
||||
#define HARDFORK_SON3_TIME (fc::time_point_sec::from_iso_string("2022-05-31T00:00:00"))
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -86,8 +86,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
bpo::variables_map options;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
bpo::parsed_options po = bpo::command_line_parser(argc, argv).options(opts).allow_unregistered().run();
|
||||
std::vector<std::string> unrecognized = bpo::collect_unrecognized(po.options, bpo::include_positional);
|
||||
if (unrecognized.size() > 0) {
|
||||
|
|
@ -98,9 +97,7 @@ int main(int argc, char **argv) {
|
|||
return 0;
|
||||
}
|
||||
bpo::store(po, options);
|
||||
}
|
||||
catch (const boost::program_options::invalid_command_line_syntax & e)
|
||||
{
|
||||
} catch (const boost::program_options::invalid_command_line_syntax &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1012,6 +1012,47 @@ BOOST_FIXTURE_TEST_CASE( prevent_missconfiguration_blockchain_param, database_fi
|
|||
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( hardfork_son2_time, database_fixture )
|
||||
{ try {
|
||||
|
||||
db.modify(db.get_global_properties(), [](global_property_object& p) {
|
||||
p.parameters.committee_proposal_review_period = fc::hours(1).to_seconds();
|
||||
});
|
||||
|
||||
generate_block();
|
||||
// check that maximum_son_count are not yet updated on 7, it should
|
||||
// be updated on HARDFORK_SON2_TIME
|
||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.maximum_son_count(), GRAPHENE_DEFAULT_MAX_SONS);
|
||||
|
||||
generate_blocks(HARDFORK_SON2_TIME);
|
||||
|
||||
// check that flags for assets are set after hardfork_son2_time
|
||||
asset_object btc_asset = get_asset("BTC");
|
||||
uint16_t check_flags{0};
|
||||
check_flags |= asset_issuer_permission_flags::charge_market_fee | asset_issuer_permission_flags::override_authority;
|
||||
uint16_t result = btc_asset.options.flags & check_flags;
|
||||
BOOST_CHECK_EQUAL( result, check_flags);
|
||||
|
||||
// move on next maintenance interval and check that maximum_son_count is updated to 7
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
generate_block(); // get the maintenance skip slots out of the way*/
|
||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.maximum_son_count(), 7);
|
||||
|
||||
generate_blocks(HARDFORK_SON3_TIME);
|
||||
// after this hardfork maximum son account should not reset the value
|
||||
// on 7 after maintenance interval anymore. So change the global parameters
|
||||
// and check the value after maintenance interval
|
||||
db.modify(db.get_global_properties(), [](global_property_object& p) {
|
||||
p.parameters.extensions.value.maximum_son_count = 13;
|
||||
});
|
||||
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
generate_block();
|
||||
|
||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.maximum_son_count(), 13);
|
||||
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture )
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Reference in a new issue