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

Update to polkadot-v1.6.0 #22

Merged
merged 18 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,490 changes: 2,678 additions & 2,812 deletions Cargo.lock

Large diffs are not rendered by default.

283 changes: 144 additions & 139 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/consensus/nimbus-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
sp-version = { workspace = true }
substrate-prometheus-endpoint = { workspace = true }

# Cumulus dependencies
cumulus-client-collator = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
Expand Down
22 changes: 15 additions & 7 deletions client/consensus/nimbus-consensus/src/collators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ pub(crate) async fn collate<ADP, Block, BI, CS, Proposer>(
inherent_data: (ParachainInherentData, InherentData),
proposal_duration: Duration,
max_pov_size: usize,
) -> Result<(Collation, ParachainBlockData<Block>, Block::Hash), Box<dyn Error + Send + 'static>>
) -> Result<
Option<(Collation, ParachainBlockData<Block>, Block::Hash)>,
Box<dyn Error + Send + 'static>,
>
where
ADP: DigestsProvider<NimbusId, <Block as BlockT>::Hash> + 'static,
Block: BlockT,
Expand All @@ -79,11 +82,7 @@ where
additional_digests_provider.provide_digests(author_id.clone(), parent_header.hash()),
);

let Proposal {
block,
storage_changes,
proof,
} = proposer
let maybe_proposal = proposer
.propose(
&parent_header,
&inherent_data.0,
Expand All @@ -95,6 +94,15 @@ where
.await
.map_err(|e| Box::new(e) as Box<dyn Error + Send>)?;

let Proposal {
block,
storage_changes,
proof,
} = match maybe_proposal {
None => return Ok(None),
Some(p) => p,
};

let (header, extrinsics) = block.clone().deconstruct();

let sig_digest = seal_header::<Block>(
Expand Down Expand Up @@ -155,7 +163,7 @@ where
);
}

Ok((collation, block_data, post_hash))
Ok(Some((collation, block_data, post_hash)))
} else {
Err(
Box::<dyn Error + Send + Sync>::from("Unable to produce collation")
Expand Down
17 changes: 11 additions & 6 deletions client/consensus/nimbus-consensus/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ where
.await
);

let (collation, _, post_hash) = try_request!(
let maybe_collation = try_request!(
super::collate::<ADP, Block, BI, CS, Proposer>(
&additional_digests_provider,
nimbus_id,
Expand All @@ -195,11 +195,16 @@ where
.await
);

let result_sender = Some(collator_service.announce_with_barrier(post_hash));
request.complete(Some(CollationResult {
collation,
result_sender,
}));
if let Some((collation, _, post_hash)) = maybe_collation {
let result_sender = Some(collator_service.announce_with_barrier(post_hash));
request.complete(Some(CollationResult {
collation,
result_sender,
}));
} else {
request.complete(None);
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
}
}
}
}
6 changes: 5 additions & 1 deletion client/consensus/nimbus-consensus/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ where
)
.await
{
Ok((collation, block_data, new_block_hash)) => {
Ok(Some((collation, block_data, new_block_hash))) => {
// Here we are assuming that the import logic protects against equivocations
// and provides sybil-resistance, as it should.
params.collator_service.announce_block(new_block_hash, None);
Expand Down Expand Up @@ -377,6 +377,10 @@ where
parent_hash = new_block_hash;
parent_header = block_data.into_header();
}
Ok(None) => {
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
break;
}
Err(err) => {
tracing::error!(target: crate::LOG_TARGET, ?err);
break;
Expand Down
17 changes: 11 additions & 6 deletions client/consensus/nimbus-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod manual_seal;
pub use import_queue::import_queue;
pub use manual_seal::NimbusManualSealConsensusDataProvider;

use cumulus_client_parachain_inherent::ParachainInherentDataProvider;
use cumulus_primitives_core::{
relay_chain::{Hash as PHash, Header as PHeader},
ParaId, PersistedValidationData,
Expand Down Expand Up @@ -78,11 +79,11 @@ where
// Determine if runtime change
let runtime_upgraded = if *parent.number() > sp_runtime::traits::Zero::zero() {
use sp_api::Core as _;
let previous_runtime_version: sp_api::RuntimeVersion = para_client
let previous_runtime_version: sp_version::RuntimeVersion = para_client
.runtime_api()
.version(parent.hash())
.map_err(Box::new)?;
let runtime_version: sp_api::RuntimeVersion = para_client
let runtime_version: sp_version::RuntimeVersion = para_client
.runtime_api()
.version(parent.hash())
.map_err(Box::new)?;
Expand All @@ -96,7 +97,7 @@ where
first_available_key(&*keystore)
} else {
first_eligible_key::<Block, Client>(
para_client.clone(),
para_client,
&*keystore,
parent,
*relay_parent_header.number(),
Expand Down Expand Up @@ -127,9 +128,13 @@ where
CIDP: CreateInherentDataProviders<Block, (PHash, PersistedValidationData, NimbusId)> + 'static,
RClient: RelayChainInterface + Send + Clone + 'static,
{
let paras_inherent_data =
ParachainInherentData::create_at(relay_parent, relay_client, validation_data, para_id)
.await;
let paras_inherent_data = ParachainInherentDataProvider::create_at(
relay_parent,
relay_client,
validation_data,
para_id,
)
.await;

let paras_inherent_data = match paras_inherent_data {
Some(p) => p,
Expand Down
7 changes: 5 additions & 2 deletions client/consensus/nimbus-consensus/src/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ use nimbus_primitives::{
};
use sc_consensus::BlockImportParams;
use sc_consensus_manual_seal::{ConsensusDataProvider, Error};
use sp_api::{BlockT, HeaderT, ProvideRuntimeApi};
use sp_api::ProvideRuntimeApi;
use sp_application_crypto::ByteArray;
use sp_core::sr25519;
use sp_inherents::InherentData;
use sp_keystore::KeystorePtr;
use sp_runtime::{Digest, DigestItem};
use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT},
Digest, DigestItem,
};
use std::{marker::PhantomData, sync::Arc};

/// Provides nimbus-compatible pre-runtime digests for use with manual seal consensus
Expand Down
1 change: 1 addition & 0 deletions pallets/async-backing/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
}

impl pallet_timestamp::Config for Test {
Expand Down
7 changes: 5 additions & 2 deletions pallets/author-inherent/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
//! with the nimubs consensus family.

use frame_support::traits::ExecuteBlock;
use sp_api::{BlockT, HeaderT};
// For some reason I can't get these logs to actually print
use log::debug;
use nimbus_primitives::{digests::CompatibleDigestItem, NimbusId, NIMBUS_ENGINE_ID};
use sp_application_crypto::ByteArray;
use sp_runtime::{generic::DigestItem, RuntimeAppPublic};
use sp_runtime::{
generic::DigestItem,
traits::{Block as BlockT, Header},
RuntimeAppPublic,
};

/// Block executive to be used by relay chain validators when validating parachain blocks built
/// with the nimubs consensus family.
Expand Down
1 change: 1 addition & 0 deletions pallets/author-inherent/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
}

pub struct DummyBeacon {}
Expand Down
1 change: 1 addition & 0 deletions pallets/author-mapping/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl frame_system::Config for Runtime {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 1;
Expand Down
1 change: 1 addition & 0 deletions pallets/author-slot-filter/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
}

impl pallet_testing::Config for Test {
Expand Down
1 change: 1 addition & 0 deletions pallets/foreign-asset-creator/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = ();
}

parameter_types! {
Expand Down
51 changes: 5 additions & 46 deletions pallets/maintenance-mode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,17 @@ mod mock;
#[cfg(test)]
mod tests;

mod types;

use frame_support::pallet;

pub use pallet::*;
pub use types::*;

#[pallet]
pub mod pallet {
#[cfg(feature = "xcm-support")]
use cumulus_primitives_core::{
relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler,
};
use frame_support::pallet_prelude::*;
use frame_support::traits::{
BuildGenesisConfig, Contains, EnsureOrigin, OffchainWorker, OnFinalize, OnIdle,
OnInitialize, OnRuntimeUpgrade,
};
use frame_support::traits::{BuildGenesisConfig, Contains, EnsureOrigin, QueuePausedQuery};
use frame_system::pallet_prelude::*;
#[cfg(feature = "xcm-support")]
use sp_std::vec::Vec;
#[cfg(feature = "xcm-support")]
use xcm_primitives::PauseXcmExecution;

/// Pallet for migrations
Expand Down Expand Up @@ -94,30 +83,6 @@ pub mod pallet {
/// Handler to suspend and resume XCM execution
#[cfg(feature = "xcm-support")]
type XcmExecutionManager: PauseXcmExecution;
/// The DMP handler to be used in normal operating mode
/// TODO: remove once https://github.com/paritytech/polkadot/pull/5035 is merged
#[cfg(feature = "xcm-support")]
type NormalDmpHandler: DmpMessageHandler;
/// The DMP handler to be used in maintenance mode
/// TODO: remove once https://github.com/paritytech/polkadot/pull/5035 is merged
#[cfg(feature = "xcm-support")]
type MaintenanceDmpHandler: DmpMessageHandler;
/// The executive hooks that will be used in normal operating mode
/// Important: Use AllPalletsWithSystem here if you dont want to modify the
/// hooks behaviour
type NormalExecutiveHooks: OnRuntimeUpgrade
+ OnInitialize<BlockNumberFor<Self>>
+ OnIdle<BlockNumberFor<Self>>
+ OnFinalize<BlockNumberFor<Self>>
+ OffchainWorker<BlockNumberFor<Self>>;
/// The executive hooks that will be used in maintenance mode
/// Important: Use AllPalletsWithSystem here if you dont want to modify the
/// hooks behaviour
type MaintenanceExecutiveHooks: OnRuntimeUpgrade
+ OnInitialize<BlockNumberFor<Self>>
+ OnIdle<BlockNumberFor<Self>>
+ OnFinalize<BlockNumberFor<Self>>
+ OffchainWorker<BlockNumberFor<Self>>;
}

#[pallet::event]
Expand Down Expand Up @@ -244,17 +209,11 @@ pub mod pallet {
}
}
}

#[cfg(feature = "xcm-support")]
impl<T: Config> DmpMessageHandler for Pallet<T> {
fn handle_dmp_messages(
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
limit: Weight,
) -> Weight {
if MaintenanceMode::<T>::get() {
T::MaintenanceDmpHandler::handle_dmp_messages(iter, limit)
} else {
T::NormalDmpHandler::handle_dmp_messages(iter, limit)
}
impl<T: Config, Origin> QueuePausedQuery<Origin> for Pallet<T> {
fn is_paused(_origin: &Origin) -> bool {
MaintenanceMode::<T>::get()
}
}
}
Loading
Loading