You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After discussion with @thanethomson, I understand that we need to take care of snapshots of proto definitions going back to 0.34.
The proposed packaging versioning schema should look as follows:
Any message definitions that exist in v0.34.x get packaged with the suffix .v1 appended to their domain package name.
Message definitions that have changed in subsequent release streams (v0.37.x and feature/abci++vef at the moment) in ways that introduce breaking changes to generated code in strictly typed languages (our primary concern being Go and Rust), are put into packages with incremental suffixes .v2, .v3, and so on. There is no direct correspondence between a package versioning suffix and any CometBFT protocol version; the suffixes are only to track evolution of message types.
Messages newly introduced since 0.34 may land into .v1 or later packages. This depends on which versioned package looks more natural considering type cross-references and changes to adjacent message types in the same domain package.
@thanethomson Regarding the output folder for the generated files, I'd prefer a single location including the ABCI stubs.
This would make buf.gen.yaml the single source of truth for the protobuf generation process, removing the tricky post-build Makefile actions.
Regarding the output folder for the generated files, I'd prefer a single location including the ABCI stubs.
This would make buf.gen.yaml the single source of truth for the protobuf generation process, removing the tricky post-build Makefile actions.
I've hit a problem in #495 with the Wrap interface method that is manually implemented for generated variant types of oneof content fields for types like Message, e.g. in consensus.
This method (permalink), for example, has to be defined in consensus/v1, because VoteSetBits is defined in the corresponding proto package and the generated struct ends up in consensus/v1/types.pb.go:
However, it needs to produce a dynamically wrapped Message from consensus/v2 for the value to actually work with other code that uses the latest version of Message (sorry I discovered it this late, being new to these parts, and the compiler could not help because the actual type is only checked dynamically). The problem is, we cannot use v2 here because the code generated for v2 itself imports v1: v2.Message refers to field types defined in v1 to avoid duplicating their definitions in v2.
I can see the following ways to solve this:
Duplicate message types in versioned proto packages to eliminate cross-package references in such oneof message definitions. This is bad because duplication is made in the proto spec to work around issues in one particular language binding (Golang/gogoproto). On the other hand, we may have other reasons to duplicate everything relevant in the latest vN, rather than backreferencing to older versions, as discussed in Versioned protobuf files #495 (comment).
Rework the wrapper offending code to not use dynamic dispatch. The result will be less elegant and convenient to use, but I see only two call sites for .Wrap() in non-test code of CometBFT, so maybe that's OK.
The only problematic use downcasts the returned interface pointer to an expected Message type. We can consider this to be a misuse of the Wrapper interface and amend its contract, so that the returned value is only used for marshalling into the (correct) wire format.
Use compiler overrides or Golang-specific annotations to selectively affect package placement of generated code. I would need some expert help or extensive documentation digging for that. Does output for other types need to be similarly customized in order for the result to be somewhat consistent? Some users might want the legacy v1 bindings to ensure backward compatibility, so we cannot just mash the latest definitions together in one happy unversioned Go package.
Create newtypes for VoteSetBits and the rest of the variant structs in the hand-coded consensus package, wrapping the generated types, and implement the Wrapper interface on these newtypes. Some amount of tedious coding is needed, perhaps exceeding the cost of option 2. In my view, this is only worth it the long run, if we generally want domain types to supplant proto-generated structs in the API.
The /api folder must effectively be a standalone Go module (i.e. have its own go.mod file, module github.com/cometbft/cometbft/api).
I don't see other go.mod files besides the one at the root of the repository, and package imports across the subdirectories work at least inside the CometBFT codebase. What are the benefits of the proposed organization? Do we get to cut the dependencies to only the ones required by the proto bindings? Can this work with the other go.mod remaining at the top, or should every Go source folder under root get its own go.mod with a trimmed down list of dependencies? I still need to hone my Go skills on this.
Meanwhile, I'm making the move of *.pb.go and associated manually-written method code into the ./api folder, and it's the easiest thing to do in this whole enterprise.
What are the benefits of the proposed organization?
As we have established in a meeting about versioning, we want the proto-derived module versioned separately from module(s) that wrap or alias the proto-generated types into the versionless API for clients to work with.
Moved to Q3. The goal is to coordinate with the main stake holders (IBC teams, SDK) to make sure they will plan their integration properly to minimize disruption. I will be doing that
After examination with @mzabaluev all tasks here are complete. Some tasks that were remaining have been moved to the parent issue (#1330), in order to make tracking them easier.
Activity
spec: migrate v0.7.1. into v0.34 (#9262)
mzabaluev commentedon Mar 6, 2023
After discussion with @thanethomson, I understand that we need to take care of snapshots of proto definitions going back to 0.34.
The proposed packaging versioning schema should look as follows:
v0.34.xget packaged with the suffix.v1appended to their domain package name.v0.37.xandfeature/abci++vefat the moment) in ways that introduce breaking changes to generated code in strictly typed languages (our primary concern being Go and Rust), are put into packages with incremental suffixes.v2,.v3, and so on. There is no direct correspondence between a package versioning suffix and any CometBFT protocol version; the suffixes are only to track evolution of message types..v1or later packages. This depends on which versioned package looks more natural considering type cross-references and changes to adjacent message types in the same domain package.mzabaluev commentedon Mar 15, 2023
@thanethomson Regarding the output folder for the generated files, I'd prefer a single location including the ABCI stubs.
This would make
buf.gen.yamlthe single source of truth for the protobuf generation process, removing the tricky post-build Makefile actions.thanethomson commentedon Mar 15, 2023
This is precisely the idea.
mzabaluev commentedon Mar 30, 2023
I've hit a problem in #495 with the
Wrapinterface method that is manually implemented for generated variant types ofoneofcontent fields for types likeMessage, e.g. inconsensus.This method (permalink), for example, has to be defined in
consensus/v1, becauseVoteSetBitsis defined in the corresponding proto package and the generated struct ends up inconsensus/v1/types.pb.go:However, it needs to produce a dynamically wrapped
Messagefromconsensus/v2for the value to actually work with other code that uses the latest version ofMessage(sorry I discovered it this late, being new to these parts, and the compiler could not help because the actual type is only checked dynamically). The problem is, we cannot usev2here because the code generated forv2itself importsv1:v2.Messagerefers to field types defined inv1to avoid duplicating their definitions inv2.I can see the following ways to solve this:
oneofmessage definitions. This is bad because duplication is made in the proto spec to work around issues in one particular language binding (Golang/gogoproto). On the other hand, we may have other reasons to duplicate everything relevant in the latestvN, rather than backreferencing to older versions, as discussed in Versioned protobuf files #495 (comment).wrapperoffending code to not use dynamic dispatch. The result will be less elegant and convenient to use, but I see only two call sites for.Wrap()in non-test code of CometBFT, so maybe that's OK.Messagetype. We can consider this to be a misuse of theWrapperinterface and amend its contract, so that the returned value is only used for marshalling into the (correct) wire format.v1bindings to ensure backward compatibility, so we cannot just mash the latest definitions together in one happy unversioned Go package.VoteSetBitsand the rest of the variant structs in the hand-codedconsensuspackage, wrapping the generated types, and implement theWrapperinterface on these newtypes. Some amount of tedious coding is needed, perhaps exceeding the cost of option 2. In my view, this is only worth it the long run, if we generally want domain types to supplant proto-generated structs in the API.mzabaluev commentedon Mar 31, 2023
Resolved the above with a modification of the approach described in point 2.
mzabaluev commentedon Mar 31, 2023
I don't see other
go.modfiles besides the one at the root of the repository, and package imports across the subdirectories work at least inside the CometBFT codebase. What are the benefits of the proposed organization? Do we get to cut the dependencies to only the ones required by the proto bindings? Can this work with the othergo.modremaining at the top, or should every Go source folder under root get its owngo.modwith a trimmed down list of dependencies? I still need to hone my Go skills on this.Meanwhile, I'm making the move of
*.pb.goand associated manually-written method code into the./apifolder, and it's the easiest thing to do in this whole enterprise.mzabaluev commentedon Apr 20, 2023
As we have established in a meeting about versioning, we want the proto-derived module versioned separately from module(s) that wrap or alias the proto-generated types into the versionless API for clients to work with.
sergio-mena commentedon Jul 5, 2023
Moved to Q3. The goal is to coordinate with the main stake holders (IBC teams, SDK) to make sure they will plan their integration properly to minimize disruption. I will be doing that
sergio-mena commentedon Sep 26, 2023
After examination with @mzabaluev all tasks here are complete. Some tasks that were remaining have been moved to the parent issue (#1330), in order to make tracking them easier.
Merge pull request cometbft#96 from osmosis-labs/mergify/bp/osmo-v25/…