@@ -182,9 +182,8 @@ func (b *ExecutionDataBackend) SubscribeExecutionDataFromStartBlockHeight(
182182 startBlockHeight uint64 ,
183183 criteria optimistic_sync.Criteria ,
184184) subscription.Subscription {
185- // can use headers, though i need a check that startBlockHeight is not greater than the highest indexed height,
185+ // TODO: can use headers, though i need a check that startBlockHeight is not greater than the highest indexed height,
186186 // i can pass this value to backend without having executionDataTracker
187-
188187 nextHeight , err := b .executionDataTracker .GetStartHeightFromHeight (startBlockHeight )
189188 if err != nil {
190189 return subscription .NewFailedSubscription (err , "could not get start block height" )
@@ -217,6 +216,11 @@ func (b *ExecutionDataBackend) createResponseHandler(criteria optimistic_sync.Cr
217216 nextCriteria := criteria
218217
219218 return func (ctx context.Context , height uint64 ) (interface {}, error ) {
219+ // TODO: there was a check like if height > highestHeight { return err }
220+ // highest height were produced by the execution data downloader in the access_node_builder.go
221+ // it was passed as an argument to the execution data tracker.
222+ // should i add back this check here?
223+
220224 // the spork root block will never have execution data available. If requested, return an empty result.
221225 if height == b .state .Params ().SporkRootBlockHeight () {
222226 return & ExecutionDataResponse {
@@ -229,26 +233,26 @@ func (b *ExecutionDataBackend) createResponseHandler(criteria optimistic_sync.Cr
229233
230234 blockID , err := b .headers .BlockIDByHeight (height )
231235 if err != nil {
236+ // TODO: potentially, node could start indexing from the block past given height,
237+ // and we would run into the infinite loop here. Maybe it is safer to return an exception?
232238 err = errors .Join (err , subscription .ErrBlockNotReady )
233239 return nil , fmt .Errorf ("could not get block ID for height %d: %w" , height , err )
234240 }
235241
236- execResultInfo , err := b .executionResultProvider .ExecutionResultInfo (blockID , criteria )
242+ execResultInfo , err := b .executionResultProvider .ExecutionResultInfo (blockID , nextCriteria )
237243 if err != nil {
238244 switch {
239245 case errors .Is (err , optimistic_sync .ErrRequiredExecutorNotFound ) ||
240246 errors .Is (err , optimistic_sync .ErrNotEnoughAgreeingExecutors ):
241247 return nil ,
242248 fmt .Errorf ("block %d is not available yet: %w" , height , subscription .ErrBlockNotReady )
243249
244- case errors .Is (err , optimistic_sync .ErrBlockNotFound ):
250+ case errors .Is (err , optimistic_sync .ErrBlockNotFound ) ||
251+ errors .Is (err , optimistic_sync .ErrForkAbandoned ):
245252 return nil , err
246253
247- case errors .Is (err , optimistic_sync .ErrForkAbandoned ):
248- return nil , fmt .Errorf ("execution fork for the current block has been abandoned" )
249-
250254 default :
251- return nil , fmt .Errorf ("failed to get events : %w" , err )
255+ return nil , fmt .Errorf ("unexpected error : %w" , err )
252256 }
253257 }
254258
0 commit comments