Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

NC-1737 Enabled warning on CLI dependent options #679

Merged

Conversation

NicolasMassart
Copy link
Contributor

PR description

This mechanism is aimed at preventing the use of options if the associated
service is disabled. This is not a generic system as our need is simple here.
But in future version of PicoCLI some options dependency mechanism may be
implemented that could replace this.
See remkop/picocli#295
Our current mechanism apply to p2p, rpc (http+ws), mining, privacy and metrics.

Also renamed inconsistent isRpcHttpEnabled option variable and moved
--privacy-enabled option to be on top of other privacy options.

Related tests where added or updated and renamed.

Fixed Issue(s)

fixes NC-1737

…options

This mechanism is aimed at preventing the use of options if the associated
service is disabled. This is not a generic system as our need is simple here.
But in future version of PicoCLI some options dependency mechanism may be
implemented that could replace this.
See remkop/picocli#295
Our current mechanism apply to p2p, rpc (http+ws), mining, privacy and metrics.

Also renamed inconsistent isRpcHttpEnabled option variable and moved
--privacy-enabled option to be on top of other privacy options.

Related tests where added or updated and renamed.
@NicolasMassart NicolasMassart changed the title Enabled warning on CLI dependent options NC-1737 Enabled warning on CLI dependent options Jan 28, 2019
@NicolasMassart NicolasMassart added the api Related to public APIs label Jan 28, 2019
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

Codewise this is fine, however, I don't think we should perform this validation. It's incredibly useful to be able to temporarily disable things like p2p networking without also having to delete multiple other options which could have been easily ignored.

For mining this is particularly true - it's very common to want to configure the coinable and extra data on the command line but then only enable mining at specific times via the JSON-RPC method. With this change that's not possible and you'd have to configure it all via JSON-RPC. I'm a little less concerned about the other options but we definitely shouldn't break this mining use case.

@shemnon
Copy link
Contributor

shemnon commented Jan 28, 2019

How does this interact with TOML files, can I leave in all the useless config I feel like there? would this just validate CLI?

@NicolasMassart
Copy link
Contributor Author

As this is just enforcing the relationship between options and not changing how options work and given the fact that there's no consensus on the need of this change, I propose that we don't include it in the 0.9 release.
Also @shemnon I confirm these rules are not enforced in config files.

@jakehaugen
Copy link
Contributor

If I'm thinking about this correctly, the goal of this change is to make it clear to the user what options are dependent on each other. The end goal is to avoid people assuming something is "on" because they've configured it. We could accomplish this by allowing them to configure the options but show a "warning" that they will have no impact until the feature is enabled. So, essentially change this from an "error" to a "warning". Does that solve our problem by communicating the dependency but still allowing things to be temporarily disabled/enabled in situations like @ajsutton called out?

@shemnon
Copy link
Contributor

shemnon commented Jan 29, 2019

I like the compromise that the CLI output will be noisy when unusable CLI flags are used. "I set the --rpc-http=port to 8545, why won't it work? Oh --rpc-http-enable!"

@ajsutton
Copy link
Contributor

Yep, logging a warning makes a lot of sense to me.

NicolasMassart and others added 11 commits January 29, 2019 13:35
injects a Logger in PantheonCommand constructor to log instead of throwing an
error and also provides injection capabilities for a mock in tests.
adds unit tests
updates tests logger name to TEST_LOGGER to prevent confusion with the mock
# Conflicts:
#	pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
…ng-peers

remove --max-trailing-peers after merge with master where it was deleted
…o NC-1737_api_enabled_warning

# Conflicts:
#	pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
shemnon and others added 4 commits January 29, 2019 17:01
…ils.java


Change wording

Co-Authored-By: NicolasMassart <NicolasMassart@users.noreply.github.com>
…nd.java


updated rules for metrics

Co-Authored-By: NicolasMassart <NicolasMassart@users.noreply.github.com>
@NicolasMassart NicolasMassart merged commit 67b42e3 into PegaSysEng:master Jan 29, 2019
@NicolasMassart NicolasMassart deleted the NC-1737_api_enabled_warning branch January 30, 2019 16:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api Related to public APIs
Projects
None yet
4 participants