Throw error when params don't match with previous run

This commit is contained in:
Emilia Hane 2023-01-31 21:24:55 +01:00
parent d8e501d3ab
commit 00ce8d9572
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA

View File

@ -95,13 +95,13 @@ pub enum HotColdDBError {
MissingRestorePoint(Hash256), MissingRestorePoint(Hash256),
MissingColdStateSummary(Hash256), MissingColdStateSummary(Hash256),
MissingHotStateSummary(Hash256), MissingHotStateSummary(Hash256),
MissingColdBlobs(Hash256),
MissingEpochBoundaryState(Hash256), MissingEpochBoundaryState(Hash256),
MissingSplitState(Hash256, Slot), MissingSplitState(Hash256, Slot),
MissingExecutionPayload(Hash256), MissingExecutionPayload(Hash256),
MissingFullBlockExecutionPayloadPruned(Hash256, Slot), MissingFullBlockExecutionPayloadPruned(Hash256, Slot),
MissingAnchorInfo, MissingAnchorInfo,
MissingPathToBlobsDatabase, MissingPathToBlobsDatabase,
BlobsPreviouslyInDefaultStore,
HotStateSummaryError(BeaconStateError), HotStateSummaryError(BeaconStateError),
RestorePointDecodeError(ssz::DecodeError), RestorePointDecodeError(ssz::DecodeError),
BlockReplayBeaconError(BeaconStateError), BlockReplayBeaconError(BeaconStateError),
@ -220,30 +220,33 @@ impl<E: EthSpec> HotColdDB<E, LevelDB<E>, LevelDB<E>> {
); );
} }
let blob_info_on_disk = db.load_blob_info()?; let blob_info = db.load_blob_info()?;
let (open_blobs_db, path) = match (&blob_info, blobs_db_path) {
if let Some(ref blob_info) = blob_info_on_disk { (Some(blob_info), Some(path)) => {
let prev_blobs_db = blob_info.blobs_db; if blob_info.blobs_db {
if prev_blobs_db { (true, path)
blobs_db_path } else {
.as_ref() return Err(HotColdDBError::BlobsPreviouslyInDefaultStore.into());
.ok_or(HotColdDBError::MissingPathToBlobsDatabase)?; }
} }
} (None, Some(path)) => (true, path),
(Some(_), None) => return Err(HotColdDBError::MissingPathToBlobsDatabase.into()),
(None, None) => (false, cold_path.to_path_buf()),
};
if let Some(path) = blobs_db_path { let new_blob_info = if open_blobs_db {
if db.spec.eip4844_fork_epoch.is_some() { db.blobs_db = Some(LevelDB::open(path.as_path())?);
db.blobs_db = Some(LevelDB::open(path.as_path())?); Some(BlobInfo { blobs_db: true })
db.compare_and_set_blob_info_with_write( } else {
blob_info_on_disk, Some(BlobInfo { blobs_db: false })
Some(BlobInfo { blobs_db: true }), };
)?;
info!( db.compare_and_set_blob_info_with_write(blob_info, new_blob_info)?;
db.log, info!(
"Blobs DB initialized"; db.log,
); "Blobs DB initialized";
} "path" => ?path
} );
// Ensure that the schema version of the on-disk database matches the software. // Ensure that the schema version of the on-disk database matches the software.
// If the version is mismatched, an automatic migration will be attempted. // If the version is mismatched, an automatic migration will be attempted.