Skip to content

feat(gov): support v1.Proposal in v1beta1.Proposal.Content#14347

Merged
robert-zaremba merged 12 commits into
mainfrom
robert/gov-v1beta1-proposals
Dec 22, 2022
Merged

feat(gov): support v1.Proposal in v1beta1.Proposal.Content#14347
robert-zaremba merged 12 commits into
mainfrom
robert/gov-v1beta1-proposals

Conversation

@robert-zaremba
Copy link
Copy Markdown
Contributor

@robert-zaremba robert-zaremba commented Dec 16, 2022

Description

Closes: #14334

Strawman solution to handle gov/v1 proposals in gov/v1beta1.Proposal.Content required for existing explorers (mintscan, ping pub, kepler) and wallets.

I tested it locally in Umee and local, with various proposals (including sofware upgrade, custom proposals, params...)


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)

@robert-zaremba robert-zaremba requested a review from a team December 16, 2022 17:54
@robert-zaremba
Copy link
Copy Markdown
Contributor Author

Adding backports to 0.46 and 0.47, but maybe we will need to make it manually , because the directory names changed.

Comment thread x/gov/migrations/v3/convert.go
return legacyProposal, nil
// hack to fill up the content with the first message
legacyProposal.Content, err = codectypes.NewAnyWithValue(msgs[0])

Copy link
Copy Markdown
Contributor Author

@robert-zaremba robert-zaremba Dec 16, 2022

Choose a reason for hiding this comment

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

The first idea I had, was to create a simple message:

message BasicContent {
  string title = 1;
  string description = 2 ;
}

and fill it using the Content interface. But, then we will remove additional attributes, which are in fact used by explorers to display the full content (I verified that with ping pub).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree, the current way you have is best imo.

@julienrbrt
Copy link
Copy Markdown
Contributor

Can we add a NotEmpty / Equal check in tests?

@robert-zaremba
Copy link
Copy Markdown
Contributor Author

@julienrbrt what do you mean?

@julienrbrt
Copy link
Copy Markdown
Contributor

@julienrbrt what do you mean?

I just mean adding a test in here: https://github.com/cosmos/cosmos-sdk/blob/main/x/gov/migrations/v3/convert_test.go, to check content is properly set.

Copy link
Copy Markdown
Contributor

@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, can we add a changelog too?

Comment thread x/gov/migrations/v3/convert.go
@sonarqubecloud
Copy link
Copy Markdown

[Cosmos SDK] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@robert-zaremba
Copy link
Copy Markdown
Contributor Author

Added an error when amount of messages in v1.Proposal is different than one. The conversion (and the endpoint) will fail in that case.

Comment thread CHANGELOG.md Outdated
Comment thread x/gov/migrations/v3/convert.go Outdated
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@robert-zaremba robert-zaremba enabled auto-merge (squash) December 22, 2022 22:23
@robert-zaremba robert-zaremba merged commit 330ff5f into main Dec 22, 2022
@robert-zaremba robert-zaremba deleted the robert/gov-v1beta1-proposals branch December 22, 2022 22:44
mergify Bot pushed a commit that referenced this pull request Dec 22, 2022
(cherry picked from commit 330ff5f)

# Conflicts:
#	CHANGELOG.md
mergify Bot pushed a commit that referenced this pull request Dec 22, 2022
(cherry picked from commit 330ff5f)

# Conflicts:
#	CHANGELOG.md
#	x/gov/migrations/v3/convert.go
#	x/gov/migrations/v3/convert_test.go
@robert-zaremba
Copy link
Copy Markdown
Contributor Author

@Mergifyio backport release/v0.47.x

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Dec 22, 2022

backport release/v0.47.x

✅ Backports have been created

Details

if len(msgs) != 1 {
return v1beta1.Proposal{}, sdkerrors.ErrInvalidType.Wrap("can't convert a gov/v1 Proposal to gov/v1beta1 Proposal when amount of proposal messages is more than one")
}
for _, msg := range msgs {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The for loop isn't needed anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes... too late :/ Is it worth to create another PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gov/v1beta1/proposal doesn't handle correctly new SoftwareUpgradeProposal

3 participants