Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Better command line in ethkey and eth#4635

Merged
gumb0 merged 8 commits intoethereum:developfrom
demon1999:develop2
Dec 13, 2017
Merged

Better command line in ethkey and eth#4635
gumb0 merged 8 commits intoethereum:developfrom
demon1999:develop2

Conversation

@demon1999
Copy link
Contributor

@demon1999 demon1999 commented Oct 28, 2017

Better comand line in ethkey and eth

@demon1999 demon1999 changed the title Develop2 Better comand line in ethkey Oct 28, 2017
@codecov-io
Copy link

codecov-io commented Oct 28, 2017

Codecov Report

Merging #4635 into develop will decrease coverage by 2.43%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4635      +/-   ##
===========================================
- Coverage    60.88%   58.44%   -2.44%     
===========================================
  Files          343      338       -5     
  Lines        27111    25677    -1434     
  Branches      2781     3141     +360     
===========================================
- Hits         16506    15008    -1498     
+ Misses        9621     9616       -5     
- Partials       984     1053      +69
Impacted Files Coverage Δ
eth/MinerAux.h 0% <0%> (ø) ⬆️
ethkey/main.cpp 0% <0%> (ø) ⬆️
eth/main.cpp 0% <0%> (ø) ⬆️
ethkey/KeyAux.h 0% <0%> (ø) ⬆️
test/unittests/libethereum/BlockQueue.cpp 5.17% <0%> (-94.83%) ⬇️
libethereum/StateImporter.h 0% <0%> (-66.67%) ⬇️
libethereum/VerifiedBlock.h 7.14% <0%> (-52.86%) ⬇️
libethereum/BlockQueue.h 30.13% <0%> (-34.25%) ⬇️
libethereum/SnapshotStorage.h 0% <0%> (-25%) ⬇️
libdevcore/TrieHash.h 80% <0%> (-20%) ⬇️
... and 202 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 117eeca...4b0bb1c. Read the comment docs.

@gumb0 gumb0 requested review from chfast and gumb0 October 28, 2017 17:18
eth/MinerAux.h Outdated
}

bool interpretOption(int& i, int argc, char** argv)
bool interpretOption(size_t& i, const vector<string>& argv)
Copy link
Member

Choose a reason for hiding this comment

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

const should be after type name according to our coding style, so should be vector<string> const&

eth/main.cpp Outdated
#include <boost/program_options.hpp>
#include <boost/program_options/options_description.hpp>

/*
Copy link
Member

Choose a reason for hiding this comment

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

This comment block shouldn't be here

eth/main.cpp Outdated
* Ethereum client.
*/

#include <thread>
Copy link
Member

Choose a reason for hiding this comment

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

Some #includes are now duplicated in this file, remove it

eth/main.cpp Outdated
if (vm.count("client-name"))
clientName = vm["client-name"].as<string>();
if (vm.count("address"))
try {
Copy link
Member

Choose a reason for hiding this comment

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

braces should be on a separate line

ethkey/main.cpp Outdated
("version,V", "Show the version and exit.")
("help,h", "Show this help message and exit.");
po::parsed_options parsed = po::command_line_parser(argc, argv).options(generalOptions).allow_unregistered().run();
vector<string> to_pass_further = collect_unrecognized(parsed.options, po::include_positional);
Copy link
Member

Choose a reason for hiding this comment

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

variable names should use camelCase, I'd name this unrecognisedOptions

@demon1999
Copy link
Contributor Author

fixed

@demon1999 demon1999 changed the title Better comand line in ethkey Better command line in ethkey Oct 31, 2017
@demon1999 demon1999 changed the title Better command line in ethkey Better command line in ethkey and eth Oct 31, 2017
@gumb0 gumb0 self-requested a review November 23, 2017 16:57
Copy link
Member

@gumb0 gumb0 left a comment

Choose a reason for hiding this comment

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

First some simple requests, mostly to fix formatting

eth/main.cpp Outdated
if (_interactive)
cout
<< "Type 'exit' to quit\n\n";
<< "Type 'exit' to quit\n\n";
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why you changed it, but anyway better put it on the same line as cout

eth/main.cpp Outdated
("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")
("json-rpc,j", "Enable JSON-RPC server (default: off).")
Copy link
Member

Choose a reason for hiding this comment

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

That was misleading description, let's change it to Enable the HTTP-RPC server (similar to geth)

eth/main.cpp Outdated
for (int i = 1; i < argc; ++i)
po::options_description clientDefaultMode("Client mode (default)");
clientDefaultMode.add_options()
("format", po::value<string>(), "<format> Set format.")
Copy link
Member

Choose a reason for hiding this comment

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

<binary/hex/human> Set the export format.

else if (arg == "--upnp" && i + 1 < argc)
}
#if ETH_EVMJIT
if (vm.count("vm"))
Copy link
Member

Choose a reason for hiding this comment

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

Don't indent the following line with brace (and if body)

eth/main.cpp Outdated
cerr << "provided genesis block description is not well formatted\n";
string genesisSample =
R"E(
R"E(
Copy link
Member

Choose a reason for hiding this comment

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

Don't change the indentation here

eth/main.cpp Outdated
rpc::NetFace, rpc::Web3Face, rpc::PersonalFace,
rpc::AdminEthFace, rpc::AdminNetFace, rpc::AdminUtilsFace,
rpc::DebugFace, rpc::TestFace
rpc::EthFace, rpc::WhisperFace,
Copy link
Member

Choose a reason for hiding this comment

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

No reason to change the indentation here

eth/main.cpp Outdated
adminEth, adminNet, adminUtils,
new rpc::Debug(*web3.ethereum()),
testEth
ethFace, new rpc::Whisper(web3, {}),
Copy link
Member

Choose a reason for hiding this comment

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

Don't change the indentation

eth/main.cpp Outdated
new rpc::AdminUtils(*sessionManager.get()),
new rpc::Debug(*web3.ethereum()),
testEth
ethFace, new rpc::Whisper(web3, {}), new rpc::Net(web3),
Copy link
Member

Choose a reason for hiding this comment

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

Don't change the indentation

ethkey/main.cpp Outdated
po::variables_map vm;
po::store(parsed, vm);
po::notify(vm);
if (vm.count("help")) {
Copy link
Member

Choose a reason for hiding this comment

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

Brace on a separate line

eth/main.cpp Outdated
for (int i = 1; i < argc; ++i)
po::options_description clientDefaultMode("Client mode (default)");
clientDefaultMode.add_options()
("format", po::value<string>(), "<format> Set format.")
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer these lines to be one tab indented, not 2 tabs like you did ( I don't see the reason to make it unusual 2 tabs and it can lead to some additional line breaks, which makes it harder to read)

eth/main.cpp Outdated
new rpc::AdminEth(*web3.ethereum(), *gasPricer.get(), keyManager, *sessionManager.get()),
new rpc::AdminNet(web3, *sessionManager.get()),
new rpc::AdminUtils(*sessionManager.get()),
new rpc::Debug(*web3.ethereum()),
Copy link
Member

@gumb0 gumb0 Nov 30, 2017

Choose a reason for hiding this comment

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

this doesn't compile, why did testeth disappear? fixed

eth/main.cpp Outdated
jsonrpcIpcServer->addConnector(ipcConnector);
ipcConnector->StartListening();
}
} testEth
Copy link
Member

@gumb0 gumb0 Nov 30, 2017

Choose a reason for hiding this comment

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

ah, here it is, please fix this

@gumb0
Copy link
Member

gumb0 commented Nov 30, 2017

I guess rlp/main.cpp shouldn't be part of this PR, as it's already in #4639 ? Remove it from here then

eth/main.cpp Outdated
Secret s(fromHex(vm["import-session-secret"].as<string>()));
toImport.emplace_back(s);
}
if (vm.count("help")) {
Copy link
Member

Choose a reason for hiding this comment

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

brace on a separate line

ethkey/main.cpp Outdated
("verbosity,v", po::value<int>(), "<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.");
po::parsed_options parsed = po::command_line_parser(argc, argv).options(generalOptions).allow_unregistered().run();
Copy link
Member

Choose a reason for hiding this comment

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

We should catch exceptions thrown from this, because parsing options can end with errors... See like I did it in #4639

@gumb0
Copy link
Member

gumb0 commented Dec 8, 2017

Squashed everything into one commit and rebased on develop. Tried not to loose anything.

@gumb0 gumb0 force-pushed the develop2 branch 2 times, most recently from 9011145 to f74b3ed Compare December 8, 2017 16:01
ethkey/main.cpp Outdated
("verbosity,v", po::value<int>(), "<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.");
po::parsed_options parsed = po::command_line_parser(argc, argv).options(generalOptions).allow_unregistered().run();
Copy link
Member

Choose a reason for hiding this comment

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

We should catch exceptions here, too

ethkey/main.cpp Outdated
<< "Options:" << endl << endl;
KeyCLI::streamHelp(cout);
cout << generalOptions;
exit(0);
Copy link
Member

Choose a reason for hiding this comment

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

Use return 0 instead of exit().

…boost.program_options doesn't support them. Help output improvements.
@gumb0
Copy link
Member

gumb0 commented Dec 11, 2017

For anyone interested here's the summary of non-backwards compatible changes affecting working command line options:

  • --testnet removed; use --ropsten instead;
  • undocumented --kill-blockchain removed; use --kill or -K instead;
  • --admin was not working, but undocumented --json-admin was working instead - this is fixed, now only --admin is working;
  • --author removed; use --address instead;
  • --public removed; use --public-ip instead;
  • --listen-port removed; use --listen instead;
  • --datadir and undocumented --path removed; use --db-path or -d instead.
  • import (without dashes) removed, use --import instead.
  • export (without dashes) removed, use --export instead.
  • undocumented --independent removed.

eth/main.cpp Outdated
listenIP = argv[++i];
listenSet = true;
cerr << "Invalid argument: " << unrecognisedOptions[i] << "\n";
exit(-1);
Copy link
Member

Choose a reason for hiding this comment

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

Missed one exit() here.

Copy link
Member

Choose a reason for hiding this comment

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

fixed

@holiman
Copy link
Contributor

holiman commented Dec 13, 2017

@gumb0
Copy link
Member

gumb0 commented Dec 13, 2017

@holiman Also this one https://github.com/karalabe/hive/blob/master/clients/cpp-ethereum:develop/eth.sh#L161
We recently removed HTTP server from eth, now instead of --json-rpc --json-rpc-port 8545 --admin-via-http you need to run scripts/jsonrpcproxy.py

@gumb0 gumb0 merged commit 19bf103 into ethereum:develop Dec 13, 2017
@holiman
Copy link
Contributor

holiman commented Dec 13, 2017

Can that be started before eth, or does eth need to create the ipc file first?

@holiman
Copy link
Contributor

holiman commented Dec 13, 2017

@karalabe does hive use the HTTP endpoints, or the ipc endpoints when the simulator queries the nodes?

@gumb0
Copy link
Member

gumb0 commented Dec 13, 2017

@holiman I think eth should be started first

@chfast
Copy link
Member

chfast commented Dec 13, 2017

It should not matter. In case it does let me know.

@gumb0
Copy link
Member

gumb0 commented Dec 13, 2017

@chfast It looks like it doesn't find ipc socket when starting it wihout runnin eth:

> scripts/jsonrpcproxy.py
Traceback (most recent call last):
  File "scripts/jsonrpcproxy.py", line 156, in <module>
    run()
  File "scripts/jsonrpcproxy.py", line 151, in run
    proxy = Proxy(args.proxy_url, args.backend_path)
  File "scripts/jsonrpcproxy.py", line 113, in __init__
    self.sock = get_ipc_socket(self.backend_address)
  File "scripts/jsonrpcproxy.py", line 69, in get_ipc_socket
    sock.connect(ipc_path)
FileNotFoundError: [Errno 2] No such file or directory

@chfast
Copy link
Member

chfast commented Dec 13, 2017

Ok. I will fix it later on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants