chore: remove query level todos (#20778)

This commit is contained in:
Marko 2024-06-26 12:14:17 +02:00 committed by GitHub
parent 929803d6cc
commit ae9116aff1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 17 deletions

View File

@ -2,7 +2,6 @@ module cosmossdk.io/server/v2/appmanager
go 1.21
// TODO: remove prior to final release
replace cosmossdk.io/core => ../../../core
require cosmossdk.io/core v0.12.0

View File

@ -190,11 +190,15 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (
// otherwise it is a KV store query
if err == nil {
res, err := c.app.Query(ctx, uint64(req.Height), protoMsg)
if err != nil {
return nil, err
resp := queryResult(err)
resp.Height = req.Height
return resp, err
}
return queryResponse(res)
return queryResponse(res, req.Height)
}
// this error most probably means that we can't handle it with a proto message, so
@ -313,6 +317,7 @@ func (c *Consensus[T]) PrepareProposal(
// TODO: vote extension meta data as a custom type to avoid possibly accepting invalid txs
// continue even if tx decoding fails
c.logger.Error("failed to decode tx", "err", err)
continue
}
decodedTxs = append(decodedTxs, decTx)
}
@ -352,6 +357,7 @@ func (c *Consensus[T]) ProcessProposal(
// TODO: vote extension meta data as a custom type to avoid possibly accepting invalid txs
// continue even if tx decoding fails
c.logger.Error("failed to decode tx", "err", err)
continue
}
decodedTxs = append(decodedTxs, decTx)
}

View File

@ -25,24 +25,16 @@ import (
consensus "cosmossdk.io/x/consensus/types"
)
func queryResponse(res transaction.Msg) (*abci.QueryResponse, error) {
// TODO(kocu): we are tightly coupled go gogoproto here, is this problem?
func queryResponse(res transaction.Msg, height int64) (*abci.QueryResponse, error) {
// this is a tied to protobuf due to client responses always being handled in protobuf
bz, err := gogoproto.Marshal(res)
if err != nil {
return nil, err
}
// TODO: how do I reply? I suppose we need to different replies depending of the query
return &abci.QueryResponse{
Code: 0,
Log: "",
Info: "",
Index: 0,
Key: []byte{},
Value: bz,
// ProofOps: &cmtcrypto.ProofOps{},
Height: 0,
Codespace: "",
Value: bz,
Height: height,
}, nil
}
@ -412,3 +404,14 @@ func uint64ToInt64(u uint64) int64 {
}
return int64(u)
}
// queryResult returns a ResponseQuery from an error. It will try to parse ABCI
// info from the error.
func queryResult(err error) *abci.QueryResponse {
space, code, log := errorsmod.ABCIInfo(err, false)
return &abci.QueryResponse{
Codespace: space,
Code: code,
Log: log,
}
}

View File

@ -262,8 +262,6 @@ func (s STF[T]) execTx(
postTxCtx := s.makeContext(ctx, appmanager.RuntimeIdentity, postTxState, execMode)
postTxCtx.setHeaderInfo(hi)
// TODO: runtime sets a noop posttxexec if the app doesnt set anything (julien)
postTxErr := s.postTxExec(postTxCtx, tx, false)
if postTxErr != nil {
// if the post tx handler fails, then we do not apply any state change to the initial state.