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

Weighted votes migrate in-place migrations #8663

Merged
merged 7 commits into from
Mar 2, 2021
Merged

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Feb 22, 2021

Description

ref: #8345 (comment)
closes #8345


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@amaury1093 amaury1093 changed the base branch from master to am-8345-modules February 22, 2021 14:42
@amaury1093 amaury1093 force-pushed the am/weighted-votes-migrate branch 2 times, most recently from 8ab73c9 to 8670f49 Compare February 22, 2021 14:44
Comment on lines 1 to 3
// Package v040 is take from:
// https://github.com/cosmos/cosmos-sdk/blob/v0.41.1/x/gov/types/vote.go
// by copy-pasted only the relevants parts for Vote.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In v040 we had

type Vote struct {
	ProposalId uint64           `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty" yaml:"proposal_id"`
	Voter      string           `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
	Option     types.VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
}

and in v042 we add a new field, and marked the 3rd field as reserved, which gives

type Vote struct {
	ProposalId uint64               `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty" yaml:"proposal_id"`
	Voter      string               `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
	Options    []WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options"`
}

Here, I went through the old .pb.go and copy-pasted the minimum to have the old vote struct and its proto marshaling working.

@lgtm-com
Copy link

lgtm-com bot commented Feb 22, 2021

This pull request introduces 1 alert when merging c5f4d03 into 0e24bad - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@clevinson clevinson added this to the v0.42 milestone Feb 23, 2021
Base automatically changed from am-8345-modules to master February 25, 2021 10:43
@codecov
Copy link

codecov bot commented Feb 25, 2021

Codecov Report

Merging #8663 (7104ee0) into master (a193522) will decrease coverage by 0.03%.
The diff coverage is 27.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8663      +/-   ##
==========================================
- Coverage   61.44%   61.41%   -0.04%     
==========================================
  Files         673      674       +1     
  Lines       38361    38399      +38     
==========================================
+ Hits        23571    23581      +10     
- Misses      12309    12335      +26     
- Partials     2481     2483       +2     
Impacted Files Coverage Δ
x/gov/keeper/migrations.go 50.00% <0.00%> (ø)
x/gov/legacy/v040/vote.go 0.00% <0.00%> (ø)
x/gov/legacy/v042/store.go 84.61% <73.33%> (-15.39%) ⬇️

@amaury1093 amaury1093 marked this pull request as ready for review February 25, 2021 11:12
Copy link
Collaborator

@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.

LGTM

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 2, 2021
@mergify mergify bot merged commit 30f58b5 into master Mar 2, 2021
@mergify mergify bot deleted the am/weighted-votes-migrate branch March 2, 2021 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:x/gov
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor store keys to allow variable-length addresses
4 participants