diff --git a/docs/01_nodeos/03_plugins/producer_plugin/index.md b/docs/01_nodeos/03_plugins/producer_plugin/index.md index 5b1f8f83fb..1fdae640e6 100644 --- a/docs/01_nodeos/03_plugins/producer_plugin/index.md +++ b/docs/01_nodeos/03_plugins/producer_plugin/index.md @@ -99,6 +99,10 @@ Config Options for eosio::producer_plugin: transactions in any block before returning to normal transaction processing. + --subjective-account-max-failures (=3) + Sets the maximum amount of failures + that are allowed for a given account + per block. --subjective-account-decay-time-minutes (=1440) Sets the time to return full subjective cpu for accounts diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index de719ca79d..ae77095caa 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -222,6 +222,7 @@ class producer_plugin_impl : public std::enable_shared_from_this _protocol_features_to_activate; bool _protocol_features_signaled = false; // to mark whether it has been signaled in start_block @@ -726,6 +727,8 @@ void producer_plugin::set_program_options( "Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing.") ("subjective-cpu-leeway-us", boost::program_options::value()->default_value( config::default_subjective_cpu_leeway_us ), "Time in microseconds allowed for a transaction that starts with insufficient CPU quota to complete and cover its CPU usage.") + ("subjective-account-max-failures", boost::program_options::value()->default_value(3), + "Sets the maximum amount of failures that are allowed for a given account per block.") ("subjective-account-decay-time-minutes", bpo::value()->default_value( config::account_cpu_usage_average_window_ms / 1000 / 60 ), "Sets the time to return full subjective cpu for accounts") ("incoming-defer-ratio", bpo::value()->default_value(1.0), @@ -880,6 +883,8 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_ my->_keosd_provider_timeout_us = fc::milliseconds(options.at("keosd-provider-timeout").as()); + my->_subjective_account_max_failures = options.at("subjective-account-max-failures").as(); + my->_produce_time_offset_us = options.at("produce-time-offset-us").as(); EOS_ASSERT( my->_produce_time_offset_us <= 0 && my->_produce_time_offset_us >= -config::block_interval_us, plugin_config_exception, "produce-time-offset-us ${o} must be 0 .. -${bi}", ("bi", config::block_interval_us)("o", my->_produce_time_offset_us) ); @@ -1813,10 +1818,13 @@ namespace { // track multiple failures on unapplied transactions class account_failures { public: - constexpr static uint32_t max_failures_per_account = 3; //lifetime of sb must outlive account_failures - explicit account_failures( const eosio::subjective_billing& sb ) : subjective_billing(sb) {} + explicit account_failures( uint32_t max_failures, const eosio::subjective_billing& sb ) + : max_failures_per_account(max_failures), + subjective_billing(sb) + { + } void add( const account_name& n, int64_t exception_code ) { auto& fa = failed_accounts[n]; @@ -1893,6 +1901,7 @@ class account_failures { }; std::map failed_accounts; + uint32_t max_failures_per_account = 0; const eosio::subjective_billing& subjective_billing; }; @@ -1902,7 +1911,7 @@ bool producer_plugin_impl::process_unapplied_trxs( const fc::time_point& deadlin { bool exhausted = false; if( !_unapplied_transactions.empty() ) { - account_failures account_fails( _subjective_billing ); + account_failures account_fails( _subjective_account_max_failures, _subjective_billing ); chain::controller& chain = chain_plug->chain(); const auto& rl = chain.get_resource_limits_manager(); int num_applied = 0, num_failed = 0, num_processed = 0;