@@ -53,11 +53,11 @@ func (r *ForcedInclusionRetriever) RetrieveForcedIncludedTxs(ctx context.Context
5353
5454 epochStart , epochEnd , currentEpochNumber := types .CalculateEpochBoundaries (daHeight , r .genesis .DAStartHeight , r .daEpochSize )
5555
56- if daHeight != epochStart {
56+ if daHeight != epochEnd {
5757 r .logger .Debug ().
5858 Uint64 ("da_height" , daHeight ).
59- Uint64 ("epoch_start " , epochStart ).
60- Msg ("not at epoch start - returning empty transactions" )
59+ Uint64 ("epoch_end " , epochEnd ).
60+ Msg ("not at epoch end - returning empty transactions" )
6161
6262 return & ForcedInclusionEvent {
6363 StartDaHeight : daHeight ,
@@ -68,16 +68,10 @@ func (r *ForcedInclusionRetriever) RetrieveForcedIncludedTxs(ctx context.Context
6868
6969 event := & ForcedInclusionEvent {
7070 StartDaHeight : epochStart ,
71+ EndDaHeight : epochEnd ,
7172 Txs : [][]byte {},
7273 }
7374
74- r .logger .Debug ().
75- Uint64 ("da_height" , daHeight ).
76- Uint64 ("epoch_start" , epochStart ).
77- Uint64 ("epoch_end" , epochEnd ).
78- Uint64 ("epoch_num" , currentEpochNumber ).
79- Msg ("retrieving forced included transactions from DA" )
80-
8175 epochEndResult := r .client .RetrieveForcedInclusion (ctx , epochEnd )
8276 if epochEndResult .Code == coreda .StatusHeightFromFuture {
8377 r .logger .Debug ().
@@ -97,58 +91,59 @@ func (r *ForcedInclusionRetriever) RetrieveForcedIncludedTxs(ctx context.Context
9791 }
9892 }
9993
100- lastProcessedHeight := epochStart
94+ r .logger .Debug ().
95+ Uint64 ("da_height" , daHeight ).
96+ Uint64 ("epoch_start" , epochStart ).
97+ Uint64 ("epoch_end" , epochEnd ).
98+ Uint64 ("epoch_num" , currentEpochNumber ).
99+ Msg ("retrieving forced included transactions from DA" )
101100
102- if err := r . processForcedInclusionBlobs ( event , & lastProcessedHeight , epochStartResult , epochStart ); err != nil {
103- return nil , err
104- }
101+ var processErrs error
102+ err := r . processForcedInclusionBlobs ( event , epochStartResult , epochStart )
103+ processErrs = errors . Join ( processErrs , err )
105104
106105 // Process heights between start and end (exclusive)
107106 for epochHeight := epochStart + 1 ; epochHeight < epochEnd ; epochHeight ++ {
108107 result := r .client .RetrieveForcedInclusion (ctx , epochHeight )
109108
110- // If any intermediate height is from future, break early
111- if result .Code == coreda .StatusHeightFromFuture {
112- r .logger .Debug ().
113- Uint64 ("epoch_height" , epochHeight ).
114- Uint64 ("last_processed" , lastProcessedHeight ).
115- Msg ("reached future DA height within epoch - stopping" )
116- break
117- }
118-
119- if err := r .processForcedInclusionBlobs (event , & lastProcessedHeight , result , epochHeight ); err != nil {
120- return nil , err
121- }
109+ err = r .processForcedInclusionBlobs (event , result , epochHeight )
110+ processErrs = errors .Join (processErrs , err )
122111 }
123112
124113 // Process epoch end (only if different from start)
125114 if epochEnd != epochStart {
126- if err := r .processForcedInclusionBlobs (event , & lastProcessedHeight , epochEndResult , epochEnd ); err != nil {
127- return nil , err
128- }
115+ err = r .processForcedInclusionBlobs (event , epochEndResult , epochEnd )
116+ processErrs = errors .Join (processErrs , err )
129117 }
130118
131- event .EndDaHeight = lastProcessedHeight
119+ // any error during process, need to retry at next call
120+ if processErrs != nil {
121+ r .logger .Warn ().
122+ Uint64 ("da_height" , daHeight ).
123+ Uint64 ("epoch_start" , epochStart ).
124+ Uint64 ("epoch_end" , epochEnd ).
125+ Uint64 ("epoch_num" , currentEpochNumber ).
126+ Err (processErrs ).
127+ Msg ("Failed to retrieve DA epoch.. retrying next iteration" )
132128
133- r .logger .Info ().
134- Uint64 ("epoch_start" , epochStart ).
135- Uint64 ("epoch_end" , lastProcessedHeight ).
136- Int ("tx_count" , len (event .Txs )).
137- Msg ("retrieved forced inclusion transactions" )
129+ return & ForcedInclusionEvent {
130+ StartDaHeight : daHeight ,
131+ EndDaHeight : daHeight ,
132+ Txs : [][]byte {},
133+ }, nil
134+ }
138135
139136 return event , nil
140137}
141138
142139// processForcedInclusionBlobs processes blobs from a single DA height for forced inclusion.
143140func (r * ForcedInclusionRetriever ) processForcedInclusionBlobs (
144141 event * ForcedInclusionEvent ,
145- lastProcessedHeight * uint64 ,
146142 result coreda.ResultRetrieve ,
147143 height uint64 ,
148144) error {
149145 if result .Code == coreda .StatusNotFound {
150146 r .logger .Debug ().Uint64 ("height" , height ).Msg ("no forced inclusion blobs at height" )
151- * lastProcessedHeight = height
152147 return nil
153148 }
154149
@@ -163,8 +158,6 @@ func (r *ForcedInclusionRetriever) processForcedInclusionBlobs(
163158 }
164159 }
165160
166- * lastProcessedHeight = height
167-
168161 r .logger .Debug ().
169162 Uint64 ("height" , height ).
170163 Int ("blob_count" , len (result .Data )).
0 commit comments