fix(cometbft/grpc): gRPC path parsing (backport #22081) (#22091)

Co-authored-by: testinginprod <98415576+testinginprod@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot] 2024-10-03 14:05:31 +02:00 committed by GitHub
parent c29d3e819f
commit 7dff16eb43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 10 deletions

View File

@ -250,12 +250,13 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq
return nil, false, err
}
path := strings.TrimPrefix(req.Path, "/")
pathFullName := protoreflect.FullName(strings.ReplaceAll(path, "/", "."))
// in order to check if it's a gRPC query we ensure that there's a descriptor
// for the path, if such descriptor exists, and it is a method descriptor
// then we assume this is a gRPC query.
fullName := protoreflect.FullName(strings.ReplaceAll(req.Path, "/", "."))
desc, err := registry.FindDescriptorByName(fullName)
desc, err := registry.FindDescriptorByName(pathFullName)
if err != nil {
return nil, false, err
}
@ -267,7 +268,7 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq
handler, found := c.queryHandlersMap[string(md.Input().FullName())]
if !found {
return nil, true, fmt.Errorf("no query handler found for %s", fullName)
return nil, true, fmt.Errorf("no query handler found for %s", req.Path)
}
protoRequest := handler.MakeMsg()
err = gogoproto.Unmarshal(req.Data, protoRequest) // TODO: use codec

View File

@ -21,7 +21,7 @@ require (
cosmossdk.io/core v1.0.0-alpha.4
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
cosmossdk.io/log v1.4.1
cosmossdk.io/server/v2 v2.0.0-20241003101412-c5889a418ae2 // main
cosmossdk.io/server/v2 v2.0.0-20241003112707-72f771638528 // main
cosmossdk.io/server/v2/appmanager v0.0.0-20241003101412-c5889a418ae2 // main
cosmossdk.io/server/v2/stf v0.0.0-20241003101412-c5889a418ae2 // main
cosmossdk.io/store/v2 v2.0.0-20240916221850-7856d226038c // main

View File

@ -24,8 +24,8 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 h1:DmOoS/1PeY6Ih0hAVlJ69kLMUrLV+TCbfICrZtB1vdU=
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-20241003101412-c5889a418ae2 h1:Q5J+36LlGK3c3xtl/k8/LeLgtpPwx9L2lFbhSRYYGPg=
cosmossdk.io/server/v2 v2.0.0-20241003101412-c5889a418ae2/go.mod h1:zXQpdRRGLQjq17VxHiieHjA0xcU2ydgjR82XOgA6Cdc=
cosmossdk.io/server/v2 v2.0.0-20241003112707-72f771638528 h1:6Ht6Yg36nsbtOjdxj+fvUk5o35Nkg9vA9WQC+oNs+sI=
cosmossdk.io/server/v2 v2.0.0-20241003112707-72f771638528/go.mod h1:zXQpdRRGLQjq17VxHiieHjA0xcU2ydgjR82XOgA6Cdc=
cosmossdk.io/server/v2/appmanager v0.0.0-20241003101412-c5889a418ae2 h1:8GOXwsEQbRtpQ/bzUEly4FCOqhBhgxFFDzBGkrPjBUs=
cosmossdk.io/server/v2/appmanager v0.0.0-20241003101412-c5889a418ae2/go.mod h1:/xDfniqVtn5nraiHkNJ4e6rYU0e83YAGsSjwmUA6H8k=
cosmossdk.io/server/v2/stf v0.0.0-20241003101412-c5889a418ae2 h1:G1kMEqy4OAO/BZD9ZJa2rVVxsYSPHzKrictiOAGPuoY=

View File

@ -11,7 +11,7 @@ require (
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/runtime/v2 v2.0.0-20241003101412-c5889a418ae2 // main
cosmossdk.io/server/v2 v2.0.0-20241003101412-c5889a418ae2 // main
cosmossdk.io/server/v2 v2.0.0-20241003112707-72f771638528 // main
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-20240916221850-7856d226038c // main
cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000

View File

@ -214,8 +214,8 @@ cosmossdk.io/runtime/v2 v2.0.0-20241003101412-c5889a418ae2 h1:/KMBWc+mflXNv6HOka
cosmossdk.io/runtime/v2 v2.0.0-20241003101412-c5889a418ae2/go.mod h1:o9I/8aO/VF6RQU1OdaAE3sMhBD10vl2GEnSrYOLwYVk=
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 h1:DmOoS/1PeY6Ih0hAVlJ69kLMUrLV+TCbfICrZtB1vdU=
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-20241003101412-c5889a418ae2 h1:Q5J+36LlGK3c3xtl/k8/LeLgtpPwx9L2lFbhSRYYGPg=
cosmossdk.io/server/v2 v2.0.0-20241003101412-c5889a418ae2/go.mod h1:zXQpdRRGLQjq17VxHiieHjA0xcU2ydgjR82XOgA6Cdc=
cosmossdk.io/server/v2 v2.0.0-20241003112707-72f771638528 h1:6Ht6Yg36nsbtOjdxj+fvUk5o35Nkg9vA9WQC+oNs+sI=
cosmossdk.io/server/v2 v2.0.0-20241003112707-72f771638528/go.mod h1:zXQpdRRGLQjq17VxHiieHjA0xcU2ydgjR82XOgA6Cdc=
cosmossdk.io/server/v2/appmanager v0.0.0-20241003101412-c5889a418ae2 h1:8GOXwsEQbRtpQ/bzUEly4FCOqhBhgxFFDzBGkrPjBUs=
cosmossdk.io/server/v2/appmanager v0.0.0-20241003101412-c5889a418ae2/go.mod h1:/xDfniqVtn5nraiHkNJ4e6rYU0e83YAGsSjwmUA6H8k=
cosmossdk.io/server/v2/stf v0.0.0-20241003101412-c5889a418ae2 h1:G1kMEqy4OAO/BZD9ZJa2rVVxsYSPHzKrictiOAGPuoY=