@@ -71,10 +71,14 @@ func NewBasedSequencer(
7171 }
7272 } else {
7373 bs .checkpoint = checkpoint
74- bs .logger .Info ().
75- Uint64 ("da_height" , checkpoint .DAHeight ).
76- Uint64 ("tx_index" , checkpoint .TxIndex ).
77- Msg ("loaded based sequencer checkpoint from DB" )
74+ // If we had a non-zero tx index, we're resuming from a crash mid-block
75+ // The transactions starting from that index are what we need
76+ if checkpoint .TxIndex > 0 {
77+ bs .logger .Debug ().
78+ Uint64 ("tx_index" , checkpoint .TxIndex ).
79+ Uint64 ("da_height" , checkpoint .DAHeight ).
80+ Msg ("resuming from checkpoint within DA epoch" )
81+ }
7882 }
7983
8084 return bs , nil
@@ -109,9 +113,8 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
109113 batch := s .createBatchFromCheckpoint (req .MaxBytes )
110114
111115 // Update checkpoint with how many transactions we consumed
112- txCount := uint64 (len (batch .Transactions ))
113- if txCount > 0 {
114- s .checkpoint .TxIndex += txCount
116+ if daHeight > 0 || len (batch .Transactions ) > 0 {
117+ s .checkpoint .TxIndex += uint64 (len (batch .Transactions ))
115118
116119 // If we've consumed all transactions from this DA epoch, move to next
117120 if s .checkpoint .TxIndex >= uint64 (len (s .currentBatchTxs )) {
@@ -125,7 +128,6 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
125128
126129 // Persist checkpoint
127130 if err := s .checkpointStore .Save (ctx , s .checkpoint ); err != nil {
128- s .logger .Error ().Err (err ).Msg ("failed to save checkpoint" )
129131 return nil , fmt .Errorf ("failed to save checkpoint: %w" , err )
130132 }
131133 }
@@ -150,17 +152,16 @@ func (s *BasedSequencer) fetchNextDAEpoch(ctx context.Context, maxBytes uint64)
150152 if err != nil {
151153 // Check if forced inclusion is not configured
152154 if errors .Is (err , block .ErrForceInclusionNotConfigured ) {
153- return time.Time {}, currentDAHeight , block .ErrForceInclusionNotConfigured
155+ return time.Time {}, 0 , block .ErrForceInclusionNotConfigured
154156 } else if errors .Is (err , coreda .ErrHeightFromFuture ) {
155157 // If we get a height from future error, stay at current position
156158 // We'll retry the same height on the next call until DA produces that block
157159 s .logger .Debug ().
158160 Uint64 ("da_height" , currentDAHeight ).
159161 Msg ("DA height from future, waiting for DA to produce block" )
160- return time.Time {}, currentDAHeight , nil
162+ return time.Time {}, 0 , nil
161163 }
162- s .logger .Error ().Err (err ).Uint64 ("da_height" , currentDAHeight ).Msg ("failed to retrieve forced inclusion transactions" )
163- return time.Time {}, currentDAHeight , err
164+ return time.Time {}, 0 , fmt .Errorf ("failed to retrieve forced inclusion transactions: %w" , err )
164165 }
165166
166167 // Validate and filter transactions
@@ -190,14 +191,6 @@ func (s *BasedSequencer) fetchNextDAEpoch(ctx context.Context, maxBytes uint64)
190191 // Cache the transactions for this DA epoch
191192 s .currentBatchTxs = validTxs
192193
193- // If we had a non-zero tx index, we're resuming from a crash mid-block
194- // The transactions starting from that index are what we need
195- if s .checkpoint .TxIndex > 0 {
196- s .logger .Info ().
197- Uint64 ("tx_index" , s .checkpoint .TxIndex ).
198- Msg ("resuming from checkpoint within DA epoch" )
199- }
200-
201194 return forcedTxsEvent .Timestamp .UTC (), forcedTxsEvent .EndDaHeight , nil
202195}
203196
0 commit comments