From 90fd6320a69a3aca91f8cac4d71b4eea66fc28fb Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 7 Aug 2024 15:07:28 +0200 Subject: [PATCH] fix(server/v2/cometbft): add tx result for failed tx (#21200) --- server/v2/cometbft/commands.go | 7 ------- server/v2/cometbft/utils.go | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/server/v2/cometbft/commands.go b/server/v2/cometbft/commands.go index 802d04a268..dac4fa63f8 100644 --- a/server/v2/cometbft/commands.go +++ b/server/v2/cometbft/commands.go @@ -325,13 +325,6 @@ func (s *CometBFTServer[T]) QueryBlockResultsCmd() *cobra.Command { Long: "Query for a specific committed block's results using the CometBFT RPC `block_results` method", Args: cobra.RangeArgs(0, 1), RunE: func(cmd *cobra.Command, args []string) error { - // clientCtx, err := client.GetClientQueryContext(cmd) - // if err != nil { - // return err - // } - - // TODO: we should be able to do this without using client context - node, err := s.rpcClient(cmd) if err != nil { return err diff --git a/server/v2/cometbft/utils.go b/server/v2/cometbft/utils.go index e97f09716d..594e046ad1 100644 --- a/server/v2/cometbft/utils.go +++ b/server/v2/cometbft/utils.go @@ -102,18 +102,24 @@ func intoABCIValidatorUpdates(updates []appmodulev2.ValidatorUpdate) []abci.Vali func intoABCITxResults(results []appmanager.TxResult, indexSet map[string]struct{}) []*abci.ExecTxResult { res := make([]*abci.ExecTxResult, len(results)) for i := range results { - if results[i].Error == nil { - res[i] = responseExecTxResultWithEvents( - results[i].Error, - results[i].GasWanted, - results[i].GasUsed, - intoABCIEvents(results[i].Events, indexSet), - false, - ) + if results[i].Error != nil { + space, code, log := errorsmod.ABCIInfo(results[i].Error, true) + res[i] = &abci.ExecTxResult{ + Codespace: space, + Code: code, + Log: log, + } + continue } - // TODO: handle properly once the we decide on the type of TxResult.Resp + res[i] = responseExecTxResultWithEvents( + results[i].Error, + results[i].GasWanted, + results[i].GasUsed, + intoABCIEvents(results[i].Events, indexSet), + false, + ) } return res