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

add frozen when icq timeout #103

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions x/feeabs/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ func (am IBCModule) OnTimeoutPacket(
if err := types.ModuleCdc.UnmarshalJSON(packet.GetData(), &icqPacketData); err != nil {
return sdkerrors.Wrapf(errorstypes.ErrUnknownRequest, "cannot unmarshal packet data: %v", err)
}
// Frozen all hostzone
am.keeper.FrozenAllHostZone(ctx)
// Resend request if timeout
err := am.keeper.OnTimeoutPacket(ctx)
if err != nil {
Expand Down
21 changes: 13 additions & 8 deletions x/feeabs/keeper/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,7 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, ack channeltypes.Acknow
),
)
case *channeltypes.Acknowledgement_Error:
k.IterateHostZone(ctx, func(hostZoneConfig types.HostChainFeeAbsConfig) (stop bool) {
err := k.FrozenHostZoneByIBCDenom(ctx, hostZoneConfig.IbcDenom)
if err != nil {
k.Logger(ctx).Error(fmt.Sprintf("Failed to frozen host zone %s", err.Error()))
}

return false
})
k.FrozenAllHostZone(ctx)
k.Logger(ctx).Error(fmt.Sprintf("failed to send packet ICQ request %v", resp.Error))

ctx.EventManager().EmitEvent(
Expand All @@ -187,6 +180,18 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, ack channeltypes.Acknow
return nil
}

// FrozenAllHostZone resend packet when timeout
func (k Keeper) FrozenAllHostZone(ctx sdk.Context) {
k.IterateHostZone(ctx, func(hostZoneConfig types.HostChainFeeAbsConfig) (stop bool) {
err := k.FrozenHostZoneByIBCDenom(ctx, hostZoneConfig.IbcDenom)
if err != nil {
k.Logger(ctx).Error(fmt.Sprintf("Failed to frozen host zone %s", err.Error()))
}

return false
})
}

// OnTimeoutPacket resend packet when timeout
func (k Keeper) OnTimeoutPacket(ctx sdk.Context) error {
return k.handleOsmosisIbcQuery(ctx)
Expand Down
Loading