Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display warning for op-mainnet launch without pre-Bedrock state #11765

Merged
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
Loading