Skip to content

Commit 2dbd786

Browse files
committed
remove header namespace config
1 parent cad9451 commit 2dbd786

File tree

8 files changed

+173
-286
lines changed

8 files changed

+173
-286
lines changed

block/namespace_test.go

Lines changed: 43 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ func TestProcessNextDAHeaderAndData_MixedResults(t *testing.T) {
131131
t.Parallel()
132132

133133
daConfig := config.DAConfig{
134-
HeaderNamespace: "test-headers",
135-
DataNamespace: "test-data",
134+
Namespace: "test-headers",
135+
DataNamespace: "test-data",
136136
}
137137
manager, mockDA, _, cancel := setupManagerForNamespaceTest(t, daConfig)
138138
daManager := newDARetriever(manager)
@@ -184,40 +184,28 @@ func TestProcessNextDAHeaderAndData_MixedResults(t *testing.T) {
184184
// TestLegacyNamespaceDetection tests the legacy namespace fallback behavior
185185
func TestLegacyNamespaceDetection(t *testing.T) {
186186
t.Parallel()
187-
188187
tests := []struct {
189-
name string
190-
legacyNamespace string
191-
headerNamespace string
192-
dataNamespace string
188+
name string
189+
namespace string
190+
dataNamespace string
193191
}{
194192
{
195193
// When only legacy namespace is set, it acts as both header and data namespace
196-
name: "only legacy namespace configured",
197-
legacyNamespace: "old-namespace",
198-
headerNamespace: "",
199-
dataNamespace: "",
200-
},
201-
{
202-
// Should check both namespaces. It will behave as legacy when data namespace is empty
203-
name: "all namespaces configured",
204-
legacyNamespace: "old-namespace",
205-
headerNamespace: "old-namespace",
206-
dataNamespace: "new-data",
194+
name: "only legacy namespace configured",
195+
namespace: "namespace",
196+
dataNamespace: "",
207197
},
208198
{
209199
// Should check both namespaces. It will behave as legacy when data namespace is empty
210-
name: "only legacy namespaces and data",
211-
legacyNamespace: "old-namespace",
212-
headerNamespace: "",
213-
dataNamespace: "new-data",
200+
name: "all namespaces configured",
201+
namespace: "old-namespace",
202+
dataNamespace: "new-data",
214203
},
215204
{
216205
// Should use default namespaces only
217-
name: "no namespaces configured",
218-
legacyNamespace: "",
219-
headerNamespace: "",
220-
dataNamespace: "",
206+
name: "no namespaces configured",
207+
namespace: "",
208+
dataNamespace: "",
221209
},
222210
}
223211

@@ -226,27 +214,24 @@ func TestLegacyNamespaceDetection(t *testing.T) {
226214
t.Parallel()
227215

228216
daConfig := config.DAConfig{
229-
Namespace: tt.legacyNamespace,
230-
HeaderNamespace: tt.headerNamespace,
231-
DataNamespace: tt.dataNamespace,
217+
Namespace: tt.namespace,
218+
DataNamespace: tt.dataNamespace,
232219
}
233220

234-
// Test the GetHeaderNamespace and GetDataNamespace methods
235-
headerNS := daConfig.GetHeaderNamespace()
221+
// Test the GetNamespace and GetDataNamespace methods
222+
headerNS := daConfig.GetNamespace()
236223
dataNS := daConfig.GetDataNamespace()
237224

238-
if tt.headerNamespace != "" {
239-
assert.Equal(t, tt.headerNamespace, headerNS)
240-
} else if tt.legacyNamespace != "" {
241-
assert.Equal(t, tt.legacyNamespace, headerNS)
225+
if tt.namespace != "" {
226+
assert.Equal(t, tt.namespace, headerNS)
242227
} else {
243228
assert.Equal(t, "rollkit-headers", headerNS) // Default
244229
}
245230

246231
if tt.dataNamespace != "" {
247232
assert.Equal(t, tt.dataNamespace, dataNS)
248-
} else if tt.legacyNamespace != "" {
249-
assert.Equal(t, tt.legacyNamespace, dataNS)
233+
} else if tt.namespace != "" {
234+
assert.Equal(t, tt.namespace, dataNS)
250235
} else {
251236
assert.Equal(t, "rollkit-data", dataNS) // Default
252237
}
@@ -256,54 +241,36 @@ func TestLegacyNamespaceDetection(t *testing.T) {
256241
daManager := newDARetriever(manager)
257242
defer cancel()
258243

259-
// Check if we should expect a legacy namespace check
260-
// Legacy check happens when migration is not completed and legacy namespace is configured
261-
if tt.legacyNamespace != "" {
262-
// When legacy namespace is the same as header/data namespaces,
244+
// Check if we should expect a namespace check
245+
if tt.namespace != "" {
246+
// When namespace is the same as data namespaces,
263247
// only one call is expected
264-
if tt.legacyNamespace == headerNS && headerNS == dataNS {
265-
// All three namespaces are the same, so we'll get 1 call.
266-
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(tt.legacyNamespace)).Return(&coreda.GetIDsResult{
267-
IDs: []coreda.ID{},
268-
}, coreda.ErrBlobNotFound).Once()
269-
} else if tt.legacyNamespace == headerNS || tt.legacyNamespace == dataNS {
270-
// Legacy matches one of the new namespaces
271-
// Plus none or one depending on whether header == data
272-
totalCalls := 1 // legacy call
273-
if headerNS == dataNS {
274-
totalCalls += 1 // header and data are same
275-
}
276-
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(tt.legacyNamespace)).Return(&coreda.GetIDsResult{
277-
IDs: []coreda.ID{},
278-
}, coreda.ErrBlobNotFound).Times(totalCalls)
279-
280-
// Mock the non-matching namespace if header != data
281-
if headerNS != dataNS {
282-
nonMatchingNS := headerNS
283-
if tt.legacyNamespace == headerNS {
284-
nonMatchingNS = dataNS
285-
}
286-
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(nonMatchingNS)).Return(&coreda.GetIDsResult{
287-
IDs: []coreda.ID{},
288-
}, coreda.ErrBlobNotFound).Once()
289-
}
290-
} else {
291-
t.Fatalf("Should never happen, forbidden by config")
292-
}
293-
} else {
294-
// No legacy namespace configured, just mock the new namespace calls
295248
if headerNS == dataNS {
296-
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(headerNS)).Return(&coreda.GetIDsResult{
249+
// All 2 namespaces are the same, so we'll get 1 call.
250+
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(tt.namespace)).Return(&coreda.GetIDsResult{
297251
IDs: []coreda.ID{},
298252
}, coreda.ErrBlobNotFound).Once()
299-
} else {
300-
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(headerNS)).Return(&coreda.GetIDsResult{
253+
} else if tt.namespace != dataNS {
254+
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(tt.namespace)).Return(&coreda.GetIDsResult{
301255
IDs: []coreda.ID{},
302256
}, coreda.ErrBlobNotFound).Once()
303-
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(dataNS)).Return(&coreda.GetIDsResult{
257+
258+
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(tt.dataNamespace)).Return(&coreda.GetIDsResult{
304259
IDs: []coreda.ID{},
305260
}, coreda.ErrBlobNotFound).Once()
261+
262+
} else {
263+
t.Fatalf("Should never happen, forbidden by config")
306264
}
265+
} else {
266+
// No namespace configured, just use default
267+
268+
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(headerNS)).Return(&coreda.GetIDsResult{
269+
IDs: []coreda.ID{},
270+
}, coreda.ErrBlobNotFound).Once()
271+
mockDA.On("GetIDs", mock.Anything, uint64(100), []byte(dataNS)).Return(&coreda.GetIDsResult{
272+
IDs: []coreda.ID{},
273+
}, coreda.ErrBlobNotFound).Once()
307274
}
308275

309276
ctx := context.Background()

block/retriever_da.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,13 @@ func (m *Manager) fetchBlobs(ctx context.Context, daHeight uint64) (coreda.Resul
460460
m.recordDAMetrics("retrieval", DAModeRetry)
461461

462462
// Try to retrieve from both header and data namespaces
463-
headerNamespace := []byte(m.config.DA.GetHeaderNamespace())
463+
headerNamespace := []byte(m.config.DA.GetNamespace())
464464
dataNamespace := []byte(m.config.DA.GetDataNamespace())
465465

466-
// Sanity check, enforced by the config validation earlier
467-
if m.config.DA.Namespace != m.config.DA.GetHeaderNamespace() && m.config.DA.Namespace != m.config.DA.GetDataNamespace() {
468-
return coreda.ResultRetrieve{
469-
BaseResult: coreda.BaseResult{Code: 1337},
470-
}, fmt.Errorf("invalid config, namespace mismatch")
471-
}
472-
473466
// Retrieve headers
474467
headerRes := types.RetrieveWithHelpers(ctx, m.da, m.logger, daHeight, headerNamespace)
475468

476-
// Both namespace are the same, so we are using the legacy flow.
469+
// Both namespace are the same, so we are not fetching from data namespace
477470
if bytes.Equal(headerNamespace, dataNamespace) {
478471
err := m.validateBlobResponse(headerRes, daHeight)
479472
return headerRes, err

block/submitter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (m *Manager) submitHeadersToDA(ctx context.Context, headersToSubmit []*type
158158
m.sendNonBlockingSignalToDAIncluderCh()
159159
},
160160
"header",
161-
[]byte(m.config.DA.GetHeaderNamespace()),
161+
[]byte(m.config.DA.GetNamespace()),
162162
)
163163
}
164164

0 commit comments

Comments
 (0)