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

modify ICA controller NewIBCMiddleware to default to nil auth module #3020

Closed
3 tasks
alpe opened this issue Jan 17, 2023 · 4 comments · Fixed by #6749
Closed
3 tasks

modify ICA controller NewIBCMiddleware to default to nil auth module #3020

alpe opened this issue Jan 17, 2023 · 4 comments · Fixed by #6749
Assignees
Labels
27-interchain-accounts type: refactor Architecture, code or CI improvements that may or may not tackle technical debt.
Milestone

Comments

@alpe
Copy link
Contributor

alpe commented Jan 17, 2023

Summary

I had some issues to setup the ICA controller. I understood that authentication module is optional but still the concrete setup was not clear to me.

Proposal

Some ideas that would have made it easier for me:

  • Add godoc for the constructor explaining app can be nil and what happens in this case
  • Provide a new constructor NewNoAuthIBCMiddleware(k keeper.Keeper) or better name that provides the correct instantiation
  • Provide a null-object like AcceptAllAuthIBCModule in the module that does noop (and you can get rid of the nil checks in the methods)
  • Replace porttypes.IBCModule interface with some new interface dedicated to authentication only. There is some overlap of methods but not all. IMHO a clear separation of concerns would improve the design and make it easier in the future. This would also give better IDE support to find all the implementations.

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@crodriguezvega crodriguezvega added needs discussion Issues that need discussion before they can be worked on type: refactor Architecture, code or CI improvements that may or may not tackle technical debt. labels Jan 18, 2023
@crodriguezvega crodriguezvega changed the title Authz setup in ICA controller Authentication module setup in ICA controller Mar 13, 2023
@crodriguezvega
Copy link
Contributor

Hi @alpe. We discussed this issue and we plan to address your first 2 items:

  1. we will add extra documentation.
  2. we will change the existing constructor to have only the keeper as argument and add a second constructor NewIBCMiddlewareWithAuth(app, keeper).

But we were not sure what you meant with your last point:

Replace porttypes.IBCModule interface with some new interface dedicated to authentication only. There is some overlap of methods but not all. IMHO a clear separation of concerns would improve the design and make it easier in the future. This would also give better IDE support to find all the implementations.

Could you please elaborate what you mean?

@crodriguezvega crodriguezvega moved this to Todo in ibc-go Apr 14, 2023
@crodriguezvega crodriguezvega added this to the v8.0.0 milestone Apr 14, 2023
@alpe
Copy link
Contributor Author

alpe commented Apr 21, 2023

Replace porttypes.IBCModule interface with some new interface dedicated to authentication only.

Could you please elaborate what you mean?

I have only a very limited context as I was not in the design discussions. From working with the ICA, I noticed:
The ica middleware constructor expects an object of type porttypes.IBCModule without any need. Only a subset of methods are called on the object within the middleware. The inter-tx demo implements only OnAcknowledgementPacket with some logic.

IMHO a new interface for the concrete purpose would make more sense. Instead of using IBC semantics, you could focus on the authentication/ authorization only. In the concrete inter-tx example, an Accept(ctx, ack,...)error would be enough.
This would be some separation of concerns that works nicely for tests and IDE support.
The design as middleware feels also not very adequate. IMHO a module would be a better fit as most ICS4Wrapper methods are not used. Passing a nil value to a middleware adds some smell, too.

@crodriguezvega
Copy link
Contributor

Thanks for the clarifications, @alpe!

I noticed: The ica middleware constructor expects an object of type porttypes.IBCModule without any need. Only a subset of methods are called on the object within the middleware. The inter-tx demo implements only OnAcknowledgementPacket with some logic.

Yes, that's true that inter-tx only really implements OnAcknowledgementPacket, but there could other authentication modules that do custom logic in the other callbacks declared in porttypes.IBCModule.

The design as middleware feels also not very adequate. IMHO a module would be a better fit as most ICS4Wrapper methods are not used. Passing a nil value to a middleware adds some smell, too.

This is the nil that is pass to NewIBCMiddleware for the app argument when there is no authentication module, right? We will fix this by removing that parameter from the argument list of NewIBCMiddleware and add a separate constructor function with signature NewIBCMiddlewareWithAuth(app, keeper) that will not allow a nil app as input.

@crodriguezvega crodriguezvega modified the milestones: v8.0.0, vNext Aug 17, 2023
@colin-axner
Copy link
Contributor

Revisiting this discussion. Sounds like the action items are:

  • Add godoc for the constructor explaining app can be nil (defaults to SDK authentication via msg server)
  • Change the existing constructor to have only the keeper as argument and add a second constructor NewIBCMiddlewareWithAuth(app, keeper)

The other concerns are very valid, but I think the general sentiment is that ics27 needs a whole v2 re-envisioning to simplify its construction and improve its dev UX. I think it makes to hold off on such changes until there's a deeper investigation into reworking ics27

@colin-axner colin-axner removed the needs discussion Issues that need discussion before they can be worked on label Jun 18, 2024
@colin-axner colin-axner changed the title Authentication module setup in ICA controller modify ICA controller NewIBCMiddleware to default to nil auth module Jun 18, 2024
@crodriguezvega crodriguezvega self-assigned this Jul 2, 2024
@crodriguezvega crodriguezvega moved this from Todo 🏃 to In progress 👷 in ibc-go Jul 2, 2024
@github-project-automation github-project-automation bot moved this from In progress 👷 to Done 🥳 in ibc-go Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
27-interchain-accounts 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