From 0e1a9ecef66bf3f4119509c90db3b832a61a8ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 4 Jan 2023 00:14:59 +0100 Subject: [PATCH 1/4] Aura: Do not verify on state import When we import the state, we can not fetch authorities to verify the seal etc. So, we can directly skip any verification. --- client/consensus/aura/src/import_queue.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index d5cf40f33359e..c647f31958cfa 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -186,6 +186,11 @@ where &mut self, mut block: BlockImportParams, ) -> Result<(BlockImportParams, Option)>>), String> { + if block.with_state() { + // When importing whole state we don't verify the seal as the state is not available. + return Ok((block, Default::default())) + } + let hash = block.header.hash(); let parent_hash = *block.header.parent_hash(); let authorities = authorities( From a4b62ce48ec7529a391f8b960009ed12f0a1c880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 4 Jan 2023 13:17:55 +0100 Subject: [PATCH 2/4] Skip checks as well for gap sync --- client/consensus/aura/src/import_queue.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index c647f31958cfa..7ae841b9df387 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -174,7 +174,7 @@ where #[async_trait::async_trait] impl Verifier for AuraVerifier> where - C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore, + C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore + HeaderBackend, C::Api: BlockBuilderApi + AuraApi> + ApiExt, P: Pair + Send + Sync + 'static, P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static, @@ -186,8 +186,22 @@ where &mut self, mut block: BlockImportParams, ) -> Result<(BlockImportParams, Option)>>), String> { + // When importing whole state we don't verify the seal as the state is not available. if block.with_state() { - // When importing whole state we don't verify the seal as the state is not available. + return Ok((block, Default::default())) + } + + let info = self.client.info(); + + // If we are importing a block in the gap, we skip all checks. + // + // It is expected that the block after the gap was checked/chosen properly, e.g. by warp + // syncing to this block. + if info + .block_gap + .map(|(start, end)| start <= *block.header.number() && *block.header.number() <= end) + .unwrap_or(false) + { return Ok((block, Default::default())) } From 28b6c17ad90b4371bdebd1f1965afa437e94641e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 4 Jan 2023 13:40:32 +0100 Subject: [PATCH 3/4] Update client/consensus/aura/src/import_queue.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> --- client/consensus/aura/src/import_queue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 7ae841b9df387..fb69b32fc94e5 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -196,7 +196,7 @@ where // If we are importing a block in the gap, we skip all checks. // // It is expected that the block after the gap was checked/chosen properly, e.g. by warp - // syncing to this block. + // syncing to this block using a finality proof. if info .block_gap .map(|(start, end)| start <= *block.header.number() && *block.header.number() <= end) From 5d4f44e9662741887281fbe602fdf1a527ef1e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 4 Jan 2023 13:51:24 +0100 Subject: [PATCH 4/4] Review comment --- client/consensus/aura/src/import_queue.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index fb69b32fc94e5..0973b33d402e6 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -174,7 +174,7 @@ where #[async_trait::async_trait] impl Verifier for AuraVerifier> where - C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore + HeaderBackend, + C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore, C::Api: BlockBuilderApi + AuraApi> + ApiExt, P: Pair + Send + Sync + 'static, P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static, @@ -191,17 +191,11 @@ where return Ok((block, Default::default())) } - let info = self.client.info(); - - // If we are importing a block in the gap, we skip all checks. + // Skip checks that include execution, if being told so. // - // It is expected that the block after the gap was checked/chosen properly, e.g. by warp - // syncing to this block using a finality proof. - if info - .block_gap - .map(|(start, end)| start <= *block.header.number() && *block.header.number() <= end) - .unwrap_or(false) - { + // This is done for example when gap syncing and it is expected that the block after the gap + // was checked/chosen properly, e.g. by warp syncing to this block using a finality proof. + if block.state_action.skip_execution_checks() { return Ok((block, Default::default())) }