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

Stop executing the handler when proposal is sumbmitted #534

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ func (keeper Keeper) SubmitProposalWithExpedite(ctx sdk.Context, content types.C
return types.Proposal{}, sdkerrors.Wrap(types.ErrNoProposalHandlerExists, content.ProposalRoute())
}

// Execute the proposal content in a new context branch (with branched store)
// to validate the actual parameter changes before the proposal proceeds
// through the governance process. State is not persisted.
cacheCtx, _ := ctx.CacheContext()
handler := keeper.router.GetRoute(content.ProposalRoute())
if err := handler(cacheCtx, content); err != nil {
return types.Proposal{}, sdkerrors.Wrap(types.ErrInvalidProposalContent, err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

does this have the side effect of allowing users to submit invalid props?

Copy link
Author

Choose a reason for hiding this comment

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

yes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to fix the underline issue other than removing this handler? What does the upstream tendermint do here?

Copy link
Author

Choose a reason for hiding this comment

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

We could mark ctx with some flag saying that handler is executed in the "submit" scope and then act accordingly in the handler. But it means that we have to be careful about every handler in the system.

The current cosmos sdk stopped executing the handlers: https://github.com/cosmos/cosmos-sdk/blob/release/v0.50.x/x/gov/keeper/proposal.go#L72

They do it only for legacy types for backward compatibility, but no one uses those legacy proposals anymore.

}

proposalID, err := keeper.GetProposalID(ctx)
if err != nil {
return types.Proposal{}, err
Expand Down
Loading