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

Add UpdateChannel to Endpoint #3984

Closed
2 of 3 tasks
DimitrisJim opened this issue Jun 29, 2023 · 5 comments · Fixed by #5725
Closed
2 of 3 tasks

Add UpdateChannel to Endpoint #3984

DimitrisJim opened this issue Jun 29, 2023 · 5 comments · Fixed by #5725
Assignees
Labels
nice-to-have testing Testing package and unit/integration tests type: code hygiene Clean up code but without changing functionality or interfaces

Comments

@DimitrisJim
Copy link
Contributor

DimitrisJim commented Jun 29, 2023

Summary

Would be nice to add a helper function on Endpoint that takes care of setting channel fields as needed. We currently have SetChannelState, would be nice if we could also set the flush status, order, etc without requiring a different function each time. Taking inspiration from Cians suggestion, we could have:

func (endpoint *Endpoint) UpdateChannel(updater func(channel *channeltypes.Channel)) error {
	channel := endpoint.GetChannel()
	updater(&channel)
	endpoint.SetChannel(channel)

	endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain)

	return endpoint.Counterparty.UpdateClient()
}

This could resolve most instances of the pattern: get channel, modify, set channel. Adding this function ideally removes SetChannelState completely and allows SetChannel/GetChannel to be private or, possibly, inlined into UpdateChannel.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@DimitrisJim DimitrisJim added testing Testing package and unit/integration tests nice-to-have type: code hygiene Clean up code but without changing functionality or interfaces labels Jun 29, 2023
@DimitrisJim
Copy link
Contributor Author

Would be best to implement and refactor relevant usages after 04-channel-ugprades has been merged.

@colin-axner
Copy link
Contributor

Going to note we should not remove any functions which can be handled with this improvement (SetChannelState for example). We can update our usage internally and add notes in the migration doc but should mark the function as deprecated. There are too many breaking changes in v8 (big release for us + sdk bump + cometbft bump) to justify any code-hygenie breaking changes. We can remove those functions in v9 if we so wish

@DimitrisJim
Copy link
Contributor Author

ah right, had completely forgotten testing package is actually part of API, that is wild.

@colin-axner
Copy link
Contributor

It's a fairly widely used component of ibc-go. Originally it was designed only for internal usage, but then it fairly quickly was forked a lot to which a second set of improvements (dubbed v2) revitalized the testing pkg to be reuseable outside of ibc-go

@crodriguezvega crodriguezvega moved this to Backlog in ibc-go Nov 6, 2023
@colin-axner colin-axner changed the title Add UpgradeChannel to Endpoint Add UpdateChannel to Endpoint Jan 15, 2024
@crodriguezvega crodriguezvega moved this from Backlog to Todo in ibc-go Jan 21, 2024
@charleenfei charleenfei self-assigned this Jan 22, 2024
@DimitrisJim
Copy link
Contributor Author

could maybe deprecate these in v10 too along with Coordinator funcs?

@crodriguezvega crodriguezvega moved this from Todo to In review in ibc-go Jan 26, 2024
@github-project-automation github-project-automation bot moved this from In review 👀 to Done 🥳 in ibc-go Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nice-to-have testing Testing package and unit/integration tests type: code hygiene Clean up code but without changing functionality or interfaces
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants