From 14fc05171e48b8bdf1f7cd34fe254d74f6f3ec12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 15 Jan 2020 16:59:23 +0100 Subject: [PATCH] Don't finalize the same block multiple times This fixes the `Safety violation:...` logging. --- cumulus/consensus/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cumulus/consensus/src/lib.rs b/cumulus/consensus/src/lib.rs index 1b1c567fea..05c91a26d1 100644 --- a/cumulus/consensus/src/lib.rs +++ b/cumulus/consensus/src/lib.rs @@ -131,12 +131,17 @@ where type Block = Block; fn finalize(&self, hash: ::Hash) -> ClientResult { - match self.finalize_block(BlockId::hash(hash), None, true) { - Ok(()) => Ok(true), - Err(e) => match e { - ClientError::UnknownBlock(_) => Ok(false), - _ => Err(e), - }, + // don't finalize the same block multiple times. + if self.chain_info().finalized_hash != hash { + match self.finalize_block(BlockId::hash(hash), None, true) { + Ok(()) => Ok(true), + Err(e) => match e { + ClientError::UnknownBlock(_) => Ok(false), + _ => Err(e), + }, + } + } else { + Ok(true) } } }