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

IBC: bug fixes for creating IBC channels #206

Merged
merged 7 commits into from
Nov 21, 2022
Merged

Conversation

SebastianElvis
Copy link
Member

@SebastianElvis SebastianElvis commented Nov 21, 2022

This PR fixes multiple bugs that occur when I try to establish an IBC channel between Babylon and Cosmos Hub. Specifically,

  • This PR adds the IBC transfer module, which is required by the relayer and eventually the Babylon tokenomics. The IBC transfer module is responsible for making cross-chain transfers.
  • This PR removes the code of setting unbonding time in genesis. This is unnecessary (since the epoching module offsets it anyway) and will break the IBC connection, which demands the trusting period to be smaller than the unbonding period (by default it's 85% of the unbonding period)
  • This PR exports the mnemonics of the additional send account so that we can test the relayer with this account.
  • This PR fixes a bug in IBC heartbeat where the timeout height was incorrectly configured. We now use timestamps in ctx instead.
  • This PR removes more checks upon IBC handshake and upon receiving IBC ack messages, which are not required and hinder deployments unless modifying the CZ code.

Copy link
Member

@vitsalis vitsalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Some discussion comments:

coins := sdk.Coins{
sdk.NewCoin("testtoken", sdk.NewInt(1000000000)),
sdk.NewCoin("bbn", sdk.NewInt(1000000000000)),
Copy link
Member

@vitsalis vitsalis Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to be added as NativeCoinMetadatas[0].Base uses the proper token (which is ubbn).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to use bbn here? since this account is used by the relayer who needs bbn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the relayer need to use bbn?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to submit txs to Babylon. Looks like we can only use bbn for submitting txs, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we should use the denomination that is available. ubbn is the only denomination we support (and testtoken for the validator dirs generated by babylond testnet). This is similar to other chains (e.g. osmosis doesn't have an osmo denomination but only uosmo)

Copy link
Member

@vitsalis vitsalis Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example to submit unbonding requests I always use ubbn, bbn is just the human readable format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, let me try if ubbn works in IBC playground

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works 👍 Let's use ubbn then

if err != nil {
_ = os.RemoveAll(outputDir)
return err
}

// save mnemonic words for this key
info := map[string]string{"secret": secret}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to store the mnemonic? For rebuilding the wallet on another machine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running locally, one can use the keyring location (without the mnemonic), since it contains the private key as well. When running on the infrastructure, we have three options:

  1. Manually identify the mnemonic and rebuild the wallet locally
  2. Copy the entire keyring from the deployment and move it locally (or just the private keys)
  3. Create a wallet locally and transfer funds to it

For testing with our partners we are going to use option 3. So I suggest we do the same for our tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need mnemonic for the relayer to import this wallet. Unfortunately relayer only supports importing via the mnemonic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We can merge this for now and then on the IBC playground we can add methodology for generating a key and transferring funds to it from a Babylon node, as we should replicate the behavior that will happen on the real environment. This can also serve as pre-work for the Docker deployment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. The current methodology is not that proper. In practice (eg demo) the relayer needs to create its own account and we need to give the relayer some funds.

}

// timeout
curHeight := clienttypes.GetSelfHeight(ctx)
curHeight.RevisionHeight += 100 // TODO: parameterise timeout
timeoutTime := uint64(ctx.BlockHeader().Time.Add(time.Hour * 24).UnixNano()) // TODO: parameterise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should come from a config file (or we can check out what other chains are doing). I suggest creating a Github issue so it doesn't get lost.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, created #207

curHeight, // if the packet is not relayed after thit height, then the packet will be timeout
uint64(0), // no need to set timeout timestamp if timeout height is set
zeroheight, // no need to set timeout height if timeout timestamp is set
timeoutTime, // if the packet is not relayed after this time, then the packet will be timeout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
timeoutTime, // if the packet is not relayed after this time, then the packet will be timeout
timeoutTime, // if the packet is not relayed after this time, then the packet will be timed out

if counterpartyVersion != types.Version {
return sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version)
}
// // TODO (Babylon): check version consistency (this requires modifying CZ code)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do chains communicate with other chains that don't use the same IBC version? I would expect that there's a standard method for negotiating versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this version is not the version of the IBC protocol, but the version of the IBC-based application. For example, it can be ics20-1 that denotes the first version of the ICS-20 fungible token transfer standard.

Since Babylon aims at establishing IBC channels with any Cosmos chains, Babylon should not impose any restriction on the version of the counterparty's module that implements IBC interfaces.

How do chains communicate with other chains that don't use the same IBC version?

For IBC itself, any two IBC-Go versions are compatible with each other.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then do we really need a TODO here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we go beyond phase 2 where we inject our code to CZs, we can create IBC connections with our module in CZs (rather than their existing ones) and have versioning in case of backward-incompatible updates.

@@ -150,11 +151,6 @@ func (im IBCModule) OnAcknowledgementPacket(

// this line is used by starport scaffolding # oracle/packet/module/ack

var modulePacketData types.ZoneconciergePacketData
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the following check getting removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly 2 reasons: 1) we don't use the packet anywhere, and 2) formats of such packets are decided by CZs, and asserting them to types looks redundant due to 1).

Copy link
Member

@vitsalis vitsalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for the discussion!

@SebastianElvis SebastianElvis merged commit c0165ab into dev Nov 21, 2022
@SebastianElvis SebastianElvis deleted the demo-ibc-fixes branch November 21, 2022 09:49
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

Successfully merging this pull request may close these issues.

2 participants