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

feat: add basic autocli config to every module #13786

Merged
merged 12 commits into from
Nov 9, 2022

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Nov 7, 2022

Description

Closes: #13293

This just adds the most basic necessary configuration to each module (essentially the name of the query and msg services). We can deal with more customization and help text in follow-ups.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Nov 7, 2022

Codecov Report

Merging #13786 (6087514) into main (4f7d9ea) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13786      +/-   ##
==========================================
- Coverage   56.78%   56.70%   -0.08%     
==========================================
  Files         644      637       -7     
  Lines       54952    54585     -367     
==========================================
- Hits        31203    30951     -252     
+ Misses      21210    21130      -80     
+ Partials     2539     2504      -35     
Impacted Files Coverage Δ
x/auth/module.go 56.17% <ø> (-0.97%) ⬇️
x/auth/autocli.go 100.00% <100.00%> (ø)
x/gov/autocli.go 100.00% <100.00%> (ø)
x/group/keeper/keeper.go 56.25% <0.00%> (-0.40%) ⬇️
tx/textual/valuerenderer/string.go
tx/textual/valuerenderer/message.go
tx/textual/valuerenderer/dec.go
tx/textual/valuerenderer/bytes.go
tx/textual/valuerenderer/coins.go
tx/textual/valuerenderer/timestamp.go
... and 4 more

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

left one comment, it looks good

Comment on lines 5 to 8
var AutoCLIOptions = &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{Service: _Query_serviceDesc.ServiceName},
Tx: &autocliv1.ServiceCommandDescriptor{Service: _Msg_serviceDesc.ServiceName},
}
Copy link
Member

Choose a reason for hiding this comment

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

could we add a quick few sentences on what each of these do in a doc. We can expand on it later.

@julienrbrt
Copy link
Member

julienrbrt commented Nov 7, 2022

How should we describe that in the docs? Do you think it worth to add a page in https://docs.cosmos.network/main/building-modules/{...} specifically for AutoCLI?

julienrbrt
julienrbrt previously approved these changes Nov 7, 2022
@pysel
Copy link
Contributor

pysel commented Nov 8, 2022

hello @aaronc. Me and @faddat are currently trying to implement autocli for Osmosis here. We implemented autocli on valset-pref module, but it seems like it does not do anything now. If possible, we would be really really really grateful for any clarification on what we might be doing wrong. Thanks in advance

@tac0turtle
Copy link
Member

hello @aaronc. Me and @faddat are currently trying to implement autocli for Osmosis here. We implemented autocli on valset-pref module, but it seems like it does not do anything now. If possible, we would be really really really grateful for any clarification on what we might be doing wrong. Thanks in advance

it doesn't seem like you have wired this up in the app.go, we will work on docs so it might help to wait for those.

@aaronc
Copy link
Member Author

aaronc commented Nov 8, 2022

@RusAkh we don't have a full to end setup ready for this yet. I will be working on showing integration with the actual CLI in a follow-up PR. Also only queries are supported thus far. A bunch of pieces still need to be built

@aaronc
Copy link
Member Author

aaronc commented Nov 8, 2022

One thing I'm considering is if we can auto-discover the config for modules with only one query and msg service. Maybe that should be the default rather than needing it to be explicit like I did in this PR. You should only need to add the config manually if there's customization needed and/or multiple services.

@pysel
Copy link
Contributor

pysel commented Nov 8, 2022

thank you for your response @aaronc! I will look into next pr then.

@aaronc aaronc marked this pull request as ready for review November 8, 2022 14:34
@aaronc aaronc dismissed julienrbrt’s stale review November 8, 2022 14:36

I made substantial changes so it would be good to get it re-approved

@aaronc
Copy link
Member Author

aaronc commented Nov 8, 2022

I changed it so that it auto-discovers options where it can. The PR is now substantially different and smaller.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm! few nits

@@ -35,4 +62,25 @@ func (a AutoCLIQueryService) AppOptions(context.Context, *autocliv1.AppOptionsRe
}, nil
}

type autocliConfigurator struct {
Copy link
Member

Choose a reason for hiding this comment

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

Nit move that down next to its methods.
Can you explain the use case?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just so that we can call RegisterServices to discover the module's service names.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this PR using the configurator approach is an intermediary solution, right? I'm in favor of removing the Configurator interface ultimately (since we're going the interfaces approach)

AppModule's RegisterServices should be simply RegisterServices(grpc.ServiceRegistrar), which would remove autocliConfigurator from this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly

x/auth/autocli.go Show resolved Hide resolved
x/auth/autocli.go Outdated Show resolved Hide resolved
x/auth/autocli.go Outdated Show resolved Hide resolved
aaronc and others added 4 commits November 8, 2022 10:08
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@aaronc
Copy link
Member Author

aaronc commented Nov 8, 2022

Could I get one more review here @tac0turtle or @AmauryM ?

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM

Service: govv1.Msg_ServiceDesc.ServiceName,
// map v1beta1 as a sub-command
SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{
"v1beta1": {Service: govv1beta1.Msg_ServiceDesc.ServiceName},
Copy link
Contributor

Choose a reason for hiding this comment

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

autocli is not wired up to simd's root cmd, right? When I try simd q gov there's no v1beta1 subcommand. I guess there's only the remote info part of autocli for now

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly

@@ -22,6 +24,31 @@ func NewAutoCLIQueryService(appModules map[string]module.AppModule) *AutoCLIQuer
AutoCLIOptions() *autocliv1.ModuleOptions
}); ok {
moduleOptions[modName] = autoCliMod.AutoCLIOptions()
} else {
// try to auto-discover options based on the last msg and query
Copy link
Contributor

Choose a reason for hiding this comment

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

I was asking above because what happens when we wire up autocli with the root cobra command, and there are conflicts in command names between this auto-discovered one and custom ones?

Copy link
Member Author

Choose a reason for hiding this comment

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

AutoCLI prefers the custom commands

@@ -35,4 +62,25 @@ func (a AutoCLIQueryService) AppOptions(context.Context, *autocliv1.AppOptionsRe
}, nil
}

type autocliConfigurator struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this PR using the configurator approach is an intermediary solution, right? I'm in favor of removing the Configurator interface ultimately (since we're going the interfaces approach)

AppModule's RegisterServices should be simply RegisterServices(grpc.ServiceRegistrar), which would remove autocliConfigurator from this file.

@amaury1093 amaury1093 enabled auto-merge (squash) November 9, 2022 10:41
@amaury1093 amaury1093 merged commit bcdf81c into main Nov 9, 2022
@amaury1093 amaury1093 deleted the aaronc/autocli-all-modules branch November 9, 2022 11:44
@julienrbrt julienrbrt mentioned this pull request Nov 9, 2022
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AutoCLI options for each module
5 participants