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: introduce censorship into x/foundation #912

Merged
merged 15 commits into from
Mar 14, 2023
Merged

Conversation

0Tech
Copy link
Collaborator

@0Tech 0Tech commented Feb 23, 2023

Description

This patch would:

  • introduce Censorship, which has its target message type url and authority.
    • its authority must be one of the following enum values:
      • CENSORSHIP_AUTHORITY_GOVERNANCE
      • CENSORSHIP_AUTHORITY_FOUNDATION
    • the authority can trigger the following messages on its target message type url:
      • /lbm.foundation.v1.MsgUpdateCensorship
      • /lbm.foundation.v1.MsgGrant
      • /lbm.foundation.v1.MsgRevoke
  • introduce /lbm.foundation.v1.MsgUpdateCensorship, which updates censorship information.
    • the corresponding enum value of the new authority must be lesser than the current one.
    • one may remove (or stop) the censorship by setting its authority to CENSORSHIP_AUTHORITY_UNSPECIFIED.
  • introduce FoundationExecProposal which allows x/gov's authority to trigger x/foundation's messages.
    • the signer(s) of the message MUST be x/gov's authority.
    • For now, only the following messages are allowed:
      • /lbm.foundation.v1.MsgUpdateCensorship
      • /lbm.foundation.v1.MsgGrant
      • /lbm.foundation.v1.MsgRevoke

closes: #910

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@0Tech 0Tech added A: improvement Changes in existing functionality C:x/foundation x/foundation module labels Feb 23, 2023
@0Tech 0Tech self-assigned this Feb 23, 2023
@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Merging #912 (3e709e3) into main (81fec6d) will increase coverage by 0.01%.
The diff coverage is 71.47%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #912      +/-   ##
==========================================
+ Coverage   62.34%   62.36%   +0.01%     
==========================================
  Files         653      655       +2     
  Lines       79485    79759     +274     
==========================================
+ Hits        49558    49741     +183     
- Misses      27248    27334      +86     
- Partials     2679     2684       +5     
Impacted Files Coverage Δ
x/foundation/client/testutil/grpc.go 91.89% <ø> (-0.61%) ⬇️
x/foundation/keeper/grpc_query.go 3.90% <0.00%> (-0.38%) ⬇️
x/foundation/keeper/keeper.go 89.47% <ø> (ø)
x/foundation/msgs.go 67.63% <0.00%> (-3.94%) ⬇️
x/foundation/proposal.go 5.40% <5.40%> (ø)
x/foundation/codec.go 45.45% <33.33%> (-1.92%) ⬇️
x/foundation/foundation.go 85.32% <70.00%> (-0.48%) ⬇️
x/foundation/genesis.go 82.91% <84.21%> (+0.05%) ⬆️
x/foundation/keeper/proposal_handler.go 85.29% <85.29%> (ø)
x/foundation/keeper/msg_server.go 87.11% <90.47%> (+0.15%) ⬆️
... and 9 more

x/foundation/README.md Show resolved Hide resolved
x/foundation/client/cli/query.go Show resolved Hide resolved
x/foundation/msgs.go Show resolved Hide resolved
@0Tech 0Tech marked this pull request as ready for review February 23, 2023 09:31
x/foundation/README.md Outdated Show resolved Hide resolved
dudong2
dudong2 previously approved these changes Feb 28, 2023
Copy link
Contributor

@dudong2 dudong2 left a comment

Choose a reason for hiding this comment

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

LGTM

dudong2
dudong2 previously approved these changes Mar 10, 2023
Copy link
Member

@tkxkd0159 tkxkd0159 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
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

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

How can we move the auth of CreateValidatorAuthorization from x/foundation to x/gov?

@0Tech
Copy link
Collaborator Author

0Tech commented Mar 14, 2023

How can we move the auth of CreateValidatorAuthorization from x/foundation to x/gov?

Please refer to the corresponding item in the description of this PR:

introduce /lbm.foundation.v1.MsgUpdateCensorship, which updates censorship information.

You can change the authority into CENSORSHIP_AUTHORITY_GOVERNANCE.

@0Tech 0Tech requested a review from zemyblue March 14, 2023 05:01
Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

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

Do you mean we need to use MsgUpdateCencorship if you want to move the auth.
But the autht to want to change should be lower the enum number. Is it right?

x/foundation/keeper/censorship.go Show resolved Hide resolved
@0Tech 0Tech requested a review from zemyblue March 14, 2023 06:21
@0Tech 0Tech merged commit d9428ec into Finschia:main Mar 14, 2023
@0Tech 0Tech deleted the censorship branch March 14, 2023 08:17
Comment on lines +171 to +177
authorityAddrs := map[foundation.CensorshipAuthority]string{
foundation.CensorshipAuthorityGovernance: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
foundation.CensorshipAuthorityFoundation: k.authority,
}
if expected := authorityAddrs[censorship.Authority]; authority != expected {
return sdkerrors.ErrUnauthorized.Wrapf("invalid authority; expected %s, got %s", expected, authority)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think it's good to use if-else, how about this?

zemyblue pushed a commit to zemyblue/finschia-sdk that referenced this pull request Mar 17, 2023
* Add censorship into proto

* Implement censorship

* Add FoundationExecProposal to proto

* Implement FoundationExecProposal

* Update documentation

* Update CHANGELOG.md

* Rename files

* Lint

* Add amino test on MsgUpdateCensorship

* Add pagination on cli

* Update x/foundation/README.md

* Update proposal cli description

* Chore

* Apply feedbacks

(cherry picked from commit d9428ec)
zemyblue added a commit that referenced this pull request Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: improvement Changes in existing functionality C:x/foundation x/foundation module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move controls of CreateValidatorAuthorization from x/foundation to x/gov
6 participants