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

Extended permissions for module accounts #4679

Merged
merged 16 commits into from
Jul 6, 2019

Conversation

colin-axner
Copy link
Contributor

@colin-axner colin-axner commented Jul 3, 2019

Extended permissions to allow ModuleAccounts to take in multiple permissions
addresses #4652

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry: clog add [section] [stanza] [message]

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Jul 3, 2019

Codecov Report

Merging #4679 into master will increase coverage by 0.1%.
The diff coverage is 85.03%.

@@            Coverage Diff            @@
##           master    #4679     +/-   ##
=========================================
+ Coverage   54.05%   54.16%   +0.1%     
=========================================
  Files         271      271             
  Lines       17281    17341     +60     
=========================================
+ Hits         9342     9392     +50     
- Misses       7257     7266      +9     
- Partials      682      683      +1

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Idk if we want to add the option to register new types of permissions cc: @alexanderbez ?

docs/spec/supply/01_concepts.md Outdated Show resolved Hide resolved
x/supply/internal/keeper/keeper.go Outdated Show resolved Hide resolved
x/supply/internal/keeper/keeper.go Outdated Show resolved Hide resolved
x/supply/internal/types/permissions.go Outdated Show resolved Hide resolved
x/supply/internal/types/account.go Outdated Show resolved Hide resolved
x/supply/internal/types/account.go Outdated Show resolved Hide resolved
x/supply/internal/keeper/account.go Outdated Show resolved Hide resolved
x/supply/internal/types/permissions.go Outdated Show resolved Hide resolved
x/supply/internal/keeper/test_common.go Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Looks good @colin-axner -- I left some initial feedback ☕️

.pending/breaking/sdk/4652-Extend-supply-p Outdated Show resolved Hide resolved
simapp/app.go Outdated Show resolved Hide resolved
x/auth/test_common.go Outdated Show resolved Hide resolved
x/supply/alias.go Show resolved Hide resolved
x/supply/internal/keeper/bank.go Outdated Show resolved Hide resolved
x/supply/internal/keeper/bank.go Outdated Show resolved Hide resolved
x/supply/internal/keeper/bank.go Outdated Show resolved Hide resolved
x/supply/internal/keeper/bank.go Outdated Show resolved Hide resolved
x/supply/internal/types/permissions.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor

Idk if we want to add the option to register new types of permissions cc: @alexanderbez ?

Probably for another PR @fedekunze -- we need to think further on what that model/logic looks like.

@colin-axner
Copy link
Contributor Author

So I updated supply to have two validate permission functions. One does basic syntax validation (we could add stricter checks but rn just checks permission isn't an empty string), the other is in Keeper and checks that the permission is contained in the mapping of allowed permissions for that module account. Not sure if we want sorted permissions in permAddrs but probably should be separate pr if we do.

Permissions can be added removed from a ModuleAccount but not from a PermAddr. I could add Register/Deregister (Add/Remove) functions for PermAddr but wanted to leave out for now.

In short, upon initialization of Keeper all module accounts and possible permissions must be specified. k.ValidatePermissions verifies that a module account only has its allowed permissions, but I'm not sure how to enforce usage of this function

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK pending CI and merge conflict fixes 👍

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM. Only minor changes suggested.

We will need to update Gaia and the migration PR once this is merged

x/auth/test_common.go Outdated Show resolved Hide resolved
x/mint/internal/keeper/test_common.go Outdated Show resolved Hide resolved
x/mint/internal/keeper/test_common.go Outdated Show resolved Hide resolved
x/supply/internal/types/permissions.go Outdated Show resolved Hide resolved
x/supply/internal/types/permissions.go Outdated Show resolved Hide resolved
@alexanderbez alexanderbez merged commit 1c9a188 into master Jul 6, 2019
@alexanderbez alexanderbez deleted the colin/4652-extend-supply-permissions branch July 6, 2019 19:42
@fedekunze fedekunze mentioned this pull request Jul 11, 2019
4 tasks
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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants