Skip to content

Commit eb24a91

Browse files
authored
Merge pull request #3252 from autonomys/map-check-state
Exit with an error if state missing for chosen mapping block
2 parents 666df00 + 46ed466 commit eb24a91

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

crates/sc-consensus-subspace/src/archiver.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,18 +630,29 @@ where
630630
best_block_to_archive = best_block_number;
631631
}
632632

633-
// If the user chooses an object mapping start block we don't have the data for, we can't
633+
// If the user chooses an object mapping start block we don't have data or state for, we can't
634634
// create mappings for it, so the node must exit with an error.
635635
let best_block_to_archive_hash = client
636636
.hash(best_block_to_archive.into())?
637637
.expect("just checked above; qed");
638-
if client.block(best_block_to_archive_hash)?.is_none() {
638+
let Some(best_block_data) = client.block(best_block_to_archive_hash)? else {
639639
let error = format!(
640-
"Missing data for mapping block {best_block_to_archive} hash {best_block_to_archive_hash},\
640+
"Missing data for mapping block {best_block_to_archive} hash {best_block_to_archive_hash}, \
641641
try a higher block number, or wipe your node and restart with `--sync full`"
642642
);
643643
return Err(sp_blockchain::Error::Application(error.into()));
644-
}
644+
};
645+
646+
// Similarly, state can be pruned, even if the data is present.
647+
client
648+
.runtime_api()
649+
.extract_block_object_mapping(*best_block_data.block.header().parent_hash(), best_block_data.block.clone())
650+
.map_err(|error| {
651+
sp_blockchain::Error::Application(
652+
format!("Missing state for mapping block {best_block_to_archive} hash {best_block_to_archive_hash}: {error}, \
653+
try a higher block number, or wipe your node and restart with `--sync full`").into(),
654+
)
655+
})?;
645656

646657
let maybe_last_archived_block = find_last_archived_block(
647658
client,

0 commit comments

Comments
 (0)