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

Refactor openIbcChannel and connectIbcChannel to align with IBC standards #22

Closed
zhengyangfeng00 opened this issue Aug 10, 2023 · 0 comments

Comments

@zhengyangfeng00
Copy link
Contributor

zhengyangfeng00 commented Aug 10, 2023

Background

In IBC standards, there are four steps in the handshake: openInit, openTry, openAck, and openConfirm.

A straightforward implementation for an IBC module would be to define four methods to handle the four steps. The relayer would then pick one to call depending on the state and who is the initiator of the connection.

However, in most cases, a user's smart contract does the same thing in openInit and openTry, and the same thing in openAck and openConfirm.

To provide a better development experience for the user, the vibc core SC requires the user's SC to implement only two callbacks: onOpenIbcChannel and onConnectIbcChannel.

The current implementation is as follows:

  • vibc core SC implements openIbcChannel, which is called in both openInit and openTry.
  • vibc core SC implements connectIbcChannel, which is called in both openAck and openConfirm.
  • openIbcChannel calls onOpenIbcChannel from the user's SC.
  • connectIbcChannel calls onConnectIbcChannel from the user's SC.

Problem and the proposed implementation

This has caused difficulty in implementing the state verification logic. In connectIbcChannel, we don't know if the method is called as the connection initiator or acceptor, and we don't know the state to verify. It could be either Ack_Pending or Confirm_Pending.

The proposed refactor is to split openIbcChannel into connOpenInit and connOpenTry, and split connectIbcChannel into connOpenAck and connOpenConfirm.

The user's SC still only needs to implement two methods, which provides the same development experience as before. This change will allow us to solve the state verification issue and better align with IBC standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants