fix(server/v2): inject latest height when not provide in grpc query (#23483)

This commit is contained in:
mmsqe 2025-01-23 16:58:58 +08:00 committed by GitHub
parent 3860b2b04b
commit 9fdcd6de98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -174,11 +174,6 @@ func (c *consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc
// Query implements types.Application.
// It is called by cometbft to query application state.
func (c *consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (resp *abciproto.QueryResponse, err error) {
resp, isGRPC, err := c.maybeRunGRPCQuery(ctx, req)
if isGRPC {
return resp, err
}
// when a client did not provide a query height, manually inject the latest
// for modules queries, AppManager does it automatically
if req.Height == 0 {
@ -189,6 +184,11 @@ func (c *consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (
req.Height = int64(latestVersion)
}
resp, isGRPC, err := c.maybeRunGRPCQuery(ctx, req)
if isGRPC {
return resp, err
}
// this error most probably means that we can't handle it with a proto message, so
// it must be an app/p2p/store query
path := splitABCIQueryPath(req.Path)