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

[Bug]: cosmos sdk 0.47.5 does not compile with new go slices package #18415

Closed
1 task done
trevormil opened this issue Nov 8, 2023 · 6 comments
Closed
1 task done
Labels

Comments

@trevormil
Copy link

trevormil commented Nov 8, 2023

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

While compiling a cosmos sdk project,
I am getting this

/root/go/pkg/mod/github.com/cosmos/[email protected]/runtime/services/reflection.go:60:28: type func(x *descriptorpb.FileDescriptorProto, y *descriptorpb.FileDescriptorProto) bool of func(x, y *descriptorpb.FileDescriptorProto) bool {…} does not match inferred type func(a *descriptorpb.FileDescriptorProto, b *descriptorpb.FileDescriptorProto) int for func(a E, b E) int

My project has a dependency for the latest go slices package, and the SDK is not compiling because of it. Others are experiencing the same (https://stackoverflow.com/questions/77159882/cosmos-sdk-does-not-compile-with-new-slices-package).

The problem function is this one in /runtime/services/reflection.go

slices.SortFunc(fds.File, func(x, y *descriptorpb.FileDescriptorProto) bool {
    return *x.Name < *y.Name
})

The golang.org/x/exp package says that .SortFunc is not stable and it changed in the v0.0.0-20230905200255-921286631fa9
Sep 5, 2023 update. The expected return value is now an integer instead of a boolean.

The most recent working version should be v0.0.0-20230425010034-47ecfdc1ba53
Apr 25, 2023.

I also noticed that in x/gov/module.go, this function is used as well.

Cosmos SDK Version

0.47

How to reproduce?

With ignite scaffold chain (v0.27.2), I scaffolded a new chain with ignite scaffold chain.

Then, I added golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect and tried to build with ignite chain build or serve with ignite chain serve.

@trevormil trevormil added the T:Bug label Nov 8, 2023
@julienrbrt
Copy link
Member

julienrbrt commented Nov 8, 2023

That is correct. This is why we haven't bumped it in v0.47.

Bumping it could potentially be API breaking for people having modules on v0.47. Patch releases must not contain any breaking changes.

What you can do it downgrade and use the same version that is used in the SDK.

Another solution, although overkill, is to upgrade to v0.50 with contains latest x/exp.

@julienrbrt julienrbrt closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2023
@arifintahu
Copy link

@trevormil solved for me by changing go.mod to go 1.19, remove golang.org/x/exp indirect package, and run go mod tidy again
image

@Satchitananda
Copy link

I have same problem while building CosmosSDK v0.47.6, however removing golang.org/x/exp and running go mod tidy, and even replacing golang.org/x/exp with specific v0.0.0-20230425010034-47ecfdc1ba53 version of package does not resolve problem

@julienrbrt
Copy link
Member

I have same problem while building CosmosSDK v0.47.6, however removing golang.org/x/exp and running go mod tidy, and even replacing golang.org/x/exp with specific v0.0.0-20230425010034-47ecfdc1ba53 version of package does not resolve problem

Can you post your error message here?

@trevormil
Copy link
Author

I resolved my issue with this, but just a suggestion: it seems like the SortFunc return value doesn't actually get returned to the user. Would it still be considered a breaking change if you just handled it internally with the new version of golang.org/x/exp?

@julienrbrt
Copy link
Member

I resolved my issue with this, but just a suggestion: it seems like the SortFunc return value doesn't actually get returned to the user. Would it still be considered a breaking change if you just handled it internally with the new version of golang.org/x/exp?

Right, but bumping it may require custom modules using this to have to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants