diff --git a/programs/cleos/CMakeLists.txt b/programs/cleos/CMakeLists.txt index 0d98fdcf63d..0787c5fe937 100644 --- a/programs/cleos/CMakeLists.txt +++ b/programs/cleos/CMakeLists.txt @@ -1,4 +1,5 @@ -add_executable( ${CLI_CLIENT_EXECUTABLE_NAME} main.cpp httpc.cpp help_text.cpp localize.hpp config.hpp CLI11.hpp) +configure_file(help_text.cpp.in help_text.cpp @ONLY) +add_executable( ${CLI_CLIENT_EXECUTABLE_NAME} main.cpp httpc.cpp ${CMAKE_CURRENT_BINARY_DIR}/help_text.cpp localize.hpp config.hpp CLI11.hpp) if( UNIX AND NOT APPLE ) set(rt_library rt ) endif() @@ -32,7 +33,7 @@ set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale) set(LOCALEDOMAIN ${CLI_CLIENT_EXECUTABLE_NAME}) configure_file(config.hpp.in config.hpp ESCAPE_QUOTES) -target_include_directories(${CLI_CLIENT_EXECUTABLE_NAME} PUBLIC ${Intl_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(${CLI_CLIENT_EXECUTABLE_NAME} PUBLIC ${Intl_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries( ${CLI_CLIENT_EXECUTABLE_NAME} PRIVATE appbase chain_api_plugin producer_plugin chain_plugin http_plugin eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ${Intl_LIBRARIES} ) diff --git a/programs/cleos/config.hpp.in b/programs/cleos/config.hpp.in index 3fe2051d74c..d9d5f45b1de 100644 --- a/programs/cleos/config.hpp.in +++ b/programs/cleos/config.hpp.in @@ -3,10 +3,12 @@ * * \warning This file is machine generated. DO NOT EDIT. See config.hpp.in for changes. */ +#pragma once namespace eosio { namespace client { namespace config { constexpr char version_str[] = "${cleos_BUILD_VERSION}"; constexpr char locale_path[] = "${LOCALEDIR}"; constexpr char locale_domain[] = "${LOCALEDOMAIN}"; constexpr char key_store_executable_name[] = "${KEY_STORE_EXECUTABLE_NAME}"; + constexpr char node_executable_name[] = "${NODE_EXECUTABLE_NAME}"; }}} diff --git a/programs/cleos/help_text.cpp b/programs/cleos/help_text.cpp.in similarity index 98% rename from programs/cleos/help_text.cpp rename to programs/cleos/help_text.cpp.in index 0f46f33114f..a133e17cade 100644 --- a/programs/cleos/help_text.cpp +++ b/programs/cleos/help_text.cpp.in @@ -65,7 +65,7 @@ const char* duplicate_key_import_help_text = _("This key is already imported int const char* unknown_abi_table_help_text = _(R"text(The ABI for the code on account "${1}" does not specify table "${2}". Please check the account and table name, and verify that the account has the expected code using: - cleos get code ${1})text"); + @CLI_CLIENT_EXECUTABLE_NAME@ get code ${1})text"); const char* failed_to_find_transaction_text = _("Failed to fetch information for transaction: \033[1m${1}\033[0m from the history plugin\n\n" "\033[32mIf you know the block number which included this transaction you providing it with the \033[2m--block-hint\033[22m option may help\033[0m"); @@ -201,7 +201,7 @@ const char* error_advice_invalid_ref_block_exception = "Ensure that the referen const char* error_advice_tx_duplicate = "You can try embedding eosio nonce action inside your transaction to ensure uniqueness."; const char* error_advice_invalid_action_args_exception = R"=====(Ensure that your arguments follow the contract abi! -You can check the contract's abi by using 'cleos get code' command.)====="; +You can check the contract's abi by using '@CLI_CLIENT_EXECUTABLE_NAME@ get code' command.)====="; const char* error_advice_permission_query_exception = "Most likely, the given account/ permission doesn't exist in the blockchain."; const char* error_advice_account_query_exception = "Most likely, the given account doesn't exist in the blockchain."; @@ -211,7 +211,7 @@ const char* error_advice_contract_query_exception = "Most likely, the given con const char* error_advice_tx_irrelevant_sig = "Please remove the unnecessary signature from your transaction!"; const char* error_advice_unsatisfied_authorization = "Ensure that you have the related private keys inside your wallet and your wallet is unlocked."; const char* error_advice_missing_auth_exception = R"=====(Ensure that you have the related authority inside your transaction!; -If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.)====="; +If you are currently using '@CLI_CLIENT_EXECUTABLE_NAME@ push action' command, try to add the relevant authority using -p option.)====="; const char* error_advice_irrelevant_auth_exception = "Please remove the unnecessary authority from your action!"; const char* error_advice_missing_chain_api_plugin_exception = "Ensure that you have \033[2meosio::chain_api_plugin\033[0m\033[32m added to your node's configuration!"; diff --git a/programs/cleos/httpc.hpp b/programs/cleos/httpc.hpp index 8d8ba5d67bc..f90e58046c4 100644 --- a/programs/cleos/httpc.hpp +++ b/programs/cleos/httpc.hpp @@ -4,6 +4,8 @@ */ #pragma once +#include "config.hpp" + namespace eosio { namespace client { namespace http { namespace detail { @@ -128,7 +130,7 @@ namespace eosio { namespace client { namespace http { const string wallet_remove_key = wallet_func_base + "/remove_key"; const string wallet_create_key = wallet_func_base + "/create_key"; const string wallet_sign_trx = wallet_func_base + "/sign_transaction"; - const string keosd_stop = "/v1/keosd/stop"; + const string keosd_stop = "/v1/" + string(client::config::key_store_executable_name) + "/stop"; FC_DECLARE_EXCEPTION( connection_exception, 1100000, "Connection Exception" ); }}} diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index caa24ae5ccf..ac6e8d4fdc0 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -252,9 +252,9 @@ fc::variant call( const std::string& url, } catch(boost::system::system_error& e) { if(url == ::url) - std::cerr << localized("Failed to connect to nodeos at ${u}; is nodeos running?", ("u", url)) << std::endl; + std::cerr << localized("Failed to connect to ${n} at ${u}; is ${n} running?", ("n", node_executable_name)("u", url)) << std::endl; else if(url == ::wallet_url) - std::cerr << localized("Failed to connect to keosd at ${u}; is keosd running?", ("u", url)) << std::endl; + std::cerr << localized("Failed to connect to ${k} at ${u}; is ${k} running?", ("k", key_store_executable_name)("u", url)) << std::endl; throw connection_exception(fc::log_messages{FC_LOG_MESSAGE(error, e.what())}); } } @@ -876,8 +876,8 @@ void try_local_port(uint32_t duration) { auto start_time = duration_cast( system_clock::now().time_since_epoch() ).count(); while ( !local_port_used()) { if (duration_cast( system_clock::now().time_since_epoch()).count() - start_time > duration ) { - std::cerr << "Unable to connect to keosd, if keosd is running please kill the process and try again.\n"; - throw connection_exception(fc::log_messages{FC_LOG_MESSAGE(error, "Unable to connect to keosd")}); + std::cerr << "Unable to connect to " << key_store_executable_name << ", if " << key_store_executable_name << " is running please kill the process and try again.\n"; + throw connection_exception(fc::log_messages{FC_LOG_MESSAGE(error, "Unable to connect to ${k}", ("k", key_store_executable_name))}); } } } @@ -935,7 +935,7 @@ void ensure_keosd_running(CLI::App* app) { } } else { std::cerr << "No wallet service listening on " - << ". Cannot automatically start keosd because keosd was not found." << std::endl; + << ". Cannot automatically start " << key_store_executable_name << " because " << key_store_executable_name << " was not found." << std::endl; } } @@ -2331,17 +2331,17 @@ int main( int argc, char** argv ) { CLI::App app{"Command Line Interface to EOSIO Client"}; app.require_subcommand(); - app.add_option( "-H,--host", obsoleted_option_host_port, localized("the host where nodeos is running") )->group("hidden"); - app.add_option( "-p,--port", obsoleted_option_host_port, localized("the port where nodeos is running") )->group("hidden"); - app.add_option( "--wallet-host", obsoleted_option_host_port, localized("the host where keosd is running") )->group("hidden"); - app.add_option( "--wallet-port", obsoleted_option_host_port, localized("the port where keosd is running") )->group("hidden"); + app.add_option( "-H,--host", obsoleted_option_host_port, localized("the host where ${n} is running", ("n", node_executable_name)) )->group("hidden"); + app.add_option( "-p,--port", obsoleted_option_host_port, localized("the port where ${n} is running", ("n", node_executable_name)) )->group("hidden"); + app.add_option( "--wallet-host", obsoleted_option_host_port, localized("the host where ${k} is running", ("k", key_store_executable_name)) )->group("hidden"); + app.add_option( "--wallet-port", obsoleted_option_host_port, localized("the port where ${k} is running", ("k", key_store_executable_name)) )->group("hidden"); - app.add_option( "-u,--url", url, localized("the http/https URL where nodeos is running"), true ); - app.add_option( "--wallet-url", wallet_url, localized("the http/https URL where keosd is running"), true ); + app.add_option( "-u,--url", url, localized("the http/https URL where ${n} is running", ("n", node_executable_name)), true ); + app.add_option( "--wallet-url", wallet_url, localized("the http/https URL where ${k} is running", ("k", key_store_executable_name)), true ); app.add_option( "-r,--header", header_opt_callback, localized("pass specific HTTP header; repeat this option to pass multiple headers")); app.add_flag( "-n,--no-verify", no_verify, localized("don't verify peer certificate when using HTTPS")); - app.add_flag( "--no-auto-keosd", no_auto_keosd, localized("don't automatically launch a keosd if one is not currently running")); + app.add_flag( "--no-auto-" + string(key_store_executable_name), no_auto_keosd, localized("don't automatically launch a ${k} if one is not currently running", ("k", key_store_executable_name))); app.set_callback([&app]{ ensure_keosd_running(&app);}); app.add_flag( "-v,--verbose", verbose, localized("output verbose errors and action console output")); @@ -2398,7 +2398,7 @@ int main( int argc, char** argv ) { bool pack_action_data_flag = false; auto pack_transaction = convert->add_subcommand("pack_transaction", localized("From plain signed json to packed form")); pack_transaction->add_option("transaction", plain_signed_transaction_json, localized("The plain signed json (string)"))->required(); - pack_transaction->add_flag("--pack-action-data", pack_action_data_flag, localized("Pack all action data within transaction, needs interaction with nodeos")); + pack_transaction->add_flag("--pack-action-data", pack_action_data_flag, localized("Pack all action data within transaction, needs interaction with ${n}", ("n", node_executable_name))); pack_transaction->set_callback([&] { fc::variant trx_var; try { @@ -2421,7 +2421,7 @@ int main( int argc, char** argv ) { bool unpack_action_data_flag = false; auto unpack_transaction = convert->add_subcommand("unpack_transaction", localized("From packed to plain signed json form")); unpack_transaction->add_option("transaction", packed_transaction_json, localized("The packed transaction json (string containing packed_trx and optionally compression fields)"))->required(); - unpack_transaction->add_flag("--unpack-action-data", unpack_action_data_flag, localized("Unpack all action data within transaction, needs interaction with nodeos")); + unpack_transaction->add_flag("--unpack-action-data", unpack_action_data_flag, localized("Unpack all action data within transaction, needs interaction with ${n}", ("n", node_executable_name))); unpack_transaction->set_callback([&] { fc::variant packed_trx_var; packed_transaction packed_trx; @@ -2541,7 +2541,7 @@ int main( int argc, char** argv ) { code_hash = old_result["code_hash"].as_string(); if(code_as_wasm) { wasm = old_result["wasm"].as_string(); - std::cout << localized("Warning: communicating to older nodeos which returns malformed binary wasm") << std::endl; + std::cout << localized("Warning: communicating to older ${n} which returns malformed binary wasm", ("n", node_executable_name)) << std::endl; } else wast = old_result["wast"].as_string(); @@ -3270,7 +3270,7 @@ int main( int argc, char** argv ) { std::cout << fc::json::to_pretty_string(v) << std::endl; }); - auto stopKeosd = wallet->add_subcommand("stop", localized("Stop keosd."), false); + auto stopKeosd = wallet->add_subcommand("stop", localized("Stop ${k}.", ("k", key_store_executable_name)), false); stopKeosd->set_callback([] { const auto& v = call(wallet_url, keosd_stop); if ( !v.is_object() || v.get_object().size() != 0 ) { //on success keosd responds with empty object @@ -3299,7 +3299,7 @@ int main( int argc, char** argv ) { fc::optional chain_id; if( str_chain_id.size() == 0 ) { - ilog( "grabbing chain_id from nodeos" ); + ilog( "grabbing chain_id from ${n}", ("n", node_executable_name) ); auto info = get_info(); chain_id = info.chain_id; } else { diff --git a/programs/eosio-launcher/config.hpp.in b/programs/eosio-launcher/config.hpp.in index f60e6ab19e5..f733308dc1b 100644 --- a/programs/eosio-launcher/config.hpp.in +++ b/programs/eosio-launcher/config.hpp.in @@ -11,6 +11,7 @@ namespace eosio { namespace launcher { namespace config { constexpr char version_str[] = "${launcher_BUILD_VERSION}"; + constexpr char node_executable_name[] = "${NODE_EXECUTABLE_NAME}"; }}} #endif // CONFIG_HPP_IN diff --git a/programs/eosio-launcher/main.cpp b/programs/eosio-launcher/main.cpp index 7e6bfbaf7b3..edebe0d5a6a 100644 --- a/programs/eosio-launcher/main.cpp +++ b/programs/eosio-launcher/main.cpp @@ -48,6 +48,7 @@ using bpo::options_description; using bpo::variables_map; using public_key_type = fc::crypto::public_key; using private_key_type = fc::crypto::private_key; +using namespace eosio::launcher::config; const string block_dir = "blocks"; const string shared_mem_dir = "state"; @@ -490,18 +491,18 @@ launcher_def::set_options (bpo::options_description &cfg) { ("shape,s",bpo::value(&shape)->default_value("star"),"network topology, use \"star\" \"mesh\" or give a filename for custom") ("p2p-plugin", bpo::value()->default_value("net"),"select a p2p plugin to use (either net or bnet). Defaults to net.") ("genesis,g",bpo::value()->default_value("./genesis.json"),"set the path to genesis.json") - ("skip-signature", bpo::bool_switch(&skip_transaction_signatures)->default_value(false), "nodeos does not require transaction signatures.") - ("nodeos", bpo::value(&eosd_extra_args), "forward nodeos command line argument(s) to each instance of nodeos, enclose arg(s) in quotes") - ("specific-num", bpo::value>()->composing(), "forward nodeos command line argument(s) (using \"--specific-nodeos\" flag) to this specific instance of nodeos. This parameter can be entered multiple times and requires a paired \"--specific-nodeos\" flag each time it is used") - ("specific-nodeos", bpo::value>()->composing(), "forward nodeos command line argument(s) to its paired specific instance of nodeos(using \"--specific-num\"), enclose arg(s) in quotes") - ("spcfc-inst-num", bpo::value>()->composing(), "Specify a specific version installation path (using \"--spcfc-inst-nodeos\" flag) for launching this specific instance of nodeos. This parameter can be entered multiple times and requires a paired \"--spcfc-inst-nodeos\" flag each time it is used") - ("spcfc-inst-nodeos", bpo::value>()->composing(), "Provide a specific version installation path to its paired specific instance of nodeos(using \"--spcfc-inst-num\")") + ("skip-signature", bpo::bool_switch(&skip_transaction_signatures)->default_value(false), (string(node_executable_name) + " does not require transaction signatures.").c_str()) + (node_executable_name, bpo::value(&eosd_extra_args), ("forward " + string(node_executable_name) + " command line argument(s) to each instance of " + string(node_executable_name) + ", enclose arg(s) in quotes").c_str()) + ("specific-num", bpo::value>()->composing(), ("forward " + string(node_executable_name) + " command line argument(s) (using \"--specific-" + string(node_executable_name) + "\" flag) to this specific instance of " + string(node_executable_name) + ". This parameter can be entered multiple times and requires a paired \"--specific-" + string(node_executable_name) +"\" flag each time it is used").c_str()) + (("specific-" + string(node_executable_name)).c_str(), bpo::value>()->composing(), ("forward " + string(node_executable_name) + " command line argument(s) to its paired specific instance of " + string(node_executable_name) + "(using \"--specific-num\"), enclose arg(s) in quotes").c_str()) + ("spcfc-inst-num", bpo::value>()->composing(), ("Specify a specific version installation path (using \"--spcfc-inst-"+ string(node_executable_name) + "\" flag) for launching this specific instance of " + string(node_executable_name) + ". This parameter can be entered multiple times and requires a paired \"--spcfc-inst-" + string(node_executable_name) + "\" flag each time it is used").c_str()) + (("spcfc-inst-" + string(node_executable_name)).c_str(), bpo::value>()->composing(), ("Provide a specific version installation path to its paired specific instance of " + string(node_executable_name) + "(using \"--spcfc-inst-num\")").c_str()) ("delay,d",bpo::value(&start_delay)->default_value(0),"seconds delay before starting each node after the first") ("boot",bpo::bool_switch(&boot)->default_value(false),"After deploying the nodes and generating a boot script, invoke it.") ("nogen",bpo::bool_switch(&nogen)->default_value(false),"launch nodes without writing new config files") ("host-map",bpo::value(),"a file containing mapping specific nodes to hosts. Used to enhance the custom shape argument") ("servers",bpo::value(),"a file containing ip addresses and names of individual servers to deploy as producers or non-producers ") - ("per-host",bpo::value(&per_host)->default_value(0),"specifies how many nodeos instances will run on a single host. Use 0 to indicate all on one.") + ("per-host",bpo::value(&per_host)->default_value(0),("specifies how many " + string(node_executable_name) + " instances will run on a single host. Use 0 to indicate all on one.").c_str()) ("network-name",bpo::value(&network.name)->default_value("testnet_"),"network name prefix used in GELF logging source") ("enable-gelf-logging",bpo::value(&gelf_enabled)->default_value(true),"enable gelf logging appender in logging configuration file") ("gelf-endpoint",bpo::value(&gelf_endpoint)->default_value("10.160.11.21:12201"),"hostname:port or ip:port of GELF endpoint") @@ -578,8 +579,8 @@ launcher_def::initialize (const variables_map &vmap) { server_ident_file = vmap["servers"].as(); } - retrieve_paired_array_parameters(vmap, "specific-num", "specific-nodeos", specific_nodeos_args); - retrieve_paired_array_parameters(vmap, "spcfc-inst-num", "spcfc-inst-nodeos", specific_nodeos_installation_paths); + retrieve_paired_array_parameters(vmap, "specific-num", "specific-" + string(node_executable_name), specific_nodeos_args); + retrieve_paired_array_parameters(vmap, "spcfc-inst-num", "spcfc-inst-" + string(node_executable_name), specific_nodeos_installation_paths); using namespace std::chrono; system_clock::time_point now = system_clock::now(); @@ -645,9 +646,9 @@ launcher_def::initialize (const variables_map &vmap) { if (vmap.count("specific-num")) { const auto specific_nums = vmap["specific-num"].as>(); - const auto specific_args = vmap["specific-nodeos"].as>(); + const auto specific_args = vmap["specific-" + string(node_executable_name)].as>(); if (specific_nums.size() != specific_args.size()) { - cerr << "ERROR: every specific-num argument must be paired with a specific-nodeos argument" << endl; + cerr << "ERROR: every specific-num argument must be paired with a specific-" << node_executable_name << " argument" << endl; exit (-1); } // don't include bios @@ -1538,7 +1539,7 @@ launcher_def::launch (eosd_def &instance, string >s) { bfs::path reerr_sl = dd / "stderr.txt"; bfs::path reerr_base = bfs::path("stderr." + launch_time + ".txt"); bfs::path reerr = dd / reerr_base; - bfs::path pidf = dd / "nodeos.pid"; + bfs::path pidf = dd / bfs::path(string(node_executable_name) + ".pid"); host_def* host; try { host = deploy_config_files (*instance.node); @@ -1557,7 +1558,7 @@ launcher_def::launch (eosd_def &instance, string >s) { install_path = specific_nodeos_installation_paths[node_num] + "/"; } } - string eosdcmd = install_path + "programs/nodeos/nodeos "; + string eosdcmd = install_path + "programs/nodeos/" + string(node_executable_name) + " "; if (skip_transaction_signatures) { eosdcmd += "--skip-transaction-signatures "; } diff --git a/programs/keosd/main.cpp b/programs/keosd/main.cpp index 196b722e5a5..626ef6bd0f8 100644 --- a/programs/keosd/main.cpp +++ b/programs/keosd/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char** argv) if(!app().initialize(argc, argv)) return -1; auto& http = app().get_plugin(); - http.add_handler("/v1/keosd/stop", [](string, string, url_response_callback cb) { cb(200, fc::variant(fc::variant_object())); std::raise(SIGTERM); } ); + http.add_handler("/v1/" + keosd::config::key_store_executable_name + "/stop", [](string, string, url_response_callback cb) { cb(200, fc::variant(fc::variant_object())); std::raise(SIGTERM); } ); app().startup(); app().exec(); } catch (const fc::exception& e) { diff --git a/programs/nodeos/config.hpp.in b/programs/nodeos/config.hpp.in index dbeba72a3d1..821477e3270 100644 --- a/programs/nodeos/config.hpp.in +++ b/programs/nodeos/config.hpp.in @@ -11,6 +11,7 @@ namespace eosio { namespace nodeos { namespace config { constexpr uint64_t version = 0x${nodeos_BUILD_VERSION}; + const string node_executable_name = "${NODE_EXECUTABLE_NAME}"; }}} #endif // CONFIG_HPP_IN diff --git a/programs/nodeos/main.cpp b/programs/nodeos/main.cpp index 7034a03858a..8b3b2d9478c 100644 --- a/programs/nodeos/main.cpp +++ b/programs/nodeos/main.cpp @@ -87,8 +87,8 @@ int main(int argc, char** argv) app().set_version(eosio::nodeos::config::version); auto root = fc::app_path(); - app().set_default_data_dir(root / "eosio/nodeos/data" ); - app().set_default_config_dir(root / "eosio/nodeos/config" ); + app().set_default_data_dir(root / "eosio" / nodeos::config::node_executable_name / "data" ); + app().set_default_config_dir(root / "eosio" / nodeos::config::node_executable_name / "config" ); http_plugin::set_defaults({ .default_unix_socket_path = "", .default_http_port = 8888 @@ -96,10 +96,10 @@ int main(int argc, char** argv) if(!app().initialize(argc, argv)) return INITIALIZE_FAIL; initialize_logging(); - ilog("nodeos version ${ver}", ("ver", app().version_string())); + ilog("${name} version ${ver}", ("name", nodeos::config::node_executable_name)("ver", app().version_string())); ilog("eosio root is ${root}", ("root", root.string())); - ilog("nodeos using configuration file ${c}", ("c", app().full_config_file_path().string())); - ilog("nodeos data directory is ${d}", ("d", app().data_dir().string())); + ilog("${name} using configuration file ${c}", ("name", nodeos::config::node_executable_name)("c", app().full_config_file_path().string())); + ilog("${name} data directory is ${d}", ("name", nodeos::config::node_executable_name)("d", app().data_dir().string())); app().startup(); app().exec(); } catch( const extract_genesis_state_exception& e ) { @@ -145,6 +145,6 @@ int main(int argc, char** argv) return OTHER_FAIL; } - ilog("nodeos successfully exiting"); + ilog("${name} successfully exiting", ("name", nodeos::config::node_executable_name)); return SUCCESS; }