-
Notifications
You must be signed in to change notification settings - Fork 629
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
imp (api)!: convert coins to token only once in MsgTransfer #7110
Conversation
@@ -35,8 +35,8 @@ func (k Keeper) TokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, erro | |||
} | |||
|
|||
// UnwindHops is a wrapper around unwindHops for testing purposes. | |||
func (k Keeper) UnwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgTransfer, error) { | |||
return k.unwindHops(ctx, msg) | |||
func (k Keeper) UnwindHops(msg *types.MsgTransfer, tokens []types.Token) (*types.MsgTransfer, 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 is an API-breaking change but since I assume the whole feature branch will this should not be an issue
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.
Please correct me if I am wrong, but since this function is in a _test.go
file, then it is not part of the public API, right?
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.
Yeah that's a good point, I wasn't too sure about it tbh!
@@ -130,30 +130,22 @@ func (k Keeper) unwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgT | |||
// getUnwindHops returns the hops to be used during unwinding. If coins consists of more than | |||
// one coin, all coins must have the exact same trace, else an error is returned. getUnwindHops | |||
// also validates that the coins are not native to the chain. | |||
func (k Keeper) getUnwindHops(ctx sdk.Context, coins sdk.Coins) ([]types.Hop, error) { | |||
func (Keeper) getUnwindHops(tokens []types.Token) ([]types.Hop, 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 function can technically be moved out of the keeper now, since it does need to read state to convert coins to token anymore. Happy to do it if it seems the best thing to do
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.
Makes sense to me!
@@ -327,13 +327,6 @@ func (suite *KeeperTestSuite) TestUnwindHops() { | |||
suite.Require().Equal(*msg, *modified, "expected msg and modified msg are different") | |||
}, | |||
}, | |||
{ |
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.
I don't believe we need this test anymore, because this would have failed during the conversion we don't perform anymore
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! Great work. The changes look good to me. It's nice to be more efficient in this approach
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.
Sorry for leaving the review after merge, but is there a reason why we couldn't merge this directly to main and then backport to v9? Then we also have these changes in the release branch. As far as I can see there is nothing in the PR that directly depends on the port router refactor, right?
@@ -35,8 +35,8 @@ func (k Keeper) TokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, erro | |||
} | |||
|
|||
// UnwindHops is a wrapper around unwindHops for testing purposes. | |||
func (k Keeper) UnwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgTransfer, error) { | |||
return k.unwindHops(ctx, msg) | |||
func (k Keeper) UnwindHops(msg *types.MsgTransfer, tokens []types.Token) (*types.MsgTransfer, 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.
Please correct me if I am wrong, but since this function is in a _test.go
file, then it is not part of the public API, right?
You're right, I could have done it but just automatically went on "feature branch" mode :) I think it should be safe to add the same PR for main, I can do it |
* test not working * refactored test and removed unneeded caese
@crodriguezvega actually scratch my previous comment. On main we don't have the inefficient looping ( ibc-go/modules/apps/transfer/keeper/msg_server.go Lines 30 to 51 in 9efb710
coins to tokens in the Transfer function since we use k.sendTransfer that takes coins ).
(inside that function we still convert |
Ah, gotcha. Thank you for explaining! |
thanks for picking this one up, LGTM |
Description
closes: #7080
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.