Skip to content

Commit

Permalink
add frozen when icq timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
GNaD13 committed Oct 31, 2023
1 parent 3ef7b78 commit d13a4b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
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

0 comments on commit d13a4b0

Please sign in to comment.