-
Notifications
You must be signed in to change notification settings - Fork 597
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
chore(api)!: move checks from Transfer to OnSendPacket #7068
chore(api)!: move checks from Transfer to OnSendPacket #7068
Conversation
* deps: bump cosmos-sdk to v0.50.8 * chore: update changelog * deps: bump cosmossdk.io/client to v2.0.0-beta.3. bump x/upgrade to v0.1.4 * chore: make tidy-all * test: bump to 3f6796fba413cca for testing purposes. * deps: bump cosmos sdk to 0.50.9 * Update CHANGELOG.md * chore: update CHANGELOG for submodules. --------- Co-authored-by: DimitrisJim <[email protected]>
@@ -391,7 +391,7 @@ func (k Keeper) iterateForwardedPackets(ctx sdk.Context, cb func(packet types.Fo | |||
|
|||
// IsBlockedAddr checks if the given address is allowed to send or receive tokens. | |||
// The module account is always allowed to send and receive tokens. | |||
func (k Keeper) isBlockedAddr(addr sdk.AccAddress) bool { | |||
func (k Keeper) IsBlockedAddr(addr sdk.AccAddress) bool { |
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.
This was needed in order to be able to call it from OnSendPacket
@@ -33,27 +29,6 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. | |||
return nil, errorsmod.Wrapf(types.ErrSendDisabled, err.Error()) |
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.
This check was left in this function as the logic is not easy to implement on OnSendPacket
, we would have to export BankKeeper
but also add a lot of logic to convert coins
back to tokens
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.
This check is necessary to be moved. We can move it into keeper.OnSendPacket
. There's already logic to convert tokens to coin there
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.
Note: going forward, users can invoke OnSendPacket
without using MsgTransfer
, so it's unsafe to have any necessary checks remain in MsgTransfer
@@ -169,21 +169,6 @@ func (suite *KeeperTestSuite) TestSendTransfer() { | |||
// }, | |||
// channeltypes.ErrInvalidPacket, | |||
// }, | |||
{ |
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.
This test now doesn't succeed due to the following logic:
Transfer
does not check for the version/forwarding combination anymore- the function that creates the packet data will ignore everything in forwarding when the version is V1.
Note that there is still a check onOnSendPacket
but it will not be triggered because Hops will not be present.
I'll open an issue to add tests specifically for OnSendPacket
since we currently do not have them
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.
It should? I wonder if this was not working because of the 1
-> 0
change?
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.
ouch thanks, yeah it does. I'm trying to give up coffee starting today and you can see the results :(
Co-authored-by: colin axnér <[email protected]>
if k.IsBlockedAddr(sender) { | ||
return errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "%s is not allowed to send funds", sender) | ||
} | ||
|
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.
this is an unnecessary addition?
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.
No idea how this got in, sorry :/
@@ -430,7 +434,7 @@ func createPacketDataBytesFromVersion(appVersion, sender, receiver, memo string, | |||
case types.V1: | |||
// Sanity check, tokens must always be of length 1 if using app version V1. | |||
if len(tokens) != 1 { | |||
return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidRequest, "cannot transfer multiple coins with %s", types.V1) | |||
return nil, errorsmod.Wrapf(types.ErrInvalidVersion, "length of tokens must be equal to 1 if using %s version", types.V1) |
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.
would recommend doing changes like this against main since it is unrelated to the port router changes
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.
this was the result of a weird merge, because we used to panic
here so I added a similar change but not identical, will revert
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.
Nice work! As a side note, I noticed #7080 which came from the initial refactor, but as it was not necessary for this work I opened a separate issue
Ah! We noticed the same with Cian and were about to open an issue :D thanks! |
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.
there is some commented out code on L54 that can be removed now!
// packetData := types.NewFungibleTokenPacketData(
// fullDenomPath, msg.Token.Amount.String(), sender.String(), msg.Receiver, msg.Memo,
// )
Quality Gate passed for 'ibc-go'Issues Measures |
Description
closes: #6949
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.