Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove useless NimbusBlockImport #43

Merged
merged 5 commits into from
Nov 22, 2024
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
22 changes: 20 additions & 2 deletions client/consensus/nimbus-consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ pub fn import_queue<Client, Block: BlockT, I, CIDP>(
create_inherent_data_providers: CIDP,
spawner: &impl sp_core::traits::SpawnEssentialNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
parachain: bool,
// Deprecated: Using a custom fork strategy for parachain at block
// import is no longer necessary.
// Context: https://github.com/paritytech/polkadot-sdk/issues/4333
use_custom_fork_strategy: Option<bool>,
) -> ClientResult<BasicQueue<Block>>
where
I: BlockImport<Block, Error = ConsensusError> + Send + Sync + 'static,
Expand All @@ -214,9 +217,19 @@ where
_marker: PhantomData,
};

let block_import_for_queue: sc_consensus::BoxBlockImport<Block> = match use_custom_fork_strategy
{
Some(parachain_context) =>
{
#[allow(deprecated)]
Box::new(NimbusBlockImport::new(block_import, parachain_context))
}
None => Box::new(block_import),
};

Ok(BasicQueue::new(
verifier,
Box::new(NimbusBlockImport::new(block_import, parachain)),
block_import_for_queue,
None,
spawner,
registry,
Expand All @@ -232,11 +245,15 @@ where
///
/// There may be additional nimbus-specific logic here in the future, but for now it is
/// only the conditional parachain logic
#[deprecated(
note = "Aura was using a custom fork strategy for parachain at block import, this is no longer necessary."
)]
pub struct NimbusBlockImport<I> {
inner: I,
parachain_context: bool,
}

#[allow(deprecated)]
impl<I> NimbusBlockImport<I> {
/// Create a new instance.
pub fn new(inner: I, parachain_context: bool) -> Self {
Expand All @@ -247,6 +264,7 @@ impl<I> NimbusBlockImport<I> {
}
}

#[allow(deprecated)]
#[async_trait::async_trait]
impl<Block, I> BlockImport<Block> for NimbusBlockImport<I>
where
Expand Down
8 changes: 4 additions & 4 deletions template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ macro_rules! construct_async_run {
runner.async_run(|$config| {
let $components = new_partial(
// We default to the non-parachain import queue and select chain.
&$config, false,
&$config,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
let partials = new_partial(&config, false)?;
let partials = new_partial(&config)?;

cmd.run(partials.client)
})
Expand Down Expand Up @@ -200,7 +200,7 @@ pub fn run() -> Result<()> {
}
}
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config, false)?;
let partials = new_partial(&config)?;
cmd.run(partials.client)
}),
#[cfg(not(feature = "runtime-benchmarks"))]
Expand All @@ -214,7 +214,7 @@ pub fn run() -> Result<()> {
}
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config, false)?;
let partials = new_partial(&config)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();

Expand Down
11 changes: 4 additions & 7 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, P
/// be able to perform chain operations.
pub fn new_partial(
config: &Configuration,
parachain: bool,
) -> Result<
PartialComponents<
ParachainClient,
Expand Down Expand Up @@ -146,9 +145,7 @@ pub fn new_partial(
client.clone(),
);

// `new_with_delayed_best_block` is now necessary: https://github.com/paritytech/polkadot-sdk/pull/2001
let block_import =
ParachainBlockImport::new_with_delayed_best_block(client.clone(), backend.clone());
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());

let import_queue = nimbus_consensus::import_queue(
client.clone(),
Expand All @@ -160,7 +157,7 @@ pub fn new_partial(
},
&task_manager.spawn_essential_handle(),
config.prometheus_registry().clone(),
parachain,
None,
)?;

Ok(PartialComponents {
Expand Down Expand Up @@ -216,7 +213,7 @@ where
{
let parachain_config = prepare_node_config(parachain_config);

let params = new_partial(&parachain_config, true)?;
let params = new_partial(&parachain_config)?;
let (block_import, mut telemetry, telemetry_worker_handle) = params.other;

let client = params.client.clone();
Expand Down Expand Up @@ -443,7 +440,7 @@ where
select_chain,
transaction_pool,
other: (_, mut telemetry, _),
} = new_partial(&config, false)?;
} = new_partial(&config)?;

let prometheus_registry = config.prometheus_registry().cloned();
let net_config =
Expand Down
Loading