Skip to content

Commit

Permalink
Update to polkadot 1.10.0 (#40)
Browse files Browse the repository at this point in the history
* Update to polkadot 1.10.0

* upgrade rust

* add one more comment
  • Loading branch information
girazoki committed Apr 29, 2024
1 parent 388aecc commit 7295a81
Show file tree
Hide file tree
Showing 24 changed files with 1,342 additions and 940 deletions.
1,785 changes: 1,007 additions & 778 deletions Cargo.lock

Large diffs are not rendered by default.

284 changes: 142 additions & 142 deletions Cargo.toml

Large diffs are not rendered by default.

85 changes: 76 additions & 9 deletions client/consensus/nimbus-consensus/src/collators/lookahead.rs
Expand Up @@ -22,7 +22,10 @@ use cumulus_client_consensus_common::{
ParentSearchParams,
};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_core::{relay_chain::Hash as PHash, CollectCollationInfo, ParaId};
use cumulus_primitives_core::{
relay_chain::{AsyncBackingParams, CoreIndex, CoreState, Hash as PHash},
CollectCollationInfo, ParaId,
};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use futures::{channel::oneshot, prelude::*};
use nimbus_primitives::{DigestsProvider, NimbusApi, NimbusId};
Expand Down Expand Up @@ -147,8 +150,20 @@ where
while let Some(relay_parent_header) = import_notifications.next().await {
let relay_parent = relay_parent_header.hash();

// First, verify if the parachain is active (have a core available on the relay)
if !is_para_scheduled(relay_parent, params.para_id, &mut params.overseer_handle).await {
// TODO: Currently we use just the first core here, but for elastic scaling
// we iterate and build on all of the cores returned.
// More info: https://github.com/paritytech/polkadot-sdk/issues/1829
let core_index = if let Some(core_index) = cores_scheduled_for_para(
relay_parent,
params.para_id,
&mut params.overseer_handle,
&mut params.relay_client,
)
.await
.get(0)
{
*core_index
} else {
tracing::trace!(
target: crate::LOG_TARGET,
?relay_parent,
Expand All @@ -157,7 +172,7 @@ where
);

continue;
}
};

// Get the PoV size limit dynamically
let max_pov_size = match params
Expand Down Expand Up @@ -371,6 +386,7 @@ where
parent_head: parent_header.encode().into(),
validation_code_hash,
result_sender: None,
core_index,
},
),
"SubmitCollation",
Expand Down Expand Up @@ -487,14 +503,41 @@ async fn max_ancestry_lookback(
}
}

/// Reads async backing parameters from the relay chain storage at the given relay parent.
async fn async_backing_params(
relay_parent: PHash,
relay_client: &impl RelayChainInterface,
) -> Option<AsyncBackingParams> {
match load_abridged_host_configuration(relay_parent, relay_client).await {
Ok(Some(config)) => Some(config.async_backing_params),
Ok(None) => {
tracing::error!(
target: crate::LOG_TARGET,
"Active config is missing in relay chain storage",
);
None
}
Err(err) => {
tracing::error!(
target: crate::LOG_TARGET,
?err,
?relay_parent,
"Failed to read active config from relay chain client",
);
None
}
}
}

// Checks if there exists a scheduled core for the para at the provided relay parent.
//
// Falls back to `false` in case of an error.
async fn is_para_scheduled(
async fn cores_scheduled_for_para(
relay_parent: PHash,
para_id: ParaId,
overseer_handle: &mut OverseerHandle,
) -> bool {
relay_client: &impl RelayChainInterface,
) -> Vec<CoreIndex> {
let (tx, rx) = oneshot::channel();
let request = RuntimeApiRequest::AvailabilityCores(tx);
overseer_handle
Expand All @@ -504,6 +547,11 @@ async fn is_para_scheduled(
)
.await;

let max_candidate_depth = async_backing_params(relay_parent, relay_client)
.await
.map(|c| c.max_candidate_depth)
.unwrap_or(0);

let cores = match rx.await {
Ok(Ok(cores)) => cores,
Ok(Err(error)) => {
Expand All @@ -513,17 +561,36 @@ async fn is_para_scheduled(
?relay_parent,
"Failed to query availability cores runtime API",
);
return false;
return Vec::new();
}
Err(oneshot::Canceled) => {
tracing::error!(
target: crate::LOG_TARGET,
?relay_parent,
"Sender for availability cores runtime request dropped",
);
return false;
return Vec::new();
}
};

cores.iter().any(|core| core.para_id() == Some(para_id))
cores
.iter()
.enumerate()
.filter_map(|(index, core)| {
let core_para_id = match core {
CoreState::Scheduled(scheduled_core) => Some(scheduled_core.para_id),
CoreState::Occupied(occupied_core) if max_candidate_depth >= 1 => occupied_core
.next_up_on_available
.as_ref()
.map(|scheduled_core| scheduled_core.para_id),
CoreState::Free | CoreState::Occupied(_) => None,
};

if core_para_id == Some(para_id) {
Some(CoreIndex(index as u32))
} else {
None
}
})
.collect()
}
5 changes: 5 additions & 0 deletions pallets/async-backing/src/mock.rs
Expand Up @@ -69,6 +69,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_timestamp::Config for Test {
Expand Down
5 changes: 5 additions & 0 deletions pallets/author-inherent/src/mock.rs
Expand Up @@ -69,6 +69,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

pub struct DummyBeacon {}
Expand Down
5 changes: 5 additions & 0 deletions pallets/author-mapping/src/mock.rs
Expand Up @@ -98,6 +98,11 @@ impl frame_system::Config for Runtime {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 1;
Expand Down
5 changes: 5 additions & 0 deletions pallets/author-slot-filter/src/mock.rs
Expand Up @@ -69,6 +69,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

impl pallet_testing::Config for Test {
Expand Down
6 changes: 6 additions & 0 deletions pallets/emergency-para-xcm/src/mock.rs
Expand Up @@ -72,6 +72,11 @@ impl frame_system::Config for Test {
type OnSetCode = ParachainSetCode<Self>;
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down Expand Up @@ -107,6 +112,7 @@ impl pallet_message_queue::Config for Test {
type HeapSize = MessageQueueHeapSize;
type MaxStale = MessageQueueMaxStale;
type ServiceWeight = MaxWeight;
type IdleMaxServiceWeight = MaxWeight;
type QueueChangeHandler = ();
type QueuePausedQuery = EmergencyParaXcm;
type WeightInfo = ();
Expand Down
5 changes: 5 additions & 0 deletions pallets/foreign-asset-creator/src/mock.rs
Expand Up @@ -72,6 +72,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions pallets/maintenance-mode/src/mock.rs
Expand Up @@ -75,6 +75,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

/// During maintenance mode we will not allow any calls.
Expand Down
5 changes: 5 additions & 0 deletions pallets/migrations/src/mock.rs
Expand Up @@ -80,6 +80,11 @@ impl frame_system::Config for Runtime {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions pallets/randomness/src/mock.rs
Expand Up @@ -75,6 +75,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions pallets/relay-storage-roots/src/mock.rs
Expand Up @@ -74,6 +74,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions precompiles/assets-erc20/src/mock.rs
Expand Up @@ -107,6 +107,11 @@ impl frame_system::Config for Runtime {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions precompiles/balances-erc20/src/mock.rs
Expand Up @@ -61,6 +61,11 @@ impl frame_system::Config for Runtime {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand Down
5 changes: 5 additions & 0 deletions precompiles/batch/src/mock.rs
Expand Up @@ -75,6 +75,11 @@ impl frame_system::Config for Runtime {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 0;
Expand Down
5 changes: 5 additions & 0 deletions precompiles/call-permit/src/mock.rs
Expand Up @@ -75,6 +75,11 @@ impl frame_system::Config for Runtime {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 0;
Expand Down
8 changes: 8 additions & 0 deletions precompiles/pallet-xcm/src/mock.rs
Expand Up @@ -102,6 +102,11 @@ impl frame_system::Config for Runtime {
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 0;
Expand Down Expand Up @@ -520,6 +525,9 @@ impl xcm_executor::Config for XcmConfig {
type Aliasers = Nothing;

type TransactionalProcessor = ();
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
}

pub fn root_origin() -> <Runtime as frame_system::Config>::RuntimeOrigin {
Expand Down

0 comments on commit 7295a81

Please sign in to comment.