cumulus-consensus-common: block import: delayed_best_block flag added (#2001)

This PR adds the `delayed_best_block` flag to `ParachainBlockImport`. If
not set, the `params.fork_choice` is not updated (to
`ForkChoiceStrategy::Custom`) during the block import.

When `delayed_best_block` is set to `false` all parachain blocks on the
[longest
fork](https://github.com/paritytech/polkadot-sdk/blob/552be4800d9e4b480f79a300fc531783e04be099/substrate/client/service/src/client/client.rs#L708-L709)
will be notified as the best block, allowing transaction pool to be
updated with every imported block.

Otherwise imported blocks will not be notified as best blocks
(`fork_choice=ForkChoiceStrategy::Custom(false)`), and transaction pool
would be updated only with best block received from relay-chain.

Improvement for: #1202

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Michal Kucharczyk
2023-11-21 15:22:42 +01:00
committed by GitHub
parent 552be4800d
commit b25d29a502
2 changed files with 33 additions and 12 deletions
+4 -2
View File
@@ -1124,7 +1124,8 @@ fn find_potential_parents_aligned_with_pending() {
let backend = Arc::new(Backend::new_test(1000, 1));
let client = Arc::new(TestClientBuilder::with_backend(backend.clone()).build());
let mut para_import = ParachainBlockImport::new(client.clone(), backend.clone());
let mut para_import =
ParachainBlockImport::new_with_delayed_best_block(client.clone(), backend.clone());
let relay_parent = relay_hash_from_block_num(10);
// Choose different relay parent for alternative chain to get new hashes.
@@ -1279,7 +1280,8 @@ fn find_potential_parents_aligned_no_pending() {
let backend = Arc::new(Backend::new_test(1000, 1));
let client = Arc::new(TestClientBuilder::with_backend(backend.clone()).build());
let mut para_import = ParachainBlockImport::new(client.clone(), backend.clone());
let mut para_import =
ParachainBlockImport::new_with_delayed_best_block(client.clone(), backend.clone());
let relay_parent = relay_hash_from_block_num(10);
// Choose different relay parent for alternative chain to get new hashes.