ibc icon indicating copy to clipboard operation
ibc copied to clipboard

Add comments to handler for async handshake

Open AdityaSripal opened this issue 2 years ago • 1 comments
trafficstars

Writeup in the comments of how to compose the utility functions provided by IBC to implement async handshakes

closes: #732

cc: @michaelfig

AdityaSripal avatar Sep 19 '23 15:09 AdityaSripal

@AdityaSripal, for async version negotiation in ibc-go, will I have to patch core/keeper/msg_server.go's ChannelOpenTry with the following?

	// Perform application logic callback
	version, err := cbs.OnChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, cap, msg.Channel.Counterparty, msg.CounterpartyVersion)
	if err != nil {
		return nil, sdkerrors.Wrap(err, "channel open try callback failed")
	}

	// FIGME: If version is the empty string, expect the app to call WriteOpenTryChannel explicitly, possibly later...
	if version != "" {
		// Write channel into state
		k.ChannelKeeper.WriteOpenTryChannel(ctx, msg.PortId, channelID, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.Channel.Counterparty, version)
	}

	return &channeltypes.MsgChannelOpenTryResponse{
		Version: version,
	}, nil

This may also justify adding something like a WriteOpenTryChannel method to ICS4Wrapper to extend the async version feature to Middleware.

michaelfig avatar Dec 18 '23 18:12 michaelfig

@michaelfig yes. We are trying to improve the interface for middleware to avoid the complicated wiring as it exists. I think this will be much cleaner in future designs, and the ICS4 wrapper interface itself should be unnecessary

AdityaSripal avatar Mar 12 '24 14:03 AdityaSripal