diff --git a/CHANGELOG.md b/CHANGELOG.md index 24eaa6173..e6a17a0a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Refetch latest da height instead of da height +1 when P2P is offline [#3201](https://github.com/evstack/ev-node/pull/3201) - Fix race on startup sync. [#3162](https://github.com/evstack/ev-node/pull/3162) - Strict raft state. [#3167](https://github.com/evstack/ev-node/pull/3167) - Retry fetching the timestamp on error in da-client [#3166](https://github.com/evstack/ev-node/pull/3166) diff --git a/block/internal/syncing/syncer.go b/block/internal/syncing/syncer.go index 3dcf80ea3..a1b926725 100644 --- a/block/internal/syncing/syncer.go +++ b/block/internal/syncing/syncer.go @@ -355,7 +355,12 @@ func (s *Syncer) initializeState() error { // Set DA height to the maximum of the genesis start height, the state's DA height, and the cached DA height. // The cache's DaHeight() is initialized from store metadata, so it's always correct even after cache clear. - s.daRetrieverHeight.Store(max(s.genesis.DAStartHeight, s.cache.DaHeight(), state.DAHeight)) + // Only use cache.DaHeight() when P2P is actively syncing (headerStore has higher height than current state). + daHeight := max(s.genesis.DAStartHeight, min(state.DAHeight-1, 0)) + if s.headerStore != nil && s.headerStore.Height() > state.LastBlockHeight { + daHeight = max(daHeight, s.cache.DaHeight()) + } + s.daRetrieverHeight.Store(daHeight) s.logger.Info(). Uint64("height", state.LastBlockHeight).