Replies: 2 comments 5 replies
-
I have some doubts about (4):
I personally think (3) is the simplest solution. We just need to be disciplined in showing a clear changelog. We obviously should strive for the maximum backwards-compatibility possible, but if a non-backwards-compatible breaking change arises, we'll still have some flexibility. |
Beta Was this translation helpful? Give feedback.
-
My original idea was to have one client lib package per backend. Then the client dev has to decide once which chain they want to connect to but then can laverage full static typing of the whole API. However, there are clearly downsides of this approch. If we assume the API is more or less the same across multiple SDK versions, we can ask the client dev to make case distictions where needed. E.g. a In order to support that, (2) sounds like a great start. As you can see in https://github.com/confio/cosmjs-types/blob/372c0256faa5b37576a03d44be100b2033a2a828/src/cosmos/bank/v1beta1/bank.ts#L35-L87, the field-level annotations propagate into TS types and will be available in modern IDEs for both TS and JS developers. Having the information there in place would be great (e.g. "Added in Cosmos SDK 0.44"). If such annotations get some sort of common format, they can even be used by linters (you told me you want to support 0.44-0.46, don't use this 0.48+ feature). This linter does not yet exist but someone will write it eventually as Android did it with Java comments. I'm not sure how to work with reflections (1). I guess I cannot use them for static typing. It could however be a way to make nice case distinctions at runtime. This would be a lot of code, requests and testing for each functionality as it moves compile time checks to run time checks. Having reflections is nice for manual debugging for grpc though. |
Beta Was this translation helpful? Give feedback.
-
@AmauryM @webmaster128 and I were discussing today some issues CosmJS is facing upgrading to v0.44 protobuf files. So even though all the changes are backwards compatible - i.e. a v0.42 CosmJS client can talk to a v0.44 chain, it will be a bit complicated for a v0.44 CosmJS to talk to a v0.42 chain. Most things should work, but some things will be a bit complicated for the v0.44 client to understand what things won't work against v0.42 and will either cause an error or get ignored entirely.
I'll quote @webmaster128 on some of these issues:
Here are the solutions I can think of:
It seems like (1) will be a bit cumbersome for devs because it doesn't take advantage of static typing - a lot of runtime feature checks will be required.
(2) is something that we could retroactively add to v0.44 to support clients.
I think (3) might be a bit too heavy-handed because you'd have a lot of stuff duplicated in multiple proto packages with subtle differences. For instance, it would be hard for a chain to support all v1 chains while using some v2 features if they happen to be available.
For this reason, I'm sort of leaning towards approach (4) where only new/significantly changed things would go in new proto packages and older packages would start gradually getting full or partial deprecation annotations. Also, this would mean that clients don't need to refactor existing functionality and change package paths when they want to support just some functionality from a new version.
I do think it's probably okay to add new fields to response types in existing proto packages without causing much confusion, but clients would just need to assume they're nullable which should probably always be the case with protobuf types.
What do others think? @webmaster128 @AmauryM ?
Beta Was this translation helpful? Give feedback.
All reactions