Skip to content
Snippets Groups Projects
Unverified Commit 795c92e2 authored by paritytech-cmd-bot-polkadot-sdk[bot]'s avatar paritytech-cmd-bot-polkadot-sdk[bot] Committed by GitHub
Browse files

[stable2412] Backport #6885 (#6902)


Backport #6885 into `stable2412` from skunert.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
parent df5b8ab7
Branches
No related merge requests found
......@@ -17,17 +17,17 @@
use crate::{ParachainInherentData, INHERENT_IDENTIFIER};
use codec::Decode;
use cumulus_primitives_core::{
relay_chain, InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData,
relay_chain, relay_chain::UpgradeGoAhead, InboundDownwardMessage, InboundHrmpMessage, ParaId,
PersistedValidationData,
};
use cumulus_primitives_parachain_inherent::MessageQueueChain;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use sc_client_api::{Backend, StorageProvider};
use sp_crypto_hashing::twox_128;
use sp_inherents::{InherentData, InherentDataProvider};
use sp_runtime::traits::Block;
use std::collections::BTreeMap;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
......@@ -68,10 +68,12 @@ pub struct MockValidationDataInherentDataProvider<R = ()> {
pub xcm_config: MockXcmConfig,
/// Inbound downward XCM messages to be injected into the block.
pub raw_downward_messages: Vec<Vec<u8>>,
// Inbound Horizontal messages sorted by channel.
/// Inbound Horizontal messages sorted by channel.
pub raw_horizontal_messages: Vec<(ParaId, Vec<u8>)>,
// Additional key-value pairs that should be injected.
/// Additional key-value pairs that should be injected.
pub additional_key_values: Option<Vec<(Vec<u8>, Vec<u8>)>>,
/// Whether upgrade go ahead should be set.
pub upgrade_go_ahead: Option<UpgradeGoAhead>,
}
/// Something that can generate randomness.
......@@ -176,6 +178,7 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
sproof_builder.current_slot =
((relay_parent_number / RELAY_CHAIN_SLOT_DURATION_MILLIS) as u64).into();
sproof_builder.upgrade_go_ahead = self.upgrade_go_ahead;
// Process the downward messages and set up the correct head
let mut downward_messages = Vec::new();
let mut dmq_mqc = MessageQueueChain::new(self.xcm_config.starting_dmq_mqc_head);
......
......@@ -21,12 +21,14 @@ use crate::common::{
};
use codec::Encode;
use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig};
use cumulus_primitives_core::ParaId;
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_runtime::traits::Header;
use std::{marker::PhantomData, sync::Arc};
......@@ -147,6 +149,18 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
.header(block)
.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
.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
},
};
let current_para_block_head =
Some(polkadot_primitives::HeadData(current_para_head.encode()));
let client_for_xcm = client_for_cidp.clone();
......@@ -169,6 +183,12 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
raw_downward_messages: vec![],
raw_horizontal_messages: vec![],
additional_key_values: None,
upgrade_go_ahead: should_send_go_ahead.then(|| {
log::info!(
"Detected pending validation code, sending go-ahead signal."
);
UpgradeGoAhead::GoAhead
}),
};
Ok((
// This is intentional, as the runtime that we expect to run against this
......
title: 'Omni-node: Detect pending code in storage and send go ahead signal in dev-mode.'
doc:
- audience: Runtime Dev
description: |-
When using the polkadot-omni-node with manual seal (`--dev-block-time`), it is now possible to perform runtime
upgrades. The node will detect the pending validation code and send a go-ahead signal to the parachain.
crates:
- name: cumulus-client-parachain-inherent
bump: major
- name: polkadot-omni-node-lib
bump: patch
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment