#170 Make sure accounts cannot be updated with impossible auhtority settings
This commit is contained in:
parent
a55b348e6c
commit
b3d299d241
3 changed files with 14 additions and 1 deletions
|
|
@ -31,6 +31,7 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio
|
|||
const auto& global_props = d.get_global_properties();
|
||||
const auto& chain_params = global_props.parameters;
|
||||
|
||||
|
||||
verify_authority_accounts( op.owner );
|
||||
verify_authority_accounts( op.active );
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,14 @@ namespace graphene { namespace chain {
|
|||
{
|
||||
account_auths[k] = w;
|
||||
}
|
||||
bool is_impossible()const
|
||||
{
|
||||
uint64_t auth_weights = 0;
|
||||
for( const auto& item : account_auths ) auth_weights += item.second;
|
||||
for( const auto& item : key_auths ) auth_weights += item.second;
|
||||
for( const auto& item : address_auths ) auth_weights += item.second;
|
||||
return auth_weights < weight_threshold;
|
||||
}
|
||||
|
||||
template<typename AuthType>
|
||||
void add_authorities(AuthType k, weight_type w)
|
||||
|
|
@ -75,7 +83,7 @@ namespace graphene { namespace chain {
|
|||
result.push_back(k.first);
|
||||
return result;
|
||||
}
|
||||
uint32_t num_auths()const { return account_auths.size() + key_auths.size(); }
|
||||
uint32_t num_auths()const { return account_auths.size() + key_auths.size() + address_auths.size(); }
|
||||
void clear() { account_auths.clear(); key_auths.clear(); }
|
||||
|
||||
uint32_t weight_threshold = 0;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ void account_create_operation::validate()const
|
|||
FC_ASSERT( owner.address_auths.size() == 0 );
|
||||
FC_ASSERT( active.num_auths() != 0 );
|
||||
FC_ASSERT( active.address_auths.size() == 0 );
|
||||
FC_ASSERT( !owner.is_impossible(), "cannot create an account with an imposible owner authority threshold" );
|
||||
FC_ASSERT( !active.is_impossible(), "cannot create an account with an imposible active authority threshold" );
|
||||
options.validate();
|
||||
}
|
||||
|
||||
|
|
@ -165,11 +167,13 @@ void account_update_operation::validate()const
|
|||
{
|
||||
FC_ASSERT( owner->num_auths() != 0 );
|
||||
FC_ASSERT( owner->address_auths.size() == 0 );
|
||||
FC_ASSERT( !owner->is_impossible(), "cannot update an account with an imposible owner authority threshold" );
|
||||
}
|
||||
if( active )
|
||||
{
|
||||
FC_ASSERT( active->num_auths() != 0 );
|
||||
FC_ASSERT( active->address_auths.size() == 0 );
|
||||
FC_ASSERT( !active->is_impossible(), "cannot update an account with an imposible active authority threshold" );
|
||||
}
|
||||
|
||||
if( new_options )
|
||||
|
|
|
|||
Loading…
Reference in a new issue