diff --git a/baseapp/abci.go b/baseapp/abci.go index 33eb1d187d56..b7b187151b9e 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -900,14 +900,29 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz func (app *BaseApp) executeTxs(ctx context.Context, txs [][]byte) ([]*abci.ExecTxResult, error) { if app.txExecutor != nil { - return app.txExecutor(ctx, len(txs), app.finalizeBlockState.ms, func(i int, ms storetypes.MultiStore, incarnationCache map[string]any) *abci.ExecTxResult { - return app.deliverTxWithMultiStore(txs[i], i, ms, incarnationCache) + return app.txExecutor(ctx, txs, app.finalizeBlockState.ms, func(i int, memTx sdk.Tx, ms storetypes.MultiStore, incarnationCache map[string]any) *abci.ExecTxResult { + return app.deliverTxWithMultiStore(txs[i], memTx, i, ms, incarnationCache) }) } txResults := make([]*abci.ExecTxResult, 0, len(txs)) for i, rawTx := range txs { - response := app.deliverTx(rawTx, i) + var response *abci.ExecTxResult + + if memTx, err := app.txDecoder(rawTx); err == nil { + response = app.deliverTx(rawTx, memTx, i) + } else { + // In the case where a transaction included in a block proposal is malformed, + // we still want to return a default response to comet. This is because comet + // expects a response for each transaction included in a block proposal. + response = responseExecTxResultWithEvents( // TODO + sdkerrors.ErrTxDecode, + 0, + 0, + nil, + false, + ) + } // check after every tx if we should abort select { case <-ctx.Done(): diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 5fab3c47ee38..00ec2ded517d 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -772,11 +772,11 @@ func (app *BaseApp) beginBlock(_ *abci.FinalizeBlockRequest) (sdk.BeginBlock, er return resp, nil } -func (app *BaseApp) deliverTx(tx []byte, txIndex int) *abci.ExecTxResult { - return app.deliverTxWithMultiStore(tx, txIndex, nil, nil) +func (app *BaseApp) deliverTx(tx []byte, memTx sdk.Tx, txIndex int) *abci.ExecTxResult { + return app.deliverTxWithMultiStore(tx, memTx, txIndex, nil, nil) } -func (app *BaseApp) deliverTxWithMultiStore(tx []byte, txIndex int, txMultiStore storetypes.MultiStore, incarnationCache map[string]any) *abci.ExecTxResult { +func (app *BaseApp) deliverTxWithMultiStore(tx []byte, memTx sdk.Tx, txIndex int, txMultiStore storetypes.MultiStore, incarnationCache map[string]any) *abci.ExecTxResult { gInfo := sdk.GasInfo{} resultStr := "successful" @@ -789,7 +789,7 @@ func (app *BaseApp) deliverTxWithMultiStore(tx []byte, txIndex int, txMultiStore telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted") }() - gInfo, result, anteEvents, err := app.runTxWithMultiStore(execModeFinalize, tx, nil, txIndex, txMultiStore, incarnationCache) + gInfo, result, anteEvents, err := app.runTxWithMultiStore(execModeFinalize, tx, memTx, txIndex, txMultiStore, incarnationCache) if err != nil { resultStr = "failed" resp = responseExecTxResultWithEvents( diff --git a/baseapp/genesis.go b/baseapp/genesis.go index 199cd63da324..def709b4e439 100644 --- a/baseapp/genesis.go +++ b/baseapp/genesis.go @@ -8,7 +8,7 @@ import ( // ExecuteGenesisTx implements a genesis TxHandler used to execute a genTxs (from genutil). func (app *BaseApp) ExecuteGenesisTx(tx []byte) error { - res := app.deliverTx(tx, -1) + res := app.deliverTx(tx, nil, -1) if res.Code != types.CodeTypeOK { return errors.New(res.Log) diff --git a/baseapp/txexecutor.go b/baseapp/txexecutor.go index 82649036dba0..b09c204e06c0 100644 --- a/baseapp/txexecutor.go +++ b/baseapp/txexecutor.go @@ -4,13 +4,14 @@ import ( "context" abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" "cosmossdk.io/store/types" ) type TxExecutor func( ctx context.Context, - blockSize int, + block [][]byte, cms types.MultiStore, - deliverTxWithMultiStore func(int, types.MultiStore, map[string]any) *abci.ExecTxResult, + deliverTxWithMultiStore func(int, sdk.Tx, types.MultiStore, map[string]any) *abci.ExecTxResult, ) ([]*abci.ExecTxResult, error)