@@ -289,9 +289,14 @@ func (r *RPCEventSubscriber) backfill(ctx context.Context, fromCadenceHeight uin
289289// maxRangeForGetEvents is the maximum range of blocks that can be fetched using the GetEventsForHeightRange method.
290290const maxRangeForGetEvents = uint64 (249 )
291291
292- // / backfillSporkFromHeight will fill the eventsChan with block events from the provided fromHeight up to the first height in the spork that comes
293- // after the spork of the provided fromHeight.
294- func (r * RPCEventSubscriber ) backfillSporkFromHeight (ctx context.Context , fromCadenceHeight uint64 , eventsChan chan <- models.BlockEvents ) (uint64 , error ) {
292+ // backfillSporkFromHeight will fill the given `eventsChan` with block events
293+ // from the provided `fromCadenceHeight` up to the first height in the spork
294+ // that comes after the spork of the provided `fromCadenceHeight`.
295+ func (r * RPCEventSubscriber ) backfillSporkFromHeight (
296+ ctx context.Context ,
297+ fromCadenceHeight uint64 ,
298+ eventsChan chan <- models.BlockEvents ,
299+ ) (uint64 , error ) {
295300 evmAddress := common .Address (systemcontracts .SystemContractsForChain (r .chain ).EVMContract .Address )
296301
297302 blockExecutedEvent := common .NewAddressLocation (
@@ -317,7 +322,10 @@ func (r *RPCEventSubscriber) backfillSporkFromHeight(ctx context.Context, fromCa
317322 Uint64 ("last-spork-height" , lastHeight ).
318323 Msg ("backfilling spork" )
319324
320- for fromCadenceHeight < lastHeight {
325+ // even when `fromCadenceHeight == lastHeight`, we still need to advance
326+ // the value of `fromCadenceHeight`, so that it crosses to the first
327+ // height of the next spork.
328+ for fromCadenceHeight <= lastHeight {
321329 r .logger .Debug ().Msg (fmt .Sprintf ("backfilling [%d / %d] ..." , fromCadenceHeight , lastHeight ))
322330
323331 startHeight := fromCadenceHeight
@@ -376,6 +384,7 @@ func (r *RPCEventSubscriber) backfillSporkFromHeight(ctx context.Context, fromCa
376384 }
377385
378386 }
387+
379388 return fromCadenceHeight , nil
380389}
381390
0 commit comments