diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 8f5071e13fe..150235c3181 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -1,6 +1,7 @@ package ante_test import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -342,6 +343,20 @@ func (suite *AnteTestSuite) TestAnteDecorator() { }, true, }, + { + "success on app callback error, app callbacks are skipped for performance", + func(suite *AnteTestSuite) []sdk.Msg { + suite.chainB.GetSimApp().IBCMockModule.IBCApp.OnRecvPacket = func( + ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, + ) exported.Acknowledgement { + panic(fmt.Errorf("failed OnRecvPacket mock callback")) + } + + // the RecvPacket message has not been submitted to the chain yet, so it will succeed + return []sdk.Msg{suite.createRecvPacketMessage(false)} + }, + true, + }, { "no success on one redundant RecvPacket message", func(suite *AnteTestSuite) []sdk.Msg { diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index a30e96d1ed6..9084091a6e9 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -488,6 +488,11 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack return nil, errorsmod.Wrap(err, "receive packet verification failed") } + // performance: return early for the redundant relayer ante handler + if ctx.IsCheckTx() || ctx.IsReCheckTx() { + return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.SUCCESS}, nil + } + // Perform application logic callback // // Cache context so that we may discard state changes from callback if the acknowledgement is unsuccessful.