Skip to content

Commit 5ca5224

Browse files
committed
wip
1 parent 5d28492 commit 5ca5224

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

block/internal/syncing/syncer.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,16 @@ func (s *Syncer) initializeState() error {
354354
}
355355

356356
// Set DA height to the maximum of the genesis start height, the state's DA height, and the cached DA height.
357-
// The cache's DaHeight() is initialized from store metadata, so it's always correct even after cache clear.
358-
// Only use cache.DaHeight() when P2P is actively syncing (headerStore has higher height than current state).
357+
// Use the DA height from the last executed block instead of the maximum from all blocks,
358+
// because P2P-fetched heights may be lost on restart.
359359
daHeight := max(s.genesis.DAStartHeight, min(state.DAHeight-1, 0))
360-
if s.headerStore != nil && s.headerStore.Height() > state.LastBlockHeight {
361-
daHeight = max(daHeight, s.cache.DaHeight())
360+
if state.LastBlockHeight > 0 {
361+
if lastHeaderDA, ok := s.cache.GetHeaderDAIncludedByHeight(state.LastBlockHeight); ok {
362+
daHeight = max(daHeight, lastHeaderDA)
363+
}
364+
if lastDataDA, ok := s.cache.GetDataDAIncludedByHeight(state.LastBlockHeight); ok {
365+
daHeight = max(daHeight, lastDataDA)
366+
}
362367
}
363368
s.daRetrieverHeight.Store(daHeight)
364369

0 commit comments

Comments
 (0)