diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 2fe586dad7..81f35fb2da 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -50,7 +50,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o FC_ASSERT( asset_symbol_itr == asset_indx.end() ); auto dotpos = op.symbol.find( '.' ); - if( dotpos != std::string::npos ) { + if( dotpos != std::string::npos && d.head_block_time() > HARDFORK_385_TIME ) { auto prefix = op.symbol.substr( 0, dotpos ); auto asset_symbol_itr = asset_indx.find( op.symbol ); FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered", diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index e366c18e64..c371f6e79e 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -23,7 +23,7 @@ #define GRAPHENE_SYMBOL "BTS" #define GRAPHENE_ADDRESS_PREFIX "BTS" -#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 3 +#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1 #define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63 #define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3 diff --git a/libraries/chain/include/graphene/chain/hardfork.hpp b/libraries/chain/include/graphene/chain/hardfork.hpp index 01907932d0..8eb93587d4 100644 --- a/libraries/chain/include/graphene/chain/hardfork.hpp +++ b/libraries/chain/include/graphene/chain/hardfork.hpp @@ -22,3 +22,4 @@ #define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 )) #define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 )) +#define HARDFORK_385_TIME (fc::time_point_sec( 1445558400 )) // October 23 enforce PARENT.CHILD and allow short names diff --git a/libraries/chain/protocol/account.cpp b/libraries/chain/protocol/account.cpp index 003af663a8..019a685145 100644 --- a/libraries/chain/protocol/account.cpp +++ b/libraries/chain/protocol/account.cpp @@ -19,6 +19,7 @@ * */ #include +#include namespace graphene { namespace chain { @@ -53,17 +54,27 @@ namespace graphene { namespace chain { * - Length is between (inclusive) GRAPHENE_MIN_ACCOUNT_NAME_LENGTH and GRAPHENE_MAX_ACCOUNT_NAME_LENGTH */ bool is_valid_name( const string& name ) -{ -#if GRAPHENE_MIN_ACCOUNT_NAME_LENGTH < 3 -#error This is_valid_name implementation implicitly enforces minimum name length of 3. -#endif - +{ try { const size_t len = name.size(); + + /** this condition will prevent witnesses from including new names before this time, but + * allow them after this time. This check can be removed from the code after HARDFORK_385_TIME + * has passed. + */ + if( fc::time_point::now() < fc::time_point(HARDFORK_385_TIME) ) + FC_ASSERT( len >= 3 ); + if( len < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH ) + { + ilog( "."); return false; + } if( len > GRAPHENE_MAX_ACCOUNT_NAME_LENGTH ) + { + ilog( "."); return false; + } size_t begin = 0; while( true ) @@ -71,8 +82,11 @@ bool is_valid_name( const string& name ) size_t end = name.find_first_of( '.', begin ); if( end == std::string::npos ) end = len; - if( end - begin < 3 ) + if( (end - begin) < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH ) + { + idump( (name) (end)(len)(begin)(GRAPHENE_MAX_ACCOUNT_NAME_LENGTH) ); return false; + } switch( name[begin] ) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': @@ -81,6 +95,7 @@ bool is_valid_name( const string& name ) case 'y': case 'z': break; default: + ilog( "."); return false; } switch( name[end-1] ) @@ -93,6 +108,7 @@ bool is_valid_name( const string& name ) case '8': case '9': break; default: + ilog( "."); return false; } for( size_t i=begin+1; i