Skip to content

Commit

Permalink
omni-node: Adjust manual seal parameters (#7451)
Browse files Browse the repository at this point in the history
This PR will make omni-node dev-mode once again compatible with older
runtimes.

The changes introduced in
#6825 changed constraints
that are enforced in the runtime. For normal chains this should work
fine, since we have real parameters there, like relay chain slots and
parachain slots.

For these manual seal parameters we need to respect the constraints,
while faking all the parameters. This PR should fix manual seal in
omni-node to work with runtime build before and after
#6825 (I tested that).

In the future, we should look into improving the parameterization here,
possibly by introducing proper aura pre-digests so that the parachain
slot moves forward. This will require quite a bit of refactoring on the
manual seal node side however. Issue:
#7453

Also, the dev chain spec in parachain template is updated. This makes it
work with stable2412-1 and master omni-node. Once the changes here are
backported and in a release, all combinations will work again.

fixes #7341

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
skunert and github-actions[bot] authored Feb 5, 2025
1 parent 31abe61 commit 9c474d5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
33 changes: 22 additions & 11 deletions cumulus/polkadot-omni-node/lib/src/nodes/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ use crate::common::{
};
use codec::Encode;
use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig};
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{CollectCollationInfo, ParaId};
use polkadot_primitives::UpgradeGoAhead;
use sc_consensus::{DefaultImportQueue, LongestChain};
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};
use sc_network::NetworkBackend;
use sc_service::{Configuration, PartialComponents, TaskManager};
use sc_telemetry::TelemetryHandle;
use sp_api::ProvideRuntimeApi;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_runtime::traits::Header;
use std::{marker::PhantomData, sync::Arc};

Expand Down Expand Up @@ -158,16 +159,24 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
.expect("Header lookup should succeed")
.expect("Header passed in as parent should be present in backend.");

let should_send_go_ahead = match client_for_cidp
let should_send_go_ahead = client_for_cidp
.runtime_api()
.collect_collation_info(block, &current_para_head)
{
Ok(info) => info.new_validation_code.is_some(),
Err(e) => {
log::error!("Failed to collect collation info: {:?}", e);
false
},
};
.map(|info| info.new_validation_code.is_some())
.unwrap_or_default();

// The API version is relevant here because the constraints in the runtime changed
// in https://github.com/paritytech/polkadot-sdk/pull/6825. In general, the logic
// here assumes that we are using the aura-ext consensushook in the parachain
// runtime.
let requires_relay_progress = client_for_cidp
.runtime_api()
.has_api_with::<dyn AuraUnincludedSegmentApi<NodeSpec::Block>, _>(
block,
|version| version > 1,
)
.ok()
.unwrap_or_default();

let current_para_block_head =
Some(polkadot_primitives::HeadData(current_para_head.encode()));
Expand All @@ -183,8 +192,10 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
),
para_id,
current_para_block_head,
relay_offset: 1000,
relay_blocks_per_para_block: 1,
relay_offset: 0,
relay_blocks_per_para_block: requires_relay_progress
.then(|| 1)
.unwrap_or_default(),
para_blocks_per_relay_epoch: 10,
relay_randomness_config: (),
xcm_config: MockXcmConfig::new(&*client_for_xcm, block, Default::default()),
Expand Down
8 changes: 8 additions & 0 deletions prdoc/pr_7451.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: 'omni-node: Adjust manual seal parameters'
doc:
- audience: Runtime Dev
description: |-
This PR restores compatibility of older runtimes with the dev mode of omni-node. Before, runtimes built without the changes in https://github.com/paritytech/polkadot-sdk/pull/6825 were failing.
crates:
- name: polkadot-omni-node-lib
bump: patch
2 changes: 1 addition & 1 deletion templates/parachain/dev_chain_spec.json

Large diffs are not rendered by default.

0 comments on commit 9c474d5

Please sign in to comment.