diff --git a/x/ibc-hooks/move-hooks/receive.go b/x/ibc-hooks/move-hooks/receive.go index 87bf4e1a..335314ce 100644 --- a/x/ibc-hooks/move-hooks/receive.go +++ b/x/ibc-hooks/move-hooks/receive.go @@ -124,5 +124,16 @@ func (h MoveHooks) execMsg(ctx sdk.Context, msg *movetypes.MsgExecute) (*movetyp } moveMsgServer := movekeeper.NewMsgServerImpl(h.moveKeeper) - return moveMsgServer.Execute(ctx, msg) + + // use cache context to prevent state changes if the message execution fails + cacheCtx, write := ctx.CacheContext() + res, err := moveMsgServer.Execute(cacheCtx, msg) + if err != nil { + return nil, err + } + + // write the cache context only if the message execution was successful + write() + + return res, nil }