From ff0be92c3f1afe05095696cd0f1c6e5b107c2a33 Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Thu, 23 Dec 2021 15:31:20 -0600 Subject: [PATCH 1/3] add expiration config --- plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 679de33bc4..ed0a366b3f 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -102,6 +102,7 @@ struct txn_test_gen_plugin_impl { name newaccountA; name newaccountB; name newaccountT; + fc::microseconds trx_expiration; void push_next_transaction(const std::shared_ptr>& trxs, const std::function& next ) { chain_plugin& cp = app().get_plugin(); @@ -376,7 +377,7 @@ struct txn_test_gen_plugin_impl { trx.actions.push_back(act_a_to_b); trx.context_free_actions.emplace_back(action({}, config::null_account_name, name("nonce"), fc::raw::pack( std::to_string(nonce_prefix)+std::to_string(nonce++) ))); trx.set_reference_block(reference_block_id); - trx.expiration = cc.head_block_time() + fc::seconds(30); + trx.expiration = cc.head_block_time() + trx_expiration; trx.max_net_usage_words = 100; trx.sign(a_priv_key, chainid); trxs.emplace_back(std::move(trx)); @@ -387,7 +388,7 @@ struct txn_test_gen_plugin_impl { trx.actions.push_back(act_b_to_a); trx.context_free_actions.emplace_back(action({}, config::null_account_name, name("nonce"), fc::raw::pack( std::to_string(nonce_prefix)+std::to_string(nonce++) ))); trx.set_reference_block(reference_block_id); - trx.expiration = cc.head_block_time() + fc::seconds(30); + trx.expiration = cc.head_block_time() + trx_expiration; trx.max_net_usage_words = 100; trx.sign(b_priv_key, chainid); trxs.emplace_back(std::move(trx)); @@ -442,6 +443,7 @@ void txn_test_gen_plugin::set_program_options(options_description&, options_desc ("txn-reference-block-lag", bpo::value()->default_value(0), "Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block)") ("txn-test-gen-threads", bpo::value()->default_value(2), "Number of worker threads in txn_test_gen thread pool") ("txn-test-gen-account-prefix", bpo::value()->default_value("txn.test."), "Prefix to use for accounts generated and used by this plugin") + ("txn-test-gen-expiration-seconds", bpo::value()->default_value(30), "expiration in seconds for transactions generated by this plugin") ; } @@ -454,6 +456,9 @@ void txn_test_gen_plugin::plugin_initialize(const variables_map& options) { my->newaccountA = eosio::chain::name(thread_pool_account_prefix + "a"); my->newaccountB = eosio::chain::name(thread_pool_account_prefix + "b"); my->newaccountT = eosio::chain::name(thread_pool_account_prefix + "t"); + my->trx_expiration = fc::seconds(options.at("txn-test-gen-expiration-seconds").as()); + EOS_ASSERT(my->trx_expiration < fc::seconds(3600), chain::plugin_config_exception, + "txn-test-gen-expiration-seconds must be smaller than 3600"); EOS_ASSERT( my->thread_pool_size > 0, chain::plugin_config_exception, "txn-test-gen-threads ${num} must be greater than 0", ("num", my->thread_pool_size) ); } FC_LOG_AND_RETHROW() From 314d4fdd3984aec316f9ac5ea28cad8f42417120 Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Fri, 24 Dec 2021 16:31:45 -0600 Subject: [PATCH 2/3] add txn-test-gen-stop-on-push-failed option --- plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index ed0a366b3f..77cad30661 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -103,6 +103,7 @@ struct txn_test_gen_plugin_impl { name newaccountB; name newaccountT; fc::microseconds trx_expiration; + bool stop_on_trx_failed; void push_next_transaction(const std::shared_ptr>& trxs, const std::function& next ) { chain_plugin& cp = app().get_plugin(); @@ -334,7 +335,7 @@ struct txn_test_gen_plugin_impl { send_transaction([this](const fc::exception_ptr& e){ if (e) { elog("pushing transaction failed: ${e}", ("e", e->to_detail_string())); - if(running) + if(running && stop_on_trx_failed) stop_generation(); } }, nonce_prefix++); @@ -444,6 +445,7 @@ void txn_test_gen_plugin::set_program_options(options_description&, options_desc ("txn-test-gen-threads", bpo::value()->default_value(2), "Number of worker threads in txn_test_gen thread pool") ("txn-test-gen-account-prefix", bpo::value()->default_value("txn.test."), "Prefix to use for accounts generated and used by this plugin") ("txn-test-gen-expiration-seconds", bpo::value()->default_value(30), "expiration in seconds for transactions generated by this plugin") + ("txn-test-gen-stop-on-push-failed", bpo::value()->default_value(true), "stop generation when pushed transaction failed") ; } @@ -459,6 +461,8 @@ void txn_test_gen_plugin::plugin_initialize(const variables_map& options) { my->trx_expiration = fc::seconds(options.at("txn-test-gen-expiration-seconds").as()); EOS_ASSERT(my->trx_expiration < fc::seconds(3600), chain::plugin_config_exception, "txn-test-gen-expiration-seconds must be smaller than 3600"); + my->stop_on_trx_failed = options.at("txn-test-gen-stop-on-push-failed").as(); + EOS_ASSERT( my->thread_pool_size > 0, chain::plugin_config_exception, "txn-test-gen-threads ${num} must be greater than 0", ("num", my->thread_pool_size) ); } FC_LOG_AND_RETHROW() From 89c698e642528514f1d6009ed2cfad4b051c83c0 Mon Sep 17 00:00:00 2001 From: Chris Gundlach Date: Thu, 9 Jun 2022 09:31:48 -0500 Subject: [PATCH 3/3] added initializers added initializers --- plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 77cad30661..4715b28842 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -102,8 +102,8 @@ struct txn_test_gen_plugin_impl { name newaccountA; name newaccountB; name newaccountT; - fc::microseconds trx_expiration; - bool stop_on_trx_failed; + fc::microseconds trx_expiration{3600}; + bool stop_on_trx_failed{true}; void push_next_transaction(const std::shared_ptr>& trxs, const std::function& next ) { chain_plugin& cp = app().get_plugin();