@@ -224,6 +224,37 @@ func (m *Manager) fetchBlobs(ctx context.Context, daHeight uint64) (coreda.Resul
224224 // Record DA retrieval retry attempt
225225 m .recordDAMetrics ("retrieval" , DAModeRetry )
226226
227+ // TODO: Remove this once XO resets their testnet
228+ // Check if we should still try the old namespace for backward compatibility
229+ if ! m .namespaceMigrationCompleted .Load () {
230+ // First, try the legacy namespace if we haven't completed migration
231+ legacyNamespace := []byte (m .config .DA .Namespace )
232+ if legacyNamespace != nil && len (legacyNamespace ) > 0 {
233+ legacyRes := types .RetrieveWithHelpers (ctx , m .da , m .logger , daHeight , legacyNamespace )
234+
235+ // Handle legacy namespace errors
236+ if legacyRes .Code == coreda .StatusError {
237+ m .recordDAMetrics ("retrieval" , DAModeFail )
238+ err = fmt .Errorf ("failed to retrieve from legacy namespace: %s" , legacyRes .Message )
239+ return legacyRes , err
240+ }
241+
242+ if legacyRes .Code == coreda .StatusHeightFromFuture {
243+ err = fmt .Errorf ("%w: height from future" , coreda .ErrHeightFromFuture )
244+ return coreda.ResultRetrieve {BaseResult : coreda.BaseResult {Code : coreda .StatusHeightFromFuture }}, err
245+ }
246+
247+ // If legacy namespace has data, use it and return
248+ if legacyRes .Code == coreda .StatusSuccess {
249+ m .logger .Debug ().Uint64 ("daHeight" , daHeight ).Msg ("found data in legacy namespace" )
250+ return legacyRes , nil
251+ }
252+
253+ // Legacy namespace returned not found, so try new namespaces
254+ m .logger .Debug ().Uint64 ("daHeight" , daHeight ).Msg ("no data in legacy namespace, trying new namespaces" )
255+ }
256+ }
257+
227258 // Try to retrieve from both header and data namespaces
228259 headerNamespace := []byte (m .config .DA .GetHeaderNamespace ())
229260 dataNamespace := []byte (m .config .DA .GetDataNamespace ())
@@ -273,10 +304,27 @@ func (m *Manager) fetchBlobs(ctx context.Context, daHeight uint64) (coreda.Resul
273304 }
274305 }
275306
276- // If both returned not found, return not found
307+ // Handle not found cases and migration completion
277308 if headerRes .Code == coreda .StatusNotFound && dataRes .Code == coreda .StatusNotFound {
278309 combinedResult .Code = coreda .StatusNotFound
279310 combinedResult .Message = "no blobs found in either namespace"
311+
312+ // If we haven't completed migration and found no data in new namespaces,
313+ // mark migration as complete to avoid future legacy namespace checks
314+ if ! m .namespaceMigrationCompleted .Load () {
315+ if err := m .setNamespaceMigrationCompleted (ctx ); err != nil {
316+ m .logger .Error ().Err (err ).Msg ("failed to mark namespace migration as completed" )
317+ } else {
318+ m .logger .Info ().Uint64 ("daHeight" , daHeight ).Msg ("marked namespace migration as completed - no more legacy namespace checks" )
319+ }
320+ }
321+ } else if (headerRes .Code == coreda .StatusSuccess || dataRes .Code == coreda .StatusSuccess ) && ! m .namespaceMigrationCompleted .Load () {
322+ // Found data in new namespaces, mark migration as complete
323+ if err := m .setNamespaceMigrationCompleted (ctx ); err != nil {
324+ m .logger .Error ().Err (err ).Msg ("failed to mark namespace migration as completed" )
325+ } else {
326+ m .logger .Info ().Uint64 ("daHeight" , daHeight ).Msg ("found data in new namespaces - marked migration as completed" )
327+ }
280328 }
281329
282330 return combinedResult , err
0 commit comments