Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions pkg/chainaccessor/default_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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,
Expand All @@ -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
}

Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/reader/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading