Skip to content

Commit

Permalink
disallow witness from voting for larger block than 2MiB (hardfork cha…
Browse files Browse the repository at this point in the history
…nge)
  • Loading branch information
ABW committed Aug 22, 2024
1 parent 903cbe1 commit 266425c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libraries/chain/hive_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ void witness_set_properties_evaluator::do_apply( const witness_set_properties_op
if( flags.max_block_changed )
{
fc::raw::unpack_from_vector( itr->second, props.maximum_block_size );
FC_TODO( "Check and move this to validate after HF 28" );
if( _db.is_in_control() || _db.has_hardfork( HIVE_HARDFORK_1_28_MAX_BLOCK_SIZE ) )
{
FC_ASSERT( props.maximum_block_size <= HIVE_MAX_BLOCK_SIZE, "Max block size cannot be more than 2MiB" );
}
}

itr = o.props.find( "sbd_interest_rate" );
Expand Down
2 changes: 2 additions & 0 deletions libraries/protocol/hardfork.d/1_28.hf
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ long next_hf_time();
#define HIVE_HARDFORK_1_28_FIX_CANCEL_POWER_DOWN (HIVE_HARDFORK_1_28)
// use max mana instead of current when determining strength of vote (issue #609)
#define HIVE_HARDFORK_1_28_STABLE_VOTE (HIVE_HARDFORK_1_28)
// block setting of maximum_block_size above limit
#define HIVE_HARDFORK_1_28_MAX_BLOCK_SIZE (HIVE_HARDFORK_1_28)

#endif
6 changes: 6 additions & 0 deletions tests/unit/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8372,6 +8372,12 @@ BOOST_AUTO_TEST_CASE( witness_set_properties_validate )
BOOST_TEST_MESSAGE( "--- success when account subsidy decay is one hour" );
prop_op.props[ "account_subsidy_decay" ] = fc::raw::pack_to_vector( uint32_t( unit / ((60*60)/HIVE_BLOCK_INTERVAL) ) );
prop_op.validate();

BOOST_TEST_MESSAGE( "--- failure when setting maximum_block_size above HIVE_MAX_BLOCK_SIZE" );
prop_op.props.clear();
prop_op.props[ "key" ] = fc::raw::pack_to_vector( signing_key.get_public_key() );
prop_op.props[ "maximum_block_size" ] = fc::raw::pack_to_vector( HIVE_MAX_BLOCK_SIZE + 1 );
HIVE_REQUIRE_ASSERT( push_transaction( prop_op, signing_key ), "props.maximum_block_size <= HIVE_MAX_BLOCK_SIZE" );
}
FC_LOG_AND_RETHROW()
}
Expand Down

0 comments on commit 266425c

Please sign in to comment.