diff --git a/PENDING.md b/PENDING.md index c370c0a96e..0012b26f50 100644 --- a/PENDING.md +++ b/PENDING.md @@ -34,11 +34,12 @@ IMPROVEMENTS * Gaia * SDK + * [\#3601] JSON-stringify the ABCI log response which includes the log and message + index. * [\#3604] Improve SDK funds related error messages and allow for unicode in JSON ABCI log. * [\#3620](https://github.com/cosmos/cosmos-sdk/pull/3620) Version command shows build tags - - * \#3638 Add Bcrypt benchmarks & justification of security parameter choice + * [\#3638] Add Bcrypt benchmarks & justification of security parameter choice * Tendermint * [\#3618] Upgrade to Tendermint 0.30.03 diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index c7f7cda868..3b61342c8b 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -628,9 +628,15 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) (ctx sdk.Con return } +type indexedABCILog struct { + MsgIndex int `json:"msg_index"` + Success bool `json:"success"` + Log string `json:"log"` +} + // runMsgs iterates through all the messages and executes them. func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (result sdk.Result) { - logs := make([]string, 0, len(msgs)) + idxlogs := make([]indexedABCILog, 0, len(msgs)) // a list of JSON-encoded logs with msg index var data []byte // NOTE: we just append them all (?!) var tags sdk.Tags // also just append them all @@ -659,23 +665,28 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (re tags = append(tags, sdk.MakeTag(sdk.TagAction, msg.Type())) tags = append(tags, msgResult.Tags...) + idxLog := indexedABCILog{MsgIndex: msgIdx, Log: msgResult.Log} + // stop execution and return on first failed message if !msgResult.IsOK() { - logs = append(logs, fmt.Sprintf("Msg %d failed: %s", msgIdx, msgResult.Log)) + idxLog.Success = false + idxlogs = append(idxlogs, idxLog) + code = msgResult.Code codespace = msgResult.Codespace break } - // construct usable logs in multi-message transactions - logs = append(logs, fmt.Sprintf("Msg %d: %s", msgIdx, msgResult.Log)) + idxLog.Success = true + idxlogs = append(idxlogs, idxLog) } + logJSON := codec.Cdc.MustMarshalJSON(idxlogs) result = sdk.Result{ Code: code, Codespace: codespace, Data: data, - Log: strings.Join(logs, "\n"), + Log: strings.TrimSpace(string(logJSON)), GasUsed: ctx.GasMeter().GasConsumed(), Tags: tags, }