From b62a7b26bf2e51fbcdafab582daf76d052422d3d Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 11 Apr 2024 20:57:44 +0200 Subject: [PATCH 1/2] imp: emit host disabled event --- .../27-interchain-accounts/host/ibc_module.go | 1 + .../27-interchain-accounts/host/keeper/events.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module.go b/modules/apps/27-interchain-accounts/host/ibc_module.go index 5c652f19b23..7a746ce3458 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module.go @@ -106,6 +106,7 @@ func (im IBCModule) OnRecvPacket( _ sdk.AccAddress, ) ibcexported.Acknowledgement { if !im.keeper.IsHostEnabled(ctx) { + keeper.EmitHostDisabledEvent(ctx, packet) return channeltypes.NewErrorAcknowledgement(types.ErrHostSubModuleDisabled) } diff --git a/modules/apps/27-interchain-accounts/host/keeper/events.go b/modules/apps/27-interchain-accounts/host/keeper/events.go index 6c320ace6c0..64d9a1361f2 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/events.go +++ b/modules/apps/27-interchain-accounts/host/keeper/events.go @@ -5,7 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v7/modules/core/exported" ) @@ -29,3 +31,16 @@ func EmitAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, ack expo ), ) } + +// EmitHostDisabledEvent emits an event signalling that the host submodule is disabled. +func EmitHostDisabledEvent(ctx sdk.Context, packet channeltypes.Packet) { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + icatypes.EventTypePacket, + sdk.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName), + sdk.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()), + sdk.NewAttribute(icatypes.AttributeKeyAckError, types.ErrHostSubModuleDisabled.Error()), + sdk.NewAttribute(icatypes.AttributeKeyAckSuccess, "false"), + ), + ) +} From f42f4406e98ab1606e9a9b87677c7f297b64a788 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 11 Apr 2024 21:00:05 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6047ec1bcf0..f9a87dbc934 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (apps/27-interchain-accounts) [\#6147](https://github.com/cosmos/ibc-go/pull/6147) Emit an event signalling that the host submodule is disabled. + ### Features ### Bug Fixes