Skip to content

Commit

Permalink
Merge pull request steemit#721 from steemit/710-testnet-log-hf
Browse files Browse the repository at this point in the history
Log hardforks for testnet nodes
  • Loading branch information
bytemaster authored Jan 5, 2017
2 parents 806cd30 + 23609e6 commit 0dd0578
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 49 deletions.
53 changes: 4 additions & 49 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4042,12 +4042,12 @@ void database::set_hardfork( uint32_t hardfork, bool apply_now )

void database::apply_hardfork( uint32_t hardfork )
{
if( _log_hardforks )
elog( "HARDFORK ${hf} at block ${b}", ("hf", hardfork)("b", head_block_num()) );

switch( hardfork )
{
case STEEMIT_HARDFORK_0_1:
#ifndef IS_TEST_NET
elog( "HARDFORK 1 at block ${b}", ("b", head_block_num()) );
#endif
perform_vesting_share_split( 1000000 );
#ifdef IS_TEST_NET
{
Expand All @@ -4064,50 +4064,26 @@ void database::apply_hardfork( uint32_t hardfork )
#endif
break;
case STEEMIT_HARDFORK_0_2:
#ifndef IS_TEST_NET
elog( "HARDFORK 2 at block ${b}", ("b", head_block_num()) );
#endif
retally_witness_votes();
break;
case STEEMIT_HARDFORK_0_3:
#ifndef IS_TEST_NET
elog( "HARDFORK 3 at block ${b}", ("b", head_block_num()) );
#endif
retally_witness_votes();
break;
case STEEMIT_HARDFORK_0_4:
#ifndef IS_TEST_NET
elog( "HARDFORK 4 at block ${b}", ("b", head_block_num()) );
#endif
reset_virtual_schedule_time();
break;
case STEEMIT_HARDFORK_0_5:
#ifndef IS_TEST_NET
elog( "HARDFORK 5 at block ${b}", ("b", head_block_num()) );
#endif
break;
case STEEMIT_HARDFORK_0_6:
#ifndef IS_TEST_NET
elog( "HARDFORK 6 at block ${b}", ("b", head_block_num()) );
#endif
retally_witness_vote_counts();
retally_comment_children();
break;
case STEEMIT_HARDFORK_0_7:
#ifndef IS_TEST_NET
elog( "HARDFORK 7 at block ${b}", ("b", head_block_num()) );
#endif
break;
case STEEMIT_HARDFORK_0_8:
#ifndef IS_TEST_NET
elog( "HARDFORK 8 at block ${b}", ("b", head_block_num()) );
#endif
retally_witness_vote_counts(true);
break;
case STEEMIT_HARDFORK_0_9:
#ifndef IS_TEST_NET
elog( "HARDFORK 9 at block ${b}", ("b", head_block_num()) );
#endif
{
for( const std::string& acc : hardfork9::get_compromised_accounts() )
{
Expand All @@ -4126,20 +4102,11 @@ void database::apply_hardfork( uint32_t hardfork )
}
break;
case STEEMIT_HARDFORK_0_10:
#ifndef IS_TEST_NET
elog( "HARDFORK 10 at block ${b}", ("b", head_block_num()) );
#endif
retally_liquidity_weight();
break;
case STEEMIT_HARDFORK_0_11:
#ifndef IS_TEST_NET
elog( "HARDFORK 11 at block ${b}", ("b", head_block_num()) );
#endif
break;
case STEEMIT_HARDFORK_0_12:
#ifndef IS_TEST_NET
elog( "HARDFORK 12 at block ${b}", ("b", head_block_num()) );
#endif
{
const auto& comment_idx = get_index< comment_index >().indices();

Expand Down Expand Up @@ -4191,24 +4158,12 @@ void database::apply_hardfork( uint32_t hardfork )
}
break;
case STEEMIT_HARDFORK_0_13:
#ifndef IS_TEST_NET
elog( "HARDFORK 13 at block ${b}", ("b", head_block_num()) );
#endif
break;
case STEEMIT_HARDFORK_0_14:
#ifndef IS_TEST_NET
elog( "HARDFORK 14 at block ${b}", ("b", head_block_num()) );
#endif
break;
case STEEMIT_HARDFORK_0_15:
#ifndef IS_TEST_NET
elog( "HARDFORK 15 at block ${b}", ("b", head_block_num()) );
#endif
case STEEMIT_HARDFORK_0_15:
break;
case STEEMIT_HARDFORK_0_16:
#ifndef IS_TEST_NET
elog( "HARDFORK 16 at block ${b}", ("b", head_block_num()) );
#endif
modify( get_feed_history(), [&]( feed_history_object& fho )
{
while( fho.price_history.size() > STEEMIT_FEED_HISTORY_WINDOW )
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/steemit/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ namespace steemit { namespace chain {
void set_producing( bool p ) { _is_producing = p; }
bool _is_producing = false;

bool _log_hardforks = true;

enum validation_steps
{
skip_nothing = 0,
Expand Down
1 change: 1 addition & 0 deletions tests/common/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void database_fixture::open_database()
{
if( !data_dir ) {
data_dir = fc::temp_directory( graphene::utilities::temp_directory_path() );
db._log_hardforks = false;
db.open( data_dir->path(), data_dir->path(), INITIAL_TEST_SUPPLY, 1024 * 1024 * 8, chainbase::database::read_write ); // 8 MB file for testing
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/tests/block_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
signed_block cutoff_block;
{
database db;
db._log_hardforks = false;
db.open(data_dir.path(), data_dir.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
b = db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1), init_account_priv_key, database::skip_nothing);

Expand All @@ -84,6 +85,7 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
}
{
database db;
db._log_hardforks = false;
db.open(data_dir.path(), data_dir.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
BOOST_CHECK_EQUAL( db.head_block_num(), cutoff_block.block_num() );
b = cutoff_block;
Expand All @@ -109,6 +111,7 @@ BOOST_AUTO_TEST_CASE( undo_block )
fc::temp_directory data_dir( graphene::utilities::temp_directory_path() );
{
database db;
db._log_hardforks = false;
db.open(data_dir.path(), data_dir.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
fc::time_point_sec now( STEEMIT_TESTING_GENESIS_TIMESTAMP );
std::vector< time_point_sec > time_stack;
Expand Down Expand Up @@ -160,8 +163,10 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
//TODO This test needs 6-7 ish witnesses prior to fork

database db1;
db1._log_hardforks = false;
db1.open( data_dir1.path(), data_dir1.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
database db2;
db2._log_hardforks = false;
db2.open( data_dir2.path(), data_dir2.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );

auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("init_key")) );
Expand Down Expand Up @@ -223,7 +228,9 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
dir2( graphene::utilities::temp_directory_path() );
database db1,
db2;
db1._log_hardforks = false;
db1.open( dir1.path(), dir1.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
db2._log_hardforks = false;
db2.open( dir2.path(), dir2.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );

auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("init_key")) );
Expand Down Expand Up @@ -280,7 +287,9 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
dir2( graphene::utilities::temp_directory_path() );
database db1,
db2;
db1._log_hardforks = false;
db1.open(dir1.path(), dir1.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
db2._log_hardforks = false;
db2.open(dir2.path(), dir2.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );
BOOST_CHECK( db1.get_chain_id() == db2.get_chain_id() );

Expand Down Expand Up @@ -330,6 +339,7 @@ BOOST_AUTO_TEST_CASE( tapos )
try {
fc::temp_directory dir1( graphene::utilities::temp_directory_path() );
database db1;
db1._log_hardforks = false;
db1.open(dir1.path(), dir1.path(), INITIAL_TEST_SUPPLY, TEST_SHARED_MEM_SIZE, chainbase::database::read_write );

auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("init_key")) );
Expand Down

0 comments on commit 0dd0578

Please sign in to comment.