apibara/dna

Support starting node at particular block

tarrencev opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Currently, the node always starts at block 0. It would be great to be able to start it at a particular block.

Describe the solution you'd like

  1. Update start to take BlockIngestionConfig as input
  2. Update BlockIngestionConfig to allow specifying the start_block
  3. Use start block if set rather than 0

Hello there, I'll gladly work on this one.

Thank you for this! The way I would tackle this is as following:

  • Add the option to the StartCommand in bin.rs. I think a good name is --ingest-from-block.
  • Update BlockIngestionConfig with the new option.
  • Most of the work will be in ingestion/started.rs. This is responsible for starting the actual ingestion:
    • replace the initial call to ingest_genesis_block to a conditional call: if the ingest-from-block option is None then ingest genesis, otherwise ingest from the block specified by the user.
    • if the user specified a block, check it's finalized before ingesting it. This is to have a stable point in case of reorg.
  • In stream/filtered.rs we need to check if the stream's starting cursor is earlier than the ingest-from-block block. You can do that in reconfigure_data_stream and if the cursor is too early, return an error to the user.