Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Make executable names configurable #7118

Merged
merged 3 commits into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions programs/cleos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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} )
Expand Down
2 changes: 2 additions & 0 deletions programs/cleos/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}}}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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.";
Expand All @@ -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!";
Expand Down
4 changes: 3 additions & 1 deletion programs/cleos/httpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
#pragma once

#include "config.hpp"

namespace eosio { namespace client { namespace http {

namespace detail {
Expand Down Expand Up @@ -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" );
}}}
34 changes: 17 additions & 17 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())});
}
}
Expand Down Expand Up @@ -876,8 +876,8 @@ void try_local_port(uint32_t duration) {
auto start_time = duration_cast<std::chrono::milliseconds>( system_clock::now().time_since_epoch() ).count();
while ( !local_port_used()) {
if (duration_cast<std::chrono::milliseconds>( 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))});
}
}
}
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -3299,7 +3299,7 @@ int main( int argc, char** argv ) {
fc::optional<chain_id_type> 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 {
Expand Down
1 change: 1 addition & 0 deletions programs/eosio-launcher/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 14 additions & 13 deletions programs/eosio-launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -490,18 +491,18 @@ launcher_def::set_options (bpo::options_description &cfg) {
("shape,s",bpo::value<string>(&shape)->default_value("star"),"network topology, use \"star\" \"mesh\" or give a filename for custom")
("p2p-plugin", bpo::value<string>()->default_value("net"),"select a p2p plugin to use (either net or bnet). Defaults to net.")
("genesis,g",bpo::value<string>()->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<string>(&eosd_extra_args), "forward nodeos command line argument(s) to each instance of nodeos, enclose arg(s) in quotes")
("specific-num", bpo::value<vector<uint>>()->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<vector<string>>()->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<vector<uint>>()->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<vector<string>>()->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<string>(&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<vector<uint>>()->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<vector<string>>()->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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately changing these config names will mean that the python test scripts will not operate when node_executable_name is not 'nodeos'

maybe these two config items should be renamed to something else that doesn't include "nodeos"? (to avoid having to preprocess all the various python scripts with whatever is configured)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the scripts you mentioned, and I guess there can be another cases which contain hard-coded these options. I don't like this way much, but what about adding new option like -node-exec, but also leaving -nodeos for backward compatibility?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come to think of it, those scripts won't work before your change anyways because of hardcoded "nodeos", "keosd", etc in the scripts too. Would be nice to take care of that in the future, but I think PR is ready as-is

("spcfc-inst-num", bpo::value<vector<uint>>()->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<vector<string>>()->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<int>(&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<string>(),"a file containing mapping specific nodes to hosts. Used to enhance the custom shape argument")
("servers",bpo::value<string>(),"a file containing ip addresses and names of individual servers to deploy as producers or non-producers ")
("per-host",bpo::value<int>(&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<int>(&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<string>(&network.name)->default_value("testnet_"),"network name prefix used in GELF logging source")
("enable-gelf-logging",bpo::value<bool>(&gelf_enabled)->default_value(true),"enable gelf logging appender in logging configuration file")
("gelf-endpoint",bpo::value<string>(&gelf_endpoint)->default_value("10.160.11.21:12201"),"hostname:port or ip:port of GELF endpoint")
Expand Down Expand Up @@ -578,8 +579,8 @@ launcher_def::initialize (const variables_map &vmap) {
server_ident_file = vmap["servers"].as<string>();
}

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();
Expand Down Expand Up @@ -645,9 +646,9 @@ launcher_def::initialize (const variables_map &vmap) {

if (vmap.count("specific-num")) {
const auto specific_nums = vmap["specific-num"].as<vector<uint>>();
const auto specific_args = vmap["specific-nodeos"].as<vector<string>>();
const auto specific_args = vmap["specific-" + string(node_executable_name)].as<vector<string>>();
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
Expand Down Expand Up @@ -1538,7 +1539,7 @@ launcher_def::launch (eosd_def &instance, string &gts) {
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);
Expand All @@ -1557,7 +1558,7 @@ launcher_def::launch (eosd_def &instance, string &gts) {
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 ";
}
Expand Down
Loading