-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
CLI/keys: define default supported keyring algorithms #8825
Conversation
This commit lets developer define what algorithms Keyring supports instead of relying on just keyring.New options. This change is needed since it allows us to support those algorithms in CLI commands too without subverting their current execution flow.
Codecov Report
@@ Coverage Diff @@
## master #8825 +/- ##
==========================================
- Coverage 59.24% 59.23% -0.01%
==========================================
Files 571 571
Lines 31807 31800 -7
==========================================
- Hits 18844 18837 -7
- Misses 10760 10761 +1
+ Partials 2203 2202 -1
|
Since Simulate is now used in both tx and query commands, move its reading routine into ReadPersistentCommandFlags. Removed DryRun from Context, since it's not needed anymore.
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACKed
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=7d230ad05e1514cc4e7a1d2175eada87fd5dde9e |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=0033cb024854468eb46b7623454cb42c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Please don't use globals for controlling a constructor behavior.
BTW: I was also looking at this code last week, and felt a need to make a simapp keys list-algos
command: #8886
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=1c573ddfeebd11607cdab08e7085bc27a361bbbb |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=ae4c2b8323951e0ec843620c528cf571228b27c9 |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=5d842bc99b774e178f8f3568bf103097 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Tests needs to be udpated (it's still using the old, failing logic)
- Context obfuscates the flow, and makes it hard to see how the parameters are passed. I propose a way to not use context - if you like we can have a chat.
- Documentation (
/docs
) and Changelog has to be updated as well.
if ctx.GenerateOnly { | ||
return keyring.New(sdk.KeyringServiceName(), keyring.BackendMemory, ctx.KeyringDir, ctx.Input) | ||
if ctx.GenerateOnly || ctx.Simulate { | ||
return keyring.New(sdk.KeyringServiceName(), keyring.BackendMemory, ctx.KeyringDir, ctx.Input, ctx.KeyringOptions...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a context, can we use it in a straight way? Using a context obfuscates a flow. We should use function parameters wherever possible.
The ReadPersistentCommandFlags
has access to flagSet
- a set of defined flags. newKeyringFromFlags
is called in that function. So we can use flagSet
to carry the information (from config or cli flag) about supported algos. We could also add one more structural parameter to the ReadPersistentCommandFlags
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Robert, I agree with you on "using a context obfuscates a flow". Fully. I am a big fan of function parameters. I hate any stateful context and I hate even more using contexts to conveniently pack variables in order to reduce the number of function's arguments because that means that you are keen to sacrifice transparency and ease of debugging for the lazy developer's sake.
And yet, this is what we have now. I like your proposed changes, but I believe they are out of scope here. We should open another issue and try to overhaul the Context in a more holistic way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but I would like to avoid adding more XOptions
directly into config, and I'm worried that someone else from other team will be motivated to do it (by following an example of what's already implemented)
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=f7a86fac39e0d17149093a401b20eedb00a716bf |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=bca31cb80c494b359a048ba45a63a543 |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=b22f83087ec55d0a1e489f4407ebe96d21598e5d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to put configs into a Context sub structure (not as a direct context attribute). But for short term this is good enough.
I created an issue to tackle the config problem: #8915
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=3090574b36246eecec0ad05efea2216b5ef23b1c |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=deaee531111fb4aad3ccabbfa6771f9a67ae42ce |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=6ed005157d684478afdd4ef199bcd44b |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=540cd0b6a7a04c1fa678feb11bad6fee |
Description
This PR adds a way for developers to specify a suite of algorithms to be used in keyring instances instantiated with
keyring.New()
.While
New()
already has ways of achieving something similar doing so in CLI commands, in a generic enough way, is very hard.We address this by providing package-level settings in
keyring
to define a defaultSigningAlgoList
, automatically used in every keyring initialization phase.This PR streamlines also the
keys add
command execution flow by using the Keyring included in the CLI context instead of instantiating a new one.closes: #8803
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes