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: add title, summary and proposer to proposal struct of gov #14390

Merged
merged 13 commits into from
Dec 26, 2022

Conversation

tac0turtle
Copy link
Member

Description

add title, summary (limited in characters) and proposer to the proposal struct. Would like to here if proposer is needed here?


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)

@github-prbot github-prbot requested review from a team, JeancarloBarrios and atheeshp and removed request for a team December 22, 2022 12:59
x/gov/keeper/msg_server.go Fixed Show fixed Hide fixed
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.

Generally in favor of this.

proto/cosmos/gov/v1/gov.proto Show resolved Hide resolved
@tac0turtle tac0turtle marked this pull request as ready for review December 23, 2022 12:13
@tac0turtle tac0turtle requested a review from a team as a code owner December 23, 2022 12:13
@tac0turtle
Copy link
Member Author

do we need migration for this? from 0.46 -> 0.47?

@julienrbrt
Copy link
Member

julienrbrt commented Dec 23, 2022

I feel like we should update CLI (submit-proposal (and draft-proposal)) to check on title being set and as well actually set it, when parsing a proposal json.
Otherwise, it will default to something empty:

func parseSubmitProposal(cdc codec.Codec, path string) ([]sdk.Msg, string, sdk.Coins, error) {

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm, we should as well add a changelog.

I will test the changes locally a bit later.

x/gov/keeper/proposal.go Outdated Show resolved Hide resolved
@@ -155,6 +155,10 @@ func (p *proposalType) Prompt(cdc codec.Codec) (*proposal, types.ProposalMetadat
return nil, metadata, fmt.Errorf("failed to set proposal deposit: %w", err)
}

// set title and summary from metadata in the proposal
Copy link
Member

@julienrbrt julienrbrt Dec 24, 2022

Choose a reason for hiding this comment

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

Nit actually we can move that up to L147, just after we set the proposal.Metadata. IMHO it makes more sense to group that.

Maybe even assign all three of them in the struct directly after the metadata prompt and remove L138.

proposal := &proposal{
    Metadata: "IPFS", // comment
    Title: metadata.Title,
    Summary: metadata.Summary, 
}

err := keeper.assertMetadataLength(metadata)
if err != nil {
return v1.Proposal{}, err
}

// assert summary is no longer than predefined max length of metdata
err = keeper.assertMetadataLength(summary)
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 warrants adding this in the documentation.

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, a small doubt.

Comment on lines 51 to 56
if msg.Title == "" {
return nil, goerrors.New("proposal title cannot be empty")
}
if msg.Summary == "" {
return nil, goerrors.New("proposal summary cannot be empty")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As I can see, these checks are already present in ValidateBasic, do we still need here?

@tac0turtle tac0turtle added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Dec 26, 2022
@alexanderbez
Copy link
Contributor

do we need migration for this? from 0.46 -> 0.47?

I don't think you can. You cannot safely infer title and summary from the (unstructured) metadata.

x/gov/README.md Outdated
}
```

> Note: By default the metadata and the proposal are both limited by 255 characters, this can be overridden by the application developer
Copy link
Member

@julienrbrt julienrbrt Dec 26, 2022

Choose a reason for hiding this comment

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

Suggested change
> Note: By default the metadata and the proposal are both limited by 255 characters, this can be overridden by the application developer
:::note
By default the metadata and the proposal are both limited by 255 characters, this can be overridden by the application developer.
:::

Nit: it shows nicer in docusaurus.

proposal.Metadata = "ipfs://CID"

proposal := &proposal{
Metadata: "ipfs://CID",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Metadata: "ipfs://CID",
Metadata: "ipfs://CID", // the metadata must be saved on IPFS, set placeholder

I think the comment still has a value.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm, we should as well add a changelog.
I will test the changes locally a bit later.

tACK.

@julienrbrt julienrbrt enabled auto-merge (squash) December 26, 2022 23:03
@julienrbrt julienrbrt merged commit 08361d5 into main Dec 26, 2022
@julienrbrt julienrbrt deleted the marko/addgov branch December 26, 2022 23:24
mergify bot pushed a commit that referenced this pull request Dec 26, 2022
tac0turtle added a commit that referenced this pull request Dec 27, 2022
…backport #14390) (#14423)

Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release C:CLI C:Simulations C:x/bank C:x/gov
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants