33## Changelog
44
55- 2020 April 27: Initial Draft
6+ - 2020 August 5: Update guidelines
67
78## Status
89
@@ -99,13 +100,62 @@ the best choices for the future.
99100
100101### Versioning
101102
102- #### Don't Allow Breaking Changes in Stable Packages
103-
104- Always use a breaking change detector such as [ Buf] ( https://buf.build ) to prevent
105- breaking changes in stable (non-alpha or beta) packages. Breaking changes can
106- break smart contracts/persistent scripts and generally provide a bad UX for
107- clients. With protobuf, there should usually be ways to extend existing
108- functionality instead of just breaking it.
103+ #### Guidelines on Stable Package Versions
104+
105+ In general, schema evolution is the way to update protobuf schemas. That means that new fields,
106+ messages, and RPC methods are _ added_ to existing schemas and old fields, messages and RPC methods
107+ are maintained as long as possible.
108+
109+ Breaking things is often unacceptable in a blockchain scenario. For instance, immutable smart contracts
110+ may depend on certain data schemas on the host chain. If the host chain breaks those schemas, the smart
111+ contract may be irreparably broken. Even when things can be fixed (for instance in client software),
112+ this often comes at a high cost.
113+
114+ Instead of breaking things, we should make every effort to evolve schemas rather than just breaking them.
115+ [ Buf] ( https://buf.build ) breaking change detection should be used on all stable (non-alpha or beta) packages
116+ to prevent such breakage.
117+
118+ With that in mind, different stable versions (i.e. ` v1 ` or ` v2 ` ) of a package should more or less be considered
119+ different packages and this should be last resort approach for upgrading protobuf schemas. Scenarios where creating
120+ a ` v2 ` may make sense are:
121+ * we want to create a new module with similar functionality to an existing module and adding ` v2 ` is the most natural
122+ way to do this. In that case, there are really just two different, but similar modules with different APIs.
123+ * we want to add a new revamped API for an existing module and it's just too cumbersome to add it to the existing package,
124+ so putting it in ` v2 ` is cleaner for users. In this case, care should be made to not deprecate support for
125+ ` v1 ` if it is actively used in immutable smart contracts.
126+
127+ #### Guidelines on unstable (alpha and beta) package versions
128+
129+ The following guidelines are recommended for marking packages as alpha or beta:
130+ * marking something as ` alpha ` or ` beta ` should be a last resort and just putting something in the
131+ stable package (i.e. ` v1 ` or ` v2 ` ) should be preferred
132+ * a package * should* be marked as ` alpha ` * if and only if* there are active discussions to remove
133+ or significantly alter the package in the near future
134+ * a package * should* be marked as ` beta ` * if and only if* there is an active discussion to
135+ significantly refactor/rework the functionality in the near future but not remove it
136+ * modules * can and should* have types in both stable (i.e. ` v1 ` or ` v2 ` ) and unstable (` alpha ` or ` beta ` ) packages.
137+
138+ * ` alpha ` and ` beta ` should not be used to avoid responsibility for maintaining compatibility.*
139+ Whenever code is released into the wild, especially on a blockchain, there is a high cost to changing things. In some
140+ cases, for instance with immutable smart contracts, a breaking change may be impossible to fix.
141+
142+ When marking something as ` alpha ` or ` beta ` , maintainers should ask the questions:
143+ * what is the cost of asking others to change their code vs the benefit of us maintaining the optionality to change it?
144+ * what is the plan for moving this to ` v1 ` and how will that affect users?
145+
146+ ` alpha ` or ` beta ` should really be used to communicate "changes are planned".
147+
148+ As a case study, gRPC reflection is in the package ` grpc.reflection.v1alpha ` . It hasn't been changed since
149+ 2017 and it is now used in other widely used software like gRPCurl. Some folks probably use it in production services
150+ and so if they actually went and changed the package to ` grpc.reflection.v1 ` , some software would break and
151+ they probably don't want to do that... So now the ` v1alpha ` package is more or less the de-facto ` v1 ` . Let's not do that.
152+
153+ The following are guidelines for working with non-stable packages:
154+ * [ Buf's recommended version suffix] ( https://buf.build/docs/lint-checkers#package_version_suffix )
155+ (ex. ` v1alpha1 ` ) _ should_ be used for non-stable packages
156+ * non-stable packages should generally be excluded from breaking change detection
157+ * immutable smart contract modules (i.e. CosmWasm) _ should_ block smart contracts/persistent
158+ scripts from interacting with ` alpha ` /` beta ` packages
109159
110160#### Omit v1 suffix
111161
@@ -115,15 +165,6 @@ allows for more concise names for common use cases like `cosmos.bank.Send`.
115165Packages that do have a second or third version can indicate that with ` .v2 `
116166or ` .v3 ` .
117167
118- #### Use ` alpha ` or ` beta ` to Denote Non-stable Packages
119-
120- [ Buf's recommended version suffix] ( https://buf.build/docs/lint-checkers#package_version_suffix )
121- (ex. ` v1alpha1 ` ) _ should_ be used for non-stable packages. These packages should
122- likely be excluded from breaking change detection and _ should_ generally
123- be blocked from usage by smart contracts/persistent scripts to prevent them
124- from breaking. The SDK _ should_ mark any packages as alpha or beta where the
125- API is likely to change significantly in the near future.
126-
127168### Package Naming
128169
129170#### Adopt a short, unique top-level package name
0 commit comments