feat: allow syncing op-mainnet with only state and without importing blocks/receipts (#10850)

Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
joshieDo
2024-09-18 18:10:38 +01:00
committed by GitHub
parent 80c1159cb8
commit c2019e35de
15 changed files with 387 additions and 86 deletions

View File

@@ -17,7 +17,7 @@ use tracing::info;
#[derive(Debug, Parser)]
pub struct InitStateCommand<C: ChainSpecParser> {
#[command(flatten)]
env: EnvironmentArgs<C>,
pub env: EnvironmentArgs<C>,
/// JSONL file with state dump.
///
@@ -37,7 +37,7 @@ pub struct InitStateCommand<C: ChainSpecParser> {
/// Allows init at a non-genesis block. Caution! Blocks must be manually imported up until
/// and including the non-genesis block to init chain at. See 'import' command.
#[arg(value_name = "STATE_DUMP_FILE", verbatim_doc_comment)]
state: PathBuf,
pub state: PathBuf,
}
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> InitStateCommand<C> {
@@ -71,5 +71,9 @@ pub fn init_at_state<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
let file = File::open(state_dump_path)?;
let reader = BufReader::new(file);
init_from_state_dump(reader, factory, etl_config)
let provider_rw = factory.provider_rw()?;
let hash = init_from_state_dump(reader, &provider_rw.0, etl_config)?;
provider_rw.commit()?;
Ok(hash)
}