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!: move v1beta2 gov types into types dir #10763

Merged
merged 19 commits into from
Dec 16, 2021
Merged

Conversation

cmwaters
Copy link
Contributor

@cmwaters cmwaters commented Dec 13, 2021

closes #9865

To be merged after #10748


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-actions github-actions bot added the C:CLI label Dec 15, 2021
@cmwaters cmwaters marked this pull request as ready for review December 15, 2021 16:30
Comment on lines 112 to 123
message TallyParams {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
bytes quorum = 1;
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
bytes threshold = 2;
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
bytes veto_threshold = 3;
string veto_threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To reviewers: This is one of the major changes made in this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

This might need a migration, we can add one in another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. I plan to write up a migration for proposals so I can couple it with this as well

x/gov/types/msgs.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added the C:x/genutil genutil module issues label Dec 15, 2021
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM overall, have some questions that don't need to be answered in this PR.

My biggest concern is if it's worth generating coins into []*sdk.Coins. I prefer to keep []sdk.Coins even though that means we still use gogoproto in v1beta2.

proto/cosmos/gov/v1beta2/genesis.proto Show resolved Hide resolved
Comment on lines 112 to 123
message TallyParams {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
bytes quorum = 1;
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
bytes threshold = 2;
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
bytes veto_threshold = 3;
string veto_threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This might need a migration, we can add one in another PR

x/gov/migrations/v043/json_test.go Outdated Show resolved Hide resolved
x/gov/types/msgs.go Outdated Show resolved Hide resolved
proto/cosmos/gov/v1beta2/gov.proto Show resolved Hide resolved
x/gov/types/deposit.go Outdated Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@amaury1093 amaury1093 added T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). T: State Machine Breaking State machine breaking changes (impacts consensus). labels Dec 16, 2021
@amaury1093 amaury1093 changed the title refactor: move v1beta2 gov types into types dir refactor!: move v1beta2 gov types into types dir Dec 16, 2021
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!

x/gov/types/proposal.go Outdated Show resolved Hide resolved
@amaury1093
Copy link
Contributor

--- FAIL: TestMsgDepositGetSignBytes (0.00s)
    msgs_test.go:31: 
        	Error Trace:	msgs_test.go:31
        	Error:      	Not equal: 
        	            	expected: "{\"type\":\"cosmos-sdk/MsgDeposit\",\"value\":{\"amount\":[{\"amount\":\"1000\",\"denom\":\"stake\"}],\"depositor\":\"cosmos1v9jxgu33kfsgr5\",\"proposal_id\":\"0\"}}"
        	            	actual  : "{\"type\":\"cosmos-sdk/MsgDeposit\",\"value\":{\"amount\":[{\"amount\":\"1000\",\"denom\":\"stake\"}],\"depositor\":\"cosmos1v9jxgu33kfsgr5\"}}"

This error is a bit concerning, as it touches signing (so consensus). I think it's due to some json tags changes (maybe omitempty?).

I believe there's no risk of simply updating the v1beta2 test (as long as the v1beta1 test doesn't change).

@cmwaters
Copy link
Contributor Author

Yeah it seems the failing test is only when proposal id is 0. When set to non zero it works fine. I'm not sure if there are any tags I need to change. I've added a validity check in genesis that proposal id can never be zero to avoid this case

@cmwaters cmwaters added the A:automerge Automatically merge PR once all prerequisites pass. label Dec 16, 2021
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

let's actually keep 0! With 1 we wouldn't have caught this bug.

x/gov/types/msgs_test.go Outdated Show resolved Hide resolved
x/gov/types/msgs_test.go Outdated Show resolved Hide resolved
@amaury1093 amaury1093 removed the A:automerge Automatically merge PR once all prerequisites pass. label Dec 16, 2021
@amaury1093
Copy link
Contributor

Yeah it seems the failing test is only when proposal id is 0. When set to non zero it works fine. I'm not sure if there are any tags I need to change.

I think it's fine like this. I just reverted the test back to use 0 and fixed it, so we're more resilient to future edge cases (if they happen again).

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Dec 16, 2021
@mergify mergify bot merged commit 350f916 into master Dec 16, 2021
@mergify mergify bot deleted the callum/gov-v1beta2 branch December 16, 2021 18:23
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:CLI C:Simulations C:x/genutil genutil module issues C:x/gov T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). T: State Machine Breaking State machine breaking changes (impacts consensus).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add []sdk.Msg to gov proposal
4 participants