From 31d1c2b7202cbbaef50ab664a5c88e1736a9aee1 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 19 Jun 2023 16:13:37 -0400 Subject: [PATCH 1/4] updates --- baseapp/baseapp.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 5e548dc77bb6..c1eaccabd624 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -832,6 +832,13 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res return sdk.GasInfo{}, nil, nil, err } + for _, msg := range msgs { + handler := app.msgServiceRouter.Handler(msg) + if handler == nil { + return sdk.GasInfo{}, nil, nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "no message handler found for %T", msg) + } + } + if app.anteHandler != nil { var ( anteCtx sdk.Context @@ -948,7 +955,7 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, msgsV2 []protov2.Me handler := app.msgServiceRouter.Handler(msg) if handler == nil { - return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg) + return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "no message handler found for %T", msg) } // ADR 031 request type routing From 491268f2f55ab5e13bc759e03c819faacde2a30c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 19 Jun 2023 16:15:19 -0400 Subject: [PATCH 2/4] updates --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ba5799b129..67003dc255fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (x/auth/types) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. +* (baseapp) [#16613](https://github.com/cosmos/cosmos-sdk/pull/16613) Ensure each message in a transaction has a registered handler, otherwise `CheckTx` will fail. ## [v0.50.0-alpha.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.0-alpha.0) - 2023-06-07 From 02949a0922c54daa6efe5dca7b3c0fa633ec70b9 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 19 Jun 2023 17:08:46 -0400 Subject: [PATCH 3/4] updates --- baseapp/abci_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 9d12ed1ac121..5f99427338cb 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -1236,7 +1236,9 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) + baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, @@ -1263,7 +1265,9 @@ func TestABCI_PrepareProposal_BadEncoding(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) + baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, From 2bd4f022fd2cf0e216b8595119a3e19611c9727b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 19 Jun 2023 17:09:42 -0400 Subject: [PATCH 4/4] updates --- baseapp/abci_test.go | 2 ++ baseapp/baseapp_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 5f99427338cb..f4ccaec78ef1 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -1292,7 +1292,9 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) + baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 44c91901f3fc..914e6e68819f 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -20,6 +20,7 @@ import ( "cosmossdk.io/store/snapshots" snapshottypes "cosmossdk.io/store/snapshots/types" storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/baseapp" baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil" "github.com/cosmos/cosmos-sdk/client" @@ -453,7 +454,9 @@ func TestCustomRunTxPanicHandler(t *testing.T) { panic(errorsmod.Wrap(anteErr, "anteHandler")) }) } + suite := NewBaseAppSuite(t, anteOpt) + baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{},