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

refactor(distribution): move ValidateBasic logic to msgServer #15755

Merged
merged 10 commits into from
Apr 11, 2023

Conversation

julienrbrt
Copy link
Member

Description

ref: #15648


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)

@julienrbrt julienrbrt mentioned this pull request Apr 7, 2023
19 tasks
@github-actions github-actions bot added the C:x/distribution distribution module related label Apr 7, 2023
@julienrbrt julienrbrt force-pushed the julien/validate-distribution branch from 99cebe9 to 16d36c7 Compare April 7, 2023 23:12

return &types.MsgCommunityPoolSpendResponse{}, nil
}

func (k msgServer) DepositValidatorRewardsPool(goCtx context.Context, req *types.MsgDepositValidatorRewardsPool) (*types.MsgDepositValidatorRewardsPoolResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
if err := k.validateAuthority(req.Authority); err != nil {
Copy link
Member Author

@julienrbrt julienrbrt Apr 8, 2023

Choose a reason for hiding this comment

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

I am a bit confused with the name authority here. It turns out, it isn't about the module authority (otherwise, the message would have been a bit useless).
I got confused because of the name, so I think people can get confused when sending the message. Changing Authority by Depositor or Sender would make more sense. cc @alexanderbez wdyt?

If this message should really be tied to a gov / any other authority, then it wasn't checked that msg the authority did match with the distribution authority (which is a bug then).

In any case, we can still update this as it is not released yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the functionality is to be able to deposit validator rewards pool from not just authority, it can be any other depositer. The changes you made makes sense to me.
Not sure, if there is more underlying meaning here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the same. @zmanian, was there a reason for this name?
(#14147)

@julienrbrt julienrbrt marked this pull request as ready for review April 8, 2023 20:29
@julienrbrt julienrbrt requested a review from a team as a code owner April 8, 2023 20:29
@github-prbot github-prbot requested review from a team, aaronc and testinginprod and removed request for a team April 8, 2023 20:30
"amount", req.Amount.String(),
"validator", req.ValidatorAddress,
)

return &types.MsgDepositValidatorRewardsPoolResponse{}, nil
}

func (k *Keeper) validateAuthority(authority string) error {
if _, err := k.authKeeper.StringToBytes(authority); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Same thoughts as here: #15760 (comment)

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.

looks like there is a proto breaking change, are we fine with a break like this?

@julienrbrt
Copy link
Member Author

julienrbrt commented Apr 10, 2023

looks like there is a proto breaking change, are we fine with a break like this?

It is due to that: #15755 (comment)

I'd like feedback on the naming and the expected behavior before merging.
As it was not released this is not a proto breaking change compared to v0.47. (This message was added in v0.48)

Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

generally, lgtm

x/distribution/keeper/msg_server.go Outdated Show resolved Hide resolved

return &types.MsgCommunityPoolSpendResponse{}, nil
}

func (k msgServer) DepositValidatorRewardsPool(goCtx context.Context, req *types.MsgDepositValidatorRewardsPool) (*types.MsgDepositValidatorRewardsPoolResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
if err := k.validateAuthority(req.Authority); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the functionality is to be able to deposit validator rewards pool from not just authority, it can be any other depositer. The changes you made makes sense to me.
Not sure, if there is more underlying meaning here.

Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

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

lgtm

msg := types.NewMsgFundCommunityPool(tc.amount, tc.depositor)
_, err := f.msgServer.FundCommunityPool(f.ctx, msg)
if tc.expErr {
require.NotNil(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we also match the error msg if possible?

@julienrbrt julienrbrt enabled auto-merge (squash) April 11, 2023 07:18
@julienrbrt julienrbrt merged commit ee53930 into main Apr 11, 2023
@julienrbrt julienrbrt deleted the julien/validate-distribution branch April 11, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/distribution distribution module related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants