From d13a4b0ce5809fa9162fe7690d98035029d56c5a Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 31 Oct 2023 11:43:37 +0700 Subject: [PATCH] add frozen when icq timeout --- x/feeabs/ibc_module.go | 2 ++ x/feeabs/keeper/ibc.go | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/x/feeabs/ibc_module.go b/x/feeabs/ibc_module.go index fed4ed64..0eeb8338 100644 --- a/x/feeabs/ibc_module.go +++ b/x/feeabs/ibc_module.go @@ -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 { diff --git a/x/feeabs/keeper/ibc.go b/x/feeabs/keeper/ibc.go index b633a43e..f9fed000 100644 --- a/x/feeabs/keeper/ibc.go +++ b/x/feeabs/keeper/ibc.go @@ -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( @@ -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)