Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove error from ics27 channel ack #751

Merged
merged 6 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/apps/27-interchain-accounts/host/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ func (im IBCModule) OnRecvPacket(
ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)})

if err := im.keeper.OnRecvPacket(ctx, packet); err != nil {
ack = channeltypes.NewErrorAcknowledgement(err.Error())
ack = channeltypes.NewErrorAcknowledgement(icatypes.AcknowledgementError)

// Emit an event including the error msg
keeper.EmitWriteErrorAcknowledgementEvent(ctx, packet, err)
}

// NOTE: acknowledgement will be written synchronously during IBC handler execution.
Expand Down
20 changes: 20 additions & 0 deletions modules/apps/27-interchain-accounts/host/keeper/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"

icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
)

// EmitWriteErrorAcknowledgementEvent emits an event signalling an error acknowledgement and including the error details
func EmitWriteErrorAcknowledgementEvent(ctx sdk.Context, packet exported.PacketI, err error) {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
icatypes.EventTypePacket,
sdk.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName),
sdk.NewAttribute(icatypes.AttributeKeyAckError, err.Error()),
sdk.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()),
),
)
}
6 changes: 6 additions & 0 deletions modules/apps/27-interchain-accounts/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const (
// AcknowledgementError defines a string constant included in error acknowledgements
// NOTE: Changing this const is state machine breaking as acknowledgements are written into state
AcknowledgementError = "error handling packet on host chain: see events for details"
)

var (
ErrUnknownDataType = sdkerrors.Register(ModuleName, 2, "unknown data type")
ErrAccountAlreadyExist = sdkerrors.Register(ModuleName, 3, "account already exist")
Expand Down
9 changes: 9 additions & 0 deletions modules/apps/27-interchain-accounts/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package types

// ICS27 Interchain Accounts events
const (
EventTypePacket = "ics27_packet"

AttributeKeyAckError = "error"
AttributeKeyHostChannelID = "host_channel_id"
)