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

handshake refactor #334

Merged
merged 39 commits into from
Jan 5, 2021
Merged

handshake refactor #334

merged 39 commits into from
Jan 5, 2021

Conversation

colin-axner
Copy link
Contributor

@colin-axner colin-axner commented Nov 30, 2020

closes: #329

contains changes from #330, couldn't push that branch to the repo for some reason so I can't open this pr against that one

TODOs:

  • Parse CreateClient events to get client ids (set in PathEnd and config file)
  • Parse ConnOpenInit/ConnOpenTry events to get connection ids (set in PathEnd and config file)
  • Parse ChanOpenInit/ChanOpenTry events to get channel ids (set in PathEnd and config file)
  • Validate that a user-filled config is mutually coherent. (ie the clients point to each other, the connections are built on underlying clients, etc)

// transaction was executed, log the success or failure using the tx response code
// NOTE: error is nil, logic should use the returned error to determine if the
// transaction was successfully executed.
if res.Code != 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes sense to cut down on the number of Send messages and just handle all the logic in one place

Copy link
Member

Choose a reason for hiding this comment

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

This is much nicer. We could also add retries for account number in here too...

relayer/connection-tx.go Show resolved Hide resolved
}
}
*/
// TODO: Query for existing identifier and fill config
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After talking with @jackzampolin, we want to make the default behaviour of the relayer to reuse existing clients/connection/channels instead of creating a new one by default. This might require adding additional helper functions on the SDK side. For now default will new things, but we can easily add this in later by inserting a function here (or after client creation steps are complete) to fill the potentially empty connection identifiers

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a nice-to-have. We should get it to work by just creating new identifiers and merge this PR. Future work can implement this feature

@lgtm-com
Copy link

lgtm-com bot commented Nov 30, 2020

This pull request introduces 1 alert when merging a18efd0 into 031ecc2 - view on LGTM.com

new alerts:

  • 1 for Impossible interface nil check

@colin-axner
Copy link
Contributor Author

colin-axner commented Nov 30, 2020

I'd suggest looking at the file, the diffs are hard to read

@lgtm-com
Copy link

lgtm-com bot commented Nov 30, 2020

This pull request introduces 2 alerts when merging c6492a3 into 031ecc2 - view on LGTM.com

new alerts:

  • 1 for Impossible interface nil check
  • 1 for Useless assignment to local variable

@@ -12,6 +12,15 @@ import (

// CreateChannel runs the channel creation messages on timeout until they pass
func (c *Chain) CreateOpenChannels(dst *Chain, maxRetries uint64, to time.Duration) error {
// client and connection identifiers must be filled in
if err := ValidateClientPaths(c, dst); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldn't this be validate connection paths?

relayer/client-tx.go Outdated Show resolved Hide resolved

// GenerateConnHandshakeProof generates all the proofs needed to prove the existence of the
// connection state on this chain. A counterparty should use these generated proofs.
func (c *Chain) GenerateConnHandshakeProof(height uint64) (ibcexported.ClientState, []byte, []byte, []byte, clienttypes.Height, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice, also this looks like easy to retry if the returned proofs are nil.

Copy link
Member

Choose a reason for hiding this comment

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

named returns would be nice here for docs

relayer/client-tx.go Outdated Show resolved Hide resolved
relayer/client-tx.go Outdated Show resolved Hide resolved
// GenSrcClientID generates the specififed identifier
func (p *Path) GenSrcClientID() { p.Src.ClientID = RandLowerCaseLetterString(10) }
func (p *Path) GenSrcClientID() { p.Src.ClientID = "" }
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can pull all that RandLowerCaseLetterString code out...

@@ -138,7 +138,8 @@ func (r *RelayMsgs) SendWithController(src, dst *Chain, useController bool) {

if r.IsMaxTx(msgLen, txSize) {
// Submit the transactions to src chain and update its status
r.Succeeded = r.Succeeded && send(src, msgs)
_, success, _ := src.SendMsgs(msgs)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That LGTM (the next line preserves the semantics I need).

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

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

Not as bad as I feared. Looking forward to testing the changeset.

@lgtm-com
Copy link

lgtm-com bot commented Dec 7, 2020

This pull request introduces 2 alerts when merging cbba72f into 031ecc2 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

@lgtm-com
Copy link

lgtm-com bot commented Dec 7, 2020

This pull request introduces 2 alerts when merging 06b5ae2 into 031ecc2 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

@lgtm-com
Copy link

lgtm-com bot commented Dec 7, 2020

This pull request introduces 2 alerts when merging 76b3044 into 031ecc2 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

@colin-axner
Copy link
Contributor Author

I bumped to rc6, cleaned up some of my commits (squashed them down) and manually tested again that this branch still works for base functionality.

I'm going to do a regular merge (not using squash) so all the contributors to this branch get credit. I'm merging with integration tests not passing because I don't think that is a sufficient reason to block development/testing/release. We can fix any issues as they arise and fix integration tests in a follow up. I will open issues for things mentioned on this pr that should be addressed in followups

@colin-axner colin-axner merged commit 6ba534a into master Jan 5, 2021
@colin-axner colin-axner deleted the colin/329-handshake-refactor branch January 5, 2021 12:04
@lgtm-com
Copy link

lgtm-com bot commented Jan 5, 2021

This pull request introduces 2 alerts when merging 465da7b into db25632 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

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.

Refactor connection/channel identifier handling
8 participants