-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
cosmos.staking.v1beta1
protos cause duplicate Validators
types in prost-generated Rust code
#12316
Comments
cc @aaronc for visibility |
What would be best solution for this issue.. |
The prost-generated `stake_authorization` contains clashing `struct Validators` and `enum Validators` owning to a `oneof` on a field named `validators`. See #154. We've been patching this by hand for quite some time, and this PR finally automates the process, implementing the solution suggested upstream at cosmos/cosmos-sdk#12316: - Renames `enum Validators` to `enum Policy` (formerly `IsStakeAuthorizationValidators`) - Retains `struct Validators` as-is, as this matches the `message` defined in the schema.
@siulee2 my original suggestion in the comments was to rename
Protobufs are specifically designed to allow renaming of fields without "unexpected results", most notably since every field in a protobuf message is identified by a numeric tag, renaming fields has no impact on serialized messages. It does, however, change the names used by language-specific bindings, but that should be generated code everywhere.
Apparently prost used to namespace I'm not sure it's going to be possible to convince them to add it back. |
) The prost-generated `stake_authorization` contains clashing `struct Validators` and `enum Validators` owning to a `oneof` on a field named `validators`. See #154. We've been patching this by hand for quite some time, and this PR finally automates the process, implementing the solution suggested upstream at cosmos/cosmos-sdk#12316: - Renames `enum Validators` to `enum Policy` (formerly `IsStakeAuthorizationValidators`) - Retains `struct Validators` as-is, as this matches the `message` defined in the schema.
…275) The prost-generated `stake_authorization` contains clashing `struct Validators` and `enum Validators` owning to a `oneof` on a field named `validators`. See #154. We've been patching this by hand for quite some time, and this PR finally automates the process, implementing the solution suggested upstream at cosmos/cosmos-sdk#12316: - Renames `enum Validators` to `enum Policy` (formerly `IsStakeAuthorizationValidators`) - Retains `struct Validators` as-is, as this matches the `message` defined in the schema.
for now we will keep the current state, but in staking v2 we will not cause this issue |
NOTE: this is not so much a "bug" as a bad interaction between the Cosmos SDK protos and the Rust tooling we are using to generate code from them.
Summary of Bug
Rust's most mature protobuf library,
prost
, does not correctly handle the following:https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/staking/v1beta1/authz.proto
Namely
prost
maps theoneof validators
onto anenum Validators
, resulting in clashing type names in the generated code:See our downstream tracking issue here: cosmos/cosmos-rust#154
Suggested resolution
Rename either
oneof validators
ormessage Validators
.Since
oneof validators
expresses a policy which is eitherallow_list
ordeny_list
, it might make sense to rename it tooneof policy
.Version
We're currently using v0.45.4 although the issue persists on the
main
branch.Steps to Reproduce
For Admin Use
The text was updated successfully, but these errors were encountered: