diff --git a/relayer/processor/path_processor.go b/relayer/processor/path_processor.go index 8af8a5358..d5e22a0db 100644 --- a/relayer/processor/path_processor.go +++ b/relayer/processor/path_processor.go @@ -49,6 +49,9 @@ const ( // made to retrieve the client consensus state in order to assemble a // MsgUpdateClient message. clientConsensusHeightUpdateThresholdBlocks = 2 + + // Needed for finding trusting block one week + defaultTrustingPeriod = 7 * 24 * time.Hour ) // PathProcessor is a process that handles incoming IBC messages from a pair of chains. diff --git a/relayer/processor/path_processor_internal.go b/relayer/processor/path_processor_internal.go index 22d1d470f..e3cbc7aed 100644 --- a/relayer/processor/path_processor_internal.go +++ b/relayer/processor/path_processor_internal.go @@ -7,6 +7,7 @@ import ( "fmt" "sort" "sync" + "time" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" @@ -1708,11 +1709,18 @@ func QueryPacketHeights( } startSeq := uint64(0) - if dst.clientState.TrustingPeriodBlock > 0 { - startSeq, err = src.chainProvider.QueryNextSeqSend(ctx, int64(src.latestBlock.Height)-dst.clientState.TrustingPeriodBlock, k.ChannelID, k.PortID) - if err != nil { - return err + if src.chainProvider.ProviderConfig().GetBlockInterval() > 0 { + // blockInterval from provider config will be in milliseconds + blockInterval := int64(src.chainProvider.ProviderConfig().GetBlockInterval()) * int64(time.Millisecond) + startBlock := int64(src.latestBlock.Height) - defaultTrustingPeriod.Nanoseconds()/blockInterval + if startBlock > 0 { + startSeq, err = src.chainProvider.QueryNextSeqSend(ctx, startBlock, k.ChannelID, k.PortID) + if err != nil { + // don't care about error here, + // if error start from startSeq 0 + } } + } c, err := src.chainProvider.QueryPacketHeights(ctx, int64(src.latestBlock.Height), k.ChannelID, k.PortID, startSeq, endSeq) diff --git a/relayer/provider/provider.go b/relayer/provider/provider.go index c7c0c4354..a3a0a0fbd 100644 --- a/relayer/provider/provider.go +++ b/relayer/provider/provider.go @@ -69,12 +69,11 @@ type IBCHeader interface { // ClientState holds the current state of a client from a single chain's perspective type ClientState struct { - ClientID string - ConsensusHeight clienttypes.Height - TrustingPeriod time.Duration // trustring period wont be there in ICON client state - ConsensusTime time.Time // consensus time wont be there in ICON light client State - Header []byte // - TrustingPeriodBlock int64 + ClientID string + ConsensusHeight clienttypes.Height + TrustingPeriod time.Duration // trustring period wont be there in ICON client state + ConsensusTime time.Time // consensus time wont be there in ICON light client State + Header []byte // } // ClientTrustedState holds the current state of a client from the perspective of both involved chains,