Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add GetTrustedHeader #390

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions relayer/client-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (c *Chain) UpdateClients(dst *Chain) (err error) {
return nil
}

// UpgradesClients upgrades the client on src after dst chain has undergone an upgrade.
// UpgradeClients upgrades the client on src after dst chain has undergone an upgrade.
func (c *Chain) UpgradeClients(dst *Chain, height int64) error {
sh, err := NewSyncHeaders(c, dst)
if err != nil {
Expand All @@ -211,10 +211,10 @@ func (c *Chain) UpgradeClients(dst *Chain, height int64) error {
height = int64(sh.GetHeight(dst.ChainID))
}

// TODO: construct method of only attempting to get dst header
// Note: we explicitly do not check the error since the source
// trusted header will fail
_, dstUpdateHeader, _ := sh.GetTrustedHeaders(c, dst)
dstUpdateHeader, err := sh.GetTrustedHeader(dst, c)
if err != nil {
return err
}

// query proofs on counterparty
clientState, proofUpgradeClient, _, err := dst.QueryUpgradedClient(height)
Expand Down
11 changes: 11 additions & 0 deletions relayer/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ func (uh *SyncHeaders) GetTrustedHeaders(src, dst *Chain) (srcTh, dstTh *tmclien
return
}

// GetTrustedHeader returns given chain ID's trusted header
func (uh *SyncHeaders) GetTrustedHeader(src, dst *Chain) (header *tmclient.Header, err error) {
eg := new(errgroup.Group)
eg.Go(func() error {
header, err = InjectTrustedFields(src, dst, uh.GetHeader(src.ChainID))
return err
})
err = eg.Wait()
return
}

// InjectTrustedFields injects the necessary trusted fields for a srcHeader coming from a srcChain
// destined for an IBC client stored on the dstChain
// TrustedHeight is the latest height of the IBC client on dstChain
Expand Down