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

Address v1beta1 proto breaking changes #9446

Closed
aaronc opened this issue Jun 2, 2021 · 10 comments · Fixed by #9534
Closed

Address v1beta1 proto breaking changes #9446

aaronc opened this issue Jun 2, 2021 · 10 comments · Fixed by #9534
Assignees
Labels
Milestone

Comments

@aaronc
Copy link
Member

aaronc commented Jun 2, 2021

As reported by @webmaster128 on discord:

Hey SDK team, I noticed a change in message Vote in https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/proto/cosmos/gov/v1beta1/gov.proto#L134-L136 which as discussed by @sunny Aggarwal | Sikka and @aaronc | Regen Network at #7802 (comment).

Now the problem for the client is: we cannot use the new .proto file for interacting with a 0.42 chain. The necessary field is simply missing (even if reserved). Why is this considered a non-breaking .proto change with no version bump in the pro namespace?

Correct my if I'm wrong, but my understanding was that a proto file is versioned by its namespace, not the SDK version.

Same for #8673 (comment). No multi-backend client is possible with that change. Seems like that Google describes there in their upgrading instructions assume a central server with multiple clients around it.

@amaury1093
Copy link
Contributor

amaury1093 commented Jun 2, 2021

Some proposals we can do for v0.43:

Proposal 1. Remove all reserved fields in the proto files, replace with what we had before. Notes:

  • we should also add backwards-compatability in the handlers. E.g. convert a Vote to a 100% WeightedVote.
  • might need to double-check if we added new fields in Msgs, and how they work with proto unknown field rejectors.

Proposal 2. Bump proto packages to v1beta2 or even v1 (#9445)

It seems like proposal 1 is the easiest path for v0.43, but we're discussing with @webmaster128 next week to discuss a more general proto updates strategy.

@aaronc
Copy link
Member Author

aaronc commented Jun 2, 2021

I think we should start with approach 1.

Although it might not be a bad idea to bump proto files to v1 if we can maintain compatibility with v1beta1 for 0.43... that seems like a bunch more work though.

I do have a concern that adding any field to a Msg could cause breaking changes for clients because of unknown field rejection and UI's populating fields that aren't supported. This may force us to separate query and tx proto packages - where queries can easily add fields but tx's must always bump the version to add fields. This would look like cosmos.bank.query.v1, cosmos.bank.tx.v1, etc. I'm not sure if this is necessary but we should definitely discuss.

@amaury1093
Copy link
Contributor

This may force us to separate query and tx proto packages - where queries can easily add fields but tx's must always bump the version to add fields. This would look like cosmos.bank.query.v1, cosmos.bank.tx.v1, etc. I'm not sure if this is necessary but we should definitely discuss.

We could also just make sure to never add fields in Msgs (e.g. manually, during PR reviews). If someone needs to add a new field, then create a new Msg. It somehow feels complex and confusing to me to have query and tx packages with different versions for the same module.

@amaury1093
Copy link
Contributor

amaury1093 commented Jun 8, 2021

Had a call with @webmaster128 and @robert-zaremba about proto bumping strategy.

The current proposed strategy for solving this issue is:

  • aim for bumping all proto packages to v1 in v0.43
  • ask the community if there's strong objection to bumping to v1 when v0.43 is already in the beta testing phase
  • if there is opposition, fallback to Proposal to add backwards-compatability in keeper handlers.

Meeting notes

@webmaster128
Copy link
Member

After thinking about this a little bit more: Do we know which modules contain incompatible changes between 0.42 and 0.43? Are there modules for which we can keep the v1beta1? Having to create case distictions for all higher level Stargate client code is going to be very tricky (and will lead to poor support of one of those versions).

@robert-zaremba
Copy link
Collaborator

@AmauryM was checking that.
For 0.43 we can only lift the modules with incompatible changes.
For 0.44 we will probably like to set v1 for all other modules anyway drop the beta tag which doesn't make sense any more.

@amaury1093
Copy link
Contributor

I added a quick audit based on a git diff between in the meeting notes in #9446 (comment).

The 2 places where I see breaking changes are:

  • cosmos.gov..v1beta1.Vote
  • cosmos.upgrade.v1beta1.Plan

How do we feel about only bumping 2 modules to v1, and not others? It might give the wrong impression the gov & upgrade modules are "more production-ready" than others, which is wrong.

Having to create case distictions for all higher level Stargate client code is going to be very tricky (and will lead to poor support of one of those versions).

Could you explain more in details what you mean here?

@webmaster128
Copy link
Member

It might give the wrong impression the gov & upgrade modules are "more production-ready" than others, which is wrong.

Yeah, releasing Stargate with the "beta" version was not great. But 🤷‍♂️ it will vanish over time.

How do we feel about only bumping 2 modules to v1, and not others?

I see your point regarding consustency. But this would reduce a lot of practical pain becauese 👇. The difference is really: SDK 0.43 support today vs. SDK 0.43 support one day soon™️.

Could you explain more in details what you mean here?

Have a look at SigningStargateClient.sendTokens: https://github.com/cosmos/cosmjs/blob/v0.25.4/packages/stargate/src/signingstargateclient.ts#L212-L227. In this simple case we fix the versioned proto file in 3 places:

  1. https://github.com/cosmos/cosmjs/blob/v0.25.4/packages/stargate/src/signingstargateclient.ts#L219
  2. https://github.com/cosmos/cosmjs/blob/v0.25.4/packages/stargate/src/encodeobjects.ts#L9
  3. https://github.com/cosmos/cosmjs/blob/v0.25.4/packages/stargate/src/encodeobjects.ts#L3

So we'd have to duplicate all this code for different versions, even if the type did not change at all.

Second problem is I don't even know which type to use for which backend. Or can I query the SDK version in a reliable and stable way?

@amaury1093
Copy link
Contributor

Makes sense. So current consensus is to:

  • update gov & upgrade proto packages to v1 for v0.43.
  • keep all other proto packages as v1beta1, update them all to v1 for v0.44.

@amaury1093
Copy link
Contributor

amaury1093 commented Jun 17, 2021

Had another talk with @aaronc and @robert-zaremba, the latest decision we're going with is:

  • NOT bump gov&upgrade to v1 for 0.43
    • Add error handling for deprecated fields, and graceful support for Vote->WeightedVote conversion
  • Bump everything to v1 at once for 0.44

(Sorry for the back & forth, we're trying to get inputs from different parties)

Some reasons we advanced:

  • a working group is working towards a Msg-based gov proposal mechanism, which would remove ProposalHandlers. This would break proto, so it doesn't make sense to bump gov to v1
  • some clients still use MsgVote, it might be too premature to only support v1 just yet

@mergify mergify bot closed this as completed in #9534 Jun 23, 2021
mergify bot pushed a commit that referenced this issue Jun 23, 2021
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

Closes: #9446 

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

---

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

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [x] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) 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)
mergify bot pushed a commit that referenced this issue Aug 2, 2021
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

This ADR is to be merged as "DRAFT" status for now, as the details for the "Bumping Protobuf Package Version" section have not been sorted out yet.

This ADR comes from discussion with @webmaster128 and @robert-zaremba about proto updates strategy. We decided to go for an ADR to document our decision for v0.43, and for visibility for other chains doing proto upgrades.

[rendered](https://github.com/cosmos/cosmos-sdk/blob/am/adr-044-protobuf/docs/architecture/adr-044-protobuf-updates-guidelines.md)

Closes: #9477
ref: #9446 
ref: #9445

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

---

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

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] 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...

- [x] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] 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
- [x] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment