Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove some deprecated options. Remove multiletter option aliases as …
…boost.program_options doesn't support them. Help output improvements.
  • Loading branch information
gumb0 committed Dec 11, 2017
commit 4ba824f329f4d5d98db964b2b9a5ba19bc4573e7
198 changes: 64 additions & 134 deletions eth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ using namespace boost::algorithm;
namespace po = boost::program_options;
namespace fs = boost::filesystem;

static std::atomic<bool> g_silence = {false};
namespace
{

std::atomic<bool> g_silence = {false};
unsigned const c_lineWidth = 160;

string ethCredits(bool _interactive = false)
{
Expand Down Expand Up @@ -197,6 +201,8 @@ class ExitHandler

bool ExitHandler::s_shouldExit = false;

}

int main(int argc, char** argv)
{
setDefaultOrCLocale();
Expand All @@ -213,9 +219,6 @@ int main(int argc, char** argv)

/// Operating mode.
OperationMode mode = OperationMode::Node;
// unsigned prime = 0;
// bool yesIReallyKnowWhatImDoing = false;
strings scripts;

/// File name for import/export.
string filename;
Expand All @@ -233,14 +236,12 @@ int main(int argc, char** argv)

string jsonAdmin;
ChainParams chainParams;
u256 gasFloor = Invalid256;
string privateChain;

bool upnp = true;
WithExisting withExisting = WithExisting::Trust;

/// Networking params.
string clientName;
string listenIP;
unsigned short listenPort = 30303;
string publicIP;
Expand Down Expand Up @@ -309,98 +310,79 @@ int main(int argc, char** argv)
string configJSON;
string genesisJSON;

po::options_description clientDefaultMode("Client mode (default)");
po::options_description clientDefaultMode("Client mode (default)", c_lineWidth);
clientDefaultMode.add_options()
("format", po::value<string>(), "<binary/hex/human> Set format.")
("script", po::value<string>(), "<script> Add script.")
("mainnet", "Use the main network protocol.")
("ropsten", "Use the Ropsten testnet.")
("testnet", "Use the Ropsten testnet.")
("gas-floor", po::value<string>(), "Set gasFloor")
("private", po::value<string>(), "<name> Use a private chain.")
("private", po::value<string>()->value_name("<name>"), "Use a private chain.")
("test", "Testing mode: Disable PoW and provide test rpc interface.")
("config", po::value<string>(), "<file> Configure specialised blockchain using given JSON information.")
("mode,o", po::value<string>(), "<full/peer> Start a full node or a peer node (default: full).\n")
("config", po::value<string>()->value_name("<file>"), "Configure specialised blockchain using given JSON information.\n")
("genesis", po::value<string>()->value_name("<file>"), "Set genesis JSON file.")
("mode,o", po::value<string>()->value_name("<full/peer>"), "Start a full node or a peer node (default: full).\n")
("ipc", "Enable IPC server (default: on).")
("ipcpath", po::value<string>(), "Set .ipc socket path (default: data directory)")
("ipcpath", po::value<string>()->value_name("<path>"), "Set .ipc socket path (default: data directory)")
("no-ipc", "Disable IPC server.")
("admin", po::value<string>(), "<password> Specify admin session key for JSON-RPC (default: auto-generated and printed at start-up).")
("admin", po::value<string>()->value_name("<password>"), "Specify admin session key for JSON-RPC (default: auto-generated and printed at start-up).")
("kill,K", "Kill the blockchain first.")
("kill-blockchain", "Kill the blockchain first.")
("rebuild,R", "Rebuild the blockchain from the existing database.")
("rescue", "Attempt to rescue a corrupt database.\n")
("import-presale", po::value<string>(), "<file> Import a pre-sale key; you'll need to specify the password to this key.")
("import-secret,s", po::value<string>(), "<secret> Import a secret key into the key store.")
("import-session-secret,S", po::value<string>(), "<secret> Import a secret session into the key store.")
("master", po::value<string>(), "<password> Give the master password for the key store. Use --master \"\" to show a prompt.")
("password", po::value<string>(), "<password> Give a password for a private key.\n")
("extra-data", po::value<string>(), "Set extra data")
("genesis", po::value<string>(), "Set genesisJSON")
("genesis-json", po::value<string>(), "Set genesisJSON")
("json-admin", po::value<string>(), "Set jsonAdmin");
("import-presale", po::value<string>()->value_name("<file>"), "Import a pre-sale key; you'll need to specify the password to this key.")
("import-secret,s", po::value<string>()->value_name("<secret>"), "Import a secret key into the key store.")
("import-session-secret,S", po::value<string>()->value_name("<secret>"), "Import a secret session into the key store.")
("master", po::value<string>()->value_name("<password>"), "Give the master password for the key store. Use --master \"\" to show a prompt.")
("password", po::value<string>()->value_name("<password>"), "Give a password for a private key.\n");

po::options_description clientTransacting("Client transactions");
po::options_description clientTransacting("Client transacting", c_lineWidth);
clientTransacting.add_options()
("ask", po::value<string>(), "See description under.")
("bid", po::value<string>(), "See description under.")
("unsafe-transactions", "Allow all transactions to proceed without verification. EXTREMELY UNSAFE.");
("ask", po::value<u256>()->value_name("<wei>"), ("Set the minimum ask gas price under which no transaction will be mined\n(default " + toString(DefaultGasPrice) + ").").c_str())
("bid", po::value<u256>()->value_name("<wei>"), ("Set the bid gas price to pay for transactions\n(default " + toString(DefaultGasPrice) + ").").c_str())
("unsafe-transactions", "Allow all transactions to proceed without verification. EXTREMELY UNSAFE.\n");

po::options_description clientMining("Client mining");
po::options_description clientMining("Client mining", c_lineWidth);
clientMining.add_options()
("address,a", po::value<string>(), "<addr> Set the author (mining payout) address to given address (default: auto).")
("author", po::value<string>(), "<addr> Set the author (mining payout) address to given address (default: auto).")
("mining,m", po::value<string>(), "<on/off/number> Enable mining, optionally for a specified number of blocks (default: off).")
("cpu,C", "When mining, use the CPU.")
("mining-threads,t", "<n> Limit number of CPU/GPU miners to n (default: use everything available on selected platform).");

po::options_description clientNetworking("Client networking");
("address,a", po::value<Address>()->value_name("<addr>"), "Set the author (mining payout) address to given address (default: auto).")
("mining,m", po::value<string>()->value_name("<on/off/number>"), "Enable mining, optionally for a specified number of blocks (default: off).")
("extra-data", po::value<string>(), "Set extra data for the sealed blocks.\n");

po::options_description clientNetworking("Client networking", c_lineWidth);
clientNetworking.add_options()
("client-name", po::value<string>(), "<name> Add a name to your client's version string (default: blank).")
("bootstrap,b", "Connect to the default Ethereum peer servers (default unless --no-discovery used).")
("no-bootstrap", "Do not connect to the default Ethereum peer servers (default only when --no-discovery is used).")
("peers,x", po::value<int>(), "<number> Attempt to connect to a given number of peers (default: 11).")
("peer-stretch", po::value<int>(), "<number> Give the accepted connection multiplier (default: 7).")
("public-ip", po::value<string>(), "<ip> Force advertised public IP to the given IP (default: auto).")
("public", po::value<string>(), "<ip> Force advertised public IP to the given IP (default: auto).")
("listen-ip", po::value<string>(), "<ip>(:<port>) Listen on the given IP for incoming connections (default: 0.0.0.0).")
("listen", po::value<short>(), "<port> Listen on the given port for incoming connections (default: 30303).")
("listen-port", po::value<short>(), "<port> Listen on the given port for incoming connections (default: 30303).")
("remote,r", po::value<string>(), "<host>(:<port>) Connect to the given remote host (default: none).")
("port", po::value<short>(), "<port> Connect to the given remote port (default: 30303).")
("network-id", po::value<string>(), "<n> Only connect to other hosts with this network id.")
("upnp", po::value<string>(), "<on/off> Use UPnP for NAT (default: on).")
("peerset", po::value<string>(), "<list> Space delimited list of peers; element format: type:publickey@ipAddress[:port].\n Types:\n default Attempt connection when no other peers are available and pinning is disabled.\n required Keep connected at all times.\n")
// TODO:
// << " --trust-peers <filename> Space delimited list of publickeys." << endl
("peers,x", po::value<int>()->value_name("<number>"), "Attempt to connect to a given number of peers (default: 11).")
("peer-stretch", po::value<int>()->value_name("<number>"), "Give the accepted connection multiplier (default: 7).")
("public-ip", po::value<string>()->value_name("<ip>"), "Force advertised public IP to the given IP (default: auto).")
("listen-ip", po::value<string>()->value_name("<ip>(:<port>)"), "Listen on the given IP for incoming connections (default: 0.0.0.0).")
("listen", po::value<unsigned short>()->value_name("<port>"), "Listen on the given port for incoming connections (default: 30303).")
("remote,r", po::value<string>()->value_name("<host>(:<port>)"), "Connect to the given remote host (default: none).")
("port", po::value<short>()->value_name("<port>"), "Connect to the given remote port (default: 30303).")
("network-id", po::value<unsigned>()->value_name("<n>"), "Only connect to other hosts with this network id.")
("upnp", po::value<string>()->value_name("<on/off>"), "Use UPnP for NAT (default: on).")
("peerset", po::value<string>()->value_name("<list>"), "Space delimited list of peers; element format: type:publickey@ipAddress[:port].\n Types:\n default Attempt connection when no other peers are available and pinning is disabled.\n required Keep connected at all times.\n")
("no-discovery", "Disable node discovery, implies --no-bootstrap.")
("pin", "Only accept or connect to trusted peers.")
("hermit", "Equivalent to --no-discovery --pin.")
("sociable", "Force discovery and no pinning.\n");

po::options_description importExportMode("Import/export mode");
po::options_description importExportMode("Import/export modes", c_lineWidth);
importExportMode.add_options()
("from", po::value<string>(), "<n> Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'.")
("to", po::value<string>(), "<n> Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'.")
("only", po::value<string>(), "<n> Equivalent to --export-from n --export-to n.")
("dont-check", "Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid.\n")
("import-snapshot", po::value<string>(), "<path> Import blockchain and state data from the Parity Warp Sync snapshot.");
("from", po::value<string>()->value_name("<n>"), "Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'.")
("to", po::value<string>()->value_name("<n>"), "Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'.")
("only", po::value<string>()->value_name("<n>"), "Equivalent to --export-from n --export-to n.")
("format", po::value<string>()->value_name("<binary/hex/human>"), "Set export format.")
("dont-check", "Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid.")
("import-snapshot", po::value<string>()->value_name("<path>"), "Import blockchain and state data from the Parity Warp Sync snapshot.\n");

po::options_description generalOptions("General Options");
po::options_description generalOptions("General Options", c_lineWidth);
generalOptions.add_options()
("db-path,d", po::value<string>(), "See description under.")
("datadir", po::value<string>(), "See description under.")
("path", po::value<string>(), "See description under.")
("db-path,d", po::value<string>()->value_name("<path>"), ("Load database from path\n(default: " + getDataDir().string() + ").\n").c_str())
#if ETH_EVMJIT
("vm", "<vm-kind> Select VM; options are: interpreter, jit or smart (default: interpreter)")
#endif // ETH_EVMJIT
("verbosity,v", po::value<int>(), "<0 - 9> Set the log verbosity from 0 to 9 (default: 8).")
("verbosity,v", po::value<int>()->value_name("<0 - 9>"), "Set the log verbosity from 0 to 9 (default: 8).")
("version,V", "Show the version and exit.")
("help,h", "Show this help message and exit.\n");

po::options_description experimentalProofOfConcept("Experimental / Proof of Concept");
experimentalProofOfConcept.add_options()
("shh", "Enable Whisper.\n");


po::options_description allowedOptions("Allowed options");
allowedOptions.add(clientDefaultMode).add(clientTransacting).add(clientMining).add(clientNetworking).add(importExportMode).add(generalOptions);

Expand Down Expand Up @@ -552,8 +534,8 @@ int main(int argc, char** argv)
}
if (vm.count("import-presale"))
presaleImports.push_back(vm["import-presale"].as<string>());
if (vm.count("json-admin"))
jsonAdmin = vm["json-admin"].as<string>();
if (vm.count("admin"))
jsonAdmin = vm["admin"].as<string>();
if (vm.count("ipc"))
ipc = true;
if (vm.count("no-ipc"))
Expand Down Expand Up @@ -612,18 +594,6 @@ int main(int argc, char** argv)
return -1;
}
}
if (vm.count("genesis-json"))
{
try
{
genesisJSON = contentsString(vm["genesis-json"].as<string>());
}
catch (...)
{
cerr << "Bad --genesis-json option: " << vm["genesis-json"].as<string>() << "\n";
return -1;
}
}
if (vm.count("config"))
{
try
Expand All @@ -648,14 +618,12 @@ int main(int argc, char** argv)
return -1;
}
}
if (vm.count("gas-floor"))
gasFloor = u256(vm["gas-floor"].as<string>());
if (vm.count("mainnet"))
{
chainParams = ChainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));
chainConfigIsSet = true;
}
if (vm.count("ropsten") || vm.count("testnet"))
if (vm.count("ropsten"))
{
chainParams = ChainParams(genesisInfo(eth::Network::Ropsten), genesisStateRoot(eth::Network::Ropsten));
chainConfigIsSet = true;
Expand All @@ -664,7 +632,7 @@ int main(int argc, char** argv)
{
try
{
askPrice = u256(vm["ask"].as<string>());
askPrice = vm["ask"].as<u256>();
}
catch (...)
{
Expand All @@ -676,7 +644,7 @@ int main(int argc, char** argv)
{
try
{
bidPrice = u256(vm["bid"].as<string>());
bidPrice = vm["bid"].as<u256>();
}
catch (...)
{
Expand All @@ -690,19 +658,12 @@ int main(int argc, char** argv)
listenSet = true;
}
if (vm.count("listen")) {
listenPort = vm["listen"].as<short>();
listenSet = true;
}
if (vm.count("listen-port")) {
listenPort = vm["listen-port"].as<short>();
listenPort = vm["listen"].as<unsigned short>();
listenSet = true;
}
if (vm.count("public-ip")) {
publicIP = vm["public-ip"].as<string>();
}
if (vm.count("public")) {
publicIP = vm["public"].as<string>();
}
if (vm.count("remote"))
{
string host = vm["remote"].as<string>();
Expand All @@ -728,8 +689,6 @@ int main(int argc, char** argv)
}
if (vm.count("dont-check"))
safeImport = true;
if (vm.count("script"))
scripts.push_back(vm["script"].as<string>());
if (vm.count("format"))
{
string m = vm["format"].as<string>();
Expand Down Expand Up @@ -767,7 +726,7 @@ int main(int argc, char** argv)
if (vm.count("network-id"))
try
{
networkID = stol(vm["network-id"].as<string>());
networkID = vm["network-id"].as<unsigned>();
}
catch (...)
{
Expand Down Expand Up @@ -795,42 +754,25 @@ int main(int argc, char** argv)
cerr << "Bad " << "--independent" << " option: " << vm["independent"].as<string>() << "\n";
return -1;
}
if (vm.count("kill") || vm.count("kill-blockchain"))
if (vm.count("kill"))
withExisting = WithExisting::Kill;
if (vm.count("rebuild"))
withExisting = WithExisting::Verify;
if (vm.count("rescue"))
withExisting = WithExisting::Rescue;
if (vm.count("client-name"))
clientName = vm["client-name"].as<string>();
if (vm.count("address"))
try
{
author = h160(fromHex(vm["address"].as<string>(), WhenError::Throw));
}
catch (BadHexCharacter&)
{
cerr << "Bad hex in " << "--adress" << " option: " << vm["address"].as<string>() << "\n";
return -1;
}
catch (...)
{
cerr << "Bad " << "--adress" << " option: " << vm["address"].as<string>() << "\n";
return -1;
}
if (vm.count("author"))
try
{
author = h160(fromHex(vm["author"].as<string>(), WhenError::Throw));
author = vm["address"].as<Address>();
}
catch (BadHexCharacter&)
{
cerr << "Bad hex in " << "--author" << " option: " << vm["author"].as<string>() << "\n";
cerr << "Bad hex in " << "--address" << " option: " << vm["address"].as<string>() << "\n";
return -1;
}
catch (...)
{
cerr << "Bad " << "--author" << " option: " << vm["author"].as<string>() << "\n";
cerr << "Bad " << "--address" << " option: " << vm["address"].as<string>() << "\n";
return -1;
}
if ((vm.count("import-secret")))
Expand All @@ -845,21 +787,15 @@ int main(int argc, char** argv)
}
if (vm.count("help"))
{
cout << "\n\n\n\n\n";
cout
<< "Usage eth [OPTIONS]\n"
<< "Options:\n\n"
<< "Wallet usage:\n";
AccountManager::streamAccountHelp(cout);
AccountManager::streamWalletHelp(cout);
cout << clientDefaultMode;
cout << clientTransacting;
cout << " --ask <wei> Set the minimum ask gas price under which no transaction will be mined\n (default" << toString(DefaultGasPrice) << ").\n";
cout << " --bid <wei> Set the bid gas price to pay for transactions\n (default " << toString(DefaultGasPrice) << ").\n";
cout << clientMining << clientNetworking;
cout << clientDefaultMode << clientTransacting << clientMining << clientNetworking;
MinerCLI::streamHelp(cout);
cout << importExportMode << generalOptions << " -d[--db-path,--path,--datadir] <path> Load database from path\n (default: " << getDataDir() << ").\n";
cout << experimentalProofOfConcept;
cout << importExportMode << generalOptions;
exit(0);
}

Expand Down Expand Up @@ -915,12 +851,9 @@ int main(int argc, char** argv)
chainParams.difficulty = chainParams.minimumDifficulty;
chainParams.gasLimit = u256(1) << 32;
}
// TODO: Open some other API path
// if (gasFloor != Invalid256)
// c_gasFloorTarget = gasFloor;

if (!chainConfigIsSet)
// default to mainnet if not already set with any of `--mainnet`, `--testnet`, `--genesis`, `--config`
// default to mainnet if not already set with any of `--mainnet`, `--ropsten`, `--genesis`, `--config`
chainParams = ChainParams(genesisInfo(eth::Network::MainNetwork), genesisStateRoot(eth::Network::MainNetwork));

if (g_logVerbosity > 0)
Expand All @@ -940,9 +873,6 @@ int main(int argc, char** argv)
// the first value is deprecated (never used)
writeFile(configFile, rlpList(author, author));

if (!clientName.empty())
clientName += "/";

string logbuf;
std::string additional;

Expand Down
Loading