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

Standardize sub-keeper usage within the ibc keeper #6058

Closed
3 tasks
chatton opened this issue Mar 26, 2024 · 3 comments · Fixed by #6081
Closed
3 tasks

Standardize sub-keeper usage within the ibc keeper #6058

chatton opened this issue Mar 26, 2024 · 3 comments · Fixed by #6081
Assignees
Labels
type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.
Milestone

Comments

@chatton
Copy link
Contributor

chatton commented Mar 26, 2024

Summary

Currently, there is a mix of both reference and value types used for keepers in the app.go wiring. This has been problematic when the same keeper instance is expected to be passed to different keepers.

For example, the clientKeeper is passed to the connectionKeeper as well as the ibcKeeper. If a mutable field is added to the clientKeeper, this field will be discarded if the keeper is de-referenced and passed by value to one, and passed by reference to another.

This has caused multiple subtle bugs, recently we ran into an issue with the consensus host validation where the overridden validation implementation was correctly assigned to ibcKeeper's clientKeeper but was not overridden in the connectionKeeper's clientKeeper.

There was also a previous issue where the router was being discarded due to the same de-referencing issue.

Because the intent is that all sub-keepers of the ibc keeper refer to the same instances, I propose we simply make all keeper references pointers, instead of values.

I think this will effectively remove this class of error from the codebase.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@chatton chatton added the type: refactor Architecture, code or CI improvements that may or may not tackle technical debt. label Mar 26, 2024
@chatton chatton added this to the v9.0.0 milestone Mar 26, 2024
@crodriguezvega
Copy link
Contributor

Thanks, @chatton. So we should change this into something like this, right?

type Keeper struct {
  // implements gRPC QueryServer interface
  types.QueryServer

  cdc codec.BinaryCodec

  ClientKeeper     *clientkeeper.Keeper
  ConnectionKeeper *connectionkeeper.Keeper
  ChannelKeeper    *channelkeeper.Keeper
  PortKeeper       *portkeeper.Keeper
  Router           *porttypes.Router

  authority string
}

@chatton
Copy link
Contributor Author

chatton commented Mar 28, 2024

Yep @crodriguezvega ! Pretty much exactly that! For all submodule keepers as well.

@crodriguezvega crodriguezvega moved this to Todo 🏃 in ibc-go Apr 1, 2024
@damiannolan
Copy link
Contributor

Yeah! I think submodules should be fine, once the NewKeeper funcs return a pointer to core and are all plumbed through correctly it shouldn't need many other changes as submodules use expected interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants