Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable bandwidth system #3022

Merged
merged 2 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions libraries/plugins/witness/witness_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace detail {
void on_pre_apply_operation( const chain::operation_notification& note );
void on_post_apply_operation( const chain::operation_notification& note );

void update_account_bandwidth( const chain::account_object& a, uint32_t trx_size, const bandwidth_type type );
// void update_account_bandwidth( const chain::account_object& a, uint32_t trx_size, const bandwidth_type type );

void schedule_production_loop();
block_production_condition::block_production_condition_enum block_production_loop();
Expand All @@ -98,7 +98,7 @@ namespace detail {
bool _production_enabled = false;
uint32_t _required_witness_participation = 33 * STEEM_1_PERCENT;
uint32_t _production_skip_flags = chain::database::skip_nothing;
bool _skip_enforce_bandwidth = true;
//bool _skip_enforce_bandwidth = true;

std::map< steem::protocol::public_key_type, fc::ecc::private_key > _private_keys;
std::set< steem::protocol::account_name_type > _witnesses;
Expand Down Expand Up @@ -260,6 +260,7 @@ namespace detail {

void witness_plugin_impl::on_pre_apply_transaction( const chain::transaction_notification& note )
{
/*
const signed_transaction& trx = note.transaction;
flat_set< account_name_type > required; vector<authority> other;
trx.get_required_authorities( required, required, required, other );
Expand All @@ -281,6 +282,7 @@ namespace detail {
}
}
}
*/
}

void witness_plugin_impl::on_pre_apply_operation( const chain::operation_notification& note )
Expand Down Expand Up @@ -316,6 +318,7 @@ namespace detail {

void witness_plugin_impl::on_post_apply_block( const block_notification& note )
{ try {
/*
const signed_block& b = note.block;
int64_t max_block_size = _db.get_dynamic_global_properties().maximum_block_size;

Expand All @@ -339,7 +342,7 @@ namespace detail {
_db.modify( *reserve_ratio_ptr, [&]( reserve_ratio_object& r )
{
r.average_block_size = ( 99 * r.average_block_size + block_size ) / 100;

*/
/**
* About once per minute the average network use is consulted and used to
* adjust the reserve ratio. Anything above 25% usage reduces the reserve
Expand All @@ -353,6 +356,7 @@ namespace detail {
* different from past observed behavior and make small adjustments when
* behavior is within expected norms.
*/
/*
if( _db.head_block_num() % 20 == 0 )
{
int64_t distance = ( ( r.average_block_size - ( max_block_size / 4 ) ) * DISTANCE_CALC_PRECISION )
Expand Down Expand Up @@ -395,12 +399,12 @@ namespace detail {
steem::plugins::block_data_export::find_export_data< exp_witness_data_object >( STEEM_WITNESS_PLUGIN_NAME );
if( export_data )
export_data->reserve_ratio = exp_reserve_ratio_object( *reserve_ratio_ptr, block_size );

*/
_dupe_customs.clear();

} FC_LOG_AND_RETHROW() }
#pragma message( "Remove FC_LOG_AND_RETHROW here before appbase release. It exists to help debug a rare lock exception" )

/*
void witness_plugin_impl::update_account_bandwidth( const chain::account_object& a, uint32_t trx_size, const bandwidth_type type )
{
const auto& props = _db.get_dynamic_global_properties();
Expand Down Expand Up @@ -465,6 +469,7 @@ namespace detail {
export_data->bandwidth_updates.emplace_back( *band, trx_size );
}
}
*/

void witness_plugin_impl::schedule_production_loop() {
// Sleep for 200ms, before checking the block production
Expand Down Expand Up @@ -670,19 +675,23 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m
}

my->_production_enabled = options.at( "enable-stale-production" ).as< bool >();
my->_skip_enforce_bandwidth = options.at( "witness-skip-enforce-bandwidth" ).as< bool >();
//my->_skip_enforce_bandwidth = options.at( "witness-skip-enforce-bandwidth" ).as< bool >();

if( my->_witnesses.size() > 0 )
{
// It is safe to access rc plugin here because of APPBASE_REQUIRES_PLUGIN
/*
FC_ASSERT( my->_skip_enforce_bandwidth,
"skip-enforce-bandwidth=true is required to produce blocks" );
*/
FC_ASSERT( !appbase::app().get_plugin< rc::rc_plugin >().get_rc_plugin_skip_flags().skip_reject_not_enough_rc,
"rc-skip-reject-not-enough-rc=false is required to produce blocks" );

// This should be a no-op
/*
FC_ASSERT( my->_skip_enforce_bandwidth != appbase::app().get_plugin< rc::rc_plugin >().get_rc_plugin_skip_flags().skip_reject_not_enough_rc,
"To produce blocks either bandwidth (witness-skip-enforce-bandwidth=false) or rc rejection (rc-skip-reject-not-enough-rc=false) must be set." );
*/
}

if( options.count( "required-participation" ) )
Expand All @@ -701,7 +710,7 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m
my->_post_apply_operation_conn = my->_db.add_pre_apply_operation_handler(
[&]( const chain::operation_notification& note ){ my->on_post_apply_operation( note ); }, *this, 0);

add_plugin_index< account_bandwidth_index >( my->_db );
//add_plugin_index< account_bandwidth_index >( my->_db );
add_plugin_index< reserve_ratio_index >( my->_db );

if( my->_witnesses.size() && my->_private_keys.size() )
Expand Down
2 changes: 2 additions & 0 deletions tests/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5960,6 +5960,7 @@ BOOST_AUTO_TEST_CASE( decline_voting_rights_apply )
FC_LOG_AND_RETHROW()
}

/*
BOOST_AUTO_TEST_CASE( account_bandwidth )
{
try
Expand Down Expand Up @@ -6012,6 +6013,7 @@ BOOST_AUTO_TEST_CASE( account_bandwidth )
}
FC_LOG_AND_RETHROW()
}
*/

BOOST_AUTO_TEST_CASE( claim_reward_balance_validate )
{
Expand Down