diff --git a/chains/tendermint/query.go b/chains/tendermint/query.go index d41caba3..76ef41c4 100644 --- a/chains/tendermint/query.go +++ b/chains/tendermint/query.go @@ -217,7 +217,7 @@ func (c *Chain) QueryUnfinalizedRelayPackets(ctx core.QueryContext, counterparty seqs, err := counterparty.QueryUnreceivedPackets(counterpartyCtx, packets.ExtractSequenceList()) if err != nil { - return nil, fmt.Errorf("failed to counterparty query unreceived packets: %w height: %v", err, counterpartyCtx.Height()) + return nil, fmt.Errorf("failed to query counterparty for unreceived packets: error=%w, height=%v", err, counterpartyCtx.Height()) } packets = packets.Filter(seqs) diff --git a/core/service.go b/core/service.go index f659b9f6..b4246bb0 100644 --- a/core/service.go +++ b/core/service.go @@ -165,34 +165,28 @@ func (srv *RelayService) Serve(ctx context.Context) error { func (srv *RelayService) shouldExecuteRelay(seqs *RelayPackets) (bool, bool) { logger := GetChannelPairLogger(srv.src, srv.dst) - var err error srcRelay := false dstRelay := false - tsSrc := time.Now() - tsDst := time.Now() - if len(seqs.Src) > 0 { - tsDst, err = srv.src.Timestamp(seqs.Src[0].EventHeight) + tsDst, err := srv.src.Timestamp(seqs.Src[0].EventHeight) if err != nil { return false, false } + if time.Since(tsDst) >= srv.optimizeRelay.dstOptimizeInterval { + dstRelay = true + } } if len(seqs.Dst) > 0 { - tsSrc, err = srv.dst.Timestamp(seqs.Dst[0].EventHeight) + tsSrc, err := srv.dst.Timestamp(seqs.Dst[0].EventHeight) if err != nil { return false, false } - } - - // time interval - if time.Since(tsSrc) >= srv.optimizeRelay.srcOptimizeInterval { - srcRelay = true - } - if time.Since(tsDst) >= srv.optimizeRelay.dstOptimizeInterval { - dstRelay = true + if time.Since(tsSrc) >= srv.optimizeRelay.srcOptimizeInterval { + srcRelay = true + } } // packet count diff --git a/tests/cases/tm2tm/scripts/test-service b/tests/cases/tm2tm/scripts/test-service index 798865f6..8b8a08f8 100755 --- a/tests/cases/tm2tm/scripts/test-service +++ b/tests/cases/tm2tm/scripts/test-service @@ -11,22 +11,22 @@ - sleep 4 - transfer x 1 - packets = 1, ack = 0 - - sleep 16 + - sleep 13 - relay service [packets = 1, time = 20] -> skip - sleep 4 - transfer x 1 - packets = 2, ack = 0 - - sleep 16 + - sleep 13 - relay service [packets = 2, time = 40] -> exec (time) - sleep 4 - packets = 0, ack = 2 - transfer x 3 - packets = 3, ack = 2 - - sleep 16 + - sleep 8 - relay service [packets = 3, time = 20] -> exec (count) - sleep 4 - - packets = 0, ack = 3 - - sleep 16 + - packets = 0, ack = 5 + - sleep 20 - relay service [acks = 5, time = 40] -> exec (time + count) - sleep 4 - packets = 0, ack = 0 diff --git a/tests/cases/tmmock2tmmock/scripts/test-service b/tests/cases/tmmock2tmmock/scripts/test-service index 0fe475a2..5b42ff0a 100755 --- a/tests/cases/tmmock2tmmock/scripts/test-service +++ b/tests/cases/tmmock2tmmock/scripts/test-service @@ -12,24 +12,24 @@ - transfer x 1 - sleep 3 finality - packets = 1, ack = 0 - - sleep 13 + - sleep 10 - relay service [packets = 1, time = 20] -> skip - sleep 4 - transfer x 1 - sleep 3 finality - packets = 2, ack = 0 - - sleep 13 + - sleep 10 - relay service [packets = 2, time = 40] -> exec (time) - sleep 4 - packets = 0, ack = 2 - transfer x 3 - sleep 3 finality - packets = 3, ack = 2 - - sleep 13 + - sleep 10 - relay service [packets = 3, time = 20] -> exec (count) - sleep 4 - packets = 0, ack = 5 - - sleep 16 + - sleep 20 - relay service [acks = 5, time = 40] -> exec (time + count) - sleep 4 - packets = 0, ack = 0