-
Notifications
You must be signed in to change notification settings - Fork 758
fix: adding check for blocked addresses before escrowing fees #1890
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
Changes from 7 commits
8525e4e
42d6666
808ee69
337df64
e9248c4
8a6b1f1
e3115f5
6309549
ffb9e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,15 @@ var _ types.MsgServer = Keeper{} | |
| func (k Keeper) RegisterPayee(goCtx context.Context, msg *types.MsgRegisterPayee) (*types.MsgRegisterPayeeResponse, error) { | ||
| ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
|
||
| payee, err := sdk.AccAddressFromBech32(msg.Payee) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if k.bankKeeper.BlockedAddr(payee) { | ||
| return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not authorized to be a payee", payee) | ||
| } | ||
|
|
||
| // only register payee address if the channel exists and is fee enabled | ||
| if _, found := k.channelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId); !found { | ||
| return nil, channeltypes.ErrChannelNotFound | ||
|
|
@@ -78,6 +87,15 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) | |
| return nil, types.ErrFeeModuleLocked | ||
| } | ||
|
|
||
| refundAcc, err := sdk.AccAddressFromBech32(msg.Signer) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if k.bankKeeper.BlockedAddr(refundAcc) { | ||
| return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to escrow fees", refundAcc) | ||
| } | ||
|
|
||
| // get the next sequence | ||
| sequence, found := k.GetNextSequenceSend(ctx, msg.SourcePortId, msg.SourceChannelId) | ||
| if !found { | ||
|
|
@@ -110,6 +128,15 @@ func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacket | |
| return nil, types.ErrFeeModuleLocked | ||
| } | ||
|
|
||
| refundAcc, err := sdk.AccAddressFromBech32(msg.PacketFee.RefundAddress) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if k.bankKeeper.BlockedAddr(refundAcc) { | ||
| return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to escrow fees", refundAcc) | ||
| } | ||
|
Comment on lines
+118
to
138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we move the check to below
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed |
||
|
|
||
| nextSeqSend, found := k.GetNextSequenceSend(ctx, msg.PacketId.PortId, msg.PacketId.ChannelId) | ||
| if !found { | ||
| return nil, sdkerrors.Wrapf(channeltypes.ErrSequenceSendNotFound, "channel does not exist, portID: %s, channelID: %s", msg.PacketId.PortId, msg.PacketId.ChannelId) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -672,9 +672,9 @@ func (app *SimApp) LoadHeight(height int64) error { | |
| func (app *SimApp) ModuleAccountAddrs() map[string]bool { | ||
| modAccAddrs := make(map[string]bool) | ||
| for acc := range maccPerms { | ||
| // do not add mock module to blocked addresses | ||
| // do not add the following modules to blocked addresses | ||
| // this is only used for testing | ||
| if acc == ibcmock.ModuleName { | ||
| if acc == ibcmock.ModuleName || acc == distrtypes.ModuleName { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pretty hacky I just left it in for discussion. I'm guessing we don't want to unblock the distribution module? We have the following test case. We ensure a non-blocked module account can escrow fees. When I try to use the mock module account I get an AuthKeeper error saying the account doesn't exist. I'm not sure why exactly. I've left the test case as is using the distribution module account for now. cc: @colin-axner
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was looking at the test case "refund account is a module account" and trying to use The account does not exist error is being returned from here in escrow.go. And interestingly if we actually use This differs from It's definitely pretty ambiguous as to what constitutes a blocked address and what doesn't. Without this logical OR added for When I use the following in the It would be nice to get some more clarity around module accounts in general. We could use the above and also fund the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the blocked address logic gets removed from the SDK, what test case would we want to have? I'd say probably still wise to just use the mock module account since it may not make sense long term to use distr (as community pool might be removed from it) Maybe we can add the mock module to the list of genAccs in Also I think you can use |
||
| continue | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of adding a new error, do something like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤝 done