Skip to content

Commit 896c6ad

Browse files
committed
Review feedback
1 parent 6c1e630 commit 896c6ad

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

block/internal/syncing/da_follower.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,13 @@ func (f *daFollower) runCatchup(ctx context.Context) {
325325
}
326326

327327
// Check for priority heights from P2P hints first.
328-
if priorityHeight := f.retriever.PopPriorityHeight(); priorityHeight > 0 {
329-
nextHeight := f.localNextDAHeight.Load()
330-
if priorityHeight < nextHeight {
331-
continue
332-
}
328+
// We drain stale hints to avoid a tight CPU loop if many are queued.
329+
priorityHeight := f.retriever.PopPriorityHeight()
330+
for priorityHeight > 0 && priorityHeight < f.localNextDAHeight.Load() {
331+
priorityHeight = f.retriever.PopPriorityHeight()
332+
}
333+
334+
if priorityHeight > 0 {
333335
f.logger.Debug().
334336
Uint64("da_height", priorityHeight).
335337
Msg("fetching priority DA height from P2P hint")

block/internal/syncing/da_retriever_strict_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ func TestDARetriever_StrictEnvelopeMode_Switch(t *testing.T) {
7070
// --- Test Scenario ---
7171

7272
// A. Initial State: StrictMode is false. Legacy blob should be accepted.
73-
assert.False(t, r.strictMode)
73+
assert.False(t, r.strictMode.Load())
7474

7575
decodedLegacy := r.tryDecodeHeader(legacyBlob, 100)
7676
require.NotNil(t, decodedLegacy)
7777
assert.Equal(t, uint64(1), decodedLegacy.Height())
7878

7979
// StrictMode should still be false because it was a legacy blob
80-
assert.False(t, r.strictMode)
80+
assert.False(t, r.strictMode.Load())
8181

8282
// B. Receiving Envelope: Should be accepted and Switch StrictMode to true.
8383
decodedEnvelope := r.tryDecodeHeader(envelopeBlob, 101)
8484
require.NotNil(t, decodedEnvelope)
8585
assert.Equal(t, uint64(2), decodedEnvelope.Height())
8686

87-
assert.True(t, r.strictMode, "retriever should have switched to strict mode")
87+
assert.True(t, r.strictMode.Load(), "retriever should have switched to strict mode")
8888

8989
// C. Receiving Legacy again: Should be REJECTED now.
9090
// We reuse the same legacyBlob (or a new one, doesn't matter, structure is legacy).

test/testda/dummy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ func (d *DummyDA) Subscribe(ctx context.Context, _ []byte) (<-chan datypes.Subsc
7070
for i, s := range d.subscribers {
7171
if s == sub {
7272
d.subscribers = append(d.subscribers[:i], d.subscribers[i+1:]...)
73+
close(ch)
7374
break
7475
}
7576
}
76-
close(ch)
7777
}()
7878

7979
return ch, nil

0 commit comments

Comments
 (0)