From f2537d4272dee8dc4ca2ebb3bbc1cc34798231ef Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Fri, 6 Oct 2017 11:18:00 -0500 Subject: [PATCH] Added configuration of each type of transaction execution time and passing them in at the appropriate API points. --- plugins/chain_plugin/chain_plugin.cpp | 33 +++++++++++++++++-- .../include/eos/chain_plugin/chain_plugin.hpp | 4 +++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index f25847cc0..0f180f642 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -48,8 +48,22 @@ public: fc::optional block_logger; fc::optional chain; chain_id_type chain_id; + uint32_t rcvd_block_trans_execution_time; + uint32_t trans_execution_time; + uint32_t create_block_trans_execution_time; }; +#ifdef NDEBUG +const uint32_t chain_plugin::DEFAULT_RECEIVED_BLOCK_TRANSACTION_EXECUTION_TIME = 12; +const uint32_t chain_plugin::DEFAULT_TRANSACTION_EXECUTION_TIME = 3; +const uint32_t chain_plugin::DEFAULT_CREATE_BLOCK_TRANSACTION_EXECUTION_TIME = 3; +#else +const uint32_t chain_plugin::DEFAULT_RECEIVED_BLOCK_TRANSACTION_EXECUTION_TIME = 72; +const uint32_t chain_plugin::DEFAULT_TRANSACTION_EXECUTION_TIME = 18; +const uint32_t chain_plugin::DEFAULT_CREATE_BLOCK_TRANSACTION_EXECUTION_TIME = 18; +#endif + + chain_plugin::chain_plugin() :my(new chain_plugin_impl()) { @@ -61,10 +75,16 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip { cfg.add_options() ("genesis-json", bpo::value(), "File to read Genesis State from") - ("genesis-timestamp", bpo::value(), "override the initial timestamp in the Genesis State file") + ("genesis-timestamp", bpo::value(), "override the initial timestamp in the Genesis State file") ("block-log-dir", bpo::value()->default_value("blocks"), "the location of the block log (absolute path or relative to application data dir)") ("checkpoint,c", bpo::value>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.") + ("rcvd-block-trans-execution-time", bpo::value()->default_value(DEFAULT_RECEIVED_BLOCK_TRANSACTION_EXECUTION_TIME), + "Limits the maximum time (in milliseconds) that is allowed a transaction's code to execute from a received block.") + ("trans-execution-time", bpo::value()->default_value(DEFAULT_TRANSACTION_EXECUTION_TIME), + "Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute.") + ("create-block-trans-execution-time", bpo::value()->default_value(DEFAULT_CREATE_BLOCK_TRANSACTION_EXECUTION_TIME), + "Limits the maximum time (in milliseconds) that is allowed a transaction's code to execute while creating a block.") ; cli.add_options() ("replay-blockchain", bpo::bool_switch()->default_value(false), @@ -139,6 +159,10 @@ void chain_plugin::plugin_initialize(const variables_map& options) { my->loaded_checkpoints[item.first] = item.second; } } + + my->rcvd_block_trans_execution_time = options.at("rcvd-block-trans-execution-time").as() * 1000; + my->trans_execution_time = options.at("trans-execution-time").as() * 1000; + my->create_block_trans_execution_time = options.at("create-block-trans-execution-time").as() * 1000; } void chain_plugin::plugin_startup() @@ -160,7 +184,10 @@ void chain_plugin::plugin_startup() my->block_logger = block_log(my->block_log_dir); my->chain_id = genesis.compute_chain_id(); my->chain = chain_controller(db, *my->fork_db, *my->block_logger, - initializer, native_contract::make_administrator()); + initializer, native_contract::make_administrator(), + my->trans_execution_time, + my->rcvd_block_trans_execution_time, + my->create_block_trans_execution_time); if(!my->readonly) { ilog("starting chain in read/write mode"); @@ -298,7 +325,7 @@ read_only::get_block_results read_only::get_block(const read_only::get_block_par } read_write::push_block_results read_write::push_block(const read_write::push_block_params& params) { - db.push_block(params); + db.push_block(params, chain_controller::validation_steps::skip_nothing); return read_write::push_block_results(); } diff --git a/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp b/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp index 22bae224e..bb66fa03a 100644 --- a/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp @@ -295,6 +295,10 @@ public: void get_chain_id (chain::chain_id_type &cid) const; + static const uint32_t DEFAULT_RECEIVED_BLOCK_TRANSACTION_EXECUTION_TIME; + static const uint32_t DEFAULT_TRANSACTION_EXECUTION_TIME; + static const uint32_t DEFAULT_CREATE_BLOCK_TRANSACTION_EXECUTION_TIME; + private: unique_ptr my; }; -- GitLab