Resolve #161: Fix account creation fee scaling
This commit is contained in:
parent
84078831e9
commit
a4e5a03973
5 changed files with 42 additions and 12 deletions
|
|
@ -107,13 +107,12 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
|
||||||
++p.accounts_registered_this_interval;
|
++p.accounts_registered_this_interval;
|
||||||
});
|
});
|
||||||
|
|
||||||
/** TODO: update fee scaling for account creation...
|
const auto& global_properties = db().get_global_properties();
|
||||||
if( dynamic_properties.accounts_registered_this_interval %
|
if( dynamic_properties.accounts_registered_this_interval %
|
||||||
global_properties.parameters.accounts_per_fee_scale == 0 )
|
global_properties.parameters.accounts_per_fee_scale == 0 )
|
||||||
db().modify(global_properties, [&dynamic_properties](global_property_object& p) {
|
db().modify(global_properties, [&dynamic_properties](global_property_object& p) {
|
||||||
p.parameters.current_fees.account_create_fee <<= p.parameters.account_fee_scale_bitshifts;
|
p.parameters.current_fees->get<account_create_operation>().basic_fee <<= p.parameters.account_fee_scale_bitshifts;
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
return new_acnt_object.id;
|
return new_acnt_object.id;
|
||||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
} FC_CAPTURE_AND_RETHROW((o)) }
|
||||||
|
|
|
||||||
|
|
@ -461,12 +461,9 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
||||||
|
|
||||||
modify(gpo, [this](global_property_object& p) {
|
modify(gpo, [this](global_property_object& p) {
|
||||||
// Remove scaling of account registration fee
|
// Remove scaling of account registration fee
|
||||||
/*
|
|
||||||
/// TODO reimplement this
|
|
||||||
const auto& dgpo = get_dynamic_global_properties();
|
const auto& dgpo = get_dynamic_global_properties();
|
||||||
p.parameters.current_fees.account_create_fee >>= p.parameters.account_fee_scale_bitshifts *
|
p.parameters.current_fees->get<account_create_operation>().basic_fee >>= p.parameters.account_fee_scale_bitshifts *
|
||||||
(dgpo.accounts_registered_this_interval / p.parameters.accounts_per_fee_scale);
|
(dgpo.accounts_registered_this_interval / p.parameters.accounts_per_fee_scale);
|
||||||
*/
|
|
||||||
|
|
||||||
if( p.pending_parameters )
|
if( p.pending_parameters )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
template<typename T> struct transform_to_fee_parameters;
|
template<typename T> struct transform_to_fee_parameters;
|
||||||
template<typename ...T>
|
template<typename ...T>
|
||||||
struct transform_to_fee_parameters<fc::static_variant<T...>>
|
struct transform_to_fee_parameters<fc::static_variant<T...>>
|
||||||
{
|
{
|
||||||
typedef fc::static_variant< typename T::fee_parameters_type... > type;
|
typedef fc::static_variant< typename T::fee_parameters_type... > type;
|
||||||
};
|
};
|
||||||
|
|
@ -21,7 +21,7 @@ namespace graphene { namespace chain {
|
||||||
static fee_schedule get_default();
|
static fee_schedule get_default();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the appropriate fee parameter struct for the operation
|
* Finds the appropriate fee parameter struct for the operation
|
||||||
* and then calculates the appropriate fee.
|
* and then calculates the appropriate fee.
|
||||||
*/
|
*/
|
||||||
asset calculate_fee( const operation& op, const price& core_exchange_rate = price::unit_price() )const;
|
asset calculate_fee( const operation& op, const price& core_exchange_rate = price::unit_price() )const;
|
||||||
|
|
@ -41,6 +41,13 @@ namespace graphene { namespace chain {
|
||||||
FC_ASSERT( itr != parameters.end() );
|
FC_ASSERT( itr != parameters.end() );
|
||||||
return itr->template get<typename Operation::fee_parameters_type>();
|
return itr->template get<typename Operation::fee_parameters_type>();
|
||||||
}
|
}
|
||||||
|
template<typename Operation>
|
||||||
|
typename Operation::fee_parameters_type& get()
|
||||||
|
{
|
||||||
|
auto itr = parameters.find( typename Operation::fee_parameters_type() );
|
||||||
|
FC_ASSERT( itr != parameters.end() );
|
||||||
|
return itr->template get<typename Operation::fee_parameters_type>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @note must be sorted by fee_parameters.which() and have no duplicates
|
* @note must be sorted by fee_parameters.which() and have no duplicates
|
||||||
|
|
@ -51,7 +58,7 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
typedef fee_schedule fee_schedule_type;
|
typedef fee_schedule fee_schedule_type;
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::fee_parameters )
|
FC_REFLECT_TYPENAME( graphene::chain::fee_parameters )
|
||||||
FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) )
|
FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) )
|
||||||
|
|
|
||||||
|
|
@ -822,7 +822,7 @@ void database_fixture::enable_fees()
|
||||||
db.modify(global_property_id_type()(db), [](global_property_object& gpo)
|
db.modify(global_property_id_type()(db), [](global_property_object& gpo)
|
||||||
{
|
{
|
||||||
gpo.parameters.current_fees = fee_schedule::get_default();
|
gpo.parameters.current_fees = fee_schedule::get_default();
|
||||||
} );
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void database_fixture::upgrade_to_lifetime_member(account_id_type account)
|
void database_fixture::upgrade_to_lifetime_member(account_id_type account)
|
||||||
|
|
|
||||||
|
|
@ -680,7 +680,7 @@ BOOST_FIXTURE_TEST_CASE( double_sign_check, database_fixture )
|
||||||
t.to = alice.id;
|
t.to = alice.id;
|
||||||
t.amount = amount;
|
t.amount = amount;
|
||||||
trx.operations.push_back(t);
|
trx.operations.push_back(t);
|
||||||
for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op);
|
for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op);
|
||||||
trx.validate();
|
trx.validate();
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE( "Verify that not-signing causes an exception" );
|
BOOST_TEST_MESSAGE( "Verify that not-signing causes an exception" );
|
||||||
|
|
@ -967,4 +967,31 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture )
|
||||||
FC_LOG_AND_RETHROW()
|
FC_LOG_AND_RETHROW()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_CASE( account_create_fee_scaling, database_fixture )
|
||||||
|
{ try {
|
||||||
|
auto accounts_per_scale = db.get_global_properties().parameters.accounts_per_fee_scale;
|
||||||
|
db.modify(global_property_id_type()(db), [](global_property_object& gpo)
|
||||||
|
{
|
||||||
|
gpo.parameters.current_fees = fee_schedule::get_default();
|
||||||
|
gpo.parameters.current_fees->get<account_create_operation>().basic_fee = 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get<account_create_operation>().basic_fee, 1);
|
||||||
|
for( int i = db.get_dynamic_global_properties().accounts_registered_this_interval; i < accounts_per_scale; ++i )
|
||||||
|
create_account("shill" + fc::to_string(i));
|
||||||
|
generate_block();
|
||||||
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get<account_create_operation>().basic_fee, 16);
|
||||||
|
for( int i = 0; i < accounts_per_scale; ++i )
|
||||||
|
create_account("moreshills" + fc::to_string(i));
|
||||||
|
generate_block();
|
||||||
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get<account_create_operation>().basic_fee, 256);
|
||||||
|
for( int i = 0; i < accounts_per_scale; ++i )
|
||||||
|
create_account("moarshills" + fc::to_string(i));
|
||||||
|
generate_block();
|
||||||
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get<account_create_operation>().basic_fee, 4096);
|
||||||
|
|
||||||
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get<account_create_operation>().basic_fee, 1);
|
||||||
|
} FC_LOG_AND_RETHROW() }
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue