diff --git a/chains/evm/executor/message-handler.go b/chains/evm/executor/message-handler.go index ebb350a1..36eadd64 100644 --- a/chains/evm/executor/message-handler.go +++ b/chains/evm/executor/message-handler.go @@ -70,7 +70,7 @@ func (mh *EVMMessageHandler) RegisterMessageHandler(address string, handler Mess mh.handlers = make(map[common.Address]MessageHandlerFunc) } - log.Info().Msgf("Registered message handler for address %s", address) + log.Debug().Msgf("Registered message handler for address %s", address) mh.handlers[common.HexToAddress(address)] = handler } diff --git a/chains/evm/listener/deposit-handler.go b/chains/evm/listener/deposit-handler.go index 3e74c2dd..1a0baabe 100644 --- a/chains/evm/listener/deposit-handler.go +++ b/chains/evm/listener/deposit-handler.go @@ -61,7 +61,7 @@ func (e *ETHDepositHandler) RegisterDepositHandler(handlerAddress string, handle return } - log.Info().Msgf("Registered deposit handler for address %s", handlerAddress) + log.Debug().Msgf("Registered deposit handler for address %s", handlerAddress) e.depositHandlers[common.HexToAddress(handlerAddress)] = handler } diff --git a/chains/evm/listener/listener.go b/chains/evm/listener/listener.go index 5063d70b..712726cc 100644 --- a/chains/evm/listener/listener.go +++ b/chains/evm/listener/listener.go @@ -11,6 +11,7 @@ import ( "github.com/ChainSafe/chainbridge-core/relayer/message" "github.com/ChainSafe/chainbridge-core/store" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) @@ -31,6 +32,8 @@ type EVMListener struct { blockRetryInterval time.Duration blockConfirmations *big.Int blockInterval *big.Int + + log zerolog.Logger } // NewEVMListener creates an EVMListener that listens to deposit events on chain @@ -43,7 +46,9 @@ func NewEVMListener( blockRetryInterval time.Duration, blockConfirmations *big.Int, blockInterval *big.Int) *EVMListener { + logger := log.With().Uint8("domainID", domainID).Logger() return &EVMListener{ + log: logger, client: client, eventHandlers: eventHandlers, blockstore: blockstore, @@ -65,7 +70,7 @@ func (l *EVMListener) ListenToEvents(ctx context.Context, startBlock *big.Int, m default: head, err := l.client.LatestBlock() if err != nil { - log.Error().Err(err).Msg("Unable to get latest block") + l.log.Error().Err(err).Msg("Unable to get latest block") time.Sleep(l.blockRetryInterval) continue } @@ -80,10 +85,12 @@ func (l *EVMListener) ListenToEvents(ctx context.Context, startBlock *big.Int, m continue } + l.log.Debug().Msgf("Fetching evm events for block range %s-%s", startBlock, endBlock) + for _, handler := range l.eventHandlers { err := handler.HandleEvent(startBlock, new(big.Int).Sub(endBlock, big.NewInt(1)), msgChan) if err != nil { - log.Error().Err(err).Str("DomainID", string(l.domainID)).Msgf("Unable to handle events") + l.log.Error().Err(err).Msgf("Unable to handle events") continue } } @@ -91,7 +98,7 @@ func (l *EVMListener) ListenToEvents(ctx context.Context, startBlock *big.Int, m //Write to block store. Not a critical operation, no need to retry err = l.blockstore.StoreBlock(endBlock, l.domainID) if err != nil { - log.Error().Str("block", endBlock.String()).Err(err).Msg("Failed to write latest block to blockstore") + l.log.Error().Str("block", endBlock.String()).Err(err).Msg("Failed to write latest block to blockstore") } startBlock.Add(startBlock, l.blockInterval)