Skip to content

Commit

Permalink
gona check for no regression
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed May 3, 2024
1 parent b0afbe3 commit 0464c7d
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions relayer/chains/cosmos/cosmos_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,24 @@ func (ccp *CosmosChainProcessor) Run(ctx context.Context, initialBlockHistory ui
ticker := time.NewTicker(persistence.minQueryLoopDuration)
defer ticker.Stop()

stuckPacketsIx := 0

var stuckPackets []*processor.StuckPacket
stuckPackets = append(stuckPackets, stuckPacket)

for {
if err := ccp.queryCycle(ctx, &persistence, stuckPacket, afterUnstuck); err != nil {
var stuckPacket *processor.StuckPacket
if stuckPacketsIx < len(stuckPackets) {
stuckPacket = stuckPackets[stuckPacketsIx]
}

unstuck, err := ccp.queryCycle(ctx, &persistence, stuckPacket, afterUnstuck)
if err != nil {
return err
}
if unstuck {
stuckPacketsIx++
}
select {
case <-ctx.Done():
return nil
Expand Down Expand Up @@ -346,7 +360,7 @@ func (ccp *CosmosChainProcessor) queryCycle(
persistence *queryCyclePersistence,
stuckPacket *processor.StuckPacket,
afterUnstuck int64,
) error {
) (didGetUnstuck bool, err error) {
status, err := ccp.nodeStatusWithRetry(ctx)
if err != nil {
// don't want to cause CosmosChainProcessor to quit here, can retry again next cycle.
Expand All @@ -355,7 +369,7 @@ func (ccp *CosmosChainProcessor) queryCycle(
zap.Uint("attempts", latestHeightQueryRetries),
zap.Error(err),
)
return nil
return
}

persistence.latestHeight = status.SyncInfo.LatestBlockHeight
Expand Down Expand Up @@ -506,6 +520,7 @@ func (ccp *CosmosChainProcessor) queryCycle(
i = persistence.latestHeight

newLatestQueriedBlock = afterUnstuck
didGetUnstuck = true
ccp.log.Info("Parsed stuck packet height, skipping to current", zap.Any("new latest queried block", persistence.latestHeight))
}

Expand All @@ -516,7 +531,7 @@ func (ccp *CosmosChainProcessor) queryCycle(
}

if (ccp.inSync && !firstTimeInSync) && newLatestQueriedBlock == persistence.latestQueriedBlock {
return nil
return
}

if !ppChanged {
Expand All @@ -526,7 +541,7 @@ func (ccp *CosmosChainProcessor) queryCycle(
}
}

return nil
return
}

for _, pp := range ccp.pathProcessors {
Expand Down Expand Up @@ -558,7 +573,7 @@ func (ccp *CosmosChainProcessor) queryCycle(

persistence.latestQueriedBlock = newLatestQueriedBlock

return nil
return
}

func (ccp *CosmosChainProcessor) CollectMetrics(ctx context.Context, persistence *queryCyclePersistence) {
Expand Down

0 comments on commit 0464c7d

Please sign in to comment.