-
Notifications
You must be signed in to change notification settings - Fork 626
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
refactor: remove SendTransfer, require IBC transfers to be initiated with MsgTransfer #2446
Conversation
Remove SendTransfer function. MsgTransfer should be used which will call sendTransfer Tests refactored to utilize MsgTransfer. Simplified test logic.
@@ -43,29 +50,31 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { | |||
} | |||
|
|||
for _, tc := range testCases { | |||
suite.SetupTest() | |||
suite.Run(tc.name, func() { |
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 like using suite.Run because it adds the test case name to the output if it fails
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2446 +/- ##
==========================================
+ Coverage 78.70% 78.74% +0.04%
==========================================
Files 178 178
Lines 12311 12298 -13
==========================================
- Hits 9689 9684 -5
+ Misses 2195 2190 -5
+ Partials 427 424 -3
|
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 on the tests! 👏
@@ -83,14 +58,6 @@ func (k Keeper) sendTransfer( | |||
timeoutHeight clienttypes.Height, | |||
timeoutTimestamp uint64, | |||
) error { | |||
if !k.GetSendEnabled(ctx) { |
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.
What's the reason to move these checks to the message server?
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 believe the message server was added after send enabled, which is why it ended up within "SendTransfer"
The reasoning for why I moved it is because I view it as auxiliary to the transfer logic. It isn't in the IBC specification for ICS20
I visualize the code like this:
// entry point
MsgTransfer
// basic checks/auxiliary logic
IsSendEnabeld?
IsSenderBlocked?
// perform ics20 logic
sendTransfer
I think this should be true for most of our handlers:
// single entry point, Msg...
// basic checks in msg_server.go
isEnabled?
object.ValidateBasic()
// perform logic (typically relay.go)
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.
In general I think we should avoid overloading functions. Basic enablement checks make sense to go directly in the entrypoint (msg_server.go), while functions nested deeper in the handler can focus on ICS logic entirely
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.
Agree++
Definitely a good way to reason about things!
if tc.expPass { | ||
suite.Require().NoError(err) | ||
suite.Require().NotNil(res) |
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.
Do you think we should also add here checks for changes that we expect to have happened in case of success (e.g. the expected amount is escrowed in the escrow account)? We check for this already in the e2e tests but maybe it's good to add here for redundancy?
Same comment maybe for the failure cases.
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 think we should. But maybe we should do in a followup issue so as not to increase the scope of this one too much?
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
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.
Super clean refactor. Nice work!
@@ -83,14 +58,6 @@ func (k Keeper) sendTransfer( | |||
timeoutHeight clienttypes.Height, | |||
timeoutTimestamp uint64, | |||
) error { | |||
if !k.GetSendEnabled(ctx) { |
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.
Agree++
Definitely a good way to reason about things!
…e-SendTransfer-pubclicfunc
…om:cosmos/ibc-go into colin/1918-remove-SendTransfer-pubclicfunc
…e-SendTransfer-pubclicfunc
…e-SendTransfer-pubclicfunc
…om:cosmos/ibc-go into colin/1918-remove-SendTransfer-pubclicfunc
…with MsgTransfer (#2446) ## Description closes: #1918 --- 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. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [x] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [x] Re-reviewed `Files changed` in the Github PR explorer - [x] Review `Codecov Report` in the comment section below once CI passes (cherry picked from commit 24b17bd) # Conflicts: # modules/apps/transfer/keeper/mbt_relay_test.go # modules/apps/transfer/keeper/msg_server_test.go # modules/apps/transfer/keeper/relay.go # modules/apps/transfer/keeper/relay_test.go
…with MsgTransfer (backport #2446) (#2527) * refactor: remove SendTransfer, require IBC transfers to be initiated with MsgTransfer (#2446) ## Description closes: #1918 --- 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. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [x] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [x] Re-reviewed `Files changed` in the Github PR explorer - [x] Review `Codecov Report` in the comment section below once CI passes (cherry picked from commit 24b17bd) # Conflicts: # modules/apps/transfer/keeper/mbt_relay_test.go # modules/apps/transfer/keeper/msg_server_test.go # modules/apps/transfer/keeper/relay.go # modules/apps/transfer/keeper/relay_test.go * fix test Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Carlos Rodriguez <crodveg@gmail.com>
Description
closes: #1918
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/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes