From a47da13c56074c2e85de563bea73f573f242fd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 23 Jan 2023 16:33:44 +0100 Subject: [PATCH 1/2] Aura: Fix warp syncing We need to set the fork choice rule! When using Cumulus this is done by the `ParachainsBlockImport`, but for standalone chains we still need this! Closes: https://github.com/paritytech/substrate/issues/13220 --- client/consensus/aura/src/import_queue.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 3ac26345db25e..09088096e0348 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -186,16 +186,14 @@ 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() { - return Ok((block, Default::default())) - } - - // Skip checks that include execution, if being told so. + // Skip checks that include execution, if being told so or when importing only state. // // 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. + // Or when we are importing state only and can not verify the seal. if block.state_action.skip_execution_checks() { + block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); + return Ok((block, Default::default())) } From d73c85672dd52359953143798255700369125383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 23 Jan 2023 16:57:12 +0100 Subject: [PATCH 2/2] Improve fork choice --- client/consensus/aura/src/import_queue.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 09088096e0348..4c8722c31f206 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -191,8 +191,9 @@ where // 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. // Or when we are importing state only and can not verify the seal. - if block.state_action.skip_execution_checks() { - block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); + if block.with_state() || block.state_action.skip_execution_checks() { + // When we are importing only the state of a block, it will be the best block. + block.fork_choice = Some(ForkChoiceStrategy::Custom(block.with_state())); return Ok((block, Default::default())) }