From 9c6c64843688b4461346a98da451cd8671848cad Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:53:48 +0000 Subject: [PATCH] fix(server): don't hardcode grpc address to localhost (backport #18254) (#18258) Co-authored-by: Julien Robert --- CHANGELOG.md | 3 ++- server/start.go | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c785974cad67..a77401feb10d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (server) [#18254](https://github.com/cosmos/cosmos-sdk/pull/18254) Don't hardcode gRPC address to localhost. * (x/gov) [#18173](https://github.com/cosmos/cosmos-sdk/pull/18173) Gov hooks now return an error and are *blocking* when they fail. Expect for `AfterProposalFailedMinDeposit` and `AfterProposalVotingPeriodEnded` which log the error and continue. * (x/gov) [#17873](https://github.com/cosmos/cosmos-sdk/pull/17873) Fail any inactive and active proposals that cannot be decoded. * (x/slashing) [#18016](https://github.com/cosmos/cosmos-sdk/pull/18016) Fixed builder function for missed blocks key (`validatorMissedBlockBitArrayPrefixKey`) in slashing/migration/v4 @@ -402,4 +403,4 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Previous Versions -[CHANGELOG of previous versions](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md#v0470---2023-03-14). \ No newline at end of file +[CHANGELOG of previous versions](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md#v0470---2023-03-14). diff --git a/server/start.go b/server/start.go index a8e250f0e03d..037c5c47697f 100644 --- a/server/start.go +++ b/server/start.go @@ -472,7 +472,7 @@ func startGrpcServer( // return grpcServer as nil if gRPC is disabled return nil, clientCtx, nil } - _, port, err := net.SplitHostPort(config.Address) + _, _, err := net.SplitHostPort(config.Address) if err != nil { return nil, clientCtx, err } @@ -487,11 +487,9 @@ func startGrpcServer( maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize } - grpcAddress := fmt.Sprintf("127.0.0.1:%s", port) - // if gRPC is enabled, configure gRPC client for gRPC gateway grpcClient, err := grpc.Dial( - grpcAddress, + config.Address, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultCallOptions( grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), @@ -504,7 +502,7 @@ func startGrpcServer( } clientCtx = clientCtx.WithGRPCClient(grpcClient) - svrCtx.Logger.Debug("gRPC client assigned to client context", "target", grpcAddress) + svrCtx.Logger.Debug("gRPC client assigned to client context", "target", config.Address) grpcSrv, err := servergrpc.NewGRPCServer(clientCtx, app, config) if err != nil {