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

connection and channel identifiers reuse #386

Merged
merged 8 commits into from
Feb 1, 2021

Conversation

akhilkumarpilli
Copy link
Contributor

Fixes: #349

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Great start! Left some comments on parts that require a little reworking

relayer/connection-tx.go Outdated Show resolved Hide resolved
relayer/connection-tx.go Outdated Show resolved Hide resolved
relayer/channel-tx.go Outdated Show resolved Hide resolved
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Thanks, almost there. Have you had a chance to test these changes as well?

relayer/connection-tx.go Outdated Show resolved Hide resolved
relayer/connection-tx.go Outdated Show resolved Hide resolved
relayer/connection-tx.go Outdated Show resolved Hide resolved
relayer/connection-tx.go Outdated Show resolved Hide resolved
relayer/channel-tx.go Show resolved Hide resolved
@akhilkumarpilli
Copy link
Contributor Author

Thanks, almost there. Have you had a chance to test these changes as well?

No, I am not able to test them.

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

utACK, please test before merging

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

utACK, but I agree with @AdityaSripal, this needs to be tested.

This can be done by adding integrations tests, see test/relayer_gaia_test.go or by manually testing (starting 2 chains and connecting them with a relayer). Writing integration tests is preferred.

For integration tests, I would make a new test for testing reuse. Copy the first part of the gaia relayer test up to client/connection/channel creation. After those are created, save the current values and clear the config and rerun the handshake. Check that the resulting values are the same as the old values. If possible, addressing other test cases mentioned in #383 would be very much appreciated

Feel free to use a different testing approach if you think of something cleaner/more modular

@akhilkumarpilli
Copy link
Contributor Author

@colin-axner , if we clear config then counterparty connection-id will be empty from config. But, when state of connection created previously is OPEN, then we can't reuse that connection as we are checking counterparty connection-id from config with counterparty.PathEnd.ConnectionId in connection details.

@colin-axner
Copy link
Contributor

@akhilkumarpilli ah yes, it is a little bit more complicated than meets the eye

I believe, because of the IBC protocol, if the connection is OPEN, then we can assume the counterparty connection ID has the exact same parameters the counterparty in our path desires (assuming the proposed existing connection ID has a counterparty that matches our counterparty).

So if the connection is OPEN, if our counterparty connection ID (on the relayer) is non-empty, it must match, if the counterparty connection ID (on the relayer) is empty and the counterparty set in that connection (on-chain) matches all the parameters of our counterparty (on the relayer) (with exception to connection ID) then we can accept it.

cc @AdityaSripal anything I'm missing?

Comment on lines +220 to +222
case srcConn.Connection.State == conntypes.OPEN && dstConn.Connection.State == conntypes.OPEN:
last = true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colin-axner, Added this extra condition since both src connection and dst connection states are OPEN and going into infinite loop. Is this right way?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes it is! It fixes a bug I was running into previously as well. Great job, great intuition. I'm glad there are tests now.

I redesigned the handshakes with the assumption that we were beginning with empty identifiers and therefore overlooked the case when a user supplies fully set identifiers

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Excellent! This is a great addition. I'd like another review from @AdityaSripal to ensure the new reuse of connection/channels in the OPEN case is safe

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

utACK, great work

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

ACK, great work!

@colin-axner colin-axner merged commit b1360ef into master Feb 1, 2021
@colin-axner colin-axner deleted the akhil/349-identifier-reuse branch February 1, 2021 15:15
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.

Support client, connection, and channel recycling
4 participants