diff --git a/CMakeLists.txt b/CMakeLists.txt index 10998a38bb8..0d098378f0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,8 +93,8 @@ include(EthExecutableHelper) include(EthDependencies) include(EthUtils) -hunter_add_package(Boost COMPONENTS filesystem system thread) -find_package(Boost CONFIG REQUIRED filesystem system thread) +hunter_add_package(Boost COMPONENTS program_options filesystem system thread) +find_package(Boost CONFIG REQUIRED program_options filesystem system thread) hunter_add_package(jsoncpp) find_package(jsoncpp CONFIG REQUIRED) @@ -149,3 +149,8 @@ endif() # TODO: Split out json_spirit, libscrypt and sec256k1. add_subdirectory(utils) + +add_executable(main rlp/main.cpp) + +add_executable(peer test/unittests/libp2p/peer.cpp) +add_executable(Options test/tools/libtesteth/Options.cpp) \ No newline at end of file diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index d6676c4227d..3f850f5c5ed 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -6,9 +6,13 @@ set( ) add_executable(eth ${sources}) -target_link_libraries( - eth - PRIVATE ethereum ethashseal evm web3jsonrpc webthree devcore + + + +target_link_libraries ( + eth + PRIVATE ethereum ethashseal evm web3jsonrpc webthree devcore Boost::program_options + ) install(TARGETS eth DESTINATION bin) diff --git a/eth/main.cpp b/eth/main.cpp index 682036fb101..7ef6983fb21 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -70,99 +72,11 @@ using namespace dev; using namespace dev::p2p; using namespace dev::eth; using namespace boost::algorithm; +namespace po = boost::program_options; namespace fs = boost::filesystem; static std::atomic g_silence = {false}; -void help() -{ - cout - << "Usage eth [OPTIONS]\n" - << "Options:\n\n" - << "Wallet usage:\n"; - AccountManager::streamAccountHelp(cout); - AccountManager::streamWalletHelp(cout); - cout - << "\nClient mode (default):\n" - << " --mainnet Use the main network protocol.\n" - << " --ropsten Use the Ropsten testnet.\n" - << " --private Use a private chain.\n" - << " --test Testing mode: Disable PoW and provide test rpc interface.\n" - << " --config Configure specialised blockchain using given JSON information.\n" - << " --oppose-dao-fork Ignore DAO hard fork (default is to participate).\n\n" - << " -o,--mode Start a full node or a peer node (default: full).\n\n" - << " -j,--json-rpc Enable JSON-RPC server (default: off).\n" - << " --ipc Enable IPC server (default: on).\n" - << " --ipcpath Set .ipc socket path (default: data directory)\n" - << " --admin-via-http Expose admin interface via http - UNSAFE! (default: off).\n" - << " --no-ipc Disable IPC server.\n" - << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: " << SensibleHttpPort << ").\n" - << " --rpccorsdomain Domain on which to send Access-Control-Allow-Origin header.\n" - << " --admin Specify admin session key for JSON-RPC (default: auto-generated and printed at start-up).\n" - << " -K,--kill Kill the blockchain first.\n" - << " -R,--rebuild Rebuild the blockchain from the existing database.\n" - << " --rescue Attempt to rescue a corrupt database.\n\n" - << " --import-presale Import a pre-sale key; you'll need to specify the password to this key.\n" - << " -s,--import-secret Import a secret key into the key store.\n" - << " --master Give the master password for the key store. Use --master \"\" to show a prompt.\n" - << " --password Give a password for a private key.\n\n" - << "Client transacting:\n" - << " --ask Set the minimum ask gas price under which no transaction will be mined (default " << toString(DefaultGasPrice) << " ).\n" - << " --bid Set the bid gas price to pay for transactions (default " << toString(DefaultGasPrice) << " ).\n" - << " --unsafe-transactions Allow all transactions to proceed without verification. EXTREMELY UNSAFE.\n" - << "Client mining:\n" - << " -a,--address Set the author (mining payout) address to given address (default: auto).\n" - << " -m,--mining Enable mining, optionally for a specified number of blocks (default: off).\n" - << " -f,--force-mining Mine even when there are no transactions to mine (default: off).\n" - << " -C,--cpu When mining, use the CPU.\n" - << " -t, --mining-threads Limit number of CPU/GPU miners to n (default: use everything available on selected platform).\n\n" - << "Client networking:\n" - << " --client-name Add a name to your client's version string (default: blank).\n" - << " --bootstrap Connect to the default Ethereum peer servers (default unless --no-discovery used).\n" - << " --no-bootstrap Do not connect to the default Ethereum peer servers (default only when --no-discovery is used).\n" - << " -x,--peers Attempt to connect to a given number of peers (default: 11).\n" - << " --peer-stretch Give the accepted connection multiplier (default: 7).\n" - - << " --public-ip Force advertised public IP to the given IP (default: auto).\n" - << " --listen-ip (:) Listen on the given IP for incoming connections (default: 0.0.0.0).\n" - << " --listen Listen on the given port for incoming connections (default: 30303).\n" - << " -r,--remote (:) Connect to the given remote host (default: none).\n" - << " --port Connect to the given remote port (default: 30303).\n" - << " --network-id Only connect to other hosts with this network id.\n" - << " --upnp Use UPnP for NAT (default: on).\n" - - << " --peerset 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 Space delimited list of publickeys." << endl - - << " --no-discovery Disable node discovery, implies --no-bootstrap.\n" - << " --pin Only accept or connect to trusted peers.\n" - << " --hermit Equivalent to --no-discovery --pin.\n" - << " --sociable Force discovery and no pinning.\n\n"; - MinerCLI::streamHelp(cout); - cout - << "Import/export modes:\n" - << " --from Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'.\n" - << " --to Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'.\n" - << " --only Equivalent to --export-from n --export-to n.\n" - << " --dont-check Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid.\n\n" - << " --import-snapshot Import blockchain and state data from the Parity Warp Sync snapshot." << endl - << "General Options:\n" - << " -d,--db-path,--datadir Load database from path (default: " << getDataDir() << ").\n" -#if ETH_EVMJIT - << " --vm Select VM; options are: interpreter, jit or smart (default: interpreter).\n" -#endif // ETH_EVMJIT - << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (default: 8).\n" - << " -V,--version Show the version and exit.\n" - << " -h,--help Show this help message and exit.\n\n" - << "Experimental / Proof of Concept:\n" - << " --shh Enable Whisper.\n\n"; - exit(0); -} - string ethCredits(bool _interactive = false) { std::ostringstream cout; @@ -305,7 +219,7 @@ int main(int argc, char** argv) #else g_logVerbosity = 1; #endif - + boost::program_options::option_description desc; /// Operating mode. OperationMode mode = OperationMode::Node; // unsigned prime = 0; @@ -406,403 +320,599 @@ int main(int argc, char** argv) bool chainConfigIsSet = false; string configJSON; string genesisJSON; + po::options_description clientDefaultMode("Client mode (default)"); + clientDefaultMode.add_options() + ("format", po::value(), " Set format.") + ("script", po::value(), "