Skip to content

Commit 191ae01

Browse files
committed
Review feedbac
1 parent 896c6ad commit 191ae01

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

apps/evm/cmd/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var RunCmd = &cobra.Command{
6464
if err != nil {
6565
return fmt.Errorf("failed to create blob client: %w", err)
6666
}
67+
defer blobClient.Close()
6768

6869
daClient := block.NewDAClient(blobClient, nodeConfig, logger)
6970

block/internal/syncing/da_follower.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func (f *daFollower) Start(ctx context.Context) error {
111111

112112
f.wg.Add(2)
113113
go f.followLoop(ctx)
114+
f.signalCatchup()
114115
go f.catchupLoop(ctx)
115116

116117
f.logger.Info().
@@ -347,7 +348,7 @@ func (f *daFollower) runCatchup(ctx context.Context) {
347348
local := f.localNextDAHeight.Load()
348349
highest := f.highestSeenDAHeight.Load()
349350

350-
if local > highest {
351+
if highest > 0 && local > highest {
351352
// Caught up.
352353
f.headReached.Store(true)
353354
return

block/internal/syncing/syncer.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,17 @@ func (s *Syncer) SetBlockSyncer(bs BlockSyncer) {
161161
}
162162

163163
// Start begins the syncing component
164-
func (s *Syncer) Start(ctx context.Context) error {
164+
func (s *Syncer) Start(ctx context.Context) (err error) {
165165
ctx, cancel := context.WithCancel(ctx)
166166
s.ctx, s.cancel = ctx, cancel
167167

168-
if err := s.initializeState(); err != nil {
168+
defer func() {
169+
if err != nil {
170+
_ = s.Stop()
171+
}
172+
}()
173+
174+
if err = s.initializeState(); err != nil {
169175
return fmt.Errorf("failed to initialize syncer state: %w", err)
170176
}
171177

@@ -177,14 +183,16 @@ func (s *Syncer) Start(ctx context.Context) error {
177183

178184
s.fiRetriever = da.NewForcedInclusionRetriever(s.daClient, s.logger, s.config, s.genesis.DAStartHeight, s.genesis.DAEpochForcedInclusion)
179185
s.p2pHandler = NewP2PHandler(s.headerStore, s.dataStore, s.cache, s.genesis, s.logger)
180-
if currentHeight, err := s.store.Height(ctx); err != nil {
181-
s.logger.Error().Err(err).Msg("failed to set initial processed height for p2p handler")
186+
187+
currentHeight, initErr := s.store.Height(ctx)
188+
if initErr != nil {
189+
s.logger.Error().Err(initErr).Msg("failed to set initial processed height for p2p handler")
182190
} else {
183191
s.p2pHandler.SetProcessedHeight(currentHeight)
184192
}
185193

186194
if s.raftRetriever != nil {
187-
if err := s.raftRetriever.Start(ctx); err != nil {
195+
if err = s.raftRetriever.Start(ctx); err != nil {
188196
return fmt.Errorf("start raft retriever: %w", err)
189197
}
190198
}
@@ -207,9 +215,7 @@ func (s *Syncer) Start(ctx context.Context) error {
207215
StartDAHeight: s.daRetrieverHeight.Load(),
208216
DABlockTime: s.config.DA.BlockTime.Duration,
209217
})
210-
if err := s.daFollower.Start(ctx); err != nil {
211-
s.cancel()
212-
s.wg.Wait()
218+
if err = s.daFollower.Start(ctx); err != nil {
213219
return fmt.Errorf("failed to start DA follower: %w", err)
214220
}
215221

0 commit comments

Comments
 (0)