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 UpdateRegistry msg for gov proposal to update the token registry #1486

Merged
merged 4 commits into from
Nov 12, 2022

Conversation

gsk967
Copy link
Collaborator

@gsk967 gsk967 commented Oct 7, 2022

Description

closes: #1001

This pull request contains below changes:

  1. Removed leverage proposal handler for update registry
  2. Add MsgGovUpdateRegistry
  3. Add UpdateRegistry Proposal from gov tx
  4. Add tests for MsgGovUpdateRegistry in msg_server

Sample proposal.json for submit the proposal from gov

Note : creator address will be the gov module address

{
    "messages": [
        {
            "@type": "/umee.leverage.v1.MsgGovUpdateRegistry",
            "authority": "umee10d07y265gmmuvt4z0w9aw880jnsr700jg5w6jp",
            "title": "Update the Leverage Token Registry",
            "description": "Update the uumee token in the leverage registry.",
            "add_tokens": [
                {
                    "base_denom": "uumee",
                    "reserve_factor": "0.100000000000000000",
                    "collateral_weight": "0.050000000000000000",
                    "liquidation_threshold": "0.050000000000000000",
                    "base_borrow_rate": "0.020000000000000000",
                    "kink_borrow_rate": "0.200000000000000000",
                    "max_borrow_rate": "1.500000000000000000",
                    "kink_utilization": "0.200000000000000000",
                    "liquidation_incentive": "0.100000000000000000",
                    "symbol_denom": "UMEE",
                    "exponent": 6,
                    "enable_msg_supply": true,
                    "enable_msg_borrow": true,
                    "blacklist": false,
                    "max_collateral_share": "0.900000000000000000",
                    "max_supply_utilization": "0.900000000000000000",
                    "min_collateral_liquidity": "0.900000000000000000",
                    "max_supply": "123123"
                },
            ],
            "update_tokens": [
                {
                    "base_denom": "uatom",
                    "reserve_factor": "0.100000000000000000",
                    "collateral_weight": "0.050000000000000000",
                    "liquidation_threshold": "0.050000000000000000",
                    "base_borrow_rate": "0.020000000000000000",
                    "kink_borrow_rate": "0.200000000000000000",
                    "max_borrow_rate": "1.500000000000000000",
                    "kink_utilization": "0.200000000000000000",
                    "liquidation_incentive": "0.100000000000000000",
                    "symbol_denom": "ATOM",
                    "exponent": 6,
                    "enable_msg_supply": true,
                    "enable_msg_borrow": true,
                    "blacklist": false,
                    "max_collateral_share": "0.900000000000000000",
                    "max_supply_utilization": "0.900000000000000000",
                    "min_collateral_liquidity": "0.900000000000000000",
                    "max_supply": "123123"
                },
            ]
        }
    ],
    "metadata": "AQ==",
    "deposit": "100uumee"
}

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
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • 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 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)

@gsk967 gsk967 requested a review from a team as a code owner October 7, 2022 17:11
@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2022

Codecov Report

Merging #1486 (88794b3) into main (b40ed0d) will increase coverage by 2.86%.
The diff coverage is 38.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1486      +/-   ##
==========================================
+ Coverage   52.47%   55.33%   +2.86%     
==========================================
  Files          73       66       -7     
  Lines        7040     6636     -404     
==========================================
- Hits         3694     3672      -22     
+ Misses       3073     2691     -382     
  Partials      273      273              
Impacted Files Coverage Δ
x/leverage/types/msgs.go 4.61% <4.61%> (ø)
x/leverage/types/codec.go 48.27% <50.00%> (+5.85%) ⬆️
x/leverage/keeper/token.go 72.72% <68.42%> (-3.28%) ⬇️
x/leverage/keeper/keeper.go 66.28% <100.00%> (+0.12%) ⬆️
x/leverage/keeper/msg_server.go 11.91% <100.00%> (+10.95%) ⬆️
x/leverage/client/cli/tx.go
x/leverage/module.go
x/leverage/genesis.go
x/leverage/abci.go
x/leverage/client/cli/query.go

@gsk967
Copy link
Collaborator Author

gsk967 commented Oct 7, 2022

@robert-zaremba should we remove NewCmdSubmitUpdateRegistryProposal from tx.go in leverage module and gov proposal handler from app.go ?

x/leverage/types/msgs.go Outdated Show resolved Hide resolved
toteki
toteki previously requested changes Oct 7, 2022
Copy link
Member

@toteki toteki left a comment

Choose a reason for hiding this comment

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

Could we make x/leverage follow the pattern seen elsewhere in the sdk, with

// GetAuthority returns the x/leverage module's authority.
func (k Keeper) GetAuthority() string {
	return k.authority
}

with k.authority set to authtypes.NewModuleAddress(govtypes.ModuleName).String()?

Similarly, MsgUpdateRegistry field Creator can be renamed to Authority and any mismatch should be rejected with err "expected gov account as only signer for proposal message"

See x/bank example

@toteki
Copy link
Member

toteki commented Oct 7, 2022

@robert-zaremba should we remove NewCmdSubmitUpdateRegistryProposal from tx.go in leverage module and gov proposal handler from app.go ?

The old proposal type can be removed in this PR, since we're adding the new one.

@gsk967
Copy link
Collaborator Author

gsk967 commented Oct 7, 2022

@robert-zaremba should we remove NewCmdSubmitUpdateRegistryProposal from tx.go in leverage module and gov proposal handler from app.go ?

The old proposal type can be removed in this PR, since we're adding the new one.

Ok

@gsk967
Copy link
Collaborator Author

gsk967 commented Oct 7, 2022

Could we make x/leverage follow the pattern seen elsewhere in the sdk, with

// GetAuthority returns the x/leverage module's authority.
func (k Keeper) GetAuthority() string {
	return k.authority
}

with k.authority set to authtypes.NewModuleAddress(govtypes.ModuleName).String()?

Similarly, MsgUpdateRegistry field Creator can be renamed to Authority and any mismatch should be rejected with err "expected gov account as only signer for proposal message"

See x/bank example

I updated the changes with authority

@gsk967 gsk967 requested a review from toteki October 7, 2022 20:36
@robert-zaremba
Copy link
Member

should we remove NewCmdSubmitUpdateRegistryProposal ...

Yes

Copy link
Member

@toteki toteki left a comment

Choose a reason for hiding this comment

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

This is looking good so far - would it be possible to create an example proposal to add to documentation?

Note: we should delay merging until after 3.1.0 release.

@toteki toteki dismissed their stale review October 10, 2022 17:01

Removing blocker, but don't merge until after 3.1.0

Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

I've made a suggestion to change the message behavior a bit. Also, let's put example proposal file in docs. This information should not be in infra because it should be available to the community.

proto/umee/leverage/v1/tx.proto Outdated Show resolved Hide resolved
@gsk967 gsk967 requested a review from a team as a code owner October 16, 2022 14:01
x/leverage/keeper/token.go Fixed Show fixed Hide fixed
x/leverage/keeper/token.go Outdated Show resolved Hide resolved
x/leverage/keeper/token.go Outdated Show resolved Hide resolved
@gsk967
Copy link
Collaborator Author

gsk967 commented Oct 20, 2022

@toteki I removed remove functionality and updated Registry to Tokens

@toteki
Copy link
Member

toteki commented Oct 31, 2022

If you could

  • document somewhere a an example CLI for creating this proposal type (possibly add it to the leverage spec or readme)
  • and run a local test to make sure it executes as expected

then I think we can merge this.

Edit: There's also a failing test - needs the field Registry to be updated to its new name.

@gsk967
Copy link
Collaborator Author

gsk967 commented Nov 2, 2022

@robert-zaremba @toteki now I moved addTokens to MsgAddTokensToRegistry message from updateRegistry , so now updateRegistry only do update the token setttings and addTokensRegistry only add tokens to registry

@gsk967 gsk967 requested a review from toteki November 2, 2022 11:18
@toteki
Copy link
Member

toteki commented Nov 3, 2022

Following this comment on a separate PR, could we rename

MsgAddTokensToRegistry -> MsgGovRegisterTokens
and
MsgUpdateRegistry -> MsgGovUpdateRegistry
?

@gsk967 gsk967 requested a review from a team as a code owner November 4, 2022 16:09
Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

Almost there. Can we query an address of the gov account, rather than recreating it? (see comments)

app/app.go Show resolved Hide resolved
x/leverage/types/msgs.go Outdated Show resolved Hide resolved
x/leverage/types/msgs.go Outdated Show resolved Hide resolved
x/leverage/README.md Outdated Show resolved Hide resolved
@gsk967 gsk967 requested a review from toteki November 11, 2022 05:55
Copy link
Member

@toteki toteki left a comment

Choose a reason for hiding this comment

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

Ran proto format to remove some extra whitespace. LGTM

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.

Move gov handler to x/gov message execution
4 participants