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

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Steven
2024-11-14 05:01:23 -06:00
committed by GitHub
parent 68a6ada460
commit 7bd7c37b13

View File

@ -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;
@ -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).
///
@ -857,6 +874,8 @@ where
}
}
self.ensure_chain_specific_db_checks()?;
Ok(None)
}