Skip to content

Commit

Permalink
feat(simapp/v2): wire new grpc gateway server (partial backport #22941)…
Browse files Browse the repository at this point in the history
… (#23189)

Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored Jan 6, 2025
1 parent 92af502 commit 117006b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions simapp/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
cosmossdk.io/log v1.5.0
cosmossdk.io/math v1.4.0
cosmossdk.io/runtime/v2 v2.0.0-20241219154748-69025c556666 // main
cosmossdk.io/server/v2 v2.0.0-beta.1 // main
cosmossdk.io/server/v2 v2.0.0-beta.1.0.20250106081242-884a7a51c3c3 // main
cosmossdk.io/server/v2/cometbft v1.0.0-beta.1
cosmossdk.io/store/v2 v2.0.0-beta.1 // main
cosmossdk.io/tools/benchmark v0.2.0-rc.1
Expand Down Expand Up @@ -45,7 +45,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
google.golang.org/protobuf v1.36.0
google.golang.org/protobuf v1.36.1
)

require (
Expand Down
8 changes: 4 additions & 4 deletions simapp/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ cosmossdk.io/runtime/v2 v2.0.0-20241219154748-69025c556666 h1:zFMi1URvs3NiJdSf2z
cosmossdk.io/runtime/v2 v2.0.0-20241219154748-69025c556666/go.mod h1:C0MTcmQlZFPQvYoXzYiWP+h9lFOgezzafEFiQBa6xYo=
cosmossdk.io/schema v1.0.0 h1:/diH4XJjpV1JQwuIozwr+A4uFuuwanFdnw2kKeiXwwQ=
cosmossdk.io/schema v1.0.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-beta.1 h1:mMfWf7wVEv6oVZcgxEZ52x8h/bOuGRjdSrUAEqNQmf4=
cosmossdk.io/server/v2 v2.0.0-beta.1/go.mod h1:lfkdTKM2tMlt6KhNi5f9zT+Ww5HcRpnINWjeKXCHjmc=
cosmossdk.io/server/v2 v2.0.0-beta.1.0.20250106081242-884a7a51c3c3 h1:r7zBzz+Xs0rAGx/ia/5tNgM2Y4xa+SkU+Rli1mIsTRI=
cosmossdk.io/server/v2 v2.0.0-beta.1.0.20250106081242-884a7a51c3c3/go.mod h1:vqgLhoQRRFyRUrLrDj7S18ojvgP8f0X+S1t6CME6GcQ=
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1 h1:EISWki+z9SDAt3OJnUl2y5Ow4qjOb+epYjLb1C7CN/E=
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1/go.mod h1:RVYxIaEdIT10nWSRqbwKDLFWfvCVx+cwAorCyPAQg9A=
cosmossdk.io/server/v2/cometbft v1.0.0-beta.1 h1:kzTMGqIwcpcynbnU0Wyoe0HObyUUBZbkD/sHBUrbZl8=
Expand Down Expand Up @@ -1484,8 +1484,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
8 changes: 1 addition & 7 deletions simapp/v2/simdv2/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/rpc"
sdktelemetry "github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
Expand Down Expand Up @@ -157,6 +156,7 @@ func InitRootCmd[T transaction.Tx](
logger,
deps.GlobalConfig,
simApp.InterfaceRegistry(),
simApp.App.AppManager,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -278,10 +278,4 @@ func registerGRPCGatewayRoutes[T transaction.Tx](
cmtservice.RegisterGRPCGatewayRoutes(deps.ClientContext, server.GRPCGatewayRouter)
_ = nodeservice.RegisterServiceHandlerClient(context.Background(), server.GRPCGatewayRouter, nodeservice.NewServiceClient(deps.ClientContext))
_ = txtypes.RegisterServiceHandlerClient(context.Background(), server.GRPCGatewayRouter, txtypes.NewServiceClient(deps.ClientContext))

for _, mod := range deps.ModuleManager.Modules() {
if gmod, ok := mod.(module.HasGRPCGateway); ok {
gmod.RegisterGRPCGatewayRoutes(deps.ClientContext, server.GRPCGatewayRouter)
}
}
}
12 changes: 9 additions & 3 deletions tests/systemtests/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,26 @@ func TestDistrValidatorGRPCQueries(t *testing.T) {

// test validator slashes grpc endpoint
slashURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s/slashes`
invalidHeightOutput := `{"code":3, "message":"strconv.ParseUint: parsing \"-3\": invalid syntax", "details":[]}`
invalidStartingHeightOutput := `{"code":3, "message":"1 error(s) decoding:\n\n* cannot parse 'starting_height' as uint: strconv.ParseUint: parsing \"-3\": invalid syntax", "details":[]}`
invalidEndingHeightOutput := `{"code":3, "message":"1 error(s) decoding:\n\n* cannot parse 'ending_height' as uint: strconv.ParseUint: parsing \"-3\": invalid syntax", "details":[]}`

if !systest.IsV2() {
invalidStartingHeightOutput = `{"code":3, "message":"strconv.ParseUint: parsing \"-3\": invalid syntax", "details":[]}`
invalidEndingHeightOutput = invalidStartingHeightOutput
}

slashTestCases := []systest.RestTestCase{
{
Name: "invalid start height",
Url: fmt.Sprintf(slashURL+`?starting_height=%s&ending_height=%s`, valOperAddr, "-3", "3"),
ExpCode: http.StatusBadRequest,
ExpOut: invalidHeightOutput,
ExpOut: invalidStartingHeightOutput,
},
{
Name: "invalid end height",
Url: fmt.Sprintf(slashURL+`?starting_height=%s&ending_height=%s`, valOperAddr, "1", "-3"),
ExpCode: http.StatusBadRequest,
ExpOut: invalidHeightOutput,
ExpOut: invalidEndingHeightOutput,
},
{
Name: "valid request get slashes",
Expand Down

0 comments on commit 117006b

Please sign in to comment.