From 8b8e5821fdb53b68457aee24c2af67f86ade18a2 Mon Sep 17 00:00:00 2001 From: Omri Date: Tue, 14 Nov 2023 18:51:45 +0100 Subject: [PATCH] feature: Added adjustments to support on-demand blocks (#6) --- relayer/client.go | 2 +- relayer/processor/message_processor.go | 5 +++++ relayer/processor/path_processor.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/relayer/client.go b/relayer/client.go index 2330b262b..e6506acf1 100644 --- a/relayer/client.go +++ b/relayer/client.go @@ -289,7 +289,7 @@ func MsgUpdateClient( eg.Go(func() error { return retry.Do(func() error { var err error - dstTrustedHeader, err = src.ChainProvider.QueryIBCHeader(egCtx, int64(dstClientState.GetLatestHeight().GetRevisionHeight())+1) + dstTrustedHeader, err = src.ChainProvider.QueryIBCHeader(egCtx, int64(dstClientState.GetLatestHeight().GetRevisionHeight())) return err }, retry.Context(egCtx), RtyAtt, RtyDel, RtyErr, retry.OnRetry(func(n uint, err error) { src.log.Info( diff --git a/relayer/processor/message_processor.go b/relayer/processor/message_processor.go index c73bab303..4ff9e34a5 100644 --- a/relayer/processor/message_processor.go +++ b/relayer/processor/message_processor.go @@ -275,6 +275,11 @@ func (mp *messageProcessor) assembleMsgUpdateClient(ctx context.Context, src, ds trustedNextValidatorsHash = header.NextValidatorsHash() } + // As we only require one chain to be in sync the src.latestHeader may be nil. In that case + // we want to skip it + if src.latestHeader == nil { + return fmt.Errorf("latest header is nil for chain_id: %s. Waiting for catching up", src.info.ChainID) + } if src.latestHeader.Height() == trustedConsensusHeight.RevisionHeight && !bytes.Equal(src.latestHeader.NextValidatorsHash(), trustedNextValidatorsHash) { return fmt.Errorf("latest header height is equal to the client trusted height: %d, "+ diff --git a/relayer/processor/path_processor.go b/relayer/processor/path_processor.go index 5b0b2c76e..e8857f1f9 100644 --- a/relayer/processor/path_processor.go +++ b/relayer/processor/path_processor.go @@ -353,7 +353,7 @@ func (pp *PathProcessor) Run(ctx context.Context, cancel func()) { } } - if !pp.pathEnd1.inSync || !pp.pathEnd2.inSync { + if !pp.pathEnd1.inSync && !pp.pathEnd2.inSync { continue }