From ae9116aff118a6da8e224ac8da019edb3e573472 Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 26 Jun 2024 12:14:17 +0200 Subject: [PATCH] chore: remove query level todos (#20778) --- server/v2/appmanager/go.mod | 1 - server/v2/cometbft/abci.go | 10 ++++++++-- server/v2/cometbft/utils.go | 27 +++++++++++++++------------ server/v2/stf/stf.go | 2 -- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/server/v2/appmanager/go.mod b/server/v2/appmanager/go.mod index 5f272491f9..1a68cf3957 100644 --- a/server/v2/appmanager/go.mod +++ b/server/v2/appmanager/go.mod @@ -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 diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index 4f3c211294..71a90cd628 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -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) } diff --git a/server/v2/cometbft/utils.go b/server/v2/cometbft/utils.go index 75f880955a..b302e90c78 100644 --- a/server/v2/cometbft/utils.go +++ b/server/v2/cometbft/utils.go @@ -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, + } +} diff --git a/server/v2/stf/stf.go b/server/v2/stf/stf.go index 6707e1d882..763cae4edd 100644 --- a/server/v2/stf/stf.go +++ b/server/v2/stf/stf.go @@ -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.