Skip to content

Commit 795c92e

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: Sebastian Kunert <[email protected]>
1 parent df5b8ab commit 795c92e

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

cumulus/client/parachain-inherent/src/mock.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
use crate::{ParachainInherentData, INHERENT_IDENTIFIER};
1818
use codec::Decode;
1919
use cumulus_primitives_core::{
20-
relay_chain, InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData,
20+
relay_chain, relay_chain::UpgradeGoAhead, InboundDownwardMessage, InboundHrmpMessage, ParaId,
21+
PersistedValidationData,
2122
};
2223
use cumulus_primitives_parachain_inherent::MessageQueueChain;
24+
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
2325
use sc_client_api::{Backend, StorageProvider};
2426
use sp_crypto_hashing::twox_128;
2527
use sp_inherents::{InherentData, InherentDataProvider};
2628
use sp_runtime::traits::Block;
2729
use std::collections::BTreeMap;
2830

29-
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
30-
3131
/// Relay chain slot duration, in milliseconds.
3232
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
3333

@@ -68,10 +68,12 @@ pub struct MockValidationDataInherentDataProvider<R = ()> {
6868
pub xcm_config: MockXcmConfig,
6969
/// Inbound downward XCM messages to be injected into the block.
7070
pub raw_downward_messages: Vec<Vec<u8>>,
71-
// Inbound Horizontal messages sorted by channel.
71+
/// Inbound Horizontal messages sorted by channel.
7272
pub raw_horizontal_messages: Vec<(ParaId, Vec<u8>)>,
73-
// Additional key-value pairs that should be injected.
73+
/// Additional key-value pairs that should be injected.
7474
pub additional_key_values: Option<Vec<(Vec<u8>, Vec<u8>)>>,
75+
/// Whether upgrade go ahead should be set.
76+
pub upgrade_go_ahead: Option<UpgradeGoAhead>,
7577
}
7678

7779
/// Something that can generate randomness.
@@ -176,6 +178,7 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
176178
sproof_builder.current_slot =
177179
((relay_parent_number / RELAY_CHAIN_SLOT_DURATION_MILLIS) as u64).into();
178180

181+
sproof_builder.upgrade_go_ahead = self.upgrade_go_ahead;
179182
// Process the downward messages and set up the correct head
180183
let mut downward_messages = Vec::new();
181184
let mut dmq_mqc = MessageQueueChain::new(self.xcm_config.starting_dmq_mqc_head);

cumulus/polkadot-omni-node/lib/src/nodes/manual_seal.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ use crate::common::{
2121
};
2222
use codec::Encode;
2323
use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig};
24-
use cumulus_primitives_core::ParaId;
24+
use cumulus_primitives_core::{CollectCollationInfo, ParaId};
25+
use polkadot_primitives::UpgradeGoAhead;
2526
use sc_consensus::{DefaultImportQueue, LongestChain};
2627
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};
2728
use sc_network::NetworkBackend;
2829
use sc_service::{Configuration, PartialComponents, TaskManager};
2930
use sc_telemetry::TelemetryHandle;
31+
use sp_api::ProvideRuntimeApi;
3032
use sp_runtime::traits::Header;
3133
use std::{marker::PhantomData, sync::Arc};
3234

@@ -147,6 +149,18 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
147149
.header(block)
148150
.expect("Header lookup should succeed")
149151
.expect("Header passed in as parent should be present in backend.");
152+
153+
let should_send_go_ahead = match client_for_cidp
154+
.runtime_api()
155+
.collect_collation_info(block, &current_para_head)
156+
{
157+
Ok(info) => info.new_validation_code.is_some(),
158+
Err(e) => {
159+
log::error!("Failed to collect collation info: {:?}", e);
160+
false
161+
},
162+
};
163+
150164
let current_para_block_head =
151165
Some(polkadot_primitives::HeadData(current_para_head.encode()));
152166
let client_for_xcm = client_for_cidp.clone();
@@ -169,6 +183,12 @@ impl<NodeSpec: NodeSpecT> ManualSealNode<NodeSpec> {
169183
raw_downward_messages: vec![],
170184
raw_horizontal_messages: vec![],
171185
additional_key_values: None,
186+
upgrade_go_ahead: should_send_go_ahead.then(|| {
187+
log::info!(
188+
"Detected pending validation code, sending go-ahead signal."
189+
);
190+
UpgradeGoAhead::GoAhead
191+
}),
172192
};
173193
Ok((
174194
// This is intentional, as the runtime that we expect to run against this

prdoc/pr_6885.prdoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: 'Omni-node: Detect pending code in storage and send go ahead signal in dev-mode.'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
When using the polkadot-omni-node with manual seal (`--dev-block-time`), it is now possible to perform runtime
6+
upgrades. The node will detect the pending validation code and send a go-ahead signal to the parachain.
7+
crates:
8+
- name: cumulus-client-parachain-inherent
9+
bump: major
10+
- name: polkadot-omni-node-lib
11+
bump: patch

0 commit comments

Comments
 (0)