From 03d1de1906315548141a750f8a75c8c668041389 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Tue, 9 Oct 2018 15:31:36 -0700 Subject: [PATCH 1/2] Delete bandwidth #3029 --- .../plugins/apis/condenser_api/CMakeLists.txt | 1 - .../apis/condenser_api/condenser_api.cpp | 48 ---- .../plugins/condenser_api/condenser_api.hpp | 18 +- .../plugins/apis/witness_api/CMakeLists.txt | 23 -- .../steem/plugins/witness_api/witness_api.hpp | 55 ---- .../witness_api/witness_api_plugin.hpp | 36 --- .../plugins/apis/witness_api/plugin.json | 5 - .../plugins/apis/witness_api/witness_api.cpp | 51 ---- .../apis/witness_api/witness_api_plugin.cpp | 20 -- libraries/plugins/witness/CMakeLists.txt | 2 +- .../witness/witness_export_objects.hpp | 71 ------ .../steem/plugins/witness/witness_objects.hpp | 135 ---------- libraries/plugins/witness/witness_plugin.cpp | 237 +----------------- .../include/steem/wallet/remote_node_api.hpp | 2 - libraries/wallet/remote_node_api.cpp | 5 - 15 files changed, 5 insertions(+), 704 deletions(-) delete mode 100644 libraries/plugins/apis/witness_api/CMakeLists.txt delete mode 100644 libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api.hpp delete mode 100644 libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api_plugin.hpp delete mode 100644 libraries/plugins/apis/witness_api/plugin.json delete mode 100644 libraries/plugins/apis/witness_api/witness_api.cpp delete mode 100644 libraries/plugins/apis/witness_api/witness_api_plugin.cpp delete mode 100644 libraries/plugins/witness/include/steem/plugins/witness/witness_export_objects.hpp delete mode 100644 libraries/plugins/witness/include/steem/plugins/witness/witness_objects.hpp diff --git a/libraries/plugins/apis/condenser_api/CMakeLists.txt b/libraries/plugins/apis/condenser_api/CMakeLists.txt index a82e919caa..ad5fa23444 100644 --- a/libraries/plugins/apis/condenser_api/CMakeLists.txt +++ b/libraries/plugins/apis/condenser_api/CMakeLists.txt @@ -17,7 +17,6 @@ target_link_libraries( condenser_api_plugin market_history_api_plugin network_broadcast_api_plugin tags_api_plugin - witness_api_plugin steem_utilities ) target_include_directories( condenser_api_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/apis/condenser_api/condenser_api.cpp b/libraries/plugins/apis/condenser_api/condenser_api.cpp index eea3d3acdc..0615293391 100644 --- a/libraries/plugins/apis/condenser_api/condenser_api.cpp +++ b/libraries/plugins/apis/condenser_api/condenser_api.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include @@ -74,7 +73,6 @@ namespace detail (get_recovery_request) (get_escrow) (get_withdraw_routes) - (get_account_bandwidth) (get_savings_withdraw_from) (get_savings_withdraw_to) (get_vesting_delegations) @@ -155,7 +153,6 @@ namespace detail std::shared_ptr< follow::follow_api > _follow_api; std::shared_ptr< reputation::reputation_api > _reputation_api; std::shared_ptr< market_history::market_history_api > _market_history_api; - std::shared_ptr< witness::witness_api > _witness_api; map< transaction_id_type, confirmation_callback > _callbacks; map< time_point_sec, vector< transaction_id_type > > _callback_expirations; @@ -785,13 +782,6 @@ namespace detail { CHECK_ARG_SIZE( 0 ) get_dynamic_global_properties_return gpo = _database_api->get_dynamic_global_properties( {} ); - if( _witness_api ) - { - auto reserve_ratio = _witness_api->get_reserve_ratio( {} ); - gpo.average_block_size = reserve_ratio.average_block_size; - gpo.current_reserve_ratio = reserve_ratio.current_reserve_ratio; - gpo.max_virtual_bandwidth = reserve_ratio.max_virtual_bandwidth; - } return gpo; } @@ -881,26 +871,6 @@ namespace detail results.back().reputation = _reputation_api->get_account_reputations( { itr->name, 1 } ).reputations[0].reputation; } - if( _witness_api ) - { - auto& e_acct = results.back(); - auto forum_bandwidth = _witness_api->get_account_bandwidth( { itr->name, witness::bandwidth_type::forum } ); - if( forum_bandwidth.bandwidth.valid() ) - { - e_acct.average_bandwidth = forum_bandwidth.bandwidth->average_bandwidth; - e_acct.lifetime_bandwidth = forum_bandwidth.bandwidth->lifetime_bandwidth; - e_acct.last_bandwidth_update = forum_bandwidth.bandwidth->last_bandwidth_update; - } - - auto market_bandwidth = _witness_api->get_account_bandwidth( { itr->name, witness::bandwidth_type::market } ); - if( market_bandwidth.bandwidth.valid() ) - { - e_acct.average_market_bandwidth = market_bandwidth.bandwidth->average_bandwidth; - e_acct.lifetime_market_bandwidth = market_bandwidth.bandwidth->lifetime_bandwidth; - e_acct.last_market_bandwidth_update = market_bandwidth.bandwidth->last_bandwidth_update; - } - } - auto vitr = vidx.lower_bound( boost::make_tuple( itr->name, account_name_type() ) ); while( vitr != vidx.end() && vitr->account == itr->name ) { results.back().witness_votes.insert( _db.get< witness_object, by_name >( vitr->witness ).owner ); @@ -1028,17 +998,6 @@ namespace detail return result; } - DEFINE_API_IMPL( condenser_api_impl, get_account_bandwidth ) - { - CHECK_ARG_SIZE( 2 ) - FC_ASSERT( _witness_api, "witness_api_plugin not enabled." ); - return _witness_api->get_account_bandwidth( - { - args[0].as< string >(), - args[1].as< witness::bandwidth_type >() - }).bandwidth; - } - DEFINE_API_IMPL( condenser_api_impl, get_savings_withdraw_from ) { CHECK_ARG_SIZE( 1 ) @@ -2202,12 +2161,6 @@ void condenser_api::api_startup() { my->_market_history_api = market_history->api; } - - auto witness = appbase::app().find_plugin< witness::witness_api_plugin >(); - if( witness != nullptr ) - { - my->_witness_api = witness->api; - } } DEFINE_LOCKLESS_APIS( condenser_api, @@ -2244,7 +2197,6 @@ DEFINE_READ_APIS( condenser_api, (get_recovery_request) (get_escrow) (get_withdraw_routes) - (get_account_bandwidth) (get_savings_withdraw_from) (get_savings_withdraw_to) (get_vesting_delegations) diff --git a/libraries/plugins/apis/condenser_api/include/steem/plugins/condenser_api/condenser_api.hpp b/libraries/plugins/apis/condenser_api/include/steem/plugins/condenser_api/condenser_api.hpp index 500dfa1d4d..bb202400f1 100644 --- a/libraries/plugins/apis/condenser_api/include/steem/plugins/condenser_api/condenser_api.hpp +++ b/libraries/plugins/apis/condenser_api/include/steem/plugins/condenser_api/condenser_api.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include @@ -233,13 +232,6 @@ struct extended_account : public api_account_object extended_account( const database_api::api_account_object& a ) : api_account_object( a ) {} - share_type average_bandwidth; - share_type lifetime_bandwidth; - time_point_sec last_bandwidth_update; - share_type average_market_bandwidth; - share_type lifetime_market_bandwidth; - time_point_sec last_market_bandwidth_update; - legacy_asset vesting_balance; /// convert vesting_shares to vesting steem share_type reputation = 0; map< uint64_t, api_operation_object > transfer_history; /// transfer to/from vesting @@ -425,10 +417,6 @@ struct extended_dynamic_global_properties uint16_t sbd_stop_percent = 0; uint16_t sbd_start_percent = 0; - - int32_t average_block_size = 0; - int64_t current_reserve_ratio = 1; - uint128_t max_virtual_bandwidth = 0; }; struct api_witness_object @@ -969,7 +957,6 @@ DEFINE_API_ARGS( get_owner_history, vector< variant >, ve DEFINE_API_ARGS( get_recovery_request, vector< variant >, optional< database_api::api_account_recovery_request_object > ) DEFINE_API_ARGS( get_escrow, vector< variant >, optional< api_escrow_object > ) DEFINE_API_ARGS( get_withdraw_routes, vector< variant >, vector< database_api::api_withdraw_vesting_route_object > ) -DEFINE_API_ARGS( get_account_bandwidth, vector< variant >, optional< witness::api_account_bandwidth_object > ) DEFINE_API_ARGS( get_savings_withdraw_from, vector< variant >, vector< api_savings_withdraw_object > ) DEFINE_API_ARGS( get_savings_withdraw_to, vector< variant >, vector< api_savings_withdraw_object > ) DEFINE_API_ARGS( get_vesting_delegations, vector< variant >, vector< api_vesting_delegation_object > ) @@ -1063,7 +1050,6 @@ class condenser_api (get_recovery_request) (get_escrow) (get_withdraw_routes) - (get_account_bandwidth) (get_savings_withdraw_from) (get_savings_withdraw_to) (get_vesting_delegations) @@ -1167,7 +1153,6 @@ FC_REFLECT( steem::plugins::condenser_api::api_account_object, ) FC_REFLECT_DERIVED( steem::plugins::condenser_api::extended_account, (steem::plugins::condenser_api::api_account_object), - (average_bandwidth)(lifetime_bandwidth)(last_bandwidth_update)(average_market_bandwidth)(lifetime_market_bandwidth)(last_market_bandwidth_update) (vesting_balance)(reputation)(transfer_history)(market_history)(post_history)(vote_history)(other_history)(witness_votes)(tags_usage)(guest_bloggers)(open_orders)(comments)(feed)(blog)(recent_replies)(recommended) ) FC_REFLECT( steem::plugins::condenser_api::api_comment_object, @@ -1191,8 +1176,7 @@ FC_REFLECT( steem::plugins::condenser_api::extended_dynamic_global_properties, (total_reward_fund_steem)(total_reward_shares2)(pending_rewarded_vesting_shares)(pending_rewarded_vesting_steem) (sbd_interest_rate)(sbd_print_rate) (maximum_block_size)(current_aslot)(recent_slots_filled)(participation_count)(last_irreversible_block_num)(vote_power_reserve_rate) - (delegation_return_period)(reverse_auction_seconds)(sbd_stop_percent)(sbd_start_percent) - (average_block_size)(current_reserve_ratio)(max_virtual_bandwidth) ) + (delegation_return_period)(reverse_auction_seconds)(sbd_stop_percent)(sbd_start_percent) ) FC_REFLECT( steem::plugins::condenser_api::api_witness_object, (id) diff --git a/libraries/plugins/apis/witness_api/CMakeLists.txt b/libraries/plugins/apis/witness_api/CMakeLists.txt deleted file mode 100644 index 97d3b06f70..0000000000 --- a/libraries/plugins/apis/witness_api/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -file(GLOB HEADERS "include/steem/plugins/witness_api/*.hpp") -add_library( witness_api_plugin - witness_api_plugin.cpp - witness_api.cpp - ) - -target_link_libraries( witness_api_plugin witness_plugin json_rpc_plugin ) -target_include_directories( witness_api_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) - -if( CLANG_TIDY_EXE ) - set_target_properties( - witness_api_plugin PROPERTIES - CXX_CLANG_TIDY "${DO_CLANG_TIDY}" - ) -endif( CLANG_TIDY_EXE ) - -install( TARGETS - witness_api_plugin - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) diff --git a/libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api.hpp b/libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api.hpp deleted file mode 100644 index b77efe2954..0000000000 --- a/libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include -#include - -#include - -#include -#include -#include - -namespace steem { namespace plugins { namespace witness { - -namespace detail -{ - class witness_api_impl; -} - -struct get_account_bandwidth_args -{ - protocol::account_name_type account; - bandwidth_type type; -}; - -typedef account_bandwidth_object api_account_bandwidth_object; - -struct get_account_bandwidth_return -{ - optional< api_account_bandwidth_object > bandwidth; -}; - -typedef json_rpc::void_type get_reserve_ratio_args; -typedef reserve_ratio_object get_reserve_ratio_return; - -class witness_api -{ - public: - witness_api(); - ~witness_api(); - - DECLARE_API( - (get_account_bandwidth) - (get_reserve_ratio) - ) - - private: - std::unique_ptr< detail::witness_api_impl > my; -}; - -} } } // steem::plugins::witness - -FC_REFLECT( steem::plugins::witness::get_account_bandwidth_args, - (account)(type) ) - -FC_REFLECT( steem::plugins::witness::get_account_bandwidth_return, - (bandwidth) ) diff --git a/libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api_plugin.hpp b/libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api_plugin.hpp deleted file mode 100644 index c7c3fdf6ae..0000000000 --- a/libraries/plugins/apis/witness_api/include/steem/plugins/witness_api/witness_api_plugin.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include -#include - -#include - -#define STEEM_WITNESS_API_PLUGIN_NAME "witness_api" - - -namespace steem { namespace plugins { namespace witness { - -using namespace appbase; - -class witness_api_plugin : public appbase::plugin< witness_api_plugin > -{ -public: - APPBASE_PLUGIN_REQUIRES( - (steem::plugins::witness::witness_plugin) - (steem::plugins::json_rpc::json_rpc_plugin) - ) - - witness_api_plugin(); - virtual ~witness_api_plugin(); - - static const std::string& name() { static std::string name = STEEM_WITNESS_API_PLUGIN_NAME; return name; } - - virtual void set_program_options( options_description& cli, options_description& cfg ) override; - - virtual void plugin_initialize( const variables_map& options ) override; - virtual void plugin_startup() override; - virtual void plugin_shutdown() override; - - std::shared_ptr< class witness_api > api; -}; - -} } } // steem::plugins::witness diff --git a/libraries/plugins/apis/witness_api/plugin.json b/libraries/plugins/apis/witness_api/plugin.json deleted file mode 100644 index 1a5afbcd67..0000000000 --- a/libraries/plugins/apis/witness_api/plugin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugin_name": "witness_api", - "plugin_namespace": "witness", - "plugin_project": "witness_api_plugin" -} diff --git a/libraries/plugins/apis/witness_api/witness_api.cpp b/libraries/plugins/apis/witness_api/witness_api.cpp deleted file mode 100644 index 382af94ea2..0000000000 --- a/libraries/plugins/apis/witness_api/witness_api.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -namespace steem { namespace plugins { namespace witness { - -namespace detail { - -class witness_api_impl -{ - public: - witness_api_impl() : _db( appbase::app().get_plugin< steem::plugins::chain::chain_plugin >().db() ) {} - - DECLARE_API_IMPL( - (get_account_bandwidth) - (get_reserve_ratio) - ) - - chain::database& _db; -}; - -DEFINE_API_IMPL( witness_api_impl, get_account_bandwidth ) -{ - get_account_bandwidth_return result; - - auto band = _db.find< witness::account_bandwidth_object, witness::by_account_bandwidth_type >( boost::make_tuple( args.account, args.type ) ); - if( band != nullptr ) - result.bandwidth = *band; - - return result; -} - -DEFINE_API_IMPL( witness_api_impl, get_reserve_ratio ) -{ - return _db.get( reserve_ratio_id_type() ); -} - -} // detail - -witness_api::witness_api(): my( new detail::witness_api_impl() ) -{ - JSON_RPC_REGISTER_API( STEEM_WITNESS_API_PLUGIN_NAME ); -} - -witness_api::~witness_api() {} - -DEFINE_READ_APIS( witness_api, - (get_account_bandwidth) - (get_reserve_ratio) -) - -} } } // steem::plugins::witness diff --git a/libraries/plugins/apis/witness_api/witness_api_plugin.cpp b/libraries/plugins/apis/witness_api/witness_api_plugin.cpp deleted file mode 100644 index bf20752f07..0000000000 --- a/libraries/plugins/apis/witness_api/witness_api_plugin.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - - -namespace steem { namespace plugins { namespace witness { - -witness_api_plugin::witness_api_plugin() {} -witness_api_plugin::~witness_api_plugin() {} - -void witness_api_plugin::set_program_options( options_description& cli, options_description& cfg ) {} - -void witness_api_plugin::plugin_initialize( const variables_map& options ) -{ - api = std::make_shared< witness_api >(); -} - -void witness_api_plugin::plugin_startup() {} -void witness_api_plugin::plugin_shutdown() {} - -} } } // steem::plugins::witness diff --git a/libraries/plugins/witness/CMakeLists.txt b/libraries/plugins/witness/CMakeLists.txt index 2fa01d83a6..9bad6e75b3 100644 --- a/libraries/plugins/witness/CMakeLists.txt +++ b/libraries/plugins/witness/CMakeLists.txt @@ -5,7 +5,7 @@ add_library( witness_plugin ${HEADERS} ) -target_link_libraries( witness_plugin p2p_plugin chain_plugin rc_plugin block_data_export_plugin appbase steem_chain steem_utilities steem_utilities ) +target_link_libraries( witness_plugin p2p_plugin chain_plugin rc_plugin appbase steem_chain steem_utilities steem_utilities ) target_include_directories( witness_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/witness/include/steem/plugins/witness/witness_export_objects.hpp b/libraries/plugins/witness/include/steem/plugins/witness/witness_export_objects.hpp deleted file mode 100644 index 29480ec543..0000000000 --- a/libraries/plugins/witness/include/steem/plugins/witness/witness_export_objects.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include -#include - -namespace steem { namespace plugins { namespace witness { - -using steem::plugins::block_data_export::exportable_block_data; - -struct exp_bandwidth_update_object -{ - exp_bandwidth_update_object(); - exp_bandwidth_update_object( const account_bandwidth_object& bwo, uint32_t tsize ); - - account_name_type account; - bandwidth_type type; - share_type average_bandwidth; - share_type lifetime_bandwidth; - time_point_sec last_bandwidth_update; - uint32_t tx_size = 0; -}; - -struct exp_reserve_ratio_object -{ - exp_reserve_ratio_object(); - exp_reserve_ratio_object( const reserve_ratio_object& rr, int32_t block_size ); - - int32_t average_block_size = 0; - int64_t current_reserve_ratio = 1; - uint128_t max_virtual_bandwidth = 0; - int32_t block_size = 0; -}; - -class exp_witness_data_object - : public exportable_block_data -{ - public: - exp_witness_data_object(); - virtual ~exp_witness_data_object(); - - virtual void to_variant( fc::variant& v )const override - { - fc::to_variant( *this, v ); - } - - std::vector< exp_bandwidth_update_object > bandwidth_updates; - exp_reserve_ratio_object reserve_ratio; -}; - -} } } - -FC_REFLECT( steem::plugins::witness::exp_bandwidth_update_object, - (account) - (type) - (average_bandwidth) - (lifetime_bandwidth) - (last_bandwidth_update) - (tx_size) - ) - -FC_REFLECT( steem::plugins::witness::exp_reserve_ratio_object, - (average_block_size) - (current_reserve_ratio) - (max_virtual_bandwidth) - (block_size) - ) - -FC_REFLECT( steem::plugins::witness::exp_witness_data_object, - (bandwidth_updates) - (reserve_ratio) - ) diff --git a/libraries/plugins/witness/include/steem/plugins/witness/witness_objects.hpp b/libraries/plugins/witness/include/steem/plugins/witness/witness_objects.hpp deleted file mode 100644 index 01b956a9e8..0000000000 --- a/libraries/plugins/witness/include/steem/plugins/witness/witness_objects.hpp +++ /dev/null @@ -1,135 +0,0 @@ -#pragma once - -#include - -#include - -namespace steem { namespace plugins{ namespace witness { - -using namespace std; -using namespace steem::chain; - -#ifndef STEEM_WITNESS_SPACE_ID -#define STEEM_WITNESS_SPACE_ID 12 -#endif - -enum witness_plugin_object_type -{ - account_bandwidth_object_type = ( STEEM_WITNESS_SPACE_ID << 8 ), - content_edit_lock_object_type = ( STEEM_WITNESS_SPACE_ID << 8 ) + 1, - reserve_ratio_object_type = ( STEEM_WITNESS_SPACE_ID << 8 ) + 2, -}; - -enum bandwidth_type -{ - post, ///< Rate limiting posting reward eligibility over time - forum, ///< Rate limiting for all forum related actins - market ///< Rate limiting for all other actions -}; - -class account_bandwidth_object : public object< account_bandwidth_object_type, account_bandwidth_object > -{ - public: - template< typename Constructor, typename Allocator > - account_bandwidth_object( Constructor&& c, allocator< Allocator > a ) - { - c( *this ); - } - - account_bandwidth_object() {} - - id_type id; - - account_name_type account; - bandwidth_type type; - share_type average_bandwidth; - share_type lifetime_bandwidth; - time_point_sec last_bandwidth_update; -}; - -typedef oid< account_bandwidth_object > account_bandwidth_id_type; - -class reserve_ratio_object : public object< reserve_ratio_object_type, reserve_ratio_object > -{ - public: - template< typename Constructor, typename Allocator > - reserve_ratio_object( Constructor&& c, allocator< Allocator > a ) - { - c( *this ); - } - - reserve_ratio_object() {} - - id_type id; - - /** - * Average block size is updated every block to be: - * - * average_block_size = (99 * average_block_size + new_block_size) / 100 - * - * This property is used to update the current_reserve_ratio to maintain approximately - * 50% or less utilization of network capacity. - */ - int32_t average_block_size = 0; - - /** - * Any time average_block_size <= 50% maximum_block_size this value grows by 1 until it - * reaches STEEM_MAX_RESERVE_RATIO. Any time average_block_size is greater than - * 50% it falls by 1%. Upward adjustments happen once per round, downward adjustments - * happen every block. - */ - int64_t current_reserve_ratio = 1; - - /** - * The maximum bandwidth the blockchain can support is: - * - * max_bandwidth = maximum_block_size * STEEM_BANDWIDTH_AVERAGE_WINDOW_SECONDS / STEEM_BLOCK_INTERVAL - * - * The maximum virtual bandwidth is: - * - * max_bandwidth * current_reserve_ratio - */ - uint128_t max_virtual_bandwidth = 0; -}; - -typedef oid< reserve_ratio_object > reserve_ratio_id_type; - -struct by_account_bandwidth_type; - -typedef multi_index_container < - account_bandwidth_object, - indexed_by < - ordered_unique< tag< by_id >, - member< account_bandwidth_object, account_bandwidth_id_type, &account_bandwidth_object::id > >, - ordered_unique< tag< by_account_bandwidth_type >, - composite_key< account_bandwidth_object, - member< account_bandwidth_object, account_name_type, &account_bandwidth_object::account >, - member< account_bandwidth_object, bandwidth_type, &account_bandwidth_object::type > - > - > - >, - allocator< account_bandwidth_object > -> account_bandwidth_index; - -struct by_account; - -typedef multi_index_container < - reserve_ratio_object, - indexed_by < - ordered_unique< tag< by_id >, - member< reserve_ratio_object, reserve_ratio_id_type, &reserve_ratio_object::id > > - >, - allocator< reserve_ratio_object > -> reserve_ratio_index; - -} } } // steem::plugins::witness - -FC_REFLECT_ENUM( steem::plugins::witness::bandwidth_type, (post)(forum)(market) ) - -FC_REFLECT( steem::plugins::witness::account_bandwidth_object, - (id)(account)(type)(average_bandwidth)(lifetime_bandwidth)(last_bandwidth_update) ) -CHAINBASE_SET_INDEX_TYPE( steem::plugins::witness::account_bandwidth_object, steem::plugins::witness::account_bandwidth_index ) - -FC_REFLECT( steem::plugins::witness::reserve_ratio_object, - (id)(average_block_size)(current_reserve_ratio)(max_virtual_bandwidth) ) -CHAINBASE_SET_INDEX_TYPE( steem::plugins::witness::reserve_ratio_object, steem::plugins::witness::reserve_ratio_index ) diff --git a/libraries/plugins/witness/witness_plugin.cpp b/libraries/plugins/witness/witness_plugin.cpp index 61181df73c..7b37d790fe 100644 --- a/libraries/plugins/witness/witness_plugin.cpp +++ b/libraries/plugins/witness/witness_plugin.cpp @@ -1,9 +1,4 @@ - -#include - -#include #include -#include #include #include @@ -32,10 +27,10 @@ namespace steem { namespace plugins { namespace witness { -using chain::plugin_exception; +using namespace steem::chain; + using std::string; using std::vector; -using steem::plugins::block_data_export::block_data_export_plugin; namespace bpo = boost::program_options; @@ -54,25 +49,6 @@ void new_chain_banner( const chain::database& db ) return; } -exp_reserve_ratio_object::exp_reserve_ratio_object() {} -exp_reserve_ratio_object::exp_reserve_ratio_object( const reserve_ratio_object& rr, int32_t bsize ) : - average_block_size( rr.average_block_size ), - current_reserve_ratio( rr.current_reserve_ratio ), - max_virtual_bandwidth( rr.max_virtual_bandwidth ), - block_size( bsize ) {} - -exp_bandwidth_update_object::exp_bandwidth_update_object() {} -exp_bandwidth_update_object::exp_bandwidth_update_object( const account_bandwidth_object& bwo, uint32_t tsize ) : - account( bwo.account ), - type( bwo.type ), - average_bandwidth( bwo.average_bandwidth ), - lifetime_bandwidth( bwo.lifetime_bandwidth ), - last_bandwidth_update( bwo.last_bandwidth_update ), - tx_size( tsize ) {} - -exp_witness_data_object::exp_witness_data_object() {} -exp_witness_data_object::~exp_witness_data_object() {} - namespace detail { class witness_plugin_impl { @@ -85,12 +61,9 @@ namespace detail { void on_pre_apply_block( const chain::block_notification& note ); void on_post_apply_block( const chain::block_notification& note ); - void on_pre_apply_transaction( const chain::transaction_notification& trx ); 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 schedule_production_loop(); block_production_condition::block_production_condition_enum block_production_loop(); block_production_condition::block_production_condition_enum maybe_produce_block(fc::mutable_variant_object& capture); @@ -98,7 +71,6 @@ 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; std::map< steem::protocol::public_key_type, fc::ecc::private_key > _private_keys; std::set< steem::protocol::account_name_type > _witnesses; @@ -110,7 +82,6 @@ namespace detail { chain::database& _db; boost::signals2::connection _pre_apply_block_conn; boost::signals2::connection _post_apply_block_conn; - boost::signals2::connection _pre_apply_transaction_conn; boost::signals2::connection _pre_apply_operation_conn; boost::signals2::connection _post_apply_operation_conn; }; @@ -258,33 +229,6 @@ namespace detail { _dupe_customs.clear(); } - 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 other; - trx.get_required_authorities( required, required, required, other ); - - auto trx_size = fc::raw::pack_size(trx); - - for( const auto& auth : required ) - { - const auto& acnt = _db.get_account( auth ); - - update_account_bandwidth( acnt, trx_size, bandwidth_type::forum ); - - for( const auto& op : trx.operations ) - { - if( is_market_operation( op ) ) - { - update_account_bandwidth( acnt, trx_size * 10, bandwidth_type::market ); - break; - } - } - } - */ - } - void witness_plugin_impl::on_pre_apply_operation( const chain::operation_notification& note ) { if( _db.is_producing() ) @@ -317,159 +261,9 @@ 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; - - auto reserve_ratio_ptr = _db.find( reserve_ratio_id_type() ); - - int32_t block_size = int32_t( fc::raw::pack_size( b ) ); - if( BOOST_UNLIKELY( reserve_ratio_ptr == nullptr ) ) - { - _db.create< reserve_ratio_object >( [&]( reserve_ratio_object& r ) - { - r.average_block_size = 0; - r.current_reserve_ratio = STEEM_MAX_RESERVE_RATIO * RESERVE_RATIO_PRECISION; - r.max_virtual_bandwidth = ( static_cast( STEEM_MAX_BLOCK_SIZE) * STEEM_MAX_RESERVE_RATIO - * STEEM_BANDWIDTH_PRECISION * STEEM_BANDWIDTH_AVERAGE_WINDOW_SECONDS ) - / STEEM_BLOCK_INTERVAL; - }); - reserve_ratio_ptr = &_db.get( reserve_ratio_id_type() ); - } - else - { - _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 - * ratio proportional to the distance from 25%. If usage is at 50% then - * the reserve ratio will half. Likewise, if it is at 12% it will increase by 50%. - * - * If the reserve ratio is consistently low, then it is probably time to increase - * the capcacity of the network. - * - * This algorithm is designed to react quickly to observations significantly - * 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 ) - / ( max_block_size / 4 ); - auto old_reserve_ratio = r.current_reserve_ratio; - - if( distance > 0 ) - { - r.current_reserve_ratio -= ( r.current_reserve_ratio * distance ) / ( distance + DISTANCE_CALC_PRECISION ); - - // We do not want the reserve ratio to drop below 1 - if( r.current_reserve_ratio < RESERVE_RATIO_PRECISION ) - r.current_reserve_ratio = RESERVE_RATIO_PRECISION; - } - else - { - // By default, we should always slowly increase the reserve ratio. - r.current_reserve_ratio += std::max( RESERVE_RATIO_MIN_INCREMENT, ( r.current_reserve_ratio * distance ) / ( distance - DISTANCE_CALC_PRECISION ) ); - - if( r.current_reserve_ratio > STEEM_MAX_RESERVE_RATIO * RESERVE_RATIO_PRECISION ) - r.current_reserve_ratio = STEEM_MAX_RESERVE_RATIO * RESERVE_RATIO_PRECISION; - } - - if( old_reserve_ratio != r.current_reserve_ratio ) - { - ilog( "Reserve ratio updated from ${old} to ${new}. Block: ${blocknum}", - ("old", old_reserve_ratio) - ("new", r.current_reserve_ratio) - ("blocknum", _db.head_block_num()) ); - } - - r.max_virtual_bandwidth = ( uint128_t( max_block_size ) * uint128_t( r.current_reserve_ratio ) - * uint128_t( STEEM_BANDWIDTH_PRECISION * STEEM_BANDWIDTH_AVERAGE_WINDOW_SECONDS ) ) - / ( STEEM_BLOCK_INTERVAL * RESERVE_RATIO_PRECISION ); - } - }); - } - - std::shared_ptr< exp_witness_data_object > export_data = - 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(); - bool has_bandwidth = true; - - if( props.total_vesting_shares.amount > 0 ) - { - auto band = _db.find< account_bandwidth_object, by_account_bandwidth_type >( boost::make_tuple( a.name, type ) ); - - if( band == nullptr ) - { - band = &_db.create< account_bandwidth_object >( [&]( account_bandwidth_object& b ) - { - b.account = a.name; - b.type = type; - }); - } - - share_type new_bandwidth; - share_type trx_bandwidth = trx_size * STEEM_BANDWIDTH_PRECISION; - auto delta_time = ( _db.head_block_time() - band->last_bandwidth_update ).to_seconds(); - - if( delta_time > STEEM_BANDWIDTH_AVERAGE_WINDOW_SECONDS ) - new_bandwidth = 0; - else - new_bandwidth = ( ( ( STEEM_BANDWIDTH_AVERAGE_WINDOW_SECONDS - delta_time ) * fc::uint128( band->average_bandwidth.value ) ) - / STEEM_BANDWIDTH_AVERAGE_WINDOW_SECONDS ).to_uint64(); - - new_bandwidth += trx_bandwidth; - - _db.modify( *band, [&]( account_bandwidth_object& b ) - { - b.average_bandwidth = new_bandwidth; - b.lifetime_bandwidth += trx_bandwidth; - b.last_bandwidth_update = _db.head_block_time(); - }); - - fc::uint128 account_vshares( _db.get_effective_vesting_shares(a, VESTS_SYMBOL).amount.value ); - fc::uint128 total_vshares( props.total_vesting_shares.amount.value ); - fc::uint128 account_average_bandwidth( band->average_bandwidth.value ); - fc::uint128 max_virtual_bandwidth( _db.get( reserve_ratio_id_type() ).max_virtual_bandwidth ); - - has_bandwidth = ( account_vshares * max_virtual_bandwidth ) > ( account_average_bandwidth * total_vshares ); - - // Prior to hf 20, we don't want to listen to the enforce bandwidth arg and always want to enforce bandwidth - // When hf 20 goes live this will default enforcement to the rc plugin. - FC_TODO( "Remove HF 20 check after HF 20" ); - if( ( !_db.has_hardfork( STEEM_HARDFORK_0_20 ) || !_skip_enforce_bandwidth ) && _db.is_producing() ) - { - STEEM_ASSERT( has_bandwidth, plugin_exception, - "Account: ${account} bandwidth limit exceeded. Please wait to transact or power up STEEM.", - ("account", a.name) - ("account_vshares", account_vshares) - ("account_average_bandwidth", account_average_bandwidth) - ("max_virtual_bandwidth", max_virtual_bandwidth) - ("total_vesting_shares", total_vshares) ); - } - - std::shared_ptr< exp_witness_data_object > export_data = - steem::plugins::block_data_export::find_export_data< exp_witness_data_object >( STEEM_WITNESS_PLUGIN_NAME ); - if( export_data ) - export_data->bandwidth_updates.emplace_back( *band, trx_size ); - } + _dupe_customs.clear(); } -*/ void witness_plugin_impl::schedule_production_loop() { // Sleep for 200ms, before checking the block production @@ -657,14 +451,6 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m ilog( "Initializing witness plugin" ); my = std::make_unique< detail::witness_plugin_impl >( appbase::app().get_io_service() ); - block_data_export_plugin* export_plugin = appbase::app().find_plugin< block_data_export_plugin >(); - if( export_plugin != nullptr ) - { - ilog( "Registering witness export data factory" ); - export_plugin->register_export_data_factory( STEEM_WITNESS_PLUGIN_NAME, - []() -> std::shared_ptr< exportable_block_data > { return std::make_shared< exp_witness_data_object >(); } ); - } - STEEM_LOAD_VALUE_SET( options, "witness", my->_witnesses, steem::protocol::account_name_type ) if( options.count("private-key") ) @@ -679,23 +465,12 @@ 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 >(); 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" ) ) @@ -707,16 +482,11 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m [&]( const chain::block_notification& note ){ my->on_pre_apply_block( note ); }, *this, 0 ); my->_post_apply_block_conn = my->_db.add_post_apply_block_handler( [&]( const chain::block_notification& note ){ my->on_post_apply_block( note ); }, *this, 0 ); - my->_pre_apply_transaction_conn = my->_db.add_pre_apply_transaction_handler( - [&]( const chain::transaction_notification& note ){ my->on_pre_apply_transaction( note ); }, *this, 0 ); my->_pre_apply_operation_conn = my->_db.add_pre_apply_operation_handler( [&]( const chain::operation_notification& note ){ my->on_pre_apply_operation( note ); }, *this, 0); 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< reserve_ratio_index >( my->_db ); - if( my->_witnesses.size() && my->_private_keys.size() ) my->_chain_plugin.set_write_lock_hold_time( -1 ); } FC_LOG_AND_RETHROW() } @@ -748,7 +518,6 @@ void witness_plugin::plugin_shutdown() { chain::util::disconnect_signal( my->_pre_apply_block_conn ); chain::util::disconnect_signal( my->_post_apply_block_conn ); - chain::util::disconnect_signal( my->_pre_apply_transaction_conn ); chain::util::disconnect_signal( my->_pre_apply_operation_conn ); chain::util::disconnect_signal( my->_post_apply_operation_conn ); diff --git a/libraries/wallet/include/steem/wallet/remote_node_api.hpp b/libraries/wallet/include/steem/wallet/remote_node_api.hpp index e1567e6a1e..d4b606b58f 100644 --- a/libraries/wallet/include/steem/wallet/remote_node_api.hpp +++ b/libraries/wallet/include/steem/wallet/remote_node_api.hpp @@ -47,7 +47,6 @@ struct remote_node_api optional< database_api::api_account_recovery_request_object > get_recovery_request( account_name_type ); optional< condenser_api::api_escrow_object > get_escrow( account_name_type, uint32_t ); vector< database_api::api_withdraw_vesting_route_object > get_withdraw_routes( account_name_type, condenser_api::withdraw_route_type ); - optional< witness::api_account_bandwidth_object > get_account_bandwidth( account_name_type, witness::bandwidth_type ); vector< condenser_api::api_savings_withdraw_object > get_savings_withdraw_from( account_name_type ); vector< condenser_api::api_savings_withdraw_object > get_savings_withdraw_to( account_name_type ); vector< condenser_api::api_vesting_delegation_object > get_vesting_delegations( account_name_type, account_name_type, uint32_t ); @@ -138,7 +137,6 @@ FC_API( steem::wallet::remote_node_api, (get_recovery_request) (get_escrow) (get_withdraw_routes) - (get_account_bandwidth) (get_savings_withdraw_from) (get_savings_withdraw_to) (get_vesting_delegations) diff --git a/libraries/wallet/remote_node_api.cpp b/libraries/wallet/remote_node_api.cpp index b4627e404b..06373034be 100644 --- a/libraries/wallet/remote_node_api.cpp +++ b/libraries/wallet/remote_node_api.cpp @@ -134,11 +134,6 @@ vector< database_api::api_withdraw_vesting_route_object > remote_node_api::get_w FC_ASSERT( false ); } -optional< witness::api_account_bandwidth_object > remote_node_api::get_account_bandwidth( account_name_type, witness::bandwidth_type ) -{ - FC_ASSERT( false ); -} - vector< condenser_api::api_savings_withdraw_object > remote_node_api::get_savings_withdraw_from( account_name_type ) { FC_ASSERT( false ); From ab93289d27e7f81bbd727d7571873f0d4a109c76 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Tue, 9 Oct 2018 16:50:21 -0700 Subject: [PATCH 2/2] Remove bandwidth from tests #3029 --- tests/tests/operation_tests.cpp | 56 --------------------------------- tests/tests/undo_tests.cpp | 2 -- 2 files changed, 58 deletions(-) diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 1cb508f7a7..2683096974 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -5960,61 +5959,6 @@ BOOST_AUTO_TEST_CASE( decline_voting_rights_apply ) FC_LOG_AND_RETHROW() } -/* -BOOST_AUTO_TEST_CASE( account_bandwidth ) -{ - try - { - BOOST_TEST_MESSAGE( "Testing: account_bandwidth" ); - ACTORS( (alice)(bob) ) - generate_block(); - vest( STEEM_INIT_MINER_NAME, "alice", ASSET( "10.000 TESTS" ) ); - fund( "alice", ASSET( "10.000 TESTS" ) ); - vest( STEEM_INIT_MINER_NAME, "bob", ASSET( "10.000 TESTS" ) ); - - generate_block(); - db->skip_transaction_delta_check = false; - - BOOST_TEST_MESSAGE( "--- Test first tx in block" ); - - signed_transaction tx; - transfer_operation op; - - op.from = "alice"; - op.to = "bob"; - op.amount = ASSET( "1.000 TESTS" ); - - tx.operations.push_back( op ); - tx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION ); - sign( tx, alice_private_key ); - - db->push_transaction( tx, 0 ); - - auto last_bandwidth_update = db->get< plugins::witness::account_bandwidth_object, plugins::witness::by_account_bandwidth_type >( boost::make_tuple( "alice", plugins::witness::bandwidth_type::market ) ).last_bandwidth_update; - auto average_bandwidth = db->get< plugins::witness::account_bandwidth_object, plugins::witness::by_account_bandwidth_type >( boost::make_tuple( "alice", plugins::witness::bandwidth_type::market ) ).average_bandwidth; - BOOST_REQUIRE( last_bandwidth_update == db->head_block_time() ); - BOOST_REQUIRE( average_bandwidth == fc::raw::pack_size( tx ) * 10 * STEEM_BANDWIDTH_PRECISION ); - auto total_bandwidth = average_bandwidth; - - BOOST_TEST_MESSAGE( "--- Test second tx in block" ); - - op.amount = ASSET( "0.100 TESTS" ); - tx.clear(); - tx.operations.push_back( op ); - tx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION ); - sign( tx, alice_private_key ); - - db->push_transaction( tx, 0 ); - - last_bandwidth_update = db->get< plugins::witness::account_bandwidth_object, plugins::witness::by_account_bandwidth_type >( boost::make_tuple( "alice", plugins::witness::bandwidth_type::market ) ).last_bandwidth_update; - average_bandwidth = db->get< plugins::witness::account_bandwidth_object, plugins::witness::by_account_bandwidth_type >( boost::make_tuple( "alice", plugins::witness::bandwidth_type::market ) ).average_bandwidth; - BOOST_REQUIRE( last_bandwidth_update == db->head_block_time() ); - BOOST_REQUIRE( average_bandwidth == total_bandwidth + fc::raw::pack_size( tx ) * 10 * STEEM_BANDWIDTH_PRECISION ); - } - FC_LOG_AND_RETHROW() -} -*/ - BOOST_AUTO_TEST_CASE( claim_reward_balance_validate ) { try diff --git a/tests/tests/undo_tests.cpp b/tests/tests/undo_tests.cpp index 012fe20d78..32e4a14394 100644 --- a/tests/tests/undo_tests.cpp +++ b/tests/tests/undo_tests.cpp @@ -10,8 +10,6 @@ #include -#include - #include #include