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(x/auth): app wiring setup #12019

Merged
merged 34 commits into from
May 27, 2022
Merged

feat(x/auth): app wiring setup #12019

merged 34 commits into from
May 27, 2022

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented May 23, 2022

Description

Ref #11899
After #11924 (this is based on the branch for that PR so the diff will get smaller after that's merged)


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)

@@ -44,8 +43,6 @@ type App struct {
beginBlockers []func(sdk.Context, abci.RequestBeginBlock)
endBlockers []func(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
baseAppOptions []BaseAppOption

msgServiceRegistrar grpc.Server
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 no longer needed and not provided by x/auth

Comment on lines +220 to +221
k := keeper.NewAccountKeeper(cdc, key, subspace, types.ProtoBaseAccount, maccPerms, config.Bech32Prefix)
m := NewAppModule(cdc, k, simulation.RandomGenesisAccounts)
Copy link
Member Author

Choose a reason for hiding this comment

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

types.ProtoBaseAccount and simulation.RandomGenesisAccounts are used here always instead of having configuration parameters. I propose that we handle this configuration in a separate PR. See #12055

@aaronc aaronc marked this pull request as ready for review May 26, 2022 16:30
@aaronc aaronc requested a review from a team as a code owner May 26, 2022 16:30
x/auth/module.go Outdated Show resolved Hide resolved
@@ -231,7 +233,7 @@ func NewSimApp(
runtimeApp := appBuilder.Build(logger, db, traceStore, baseAppOptions...)

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
Copy link
Member

Choose a reason for hiding this comment

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

Bit of an issue here surfaced in tests.
authTypes.Store = "acc" (not "auth"), but runtime.ProvideKVStoreKey makes the assumption that storeKey = moduleName ("auth")

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm... this could be an issue when migrating existing stores. One option is to give the module the name acc in the app config. In general I think the existing practice of hard coding these names is wrong, but we need to cope with how things are currently done too... we'll need to think about this a bit

Copy link
Member Author

Choose a reason for hiding this comment

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

Two options I can think of:

  1. Let modules give a store key name, not a huge fan of this
  2. Let users specify an alternate store key name for a module in the runtime config

Sort of leaning towards 2

Copy link
Contributor

Choose a reason for hiding this comment

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

I favor (2) as well (key overrides)

Copy link
Member

Choose a reason for hiding this comment

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

implementation of (2) pushed for review in 90759ac


// module_store_keys is an optional list of overrides for the module store keys
// used in keeper construction.
repeated ModuleStoreKey module_store_keys = 6;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
repeated ModuleStoreKey module_store_keys = 6;
repeated ModuleStoreKey override_store_keys = 6;

string module_name = 1;

// the store key to use instead of the module name.
string store_key = 2;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
string store_key = 2;
string kv_store_key = 2;


// ModuleStoreKey may be supplied to override the default module store key, which
// is the module name.
message ModuleStoreKey {
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
message ModuleStoreKey {
message StoreKeyConfig {

@@ -397,7 +397,6 @@ func NewSimApp(
app.ModuleManager.RegisterInvariants(&app.CrisisKeeper)
app.ModuleManager.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.ModuleManager.RegisterServices(app.configurator)
Copy link
Member

@kocubinski kocubinski May 27, 2022

Choose a reason for hiding this comment

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

Already called once in runtime/app so removing this call.

* only implement kv store key overrides.
* configurator in runtime/app and create getter fn for tests
* refactor test usages of configurator fetching
@codecov
Copy link

codecov bot commented May 27, 2022

Codecov Report

Merging #12019 (7dadcf7) into main (81ee241) will increase coverage by 0.03%.
The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12019      +/-   ##
==========================================
+ Coverage   66.06%   66.09%   +0.03%     
==========================================
  Files         671      671              
  Lines       70924    70936      +12     
==========================================
+ Hits        46856    46887      +31     
+ Misses      21411    21391      -20     
- Partials     2657     2658       +1     
Impacted Files Coverage Δ
simapp/upgrades.go 6.38% <0.00%> (ø)
x/auth/module.go 63.29% <93.75%> (+8.60%) ⬆️
simapp/app.go 83.33% <100.00%> (-0.16%) ⬇️
crypto/keys/internal/ecdsa/privkey.go 81.13% <0.00%> (-1.89%) ⬇️
x/params/module.go 69.84% <0.00%> (+3.17%) ⬆️
x/distribution/simulation/operations.go 90.10% <0.00%> (+9.89%) ⬆️

@aaronc aaronc merged commit dfe29ee into main May 27, 2022
@aaronc aaronc deleted the aaronc/app-wiring-auth branch May 27, 2022 20:54
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants