diff --git a/cumulus/client/consensus/aura/src/collators/lookahead.rs b/cumulus/client/consensus/aura/src/collators/lookahead.rs
index 8ac43fbd116e..2dbcf5eb58e9 100644
--- a/cumulus/client/consensus/aura/src/collators/lookahead.rs
+++ b/cumulus/client/consensus/aura/src/collators/lookahead.rs
@@ -36,17 +36,15 @@ use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterfa
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
-use cumulus_primitives_core::{
- ClaimQueueOffset, CollectCollationInfo, PersistedValidationData, DEFAULT_CLAIM_QUEUE_OFFSET,
-};
+use cumulus_primitives_core::{ClaimQueueOffset, CollectCollationInfo, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_node_primitives::{PoV, SubmitCollationParams};
use polkadot_node_subsystem::messages::CollationGenerationMessage;
use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::{
- BlockNumber as RBlockNumber, CollatorPair, Hash as RHash, HeadData, Id as ParaId,
- OccupiedCoreAssumption,
+ vstaging::DEFAULT_CLAIM_QUEUE_OFFSET, BlockNumber as RBlockNumber, CollatorPair, Hash as RHash,
+ HeadData, Id as ParaId, OccupiedCoreAssumption,
};
use futures::prelude::*;
diff --git a/cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs b/cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs
index e75b52aeebd3..425151230704 100644
--- a/cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs
+++ b/cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs
@@ -20,13 +20,11 @@ use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterfa
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
-use cumulus_primitives_core::{
- GetCoreSelectorApi, PersistedValidationData, DEFAULT_CLAIM_QUEUE_OFFSET,
-};
+use cumulus_primitives_core::{GetCoreSelectorApi, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_primitives::{
- vstaging::{ClaimQueueOffset, CoreSelector},
+ vstaging::{ClaimQueueOffset, CoreSelector, DEFAULT_CLAIM_QUEUE_OFFSET},
BlockId, CoreIndex, Hash as RelayHash, Header as RelayHeader, Id as ParaId,
OccupiedCoreAssumption,
};
diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs
index 98989a852b8d..39fc8321a072 100644
--- a/cumulus/pallets/parachain-system/src/lib.rs
+++ b/cumulus/pallets/parachain-system/src/lib.rs
@@ -35,12 +35,12 @@ use core::{cmp, marker::PhantomData};
use cumulus_primitives_core::{
relay_chain::{
self,
- vstaging::{ClaimQueueOffset, CoreSelector},
+ vstaging::{ClaimQueueOffset, CoreSelector, DEFAULT_CLAIM_QUEUE_OFFSET},
},
AbridgedHostConfiguration, ChannelInfo, ChannelStatus, CollationInfo, GetChannelInfo,
InboundDownwardMessage, InboundHrmpMessage, ListChannelInfos, MessageSendError,
OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender,
- XcmpMessageHandler, XcmpMessageSource, DEFAULT_CLAIM_QUEUE_OFFSET,
+ XcmpMessageHandler, XcmpMessageSource,
};
use cumulus_primitives_parachain_inherent::{MessageQueueChain, ParachainInherentData};
use frame_support::{
diff --git a/cumulus/primitives/core/src/lib.rs b/cumulus/primitives/core/src/lib.rs
index dfb574ef3301..f88e663db19e 100644
--- a/cumulus/primitives/core/src/lib.rs
+++ b/cumulus/primitives/core/src/lib.rs
@@ -333,10 +333,6 @@ pub mod rpsr_digest {
}
}
-/// The default claim queue offset to be used if it's not configured/accessible in the parachain
-/// runtime
-pub const DEFAULT_CLAIM_QUEUE_OFFSET: u8 = 0;
-
/// Information about a collation.
///
/// This was used in version 1 of the [`CollectCollationInfo`] runtime api.
diff --git a/polkadot/node/collation-generation/src/error.rs b/polkadot/node/collation-generation/src/error.rs
index 68902f58579a..2599026080df 100644
--- a/polkadot/node/collation-generation/src/error.rs
+++ b/polkadot/node/collation-generation/src/error.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see .
-use polkadot_primitives::vstaging::CandidateReceiptError;
+use polkadot_primitives::vstaging::CommittedCandidateReceiptError;
use thiserror::Error;
#[derive(Debug, Error)]
@@ -34,7 +34,7 @@ pub enum Error {
#[error("Collation submitted before initialization")]
SubmittedBeforeInit,
#[error("V2 core index check failed: {0}")]
- CandidateReceiptCheck(CandidateReceiptError),
+ CandidateReceiptCheck(CommittedCandidateReceiptError),
#[error("PoV size {0} exceeded maximum size of {1}")]
POVSizeExceeded(usize, usize),
}
diff --git a/polkadot/node/collation-generation/src/lib.rs b/polkadot/node/collation-generation/src/lib.rs
index 9e975acf10b8..b371017a8289 100644
--- a/polkadot/node/collation-generation/src/lib.rs
+++ b/polkadot/node/collation-generation/src/lib.rs
@@ -554,7 +554,7 @@ async fn construct_and_distribute_receipt(
ccr.to_plain()
} else {
- if commitments.selected_core().is_some() {
+ if commitments.core_selector().map_err(Error::CandidateReceiptCheck)?.is_some() {
gum::warn!(
target: LOG_TARGET,
?pov_hash,
diff --git a/polkadot/node/subsystem-util/src/inclusion_emulator/mod.rs b/polkadot/node/subsystem-util/src/inclusion_emulator/mod.rs
index 20ca62d41f5b..48d3f27b1fa6 100644
--- a/polkadot/node/subsystem-util/src/inclusion_emulator/mod.rs
+++ b/polkadot/node/subsystem-util/src/inclusion_emulator/mod.rs
@@ -82,9 +82,9 @@
/// in practice at most once every few weeks.
use polkadot_node_subsystem::messages::HypotheticalCandidate;
use polkadot_primitives::{
- async_backing::Constraints as PrimitiveConstraints, BlockNumber, CandidateCommitments,
- CandidateHash, Hash, HeadData, Id as ParaId, PersistedValidationData, UpgradeRestriction,
- ValidationCodeHash,
+ async_backing::Constraints as PrimitiveConstraints, vstaging::skip_ump_signals, BlockNumber,
+ CandidateCommitments, CandidateHash, Hash, HeadData, Id as ParaId, PersistedValidationData,
+ UpgradeRestriction, ValidationCodeHash,
};
use std::{collections::HashMap, sync::Arc};
@@ -601,13 +601,8 @@ impl Fragment {
persisted_validation_data: &PersistedValidationData,
) -> Result {
// Filter UMP signals and the separator.
- let upward_messages = if let Some(separator_index) =
- commitments.upward_messages.iter().position(|message| message.is_empty())
- {
- commitments.upward_messages.split_at(separator_index).0
- } else {
- &commitments.upward_messages
- };
+ let upward_messages =
+ skip_ump_signals(commitments.upward_messages.iter()).collect::>();
let ump_messages_sent = upward_messages.len();
let ump_bytes_sent = upward_messages.iter().map(|msg| msg.len()).sum();
diff --git a/polkadot/primitives/src/vstaging/mod.rs b/polkadot/primitives/src/vstaging/mod.rs
index ca9c3e1bebad..271f78efe090 100644
--- a/polkadot/primitives/src/vstaging/mod.rs
+++ b/polkadot/primitives/src/vstaging/mod.rs
@@ -39,6 +39,10 @@ use sp_staking::SessionIndex;
/// Async backing primitives
pub mod async_backing;
+/// The default claim queue offset to be used if it's not configured/accessible in the parachain
+/// runtime
+pub const DEFAULT_CLAIM_QUEUE_OFFSET: u8 = 0;
+
/// A type representing the version of the candidate descriptor and internal version number.
#[derive(PartialEq, Eq, Encode, Decode, Clone, TypeInfo, RuntimeDebug, Copy)]
#[cfg_attr(feature = "std", derive(Hash))]
@@ -430,49 +434,45 @@ pub enum UMPSignal {
/// Separator between `XCM` and `UMPSignal`.
pub const UMP_SEPARATOR: Vec = vec![];
-impl CandidateCommitments {
- /// Returns the core selector and claim queue offset the candidate has committed to, if any.
- pub fn selected_core(&self) -> Option<(CoreSelector, ClaimQueueOffset)> {
- // We need at least 2 messages for the separator and core selector
- if self.upward_messages.len() < 2 {
- return None
- }
-
- let separator_pos =
- self.upward_messages.iter().rposition(|message| message == &UMP_SEPARATOR)?;
-
- // Use first commitment
- let message = self.upward_messages.get(separator_pos + 1)?;
+/// Utility function for skipping the ump signals.
+pub fn skip_ump_signals<'a>(
+ upward_messages: impl Iterator>,
+) -> impl Iterator> {
+ upward_messages.take_while(|message| *message != &UMP_SEPARATOR)
+}
- match UMPSignal::decode(&mut message.as_slice()).ok()? {
- UMPSignal::SelectCore(core_selector, cq_offset) => Some((core_selector, cq_offset)),
- }
- }
+impl CandidateCommitments {
+ /// Returns the core selector and claim queue offset determined by `UMPSignal::SelectCore`
+ /// commitment, if present.
+ pub fn core_selector(
+ &self,
+ ) -> Result