Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/utils: don't enumerate usb when --usb isn't set #22130

Merged
merged 3 commits into from
Jan 13, 2021

Conversation

gballet
Copy link
Member

@gballet gballet commented Jan 6, 2021

USB enumeration still occured. Make sure it will only occur if --usb is set.

@gballet gballet requested a review from fjl January 6, 2021 16:06
if ctx.GlobalIsSet(USBFlag.Name) {
cfg.NoUSB = !ctx.GlobalBool(USBFlag.Name)
}
cfg.NoUSB = !ctx.GlobalIsSet(USBFlag.Name) || !ctx.GlobalBool(USBFlag.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not right and it will break the config file.
What needs to happen is: the default of NoUSB in the struct needs to be made true.
Then, if the flag is set, it needs to be changed to false.

If someone has NoUSB = false in the config file, it should still work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since it doesn't seem to set default values in the deserializer, the default has to be set either before or after deserializing. How do you propose to distinguish the case when NoUSB is absent from the TOML file, from the case when the user explicitly set NoUSB = false ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is very unlikely that people will want to set NoUSB = false because until now, NoUSB = false was the default and now if they want to enable USB by default they don't have an option for that yet. What I suggest is also add a USB command in the config that will default to false, and that people can set to true.

@gballet gballet requested a review from renaynay as a code owner January 7, 2021 09:53
@gballet
Copy link
Member Author

gballet commented Jan 7, 2021

@fjl I iintroduced a config.USB option to remove the ambiguity introduced by the previous PR. If people set config.NoUSB in their TOML file, then it will display a warning. If people want to enable USB by default, they can either use --usb or set USB = true in their TOML config file.

Copy link
Contributor

@renaynay renaynay left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman
Copy link
Contributor

holiman commented Jan 9, 2021

I think there are a few more places you could clean up.

[user@work go-ethereum]$ grep -r "nousb" .
./cmd/geth/les_test.go:	args = append([]string{"--networkid=42", "--port=0", "--nousb", "--ipcpath", ipcName}, args...)
./cmd/geth/les_test.go:	args := []string{"--nousb", "--networkid=42", "init", "./testdata/clique.json"}
...

@gballet gballet added this to the 1.10.0 milestone Jan 13, 2021
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@fjl fjl merged commit c7a6be1 into ethereum:master Jan 13, 2021
bulgakovk pushed a commit to bulgakovk/go-ethereum that referenced this pull request Jan 26, 2021
USB enumeration still occured. Make sure it will only occur if --usb is set.
This also deprecates the 'NoUSB' config file option in favor of a new option 'USB'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants