diff --git a/pkg/chainaccessor/default_accessor.go b/pkg/chainaccessor/default_accessor.go index baef2a60c..29a02b69a 100644 --- a/pkg/chainaccessor/default_accessor.go +++ b/pkg/chainaccessor/default_accessor.go @@ -45,8 +45,10 @@ func NewDefaultAccessor( if contractWriter == nil { return nil, fmt.Errorf("contractWriter cannot be nil") } + + sLggr := logger.Sugared(lggr).Named("DefaultAccessor").Named(chainSelector.String()) return &DefaultAccessor{ - lggr: lggr, + lggr: sLggr, chainSelector: chainSelector, contractReader: contractReader, contractWriter: contractWriter, @@ -77,17 +79,19 @@ func (l *DefaultAccessor) GetAllConfigsLegacy( destChainSelector cciptypes.ChainSelector, sourceChainSelectors []cciptypes.ChainSelector, ) (cciptypes.ChainConfigSnapshot, map[cciptypes.ChainSelector]cciptypes.SourceChainConfig, error) { - lggr := logutil.WithContextValues(ctx, l.lggr) + lggr := logger.With( + l.lggr, + "destChainSelector", destChainSelector, + "sourceChainSelector", l.chainSelector, + ) var configRequests contractreader.ExtendedBatchGetLatestValuesRequest var standardOffRampRequestCount int if l.chainSelector == destChainSelector { - lggr.Debugw("getting ChainConfigSnapshot and and OffRamp SourceChainConfigs for destination chain", - "chainSelector", l.chainSelector) + lggr.Debugw("getting ChainConfigSnapshot and and OffRamp SourceChainConfigs for destination chain") configRequests, standardOffRampRequestCount = prepareDestChainRequest(sourceChainSelectors) } else { - lggr.Debugw("getting ChainConfigSnapshot for a source chain", - "chainSelector", l.chainSelector) + lggr.Debugw("getting ChainConfigSnapshot for a source chain") configRequests = prepareSourceChainRequest(destChainSelector) } @@ -98,7 +102,7 @@ func (l *DefaultAccessor) GetAllConfigsLegacy( } if len(skipped) > 0 { - lggr.Warnw("chain reader skipped some config requests", "skipped", skipped) + lggr.Debugw("chain reader skipped some config requests", "skipped", skipped) } // Process standard results (ChainConfigSnapshot) @@ -287,7 +291,6 @@ func (l *DefaultAccessor) Sync( contractName string, contractAddress cciptypes.UnknownAddress, ) error { - lggr := logutil.WithContextValues(ctx, l.lggr) addressStr, err := l.addrCodec.AddressBytesToString(contractAddress, l.chainSelector) if err != nil { return fmt.Errorf("unable to convert address bytes to string: %w, address: %v", err, contractAddress) @@ -298,11 +301,8 @@ func (l *DefaultAccessor) Sync( Name: contractName, } - lggr.Debugw("Binding contract", - "chainSelector", l.chainSelector, - "contractName", contractName, - "address", addressStr, - ) + l.lggr.Debugw("Binding contract", "contractName", contractName, "address", addressStr) + // Bind the contract address to the reader. // If the same address exists -> no-op // If the address is changed -> updates the address, overwrites the existing one @@ -320,6 +320,8 @@ func (l *DefaultAccessor) MsgsBetweenSeqNums( seqNumRange cciptypes.SeqNumRange, ) ([]cciptypes.Message, error) { lggr := logutil.WithContextValues(ctx, l.lggr) + lggr = logger.With(lggr, "destChainSelector", destChainSelector, "seqNumRange", seqNumRange.String()) + seq, err := l.contractReader.ExtendedQueryKey( ctx, consts.ContractNameOnRamp, @@ -386,11 +388,6 @@ func (l *DefaultAccessor) MsgsBetweenSeqNums( msgsWithoutDataField[i] = msg.CopyWithoutData() } - lggr.Debugw("decoded messages between sequence numbers", - "msgsWithoutDataField", msgsWithoutDataField, - "sourceChainSelector", l.chainSelector, - "seqNumRange", seqNumRange.String(), - ) lggr.Infow("decoded message IDs between sequence numbers", "seqNum.MsgID", slicelib.Map(msgsWithoutDataField, func(m cciptypes.Message) string { return fmt.Sprintf("%d.%d", m.Header.SequenceNumber, m.Header.MessageID) @@ -406,7 +403,7 @@ func (l *DefaultAccessor) LatestMessageTo( ctx context.Context, destChainSelector cciptypes.ChainSelector, ) (cciptypes.SeqNum, error) { - lggr := logutil.WithContextValues(ctx, l.lggr) + lggr := logger.With(l.lggr, "destChainSelector", destChainSelector) seq, err := l.contractReader.ExtendedQueryKey( ctx, @@ -436,6 +433,7 @@ func (l *DefaultAccessor) LatestMessageTo( lggr.Debugw("queried latest message from source", "numMsgs", len(seq), "sourceChainSelector", l.chainSelector, + "destChainSelector", destChainSelector, ) if len(seq) > 1 { return 0, fmt.Errorf("more than one message found for the latest message query") @@ -462,6 +460,7 @@ func (l *DefaultAccessor) GetExpectedNextSequenceNumber( ctx context.Context, destChainSelector cciptypes.ChainSelector, ) (cciptypes.SeqNum, error) { + lggr := logger.With(l.lggr, "destChainSelector", destChainSelector) var expectedNextSequenceNumber uint64 err := l.contractReader.ExtendedGetLatestValue( ctx, @@ -483,6 +482,9 @@ func (l *DefaultAccessor) GetExpectedNextSequenceNumber( l.chainSelector, destChainSelector) } + lggr.Debugw("fetched expected next sequence number", + "expectedNextSequenceNumber", cciptypes.SeqNum(expectedNextSequenceNumber).String(), + ) return cciptypes.SeqNum(expectedNextSequenceNumber), nil } @@ -523,6 +525,7 @@ func (l *DefaultAccessor) CommitReportsGTETimestamp( limit int, ) ([]cciptypes.CommitPluginReportWithMeta, error) { lggr := logutil.WithContextValues(ctx, l.lggr) + lggr = logger.With(lggr, "ts", ts, "confidence", confidence, "limit", limit) internalLimit := limit * 2 iter, err := l.contractReader.ExtendedQueryKey( @@ -549,10 +552,7 @@ func (l *DefaultAccessor) CommitReportsGTETimestamp( return nil, fmt.Errorf("failed to query offRamp: %w", err) } - lggr.Debugw("queried commit reports", "numReports", len(iter), - "destChain", l.chainSelector, - "ts", ts, - "limit", internalLimit) + lggr.Debugw("queried commit reports", "numReports", len(iter), "internalLimit", internalLimit) reports := l.processCommitReports(lggr, iter, ts, limit) return reports, nil @@ -564,6 +564,7 @@ func (l *DefaultAccessor) ExecutedMessages( confidence primitives.ConfidenceLevel, ) (map[cciptypes.ChainSelector][]cciptypes.SeqNum, error) { lggr := logutil.WithContextValues(ctx, l.lggr) + lggr = logger.With(lggr, "confidence", confidence, "rangesPerChain", rangesPerChain) // trim empty ranges from rangesPerChain // otherwise we may get SQL errors from the chainreader. @@ -613,6 +614,7 @@ func (l *DefaultAccessor) ExecutedMessages( append(executed[stateChange.SourceChainSelector], stateChange.SequenceNumber) } + lggr.Debug("decoded executed message sequence numbers", "executed", executed) return executed, nil } @@ -795,6 +797,7 @@ func (l *DefaultAccessor) GetChainFeePriceUpdate( selectors []cciptypes.ChainSelector, ) (map[cciptypes.ChainSelector]cciptypes.TimestampedUnixBig, error) { lggr := logutil.WithContextValues(ctx, l.lggr) + lggr = logger.With(lggr, "requestedSelectors", selectors) // 1. Build Batch Request contractBatch := make([]types.BatchRead, 0, len(selectors)) @@ -848,7 +851,9 @@ func (l *DefaultAccessor) GetChainFeePriceUpdate( } // 4. Process Results using helper - return l.processFeePriceUpdateResults(lggr, selectors, feeQuoterResults), nil + updates := l.processFeePriceUpdateResults(lggr, selectors, feeQuoterResults) + lggr.Debugw("updated fee price updates", "updates", updates) + return updates, nil } // processFeePriceUpdateResults iterates through batch results, validates them, diff --git a/pkg/reader/ccip.go b/pkg/reader/ccip.go index 431da9958..42e01a240 100644 --- a/pkg/reader/ccip.go +++ b/pkg/reader/ccip.go @@ -476,7 +476,7 @@ func (r *ccipChainReader) GetWrappedNativeTokenPriceUSD( nativeTokenAddress := config.Router.WrappedNativeAddress if cciptypes.UnknownAddress(nativeTokenAddress).IsZeroOrEmpty() { - lggr.Warnw("Native token address is zero or empty. Ignore for disabled chains otherwise "+ + lggr.Debug("Native token address is zero or empty. Ignore for disabled chains otherwise "+ "check for router misconfiguration", "chain", chain, "address", nativeTokenAddress.String()) return }