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

refactor(server)!: remove duplicate bech32 prefix endpoint #18909

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/auth) [#18351](https://github.com/cosmos/cosmos-sdk/pull/18351) Auth module was moved to its own go.mod `cosmossdk.io/x/auth`
* (types) [#18372](https://github.com/cosmos/cosmos-sdk/pull/18372) Removed global configuration for coin type and purpose. Setters and getters should be removed and access directly to defined types.
* (types) [#18695](https://github.com/cosmos/cosmos-sdk/pull/18695) Removed global configuration for txEncoder.
* (server) [#18909](https://github.com/cosmos/cosmos-sdk/pull/18909) Remove configuration endpoint on grpc reflection endpoint in favour of auth module bech32prefix endpoint already exposed.

### CLI Breaking Changes

Expand Down
10 changes: 3 additions & 7 deletions server/grpc/reflection/v2alpha1/reflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v2alpha1

import (
"context"
"errors"
"fmt"

"github.com/cosmos/gogoproto/proto"
Expand All @@ -15,7 +16,6 @@ import (
type Config struct {
SigningModes map[string]int32
ChainID string
SdkConfig *sdk.Config
InterfaceRegistry codectypes.InterfaceRegistry
}

Expand Down Expand Up @@ -47,7 +47,7 @@ func (r reflectionServiceServer) GetCodecDescriptor(_ context.Context, _ *GetCod
}

func (r reflectionServiceServer) GetConfigurationDescriptor(_ context.Context, _ *GetConfigurationDescriptorRequest) (*GetConfigurationDescriptorResponse, error) {
return &GetConfigurationDescriptorResponse{Config: r.desc.Configuration}, nil
return nil, errors.New("this endpoint has been depreacted, please see auth/Bech32Prefix for the data you are seeking")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetConfigurationDescriptor function has been modified to return an error, indicating the endpoint is deprecated. This change is in line with the PR's objective to remove the redundant bech32prefix endpoint. Ensure that this deprecation does not affect clients that may still be calling this endpoint.

}

func (r reflectionServiceServer) GetQueryServicesDescriptor(_ context.Context, _ *GetQueryServicesDescriptorRequest) (*GetQueryServicesDescriptorResponse, error) {
Expand All @@ -61,10 +61,7 @@ func (r reflectionServiceServer) GetTxDescriptor(_ context.Context, _ *GetTxDesc
func newReflectionServiceServer(grpcSrv *grpc.Server, conf Config) (reflectionServiceServer, error) {
// set chain descriptor
chainDescriptor := &ChainDescriptor{Id: conf.ChainID}
// set configuration descriptor
configurationDescriptor := &ConfigurationDescriptor{
Bech32AccountAddressPrefix: conf.SdkConfig.GetBech32AccountAddrPrefix(),
}

// set codec descriptor
codecDescriptor, err := newCodecDescriptor(conf.InterfaceRegistry)
if err != nil {
Expand All @@ -82,7 +79,6 @@ func newReflectionServiceServer(grpcSrv *grpc.Server, conf Config) (reflectionSe
Authn: authnDescriptor,
Chain: chainDescriptor,
Codec: codecDescriptor,
Configuration: configurationDescriptor,
QueryServices: queryServiceDescriptor,
Tx: txDescriptor,
}
Expand Down
2 changes: 0 additions & 2 deletions server/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/server/grpc/gogoreflection"
reflection "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1"
"github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
_ "github.com/cosmos/cosmos-sdk/types/tx/amino" // Import amino.proto file for reflection
)

Expand Down Expand Up @@ -54,7 +53,6 @@ func NewGRPCServer(clientCtx client.Context, app types.Application, cfg config.G
return modes
}(),
ChainID: clientCtx.ChainID,
SdkConfig: sdk.GetConfig(),
InterfaceRegistry: clientCtx.InterfaceRegistry,
})
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions tools/hubl/internal/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/descriptorpb"

authv1betav1 "cosmossdk.io/api/cosmos/auth/v1beta1"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv2alpha1 "cosmossdk.io/api/cosmos/base/reflection/v2alpha1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/tools/hubl/internal/config"
)
Expand Down Expand Up @@ -188,15 +188,15 @@ func (c *ChainInfo) OpenClient() (*grpc.ClientConn, error) {

// getAddressPrefix returns the address prefix of the chain.
func getAddressPrefix(ctx context.Context, conn grpc.ClientConnInterface) (string, error) {
reflectionClient := reflectionv2alpha1.NewReflectionServiceClient(conn)
resp, err := reflectionClient.GetConfigurationDescriptor(ctx, &reflectionv2alpha1.GetConfigurationDescriptorRequest{})
authClient := authv1betav1.NewQueryClient(conn)
resp, err := authClient.Bech32Prefix(ctx, &authv1betav1.Bech32PrefixRequest{})
if err != nil {
return "", err
}

if resp == nil || resp.Config == nil || resp.Config.Bech32AccountAddressPrefix == "" {
if resp == nil || resp.Bech32Prefix == "" {
return "", cockroachdberrors.New("bech32 account address prefix is not set")
}

return resp.Config.Bech32AccountAddressPrefix, nil
return resp.Bech32Prefix, nil
}
5 changes: 2 additions & 3 deletions x/tx/internal/testpb/signers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ message DeeplyNestedSigner {

message DeeplyNestedRepeatedSigner {
option (cosmos.msg.v1.signer) = "inner";
repeated Inner inner = 1;
repeated Inner inner = 1;

message Inner {
option (cosmos.msg.v1.signer) = "inner";
repeated Inner inner = 1;
repeated Inner inner = 1;

message Inner {
option (cosmos.msg.v1.signer) = "inner";
Expand All @@ -90,7 +90,6 @@ message DeeplyNestedRepeatedSigner {
}
}


message BadSigner {
option (cosmos.msg.v1.signer) = "signer";
bytes signer = 1;
Expand Down