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.
|
|
||
| for _, tc := range testCases { | ||
| suite.SetupTest() | ||
| suite.Run(tc.name, func() { |
There was a problem hiding this comment.
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
|
crodriguezvega
left a comment
There was a problem hiding this comment.
Nice work on the tests! 👏
| timeoutHeight clienttypes.Height, | ||
| timeoutTimestamp uint64, | ||
| ) error { | ||
| if !k.GetSendEnabled(ctx) { |
There was a problem hiding this comment.
What's the reason to move these checks to the message server?
There was a problem hiding this comment.
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.
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.
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.
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.
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>
damiannolan
left a comment
There was a problem hiding this comment.
Super clean refactor. Nice work!
| timeoutHeight clienttypes.Height, | ||
| timeoutTimestamp uint64, | ||
| ) error { | ||
| if !k.GetSendEnabled(ctx) { |
There was a problem hiding this comment.
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/)godoccomments.Unreleasedsection inCHANGELOG.mdFiles changedin the Github PR explorerCodecov Reportin the comment section below once CI passes