Skip to content

Commit

Permalink
feat: display warning for op-mainnet launch without pre-Bedrock state (
Browse files Browse the repository at this point in the history
…#11765)

Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
stevencartavia and mattsse authored Nov 14, 2024
1 parent 68a6ada commit 7bd7c37
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions crates/node/builder/src/launch/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ use reth_node_metrics::{
use reth_primitives::Head;
use reth_provider::{
providers::{BlockchainProvider, BlockchainProvider2, ProviderNodeTypes, StaticFileProvider},
BlockHashReader, CanonStateNotificationSender, ChainSpecProvider, ProviderFactory,
ProviderResult, StageCheckpointReader, StateProviderFactory, StaticFileProviderFactory,
TreeViewer,
BlockHashReader, BlockNumReader, CanonStateNotificationSender, ChainSpecProvider,
ProviderError, ProviderFactory, ProviderResult, StageCheckpointReader, StateProviderFactory,
StaticFileProviderFactory, TreeViewer,
};
use reth_prune::{PruneModes, PrunerBuilder};
use reth_rpc_api::clients::EthApiClient;
Expand Down Expand Up @@ -814,6 +814,23 @@ where
self.node_config().debug.terminate || self.node_config().debug.max_block.is_some()
}

/// Ensures that the database matches chain-specific requirements.
///
/// This checks for OP-Mainnet and ensures we have all the necessary data to progress (past
/// bedrock height)
fn ensure_chain_specific_db_checks(&self) -> ProviderResult<()> {
if self.chain_id() == Chain::optimism_mainnet() {
let latest = self.blockchain_db().last_block_number()?;
// bedrock height
if latest < 105235063 {
error!("Op-mainnet has been launched without importing the pre-Bedrock state. The chain can't progress without this. See also https://reth.rs/run/sync-op-mainnet.html?minimal-bootstrap-recommended");
return Err(ProviderError::BestBlockNotFound)
}
}

Ok(())
}

/// Check if the pipeline is consistent (all stages have the checkpoint block numbers no less
/// than the checkpoint of the first stage).
///
Expand Down Expand Up @@ -857,6 +874,8 @@ where
}
}

self.ensure_chain_specific_db_checks()?;

Ok(None)
}

Expand Down

0 comments on commit 7bd7c37

Please sign in to comment.