diff --git a/baseapp/abci.go b/baseapp/abci.go index 874926e50728..5ba1f88e9f5a 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -357,9 +357,9 @@ func (app *BaseApp) CheckTxSync(req *abci.RequestCheckTx) (*abci.ResponseCheckTx waitWgs(waits) defer app.checkAccountWGs.Done(signals) - gInfo, err := app.checkTx(mode, req.Tx, tx) + gInfo, anteEvents, err := app.checkTx(mode, req.Tx, tx) if err != nil { - return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, nil, false), nil + return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, false), nil } return &abci.ResponseCheckTx{ GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints? diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 9dbd2f8d257d..0906ac21291b 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -768,7 +768,7 @@ func (app *BaseApp) preCheckTx(txBytes []byte) (tx sdk.Tx, err error) { return tx, err } -func (app *BaseApp) checkTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.GasInfo, err error) { +func (app *BaseApp) checkTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.GasInfo, anteEvents []abci.Event, err error) { ctx := app.getContextForTx(mode, txBytes, -1) gasCtx := &ctx @@ -785,15 +785,20 @@ func (app *BaseApp) checkTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk if !anteCtx.IsZero() { gasCtx = &anteCtx } + if err != nil { + return gInfo, anteEvents, err + } if mode == execModeCheck { err = app.mempool.Insert(ctx, tx) if err != nil { - return gInfo, err + return gInfo, anteEvents, err } } - return gInfo, err + anteEvents = anteCtx.EventManager().Events().ToABCIEvents() + + return gInfo, anteEvents, err } func (app *BaseApp) anteTx(ctx sdk.Context, txBytes []byte, tx sdk.Tx, simulate bool) (sdk.Context, error) { diff --git a/baseapp/reactor.go b/baseapp/reactor.go index 081560d737e5..9d66936a2d10 100644 --- a/baseapp/reactor.go +++ b/baseapp/reactor.go @@ -62,9 +62,9 @@ func (app *BaseApp) checkTxAsync(req *RequestCheckTxAsync, waits []*sync.WaitGro panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.txType)) } - gInfo, err := app.checkTx(mode, req.txBytes, req.tx) + gInfo, anteEvents, err := app.checkTx(mode, req.txBytes, req.tx) if err != nil { - req.callback(sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, nil, false)) + req.callback(sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, false)) return }