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

zoneconcierge: heartbeat IBC packet to keep relayer awake #195

Merged
merged 13 commits into from
Nov 10, 2022

Conversation

SebastianElvis
Copy link
Member

Fixes BM-277

This PR implements the functionality of sending heartbeat IBC packets to the CZs upon each BeginBlock. Such heartbeat packet is needed because the relayer relays headers and IBC packets only when there exists pending packets. Along the way, this PR also removes the restrictions on the port/version when establishing IBC channels, since ZoneConcierge is intended to serve any CZ without asking CZ to change its config.

This PR also comes with a unit test that establishes an IBC channel between Babylon and CZ, triggers some heartbeat packets, and checks the consistency.

@SebastianElvis SebastianElvis changed the title zoneconcierge: heartbeat IBC packet to all channels zoneconcierge: heartbeat IBC packet to keep relayer awake Nov 8, 2022
Copy link
Contributor

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

Awesome! You must have done a lot of investigation to make this PR done. Now I understand that the relayer will not relay headers if there are no pending IBC packets so we have to add some dummy messages in the channel periodically. This looks strange to me. If there are no IBC packets pending for a long time, wouldn't there be a lot of headers pending as well?

I would appreciate it if you could provide more context about why we need to put some TAO logic of ibc in zoneconcierge (i.e., setting up the channels and stuff). Can't we just create heartbeat messages and hand them over to ibc?

@SebastianElvis
Copy link
Member Author

why we need to put some TAO logic of ibc in zoneconcierge (i.e., setting up the channels and stuff).

Which part of this PR is about TAO logic? I guess you mean the interfaces in module_ibc.go. These interfaces have to be implemented by any module that uses IBC.

You are right that we are not interested in injecting any logic into these interfaces since ZoneConcierge just needs to send heartbeat packets periodically to channels. In fact, this requires the ZoneConcierge to handle acknowledgements of these heartbeat messages, which require OnAcknowledgementPacket and thus implementing porttypes.IBCModule interface. We don't do anything to the acknowledgement msg though.

Can't we just create heartbeat messages and hand them over to ibc?

That's right. The problem is that in order to use this functionality (specifically, function SendPacket in the channel keeper), ZoneConcierge needs to enable IBC following all of these steps.

Copy link
Contributor

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

Thanks for your explanation and the link. I think I did miss something. So basically, for any module that wants to send IBC packets needs to implement the IBCModule interface in order to set up channels and process Ack messages.

This PR LGTM! Only one question for the test. Do we need to add asserts about checking whether the headers are indeed updated in the clients?

suite.True(found)

// Assert the gap between two sequence numbers
// Note that CommitBlock triggers 2 times of BeginBlock
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please explain why 2 times?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need to add asserts about checking whether the headers are indeed updated in the clients?

This is already tested by our forked IBC-Go and Babylon's test cases here. We could test this again here but it might be out of the scope of this test, which focuses on the heartbeat messages.

Could you please explain why 2 times?

I believe there is a bug (or maybe feature) in the ibctesting's CommitBlock function. It triggers BeginBlock twice rather than once. To make the test more clear without affecting the functionality, I moved the heartbeat logic into EndBlock. Now the sequence number gap is exactly the same as the number of heartbeat msgs sent.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, maybe we can report this issue to the cosmos team 😄

@SebastianElvis SebastianElvis merged commit 00d2b9c into dev Nov 10, 2022
@SebastianElvis SebastianElvis deleted the zoneconcierge-heartbeat-ibc-packet branch November 10, 2022 06:05
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