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 upgrade callbacks IBCModule interface #1614

Closed
3 tasks
damiannolan opened this issue Jun 29, 2022 · 11 comments
Closed
3 tasks

Add upgrade callbacks IBCModule interface #1614

damiannolan opened this issue Jun 29, 2022 · 11 comments
Assignees
Labels
04-channel channel-upgradability Channel upgradability feature needs discussion Issues that need discussion before they can be worked on

Comments

@damiannolan
Copy link
Member

damiannolan commented Jun 29, 2022

Summary

Update the IBCModule interface to include application callback handlers for the 04-channel upgrade API.

As adapted from ICS004 Channel Upgrades:

func OnChanUpgradeInit(
        ctx sdk.Context,
        portID,
        channelID string,
        version string,
        order channeltypes.Order,
        connectionHops []string,
        previousVersion string,
) (string, error)

func OnChanUpgradeTry(
        ctx sdk.Context,
        portID,
        channelID string,
        order channeltypes.Order,
        connectionHops []string,
        counterpartyVersion string,
) (string, error)

func OnChanUpgradeAck(
        ctx sdk.Context,
        portID,
        channelID, 
        counterpartyChannelID,
        counterpartyVersion string
) error

func OnChanUpgradeConfirm(
        ctx sdk.Context,
        portID,
        channelID string,
) error

func OnChanUpgradeRestore(
        ctx sdk.Context,
        portID,
        channelID string,
) error

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@damiannolan damiannolan added this to the 04-channel upgrades alpha milestone Jun 29, 2022
@damiannolan damiannolan self-assigned this Jun 29, 2022
@damiannolan damiannolan mentioned this issue Jun 29, 2022
10 tasks
@AdityaSripal
Copy link
Member

Transfer and ICA will be trivial since upgrades are not supported at the moment.

We will want to provide a path for non-fee enabled channels to become fee enabled by using the upgrade callbacks in ics-29

@crodriguezvega crodriguezvega moved this to Backlog in ibc-go Jun 29, 2022
@damiannolan damiannolan moved this from Backlog to Todo in ibc-go Jul 21, 2022
@damiannolan
Copy link
Member Author

Check the spec for any updates to callbacks. (e.g. previous channel version should be included)

@chatton chatton assigned chatton and damiannolan and unassigned damiannolan and chatton Jul 27, 2022
@damiannolan damiannolan moved this from Todo to In progress in ibc-go Aug 1, 2022
@crodriguezvega crodriguezvega moved this to Todo in ibc-go Nov 1, 2022
@damiannolan
Copy link
Member Author

Scaffolding with no-op callback handlers has been added in #3323

@AdityaSripal
Copy link
Member

I think this should be a separate interface so it isn't absolutely necessary to implement for IBC functionality.

Similar to how AppModule in the SDK actually has multiple interfaces that each extend the previous with more functionality

@damiannolan
Copy link
Member Author

I agree it would be nice to not enforce it.

So essentially remove this https://github.com/cosmos/ibc-go/blob/04-channel-upgrades/modules/core/05-port/types/module.go#L15. When we retrieve cbs using the Router we will need to do a conversion then in order to invoke the upgrade callbacks.

@chatton chatton self-assigned this Jun 27, 2023
@chatton
Copy link
Contributor

chatton commented Jun 27, 2023

Conceptually I like the idea of having this split off as separate interface entirely, but this might lead to a bad UX for middleware devs.

If a middleware implements the IBCModule interface (but not the UpgradableModule interface ), we could end up in a situation where a component of the stack does not implement this interface and it would fail.

It adds more work for middle ware developers to make sure that they implement these 2 interfaces and would not get compile time errors in their app.go as the only requirement is the IBCModule module.

To me it is preferable to just need to worry about a single interface and let the compiler help with showing which methods need to be defined.

I discussed this a while back with @colin-axner if you have anything else to add!

@DimitrisJim
Copy link
Contributor

DimitrisJim commented Jun 29, 2023

on the flip-side this imposes a change on all middleware devs and could be another reason why someone wouldn't update to the most recent version of ibc-go. (Even if the change is merely stub impls of the relevant methods)

Do we expect all middleware to support upgradability? Must they? (What happens if they don't?). If so, I'd say its sensible to enforce it, if not, would be nice to let them choose.

Considering this, do we have a channel we could get feed-back on from third-party consumers of the interface? Would be nice to hear other opinions too.

@chatton
Copy link
Contributor

chatton commented Jul 4, 2023

@DimitrisJim good point, one thing to possibly consider is exporting an UpgradeUnsupported type that implements all the upgrade handlers returning errors.

This makes the code change a 1 line where you would just need to embed this type into the middleware

@chatton chatton removed their assignment Jul 5, 2023
@chatton chatton added the needs discussion Issues that need discussion before they can be worked on label Jul 18, 2023
@chatton
Copy link
Contributor

chatton commented Jul 18, 2023

Adding the needs discussion label to this one because I'm not sure there is a consensus on how we want to proceed with this one!

@DimitrisJim
Copy link
Contributor

Ah, I think I was thinking of this at some point and remember flipping and leaning towards your position. Would be nice to discuss tho.

@damiannolan
Copy link
Member Author

The Upgrade interface is currently embedded within the IBCModule interface: https://github.com/cosmos/ibc-go/blob/04-channel-upgrades/modules/core/05-port/types/module.go#L15

This makes it an API breaking change for app developers. If we wish to release channel upgrades in a minor version release, e.g. v8.1.0 we should remove the embedded interface and instead use a type assertion in the core msg server handler.

Example:

+ app, ok := k.Router.GetRoute(module)
+ if !ok {
+	ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
+	return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
+ }

- cbs, ok := k.Router.GetRoute(module).(porttypes.UpgradableModule)
+ cbs, ok := app.(porttypes.UpgradableModule)
if !ok {
	ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
	return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
04-channel channel-upgradability Channel upgradability feature needs discussion Issues that need discussion before they can be worked on
Projects
Archived in project
Development

No branches or pull requests

5 participants