From f7e498eec133778a7d5c5a056fd740a9bf93068d Mon Sep 17 00:00:00 2001 From: Debendra Oli Date: Wed, 5 Jun 2024 10:04:08 +0545 Subject: [PATCH] rf: refactors, add: debug log for mainnet debug --- relayer/chain_runtime.go | 6 ++---- relayer/chains/evm/listener.go | 2 +- relayer/chains/icon/listener.go | 3 --- relayer/relay.go | 10 ++++------ 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/relayer/chain_runtime.go b/relayer/chain_runtime.go index ba29a0ee..10fb6430 100644 --- a/relayer/chain_runtime.go +++ b/relayer/chain_runtime.go @@ -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 } diff --git a/relayer/chains/evm/listener.go b/relayer/chains/evm/listener.go index ed36dfc0..721abfea 100644 --- a/relayer/chains/evm/listener.go +++ b/relayer/chains/evm/listener.go @@ -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}) } diff --git a/relayer/chains/icon/listener.go b/relayer/chains/icon/listener.go index 8f0e7c0a..7cc8cb7e 100644 --- a/relayer/chains/icon/listener.go +++ b/relayer/chains/icon/listener.go @@ -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() { @@ -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) diff --git a/relayer/relay.go b/relayer/relay.go index 991f89cb..b220282e 100644 --- a/relayer/relay.go +++ b/relayer/relay.go @@ -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 @@ -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 } @@ -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) {