@@ -233,14 +233,20 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
233
233
destChain , c .destChainSelector )
234
234
}
235
235
236
+ lggr := logger .With (c .lggr , "function" , "config_poller_v2 GetOfframpSourceChainConfigs" , "destChain" , destChain , "sourceChains" , sourceChains )
237
+
236
238
// 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" )
237
240
filteredSourceChains := filterOutChainSelector (sourceChains , c .destChainSelector )
241
+ lggr .Debugw ("filtered source chains" , "filteredSourceChains" , filteredSourceChains )
238
242
if len (filteredSourceChains ) == 0 {
243
+ lggr .Debugw ("No source chains to fetch after filtering out destination chain, returning empty map" )
239
244
return make (map [cciptypes.ChainSelector ]StaticSourceChainConfig ), nil
240
245
}
241
246
242
247
// Add any new source chains to list of tracked source chains for background refreshing
243
248
for _ , chain := range filteredSourceChains {
249
+ lggr .Debugw ("adding source chain to tracking list for dest chain" )
244
250
if ! c .trackSourceChainForDest (chain ) {
245
251
c .lggr .Warnw ("Could not track source chain for background refreshing" ,
246
252
"destChain" , c .destChainSelector ,
@@ -250,9 +256,13 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
250
256
251
257
destChainCache := c .getOrCreateChainCache (c .destChainSelector )
252
258
if destChainCache == nil {
259
+ lggr .Debugw ("failed to get or create chain cache for destination chain" )
253
260
return nil , fmt .Errorf ("failed to get chain cache for destination chain %s" , c .destChainSelector )
254
261
}
255
262
263
+ lggr .Debugw ("got cache for destination chain, checking for cached source chain configs" ,
264
+ "cacheAge" , time .Since (destChainCache .sourceChainRefresh ))
265
+
256
266
destChainCache .sourceChainMu .RLock ()
257
267
258
268
// Initialize results map
@@ -263,9 +273,11 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
263
273
for _ , chain := range filteredSourceChains {
264
274
staticSourceChainConfig , exists := destChainCache .staticSourceChainConfigs [chain ]
265
275
if exists {
276
+ lggr .Debugw ("found source chain config in cache" , "sourceChain" , chain , "staticSourceChainConfig" , staticSourceChainConfig )
266
277
cachedSourceConfigs [chain ] = staticSourceChainConfig
267
278
} else {
268
279
// This chain isn't in cache yet
280
+ lggr .Debugw ("source chain config not found in cache" , "sourceChain" , chain )
269
281
missingChains = append (missingChains , chain )
270
282
}
271
283
}
@@ -282,19 +294,28 @@ func (c *configPollerV2) GetOfframpSourceChainConfigs(
282
294
// Release lock before issuing batch refresh
283
295
destChainCache .sourceChainMu .RUnlock ()
284
296
297
+ lggr .Debugw ("issuing batch refresh since we had some missing chains in the cache" , "missingChains" , missingChains )
285
298
if err := c .batchRefreshChainAndSourceConfigs (ctx , c .destChainSelector ); err != nil {
286
299
return nil , err
287
300
}
288
301
302
+ lggr .Debugw ("looping through requested source chains to build result set after batch refresh" )
303
+
289
304
// Re-acquire the lock to return only the cached configs that were requested
290
305
destChainCache .sourceChainMu .RLock ()
291
306
defer destChainCache .sourceChainMu .RUnlock ()
307
+
292
308
result := make (map [cciptypes.ChainSelector ]StaticSourceChainConfig )
293
309
for _ , chain := range filteredSourceChains {
310
+ lggr .Debugw ("attempting to add source chain config to result set" , "sourceChain" , chain )
294
311
if cfg , exists := destChainCache .staticSourceChainConfigs [chain ]; exists {
295
312
result [chain ] = cfg
313
+ } else {
314
+ lggr .Warnw ("Source chain config still not found in cache after batch refresh" , "sourceChain" , chain )
296
315
}
297
316
}
317
+
318
+ lggr .Debugw ("returning source chain configs after batch refresh" , "result" , result )
298
319
return result , nil
299
320
}
300
321
@@ -374,32 +395,35 @@ func (c *configPollerV2) batchRefreshChainAndSourceConfigs(
374
395
ctx context.Context ,
375
396
chainSel cciptypes.ChainSelector ,
376
397
) error {
398
+ lggr := logger .With (c .lggr , "function" , "config_poller_v2 batchRefreshChainAndSourceConfigs" , "chain" , chainSel , "destChain" , c .destChainSelector )
377
399
start := time .Now ()
378
400
fetchingForDestChain := chainSel == c .destChainSelector
379
401
380
402
sourceChainSelectors := make ([]cciptypes.ChainSelector , 0 )
381
403
if fetchingForDestChain {
382
404
// Acquires read lock on 'c'
383
405
sourceChainSelectors = c .getKnownSourceChainsForDestChain ()
384
- c . lggr .Debugw ("Issuing batch refresh for dest chain" ,
406
+ lggr .Debugw ("Issuing batch refresh for dest chain" ,
385
407
"destChainSelector" , c .destChainSelector , "sourceChains" , sourceChainSelectors )
386
408
}
387
409
388
410
// Use chainAccessor to fetch ChainConfigSnapshot (and SourceChainConfigs if destChain)
389
411
accessor , err := getChainAccessor (c .chainAccessors , chainSel )
390
412
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 )
392
414
return fmt .Errorf ("failed to get chain accessor for %s: %w" , chainSel , err )
393
415
}
394
416
417
+ lggr .Debugw ("calling accessor.GetAllConfigsLegacy" , "sourceChainSelectors" , sourceChainSelectors )
418
+
395
419
// NO LOCKING DURING IO
396
420
chainConfigSnapshot , sourceChainConfigs , err := accessor .GetAllConfigsLegacy (
397
421
ctx ,
398
422
c .destChainSelector ,
399
423
sourceChainSelectors ,
400
424
)
401
425
if err != nil {
402
- c . lggr .Errorw ("Failed batch fetch via chainAccessor" ,
426
+ lggr .Errorw ("Failed batch fetch via chainAccessor" ,
403
427
"chain" , chainSel , "destChainSelector" , c .destChainSelector , "error" , err )
404
428
return err
405
429
}
@@ -413,6 +437,7 @@ func (c *configPollerV2) batchRefreshChainAndSourceConfigs(
413
437
cache .chainConfigMu .Lock ()
414
438
cache .chainConfigData = chainConfigSnapshot
415
439
cache .chainConfigRefresh = time .Now ()
440
+ lggr .Debugw ("fetched chainConfigSnapshot via chainAccessor" , "chainConfigSnapshot" , chainConfigSnapshot )
416
441
cache .chainConfigMu .Unlock ()
417
442
418
443
// Acquire StaticSourceChainConfigs lock and update
0 commit comments