Skip to content
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

feat: adding InitChannel util function #534

Closed
wants to merge 1 commit into from

Conversation

seantking
Copy link
Contributor

Description

Adding a helper function to open a new channel in the case that a channel closes. This is necessary so that a controller chain can regain access to an ICA.

closes: #509


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.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

// Opens a new channel on a particular port given a connection
// This is a helper function to open a new channel
// in case of a channel closing and the controller chain needs to regain access to an interchain account on the host chain
func (k Keeper) InitChannel(ctx sdk.Context, portID, connectionID string) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the naming here. I would like some opinions on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReopenChannel? I'm not sure either, but I wouldn't want external users to start using InitChannel in place of InitInterchainAccount

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point.

portID, _ = types.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointA.Counterparty.ConnectionID)

// bind port and claim capability
cap := suite.chainA.GetSimApp().ICAKeeper.BindPort(suite.chainA.GetContext(), portID)
Copy link
Contributor Author

@seantking seantking Nov 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not entirely sure what the best method for testing this out is or how far we want to go with testing. I initially made a call to InitInterchainAccount and finished the handshake, and then tried to call InitChannel and finish a second handshake, but I ran into verification issues. This is probs overkill anyway.

Basically, I'm just binding the port fresh here and then checking that we can finish a handshake.

// finish the channel handshake

// commit state changes for proof verification
path.EndpointA.Chain.App.Commit()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe overkill finishing the handshake here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong preference, but might be better to split this off into its own test, ie one test doing table tests and another finishing the handshake in the happy case

@codecov-commenter
Copy link

Codecov Report

Merging #534 (48f61cd) into interchain-accounts (3ff5bf8) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                   Coverage Diff                   @@
##           interchain-accounts     #534      +/-   ##
=======================================================
+ Coverage                79.10%   79.11%   +0.01%     
=======================================================
  Files                      134      134              
  Lines                    10347    10354       +7     
=======================================================
+ Hits                      8185     8192       +7     
  Misses                    1753     1753              
  Partials                   409      409              
Impacted Files Coverage Δ
...ules/apps/27-interchain-accounts/keeper/account.go 83.78% <100.00%> (+3.78%) ⬆️

@seantking
Copy link
Contributor Author

@AdityaSripal @colin-axner @damiannolan I'm actually questioning now if this is even necessary at all and maybe should be removed from the spec as well.

In the case that a channel closes, an ICA-auth module could just call the OnChanOpenInit function directly I imagine. Or just use a relayer to re-open a channel. Although perhaps this util will make things a bit easier.

@AdityaSripal
Copy link
Member

Hmm it seems like the way you have it here is the cleanest option.

If you want to reopen the channel directly, you could do

icaKeeper.channelKeeper.ChanOpenInit(...)
// callback doesn't get called by channelKeeper's ChanOpenInit function
// it gets called by the msg server
icaModule.OnChanOpenInit(...)

But sending the message to IBC's msgserver, just abstracts the above lines for you since that is basically what the message server does. And it seems like easier maintanence to me, if core IBC ever refactors its message handling, then you don't have to reimplement the channel msg server function within ICA

// Opens a new channel on a particular port given a connection
// This is a helper function to open a new channel
// in case of a channel closing and the controller chain needs to regain access to an interchain account on the host chain
func (k Keeper) InitChannel(ctx sdk.Context, portID, connectionID string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReopenChannel? I'm not sure either, but I wouldn't want external users to start using InitChannel in place of InitInterchainAccount


// Opens a new channel on a particular port given a connection
// This is a helper function to open a new channel
// in case of a channel closing and the controller chain needs to regain access to an interchain account on the host chain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

godoc should begin with the name of the function

@@ -67,3 +68,74 @@ func (suite *KeeperTestSuite) TestInitInterchainAccount() {
})
}
}

func (suite *KeeperTestSuite) TestInitChannel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should test that when a channel is closed and the portID is set to inactive, a new channel can be opened

// finish the channel handshake

// commit state changes for proof verification
path.EndpointA.Chain.App.Commit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong preference, but might be better to split this off into its own test, ie one test doing table tests and another finishing the handshake in the happy case

@colin-axner
Copy link
Contributor

@seantking I also question whether we need this. My hesitancy is that we don't fully understand when this might be needed. If the function is just creating a MsgChannelOpenInit then I wonder if it is best to let the caller handle this complexity (since it isn't very much). I don't have a preference though

@crodriguezvega
Copy link
Contributor

Not sure if this is feasible, but would there be any way of using the InitInterchainAccount for this use case as well? Maybe the function needs to be renamed to something else more descriptive, but if we have only one function to initialize the interchain account whether the channel is open or not, then I guess the API is simplified for the user. For example, if the channel is closed and the caller calls InitInterchainAccount again (assuming with the same arguments as for the first time it was invoked), then you skip the port binding and do only the opening of the channel.

@colin-axner
Copy link
Contributor

One point of consideration is that this change could be released in a minor release. Perhaps it is best to not add it for now and add it later if it becomes desirable? Relayers could always just send the MsgChanOpenInit themselves?

@seantking
Copy link
Contributor Author

seantking commented Jan 10, 2022

Closing this for the now as we are deciding to leave this out of the API for the time being. @AdityaSripal We may want to remove this from the spec if we decide to leave it out of the release.

@seantking seantking closed this Jan 10, 2022
faddat pushed a commit to notional-labs/ibc-go that referenced this pull request Feb 23, 2022
faddat pushed a commit to notional-labs/ibc-go that referenced this pull request Mar 1, 2022
* WIP Provider interface

* Add definitions to the txProvider and begin migration of cosmos specific logic to cosmos provider

* get connection based msgs behind TxProvider

* finish implementing TxProvider interface

* WIP: implementing QueryProvider

* finish implementing QueryProvider

* Define and implement the KeyProvider interface

* Merge PR cosmos#530: Config refactor to handle provider abstraction

* WIP: refactor config for provider abstraction

* bump gopkg.in/yaml from v2 to v3

* refactor config for provider abstraction

* better var naming & doc tweaks

* Merge PR cosmos#533: Refactor core relayer code to use provider interface

* refactor cli based key management

* refactor path cli based commands

* testing new config

* WIP: refactor chain cli based commands

* delete dev and testnet cmds

* Merge PR cosmos#534: State Based Relaying, Reenable tests, Add Osmosis to tests

* Migrate https://github.com/strangelove-ventures/relayer/pull/35 to this PR

* Merge PR cosmos#535: Working tests and Strategy removal

* Add osmosis to supported chains for test env

* Remove more stuff and add make test-short

* Add build osmosis container make file

* WIP: push everything behind provider interface

* WIP: push everything behind provider interface pt 2

* WIP: swap out old function calls for new provider calls

* IT'S ALIVE! (bug fix time)

* Most tests working! 🎉🚀💯

* update filename for fetch tests

Co-authored-by: Jack Zampolin <[email protected]>

* Fix test race conditions

* Add back makefile test targets

Co-authored-by: jtieri <[email protected]>
@seantking seantking deleted the sean/issue#509-init-channel branch August 3, 2022 14:00
CosmosCar pushed a commit to caelus-labs/ibc-go that referenced this pull request Nov 6, 2023
…2.0 (cosmos#534)

Bumps [nosborn/github-action-markdown-cli](https://github.com/nosborn/github-action-markdown-cli) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/nosborn/github-action-markdown-cli/releases)
- [Commits](nosborn/github-action-markdown-cli@v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: nosborn/github-action-markdown-cli
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants