@@ -29,8 +29,6 @@ var _ coresequencer.Sequencer = (*BasedSequencer)(nil)
2929// It uses DA as a queue and only persists a checkpoint of where it is in processing.
3030type BasedSequencer struct {
3131 fiRetriever ForcedInclusionRetriever
32- da coreda.DA
33- genesis genesis.Genesis
3432 logger zerolog.Logger
3533
3634 daHeight atomic.Uint64
@@ -45,15 +43,12 @@ type BasedSequencer struct {
4543func NewBasedSequencer (
4644 ctx context.Context ,
4745 fiRetriever ForcedInclusionRetriever ,
48- da coreda.DA ,
4946 db ds.Batching ,
5047 genesis genesis.Genesis ,
5148 logger zerolog.Logger ,
5249) (* BasedSequencer , error ) {
5350 bs := & BasedSequencer {
5451 fiRetriever : fiRetriever ,
55- da : da ,
56- genesis : genesis ,
5752 logger : logger .With ().Str ("component" , "based_sequencer" ).Logger (),
5853 checkpointStore : seqcommon .NewCheckpointStore (db , ds .NewKey ("/based/checkpoint" )),
5954 }
@@ -96,11 +91,15 @@ func (s *BasedSequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.S
9691// It treats DA as a queue and only persists where it is in processing
9792func (s * BasedSequencer ) GetNextBatch (ctx context.Context , req coresequencer.GetNextBatchRequest ) (* coresequencer.GetNextBatchResponse , error ) {
9893 // If we have no cached transactions or we've consumed all from the current DA block,
99- // fetch the next DA block
94+ // fetch the next DA epoch
95+ daHeight := s .GetDAHeight ()
10096 if len (s .currentBatchTxs ) == 0 || s .checkpoint .TxIndex >= uint64 (len (s .currentBatchTxs )) {
101- if err := s .fetchNextDABatch (ctx ); err != nil {
97+ daEndHeight , err := s .fetchNextDAEpoch (ctx )
98+ if err != nil {
10299 return nil , err
103100 }
101+
102+ daHeight = daEndHeight
104103 }
105104
106105 // Create batch from current position up to MaxBytes
@@ -113,7 +112,7 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
113112
114113 // If we've consumed all transactions from this DA block, move to next
115114 if s .checkpoint .TxIndex >= uint64 (len (s .currentBatchTxs )) {
116- s .checkpoint .DAHeight ++
115+ s .checkpoint .DAHeight = daHeight + 1
117116 s .checkpoint .TxIndex = 0
118117 s .currentBatchTxs = nil
119118
@@ -135,8 +134,8 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
135134 }, nil
136135}
137136
138- // fetchNextDABatch fetches transactions from the next DA block
139- func (s * BasedSequencer ) fetchNextDABatch (ctx context.Context ) error {
137+ // fetchNextDAEpoch fetches transactions from the next DA epoch
138+ func (s * BasedSequencer ) fetchNextDAEpoch (ctx context.Context ) ( uint64 , error ) {
140139 currentDAHeight := s .checkpoint .DAHeight
141140
142141 s .logger .Debug ().
@@ -148,17 +147,17 @@ func (s *BasedSequencer) fetchNextDABatch(ctx context.Context) error {
148147 if err != nil {
149148 // Check if forced inclusion is not configured
150149 if errors .Is (err , block .ErrForceInclusionNotConfigured ) {
151- return errors . New ( "forced inclusion not configured" )
150+ return currentDAHeight , block . ErrForceInclusionNotConfigured
152151 } else if errors .Is (err , coreda .ErrHeightFromFuture ) {
153152 // If we get a height from future error, stay at current position
154153 // We'll retry the same height on the next call until DA produces that block
155154 s .logger .Debug ().
156155 Uint64 ("da_height" , currentDAHeight ).
157156 Msg ("DA height from future, waiting for DA to produce block" )
158- return nil
157+ return currentDAHeight , nil
159158 }
160159 s .logger .Error ().Err (err ).Uint64 ("da_height" , currentDAHeight ).Msg ("failed to retrieve forced inclusion transactions" )
161- return err
160+ return currentDAHeight , err
162161 }
163162
164163 // Validate and filter transactions
@@ -184,18 +183,18 @@ func (s *BasedSequencer) fetchNextDABatch(ctx context.Context) error {
184183 Uint64 ("da_height_end" , forcedTxsEvent .EndDaHeight ).
185184 Msg ("fetched forced inclusion transactions from DA" )
186185
187- // Cache the transactions for this DA block
186+ // Cache the transactions for this DA epoch
188187 s .currentBatchTxs = validTxs
189188
190189 // If we had a non-zero tx index, we're resuming from a crash mid-block
191190 // The transactions starting from that index are what we need
192191 if s .checkpoint .TxIndex > 0 {
193192 s .logger .Info ().
194193 Uint64 ("tx_index" , s .checkpoint .TxIndex ).
195- Msg ("resuming from checkpoint within DA block " )
194+ Msg ("resuming from checkpoint within DA epoch " )
196195 }
197196
198- return nil
197+ return forcedTxsEvent . EndDaHeight , nil
199198}
200199
201200// createBatchFromCheckpoint creates a batch from the current checkpoint position respecting MaxBytes
0 commit comments