Skip to content

Commit 4b481b4

Browse files
committed
more logs
1 parent a6b1f88 commit 4b481b4

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

pkg/reader/ccip.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,11 @@ func (r *ccipChainReader) discoverOffRampContracts(
635635
lggr logger.Logger,
636636
chains []cciptypes.ChainSelector,
637637
) (ContractAddresses, error) {
638+
lggr = logger.With(lggr, "function", "discoverOffRampContracts",
639+
"destChain", r.destChain, "offRamp", r.offrampAddress, "chains", chains)
640+
638641
// Get from cache
642+
lggr.Debugw("fetching offramp dest chain config")
639643
config, err := r.configPoller.GetChainConfig(ctx, r.destChain)
640644
if err != nil {
641645
return nil, fmt.Errorf("unable to lookup RMN remote address (RMN proxy): %w", err)
@@ -645,9 +649,10 @@ func (r *ccipChainReader) discoverOffRampContracts(
645649

646650
// OnRamps are in the offRamp SourceChainConfig.
647651
{
652+
lggr.Debugw("fetching offramp source chain configs")
648653
sourceConfigs, err := r.getOffRampSourceChainsConfig(ctx, lggr, chains, false)
649-
650654
if err != nil {
655+
lggr.Debugw("unable to get SourceChainsConfig", "err", err)
651656
return nil, fmt.Errorf("unable to get SourceChainsConfig: %w", err)
652657
}
653658

@@ -932,6 +937,8 @@ func (r *ccipChainReader) getOffRampSourceChainsConfig(
932937
return nil, fmt.Errorf("get source chain configs: %w", err)
933938
}
934939

940+
lggr.Debugw("fetched offramp source chain configs from config poller", "count", len(configs), "configs", configs)
941+
935942
// Filter out disabled chains if needed
936943
if !includeDisabled {
937944
for chain, cfg := range configs {
@@ -949,6 +956,7 @@ func (r *ccipChainReader) getOffRampSourceChainsConfig(
949956
}
950957
}
951958

959+
lggr.Debugw("returning offramp source chain configs", "count", len(configs))
952960
return configs, nil
953961
}
954962

pkg/reader/config_poller_v2.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,20 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
233233
destChain, c.destChainSelector)
234234
}
235235

236+
lggr := logger.With(c.lggr, "function", "config_poller_v2 GetOfframpSourceChainConfigs", "destChain", destChain, "sourceChains", sourceChains)
237+
236238
// Ensure we're not trying to fetch source chain configs for the destination chain itself
239+
lggr.Debugw("filtering out destination chain from source chains")
237240
filteredSourceChains := filterOutChainSelector(sourceChains, c.destChainSelector)
241+
lggr.Debugw("filtered source chains", "filteredSourceChains", filteredSourceChains)
238242
if len(filteredSourceChains) == 0 {
243+
lggr.Debugw("No source chains to fetch after filtering out destination chain, returning empty map")
239244
return make(map[cciptypes.ChainSelector]StaticSourceChainConfig), nil
240245
}
241246

242247
// Add any new source chains to list of tracked source chains for background refreshing
243248
for _, chain := range filteredSourceChains {
249+
lggr.Debugw("adding source chain to tracking list for dest chain")
244250
if !c.trackSourceChainForDest(chain) {
245251
c.lggr.Warnw("Could not track source chain for background refreshing",
246252
"destChain", c.destChainSelector,
@@ -250,9 +256,13 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
250256

251257
destChainCache := c.getOrCreateChainCache(c.destChainSelector)
252258
if destChainCache == nil {
259+
lggr.Debugw("failed to get or create chain cache for destination chain")
253260
return nil, fmt.Errorf("failed to get chain cache for destination chain %s", c.destChainSelector)
254261
}
255262

263+
lggr.Debugw("got cache for destination chain, checking for cached source chain configs",
264+
"cacheAge", time.Since(destChainCache.sourceChainRefresh))
265+
256266
destChainCache.sourceChainMu.RLock()
257267

258268
// Initialize results map
@@ -263,9 +273,11 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
263273
for _, chain := range filteredSourceChains {
264274
staticSourceChainConfig, exists := destChainCache.staticSourceChainConfigs[chain]
265275
if exists {
276+
lggr.Debugw("found source chain config in cache", "sourceChain", chain, "staticSourceChainConfig", staticSourceChainConfig)
266277
cachedSourceConfigs[chain] = staticSourceChainConfig
267278
} else {
268279
// This chain isn't in cache yet
280+
lggr.Debugw("source chain config not found in cache", "sourceChain", chain)
269281
missingChains = append(missingChains, chain)
270282
}
271283
}
@@ -282,19 +294,28 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
282294
// Release lock before issuing batch refresh
283295
destChainCache.sourceChainMu.RUnlock()
284296

297+
lggr.Debugw("issuing batch refresh since we had some missing chains in the cache", "missingChains", missingChains)
285298
if err := c.batchRefreshChainAndSourceConfigs(ctx, c.destChainSelector); err != nil {
286299
return nil, err
287300
}
288301

302+
lggr.Debugw("looping through requested source chains to build result set after batch refresh")
303+
289304
// Re-acquire the lock to return only the cached configs that were requested
290305
destChainCache.sourceChainMu.RLock()
291306
defer destChainCache.sourceChainMu.RUnlock()
307+
292308
result := make(map[cciptypes.ChainSelector]StaticSourceChainConfig)
293309
for _, chain := range filteredSourceChains {
310+
lggr.Debugw("attempting to add source chain config to result set", "sourceChain", chain)
294311
if cfg, exists := destChainCache.staticSourceChainConfigs[chain]; exists {
295312
result[chain] = cfg
313+
} else {
314+
lggr.Warnw("Source chain config still not found in cache after batch refresh", "sourceChain", chain)
296315
}
297316
}
317+
318+
lggr.Debugw("returning source chain configs after batch refresh", "result", result)
298319
return result, nil
299320
}
300321

@@ -374,32 +395,35 @@ func (c *configPollerV2) batchRefreshChainAndSourceConfigs(
374395
ctx context.Context,
375396
chainSel cciptypes.ChainSelector,
376397
) error {
398+
lggr := logger.With(c.lggr, "function", "config_poller_v2 batchRefreshChainAndSourceConfigs", "chain", chainSel, "destChain", c.destChainSelector)
377399
start := time.Now()
378400
fetchingForDestChain := chainSel == c.destChainSelector
379401

380402
sourceChainSelectors := make([]cciptypes.ChainSelector, 0)
381403
if fetchingForDestChain {
382404
// Acquires read lock on 'c'
383405
sourceChainSelectors = c.getKnownSourceChainsForDestChain()
384-
c.lggr.Debugw("Issuing batch refresh for dest chain",
406+
lggr.Debugw("Issuing batch refresh for dest chain",
385407
"destChainSelector", c.destChainSelector, "sourceChains", sourceChainSelectors)
386408
}
387409

388410
// Use chainAccessor to fetch ChainConfigSnapshot (and SourceChainConfigs if destChain)
389411
accessor, err := getChainAccessor(c.chainAccessors, chainSel)
390412
if err != nil {
391-
c.lggr.Errorw("Failed to get chain accessor", "chain", chainSel, "error", err)
413+
lggr.Errorw("Failed to get chain accessor", "chain", chainSel, "error", err)
392414
return fmt.Errorf("failed to get chain accessor for %s: %w", chainSel, err)
393415
}
394416

417+
lggr.Debugw("calling accessor.GetAllConfigsLegacy", "sourceChainSelectors", sourceChainSelectors)
418+
395419
// NO LOCKING DURING IO
396420
chainConfigSnapshot, sourceChainConfigs, err := accessor.GetAllConfigsLegacy(
397421
ctx,
398422
c.destChainSelector,
399423
sourceChainSelectors,
400424
)
401425
if err != nil {
402-
c.lggr.Errorw("Failed batch fetch via chainAccessor",
426+
lggr.Errorw("Failed batch fetch via chainAccessor",
403427
"chain", chainSel, "destChainSelector", c.destChainSelector, "error", err)
404428
return err
405429
}
@@ -413,6 +437,7 @@ func (c *configPollerV2) batchRefreshChainAndSourceConfigs(
413437
cache.chainConfigMu.Lock()
414438
cache.chainConfigData = chainConfigSnapshot
415439
cache.chainConfigRefresh = time.Now()
440+
lggr.Debugw("fetched chainConfigSnapshot via chainAccessor", "chainConfigSnapshot", chainConfigSnapshot)
416441
cache.chainConfigMu.Unlock()
417442

418443
// Acquire StaticSourceChainConfigs lock and update

0 commit comments

Comments
 (0)