From 88d38b94000f9aee041a5eed96cfc701e5f72991 Mon Sep 17 00:00:00 2001
From: Andrew Gouin <andrew@gouin.io>
Date: Tue, 19 Jul 2022 13:50:56 -0600
Subject: [PATCH] query for ibc header if trusted consensus height is zero.
 (#857)

---
 relayer/processor/path_processor_internal.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/relayer/processor/path_processor_internal.go b/relayer/processor/path_processor_internal.go
index c8b7dc52e..c247bcd11 100644
--- a/relayer/processor/path_processor_internal.go
+++ b/relayer/processor/path_processor_internal.go
@@ -324,7 +324,8 @@ func (pp *PathProcessor) assembleMsgUpdateClient(ctx context.Context, src, dst *
 	// the latest block, we cannot send a MsgUpdateClient until another block is observed on the counterparty.
 	// If the client state height is in the past, beyond ibcHeadersToCache, then we need to query for it.
 	if !trustedConsensusHeight.EQ(clientConsensusHeight) {
-		if int64(clientConsensusHeight.RevisionHeight)-int64(trustedConsensusHeight.RevisionHeight) <= clientConsensusHeightUpdateThresholdBlocks {
+		deltaConsensusHeight := int64(clientConsensusHeight.RevisionHeight) - int64(trustedConsensusHeight.RevisionHeight)
+		if trustedConsensusHeight.RevisionHeight != 0 && deltaConsensusHeight <= clientConsensusHeightUpdateThresholdBlocks {
 			return nil, fmt.Errorf("observed client trusted height: %d does not equal latest client state height: %d",
 				trustedConsensusHeight.RevisionHeight, clientConsensusHeight.RevisionHeight)
 		}