@@ -244,7 +244,14 @@ func (b *Bootstrap) StartAPIServer(ctx context.Context) error {
244244 return fmt .Errorf ("failed to create rate limiter: %w" , err )
245245 }
246246
247- blockchainAPI , err := api .NewBlockChainAPI (
247+ // get the height from which the indexing resumed since the last restart,
248+ // this is needed for the `eth_syncing` endpoint.
249+ indexingResumedHeight , err := b .storages .Blocks .LatestEVMHeight ()
250+ if err != nil {
251+ return fmt .Errorf ("failed to retrieve the indexing resumed height: %w" , err )
252+ }
253+
254+ blockchainAPI := api .NewBlockChainAPI (
248255 b .logger ,
249256 b .config ,
250257 evm ,
@@ -253,10 +260,8 @@ func (b *Bootstrap) StartAPIServer(ctx context.Context) error {
253260 b .storages .Receipts ,
254261 ratelimiter ,
255262 b .collector ,
263+ indexingResumedHeight ,
256264 )
257- if err != nil {
258- return err
259- }
260265
261266 streamAPI := api .NewStreamAPI (
262267 b .logger ,
@@ -565,14 +570,16 @@ func Run(ctx context.Context, cfg *config.Config, ready component.ReadyFunc) err
565570 return err
566571 }
567572
568- if err := boot .StartEventIngestion (ctx ); err != nil {
569- return fmt .Errorf ("failed to start event ingestion engine: %w" , err )
570- }
571-
573+ // Start the API Server first, to avoid any races with incoming
574+ // EVM events, that might affect the starting state.
572575 if err := boot .StartAPIServer (ctx ); err != nil {
573576 return fmt .Errorf ("failed to start API server: %w" , err )
574577 }
575578
579+ if err := boot .StartEventIngestion (ctx ); err != nil {
580+ return fmt .Errorf ("failed to start event ingestion engine: %w" , err )
581+ }
582+
576583 if err := boot .StartMetricsServer (ctx ); err != nil {
577584 return fmt .Errorf ("failed to start metrics server: %w" , err )
578585 }
0 commit comments