Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Enrich TooManySiblingBlocks error info #13052

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions client/state-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub enum StateDbError {
/// Invalid pruning mode specified. Contains expected mode.
IncompatiblePruningModes { stored: PruningMode, requested: PruningMode },
/// Too many unfinalized sibling blocks inserted.
TooManySiblingBlocks,
TooManySiblingBlocks { number: u64 },
/// Trying to insert existing block.
BlockAlreadyExists,
/// Invalid metadata
Expand Down Expand Up @@ -184,7 +184,8 @@ impl fmt::Debug for StateDbError {
"Incompatible pruning modes [stored: {:?}; requested: {:?}]",
stored, requested
),
Self::TooManySiblingBlocks => write!(f, "Too many sibling blocks inserted"),
Self::TooManySiblingBlocks { number } =>
write!(f, "Too many sibling blocks at #{number} inserted"),
Self::BlockAlreadyExists => write!(f, "Block already exists"),
Self::Metadata(message) => write!(f, "Invalid metadata: {}", message),
Self::BlockUnavailable =>
Expand Down
7 changes: 6 additions & 1 deletion client/state-db/src/noncanonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
};

if level.blocks.len() >= MAX_BLOCKS_PER_LEVEL as usize {
return Err(StateDbError::TooManySiblingBlocks)
trace!(
target: "state-db",
"Too many sibling blocks at #{number}: {:?}",
level.blocks.iter().map(|b| &b.hash).collect::<Vec<_>>()
);
return Err(StateDbError::TooManySiblingBlocks { number })
}
if level.blocks.iter().any(|b| b.hash == *hash) {
return Err(StateDbError::BlockAlreadyExists)
Expand Down