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 light client handling, remove reliance on histroical info #416

Merged
merged 16 commits into from
Feb 10, 2021

Conversation

colin-axner
Copy link
Contributor

@colin-axner colin-axner commented Feb 9, 2021

I set out to redirect trusted header injection queries to use the connected full node and not the on-chain historical info since this was the cause of many problems for users. I quickly ran into many issues due to a poorly defined API with unnecessary complexity.

Specifically functions like UpdatesWithHeaders updates the light clients with untrusted headers (simply pulling the validator info from the current block without verifying it against a trusted header). This result in an error when trying to grab the trusted header after updating with that header since the light client never verified it and stored it in the store. Furthermore, I realized SyncHeaders was a depth one cache for headers mapped to chain-id. This added unnecessary layers of complexity with little to no performance benefit.

I removed SyncHeaders enitrely. I replaced the existing API with much simpler logic. There is a function UpdateLightClient which belongs to the Chain struct, which will update its connected off-chain light client and return the light block. Then there is a separate function also connected to Chain struct called GetIBCUpdateHeader which returns the IBC SDK TM header which will update an on-chain client. It is injected with the trusted header retrieved from the trusted store of the light client.

I added some other useful functions like GetIBCCreationHeader (no trusted header injected), MustGetLatestLightHeight latest height of connected light client.

closes: #375
closes: #414
closes: #327
closes: #373

Remove SyncHeaders entirely. Reduce light client API. We can update off chain light clients. Then we can get creation or update headers to handle on chain light clients. No other functions necessary
Copy link
Contributor Author

@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.

I have some small fixes to do later today

relayer/channel.go Outdated Show resolved Hide resolved
@@ -1,159 +0,0 @@
package relayer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

❤️

relayer/naive-strategy.go Outdated Show resolved Hide resolved
relayer/tm-light-client.go Outdated Show resolved Hide resolved
relayer/tm-light-client.go Show resolved Hide resolved
@colin-axner colin-axner marked this pull request as draft February 9, 2021 11:58
@lgtm-com
Copy link

lgtm-com bot commented Feb 9, 2021

This pull request introduces 2 alerts and fixes 2 when merging 970762f into 9f13a93 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

fixed alerts:

  • 2 for Unreachable statement

@colin-axner colin-axner marked this pull request as ready for review February 9, 2021 15:33
@lgtm-com
Copy link

lgtm-com bot commented Feb 9, 2021

This pull request introduces 2 alerts and fixes 4 when merging 1fd3e36 into 9f13a93 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

fixed alerts:

  • 2 for Missing error check
  • 2 for Unreachable statement

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.

Awesome work @colin-axner!! Just a couple nits

relayer/ibc-client.go Outdated Show resolved Hide resolved
relayer/ibc-client.go Outdated Show resolved Hide resolved
relayer/query.go Outdated Show resolved Hide resolved
relayer/query.go Outdated Show resolved Hide resolved
@colin-axner
Copy link
Contributor Author

cc @michaelfig when merged, this should fix any trusted headers errors (since it will now query from the connected light client)

@lgtm-com
Copy link

lgtm-com bot commented Feb 10, 2021

This pull request introduces 2 alerts and fixes 4 when merging 3b551e7 into 9f13a93 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

fixed alerts:

  • 2 for Missing error check
  • 2 for Unreachable statement

@colin-axner
Copy link
Contributor Author

fyi, the lgtm alert I believe is something that cannot be fixed and already has a lgtm suppression tag

@@ -86,7 +86,8 @@ func (c *Chain) CreateClients(dst *Chain) (modified bool, err error) {

} else {
// Ensure client exists in the event of user inputted identifiers
_, err := c.QueryClientState(srcH.Header.Height)
// TODO: check client is not expired
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this will error regardless, but maybe we should create an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great minds think alike #417. I made one when I added it

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.

Awesome work left some minor comments. Thanks @colin-axner

relayer/ibc-client.go Show resolved Hide resolved
relayer/ibc-client.go Show resolved Hide resolved
relayer/ibc-client.go Show resolved Hide resolved
relayer/msgs.go Show resolved Hide resolved
relayer/msgs.go Show resolved Hide resolved
relayer/relayPackets.go Show resolved Hide resolved
relayer/relayPackets.go Show resolved Hide resolved
@@ -15,11 +15,11 @@ var (
// Strategy defines
type Strategy interface {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 👍

@colin-axner colin-axner merged commit 872dc2e into master Feb 10, 2021
@colin-axner colin-axner deleted the colin/375-rm-hist-info-reliance branch February 10, 2021 13:23
@lgtm-com
Copy link

lgtm-com bot commented Feb 10, 2021

This pull request introduces 2 alerts and fixes 4 when merging 47ef9be into 1e98674 - view on LGTM.com

new alerts:

  • 2 for Unreachable statement

fixed alerts:

  • 2 for Missing error check
  • 2 for Unreachable statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Refactor TYPE: Refactor
Projects
None yet
3 participants