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

refactor and harden check_core_index #6217

Merged
merged 16 commits into from
Nov 5, 2024
Merged
8 changes: 3 additions & 5 deletions cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
4 changes: 0 additions & 4 deletions cumulus/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions polkadot/node/collation-generation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use polkadot_primitives::vstaging::CandidateReceiptError;
use polkadot_primitives::vstaging::CommittedCandidateReceiptError;
use thiserror::Error;

#[derive(Debug, Error)]
Expand All @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/collation-generation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 5 additions & 10 deletions polkadot/node/subsystem-util/src/inclusion_emulator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -601,13 +601,8 @@ impl Fragment {
persisted_validation_data: &PersistedValidationData,
) -> Result<ConstraintModifications, FragmentValidityError> {
// 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::<Vec<_>>();

let ump_messages_sent = upward_messages.len();
let ump_bytes_sent = upward_messages.iter().map(|msg| msg.len()).sum();
Expand Down
Loading
Loading