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

check fee module locked and enable fee before refunding all fees #1341

Merged
merged 11 commits into from
May 16, 2022
8 changes: 8 additions & 0 deletions modules/apps/29-fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ func (im IBCMiddleware) OnChanCloseConfirm(
return err
}

if im.keeper.IsLocked(ctx) {
return types.ErrFeeModuleLocked
}
colin-axner marked this conversation as resolved.
Show resolved Hide resolved

if !im.keeper.IsFeeEnabled(ctx, portID, channelID) {
seantking marked this conversation as resolved.
Show resolved Hide resolved
return types.ErrFeeNotEnabled
}
Copy link
Contributor

@colin-axner colin-axner May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good for us to think about why we even have "fee enabled channels". This is because non fee enabled channels still use the same middleware stack as fee enabled channels. Thus this check prevents closing of a non fee enabled channel. A key requirement of the middleware design is that middleware not enabled for a specific channel must not affect the behaviour of that channel (this requirement is broken by returning an error).

We should:

  • return nil if the fee is not enabled (exit early)
  • move this check above IsLocked

The reasoning for the second point is that we don't want non fee enabled channels to get affected by the fee module getting locked. A locked fee module should not affect non fee enabled channels

btw, thanks for the contribution! :)

Copy link
Contributor Author

@vuong177 vuong177 May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you. It helped me understand. I'll make the changes.


if err := im.keeper.RefundFeesOnChannelClosure(ctx, portID, channelID); err != nil {
return err
}
Expand Down