Skip to content

Commit

Permalink
rf: refactors, add: debug log for mainnet debug
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Jun 5, 2024
1 parent db31d28 commit f7e498e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
6 changes: 2 additions & 4 deletions relayer/chain_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ func (dst *ChainRuntime) shouldSendMessage(ctx context.Context, routeMessage *ty
return false
}

ok, err := dst.Provider.ShouldReceiveMessage(ctx, routeMessage.Message)
if !ok || err != nil {
if ok, err := dst.Provider.ShouldReceiveMessage(ctx, routeMessage.Message); !ok || err != nil {
return false
}

ok, err = src.Provider.ShouldSendMessage(ctx, routeMessage.Message)
if !ok || err != nil {
if ok, err := src.Provider.ShouldSendMessage(ctx, routeMessage.Message); !ok || err != nil {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion relayer/chains/evm/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, blockIn
for i := startHeight; i < latestHeight; i += p.cfg.BlockBatchSize {
end := i + p.cfg.BlockBatchSize
if end > latestHeight {
end = latestHeight + 1
end = latestHeight
}
blockReqs = append(blockReqs, &blockReq{start: i, end: end, retry: maxBlockQueryFailedRetry})
}
Expand Down
3 changes: 0 additions & 3 deletions relayer/chains/icon/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type btpBlockRequest struct {
}

func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, incoming chan *providerTypes.BlockInfo) error {
errCh := make(chan error) // error channel
reconnectCh := make(chan struct{}, 1) // reconnect channel

reconnect := func() {
Expand Down Expand Up @@ -60,8 +59,6 @@ func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, incomin
select {
case <-ctx.Done():
return ctx.Err()
case err := <-errCh:
return err

case <-reconnectCh:
ctxMonitorBlock, cancelMonitorBlock := context.WithCancel(ctx)
Expand Down
10 changes: 4 additions & 6 deletions relayer/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (r *Relayer) flushMessages(ctx context.Context) {
chain.log.Warn("error occured when query messagesFromStore", zap.Error(err))
continue
}
chain.log.Debug("flushing messages", zap.Int("message count", len(messages)))
chain.log.Debug("flushing messages", zap.Int("count", len(messages)))
// adding message to messageCache
// TODO: message with no txHash

Expand Down Expand Up @@ -225,7 +225,8 @@ func (r *Relayer) processMessages(ctx context.Context) {
}

if ok := dst.shouldSendMessage(ctx, message, src); !ok {
dst.log.Debug("message not ready to send", zap.String("src", message.Src), zap.Uint64("sn", message.Sn.Uint64()))
// debug log
r.log.Debug("message not sent to destination", zap.Any("message", message))
continue
}

Expand Down Expand Up @@ -274,10 +275,7 @@ func (r *Relayer) SaveBlockHeight(ctx context.Context, chainRuntime *ChainRuntim
r.log.Debug("saving height:", zap.String("srcChain", chainRuntime.Provider.NID()), zap.Uint64("height", height))
chainRuntime.LastSavedHeight = height
chainRuntime.LastBlockHeight = height
if err := r.blockStore.StoreBlock(height, chainRuntime.Provider.NID()); err != nil {
return fmt.Errorf("error while saving height of chain:%s %v", chainRuntime.Provider.NID(), err)
}
return nil
return r.blockStore.StoreBlock(height, chainRuntime.Provider.NID())
}

func (r *Relayer) FindChainRuntime(nId string) (*ChainRuntime, error) {
Expand Down

0 comments on commit f7e498e

Please sign in to comment.