mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 12:15:42 +00:00
Update Substrate & Polkadot (#387)
* Update Substrate & Polkadot * Enforce `ParachainSetCode`
This commit is contained in:
Generated
+884
-550
File diff suppressed because it is too large
Load Diff
@@ -31,18 +31,19 @@ use sp_runtime::{
|
|||||||
use sp_state_machine::InspectState;
|
use sp_state_machine::InspectState;
|
||||||
|
|
||||||
use cumulus_client_consensus_common::ParachainConsensus;
|
use cumulus_client_consensus_common::ParachainConsensus;
|
||||||
use polkadot_node_primitives::{Collation, CollationGenerationConfig, CollationResult};
|
use polkadot_node_primitives::{
|
||||||
|
BlockData, Collation, CollationGenerationConfig, CollationResult, PoV,
|
||||||
|
};
|
||||||
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
|
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
|
||||||
use polkadot_overseer::OverseerHandler;
|
use polkadot_overseer::OverseerHandler;
|
||||||
use polkadot_primitives::v1::{
|
use polkadot_primitives::v1::{
|
||||||
BlockData, BlockNumber as PBlockNumber, CollatorPair, Hash as PHash, HeadData, Id as ParaId,
|
BlockNumber as PBlockNumber, CollatorPair, Hash as PHash, HeadData, Id as ParaId, UpwardMessage,
|
||||||
PoV, UpwardMessage,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use futures::{channel::oneshot, FutureExt};
|
use futures::{channel::oneshot, FutureExt};
|
||||||
use std::sync::Arc;
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use std::sync::Arc;
|
||||||
use tracing::Instrument;
|
use tracing::Instrument;
|
||||||
|
|
||||||
/// The logging target.
|
/// The logging target.
|
||||||
@@ -429,6 +430,7 @@ mod tests {
|
|||||||
|
|
||||||
self.client
|
self.client
|
||||||
.import(BlockOrigin::Own, block.clone())
|
.import(BlockOrigin::Own, block.clone())
|
||||||
|
.await
|
||||||
.expect("Imports the block");
|
.expect("Imports the block");
|
||||||
|
|
||||||
Some(ParachainCandidate {
|
Some(ParachainCandidate {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ where
|
|||||||
h,
|
h,
|
||||||
&*parachain,
|
&*parachain,
|
||||||
&mut unset_best_header,
|
&mut unset_best_header,
|
||||||
),
|
).await,
|
||||||
None => {
|
None => {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
target: "cumulus-consensus",
|
target: "cumulus-consensus",
|
||||||
@@ -221,7 +221,7 @@ where
|
|||||||
&mut unset_best_header,
|
&mut unset_best_header,
|
||||||
&*parachain,
|
&*parachain,
|
||||||
&*announce_block,
|
&*announce_block,
|
||||||
),
|
).await,
|
||||||
None => {
|
None => {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
target: "cumulus-consensus",
|
target: "cumulus-consensus",
|
||||||
@@ -236,11 +236,11 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handle a new import block of the parachain.
|
/// Handle a new import block of the parachain.
|
||||||
fn handle_new_block_imported<Block, P>(
|
async fn handle_new_block_imported<Block, P>(
|
||||||
notification: BlockImportNotification<Block>,
|
notification: BlockImportNotification<Block>,
|
||||||
unset_best_header_opt: &mut Option<Block::Header>,
|
unset_best_header_opt: &mut Option<Block::Header>,
|
||||||
parachain: &P,
|
parachain: &P,
|
||||||
announce_block: &dyn Fn(Block::Hash, Option<Vec<u8>>),
|
announce_block: &(dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync),
|
||||||
) where
|
) where
|
||||||
Block: BlockT,
|
Block: BlockT,
|
||||||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
||||||
@@ -280,7 +280,7 @@ fn handle_new_block_imported<Block, P>(
|
|||||||
.take()
|
.take()
|
||||||
.expect("We checked above that the value is set; qed");
|
.expect("We checked above that the value is set; qed");
|
||||||
|
|
||||||
import_block_as_new_best(unset_hash, unset_best_header, parachain);
|
import_block_as_new_best(unset_hash, unset_best_header, parachain).await;
|
||||||
}
|
}
|
||||||
state => tracing::debug!(
|
state => tracing::debug!(
|
||||||
target: "cumulus-consensus",
|
target: "cumulus-consensus",
|
||||||
@@ -293,7 +293,7 @@ fn handle_new_block_imported<Block, P>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handle the new best parachain head as extracted from the new best relay chain.
|
/// Handle the new best parachain head as extracted from the new best relay chain.
|
||||||
fn handle_new_best_parachain_head<Block, P>(
|
async fn handle_new_best_parachain_head<Block, P>(
|
||||||
head: Vec<u8>,
|
head: Vec<u8>,
|
||||||
parachain: &P,
|
parachain: &P,
|
||||||
unset_best_header: &mut Option<Block::Header>,
|
unset_best_header: &mut Option<Block::Header>,
|
||||||
@@ -328,7 +328,7 @@ fn handle_new_best_parachain_head<Block, P>(
|
|||||||
Ok(BlockStatus::InChainWithState) => {
|
Ok(BlockStatus::InChainWithState) => {
|
||||||
unset_best_header.take();
|
unset_best_header.take();
|
||||||
|
|
||||||
import_block_as_new_best(hash, parachain_head, parachain);
|
import_block_as_new_best(hash, parachain_head, parachain).await;
|
||||||
}
|
}
|
||||||
Ok(BlockStatus::InChainPruned) => {
|
Ok(BlockStatus::InChainPruned) => {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
@@ -359,11 +359,8 @@ fn handle_new_best_parachain_head<Block, P>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn import_block_as_new_best<Block, P>(
|
async fn import_block_as_new_best<Block, P>(hash: Block::Hash, header: Block::Header, parachain: &P)
|
||||||
hash: Block::Hash,
|
where
|
||||||
header: Block::Header,
|
|
||||||
parachain: &P,
|
|
||||||
) where
|
|
||||||
Block: BlockT,
|
Block: BlockT,
|
||||||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
||||||
for<'a> &'a P: BlockImport<Block>,
|
for<'a> &'a P: BlockImport<Block>,
|
||||||
@@ -373,7 +370,10 @@ fn import_block_as_new_best<Block, P>(
|
|||||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
|
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
|
||||||
block_import_params.import_existing = true;
|
block_import_params.import_existing = true;
|
||||||
|
|
||||||
if let Err(err) = (&*parachain).import_block(block_import_params, Default::default()) {
|
if let Err(err) = (&*parachain)
|
||||||
|
.import_block(block_import_params, Default::default())
|
||||||
|
.await
|
||||||
|
{
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
target: "cumulus-consensus",
|
target: "cumulus-consensus",
|
||||||
block_hash = ?hash,
|
block_hash = ?hash,
|
||||||
@@ -555,7 +555,9 @@ impl<B: BlockT> ParachainConsensus<B> for Box<dyn ParachainConsensus<B> + Send +
|
|||||||
relay_parent: PHash,
|
relay_parent: PHash,
|
||||||
validation_data: &PersistedValidationData,
|
validation_data: &PersistedValidationData,
|
||||||
) -> Option<ParachainCandidate<B>> {
|
) -> Option<ParachainCandidate<B>> {
|
||||||
(*self).produce_candidate(parent, relay_parent, validation_data).await
|
(*self)
|
||||||
|
.produce_candidate(parent, relay_parent, validation_data)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,9 +655,7 @@ mod tests {
|
|||||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(false));
|
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(false));
|
||||||
block_import_params.body = Some(body);
|
block_import_params.body = Some(body);
|
||||||
|
|
||||||
client
|
block_on(client.import_block(block_import_params, Default::default())).unwrap();
|
||||||
.import_block(block_import_params, Default::default())
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(0, client.chain_info().best_number);
|
assert_eq!(0, client.chain_info().best_number);
|
||||||
|
|
||||||
block
|
block
|
||||||
@@ -865,6 +865,7 @@ mod tests {
|
|||||||
// Now import the unkown block to make it "known"
|
// Now import the unkown block to make it "known"
|
||||||
client
|
client
|
||||||
.import_block(block_import_params, Default::default())
|
.import_block(block_import_params, Default::default())
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
@@ -38,13 +38,14 @@ struct Verifier<Client, Block> {
|
|||||||
_marker: PhantomData<Block>,
|
_marker: PhantomData<Block>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
impl<Client, Block> VerifierT<Block> for Verifier<Client, Block>
|
impl<Client, Block> VerifierT<Block> for Verifier<Client, Block>
|
||||||
where
|
where
|
||||||
Block: BlockT,
|
Block: BlockT,
|
||||||
Client: ProvideRuntimeApi<Block> + Send + Sync,
|
Client: ProvideRuntimeApi<Block> + Send + Sync,
|
||||||
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
|
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
|
||||||
{
|
{
|
||||||
fn verify(
|
async fn verify(
|
||||||
&mut self,
|
&mut self,
|
||||||
origin: BlockOrigin,
|
origin: BlockOrigin,
|
||||||
header: Block::Header,
|
header: Block::Header,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ pub struct RelayChainConsensus<B, PF, BI, RClient, RBackend> {
|
|||||||
_phantom: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
proposer_factory: Arc<Mutex<PF>>,
|
proposer_factory: Arc<Mutex<PF>>,
|
||||||
inherent_data_providers: InherentDataProviders,
|
inherent_data_providers: InherentDataProviders,
|
||||||
block_import: Arc<Mutex<BI>>,
|
block_import: Arc<futures::lock::Mutex<BI>>,
|
||||||
relay_chain_client: Arc<RClient>,
|
relay_chain_client: Arc<RClient>,
|
||||||
relay_chain_backend: Arc<RBackend>,
|
relay_chain_backend: Arc<RBackend>,
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ where
|
|||||||
para_id,
|
para_id,
|
||||||
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
||||||
inherent_data_providers,
|
inherent_data_providers,
|
||||||
block_import: Arc::new(Mutex::new(block_import)),
|
block_import: Arc::new(futures::lock::Mutex::new(block_import)),
|
||||||
relay_chain_backend: polkadot_backend,
|
relay_chain_backend: polkadot_backend,
|
||||||
relay_chain_client: polkadot_client,
|
relay_chain_client: polkadot_client,
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
@@ -212,7 +212,9 @@ where
|
|||||||
if let Err(err) = self
|
if let Err(err) = self
|
||||||
.block_import
|
.block_import
|
||||||
.lock()
|
.lock()
|
||||||
|
.await
|
||||||
.import_block(block_import_params, Default::default())
|
.import_block(block_import_params, Default::default())
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ fn relay_parent_not_imported_when_block_announce_is_processed() {
|
|||||||
|
|
||||||
client
|
client
|
||||||
.import(BlockOrigin::Own, block)
|
.import(BlockOrigin::Own, block)
|
||||||
|
.await
|
||||||
.expect("Imports the block");
|
.expect("Imports the block");
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
@@ -386,7 +387,11 @@ sp_api::mock_impl_runtime_apis! {
|
|||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn persisted_validation_data(&self, _: ParaId, _: OccupiedCoreAssumption) -> Option<PersistedValidationData<BlockNumber>> {
|
fn persisted_validation_data(
|
||||||
|
&self,
|
||||||
|
_: ParaId,
|
||||||
|
_: OccupiedCoreAssumption,
|
||||||
|
) -> Option<PersistedValidationData<PHash, BlockNumber>> {
|
||||||
Some(PersistedValidationData {
|
Some(PersistedValidationData {
|
||||||
parent_head: HeadData(default_header().encode()),
|
parent_head: HeadData(default_header().encode()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -430,5 +435,9 @@ sp_api::mock_impl_runtime_apis! {
|
|||||||
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
|
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
|
||||||
BTreeMap::new()
|
BTreeMap::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn validation_code_by_hash(_: PHash) -> Option<ValidationCode> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,9 +165,7 @@ mod tests {
|
|||||||
let (mut client, backend, block) = build_client_backend_and_block();
|
let (mut client, backend, block) = build_client_backend_and_block();
|
||||||
let hash = block.hash();
|
let hash = block.hash();
|
||||||
|
|
||||||
client
|
block_on(client.import(BlockOrigin::Own, block)).expect("Imports the block");
|
||||||
.import(BlockOrigin::Own, block)
|
|
||||||
.expect("Imports the block");
|
|
||||||
|
|
||||||
let wait = WaitOnRelayChainBlock::new(backend, client);
|
let wait = WaitOnRelayChainBlock::new(backend, client);
|
||||||
|
|
||||||
@@ -195,6 +193,7 @@ mod tests {
|
|||||||
// Import the block that should fire the notification
|
// Import the block that should fire the notification
|
||||||
client
|
client
|
||||||
.import(BlockOrigin::Own, block)
|
.import(BlockOrigin::Own, block)
|
||||||
|
.await
|
||||||
.expect("Imports the block");
|
.expect("Imports the block");
|
||||||
|
|
||||||
// Now it should have received the notification and report that the block was imported
|
// Now it should have received the notification and report that the block was imported
|
||||||
@@ -246,6 +245,7 @@ mod tests {
|
|||||||
// Import the block that should fire the notification
|
// Import the block that should fire the notification
|
||||||
client
|
client
|
||||||
.import(BlockOrigin::Own, block2)
|
.import(BlockOrigin::Own, block2)
|
||||||
|
.await
|
||||||
.expect("Imports the second block");
|
.expect("Imports the second block");
|
||||||
|
|
||||||
// The import notification of the second block should not make this one finish
|
// The import notification of the second block should not make this one finish
|
||||||
@@ -255,6 +255,7 @@ mod tests {
|
|||||||
|
|
||||||
client
|
client
|
||||||
.import(BlockOrigin::Own, block)
|
.import(BlockOrigin::Own, block)
|
||||||
|
.await
|
||||||
.expect("Imports the first block");
|
.expect("Imports the first block");
|
||||||
|
|
||||||
// Now it should be ready
|
// Now it should be ready
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
use cumulus_client_consensus_common::ParachainConsensus;
|
use cumulus_client_consensus_common::ParachainConsensus;
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use polkadot_primitives::v1::{Block as PBlock, CollatorId, CollatorPair};
|
use polkadot_primitives::v1::{Block as PBlock, CollatorPair};
|
||||||
use polkadot_service::{AbstractClient, Client as PClient, ClientHandle, RuntimeApiCollection};
|
use polkadot_service::{AbstractClient, Client as PClient, ClientHandle, RuntimeApiCollection};
|
||||||
use sc_client_api::{
|
use sc_client_api::{
|
||||||
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
|
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
|
||||||
@@ -233,7 +233,7 @@ pub fn prepare_node_config(mut parachain_config: Configuration) -> Configuration
|
|||||||
#[sc_tracing::logging::prefix_logs_with("Relaychain")]
|
#[sc_tracing::logging::prefix_logs_with("Relaychain")]
|
||||||
pub fn build_polkadot_full_node(
|
pub fn build_polkadot_full_node(
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
collator_id: CollatorId,
|
collator_pair: CollatorPair,
|
||||||
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
|
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
|
||||||
) -> Result<RFullNode<PClient>, polkadot_service::Error> {
|
) -> Result<RFullNode<PClient>, polkadot_service::Error> {
|
||||||
let is_light = matches!(config.role, Role::Light);
|
let is_light = matches!(config.role, Role::Light);
|
||||||
@@ -244,7 +244,7 @@ pub fn build_polkadot_full_node(
|
|||||||
} else {
|
} else {
|
||||||
polkadot_service::build_full(
|
polkadot_service::build_full(
|
||||||
config,
|
config,
|
||||||
polkadot_service::IsCollator::Yes(collator_id),
|
polkadot_service::IsCollator::Yes(collator_pair),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
telemetry_worker_handle,
|
telemetry_worker_handle,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ mod relay_state_snapshot;
|
|||||||
pub mod validate_block;
|
pub mod validate_block;
|
||||||
|
|
||||||
/// The pallet's configuration trait.
|
/// The pallet's configuration trait.
|
||||||
pub trait Config: frame_system::Config {
|
pub trait Config: frame_system::Config<OnSetCode = ParachainSetCode<Self>> {
|
||||||
/// The overarching event type.
|
/// The overarching event type.
|
||||||
type Event: From<Event> + Into<<Self as frame_system::Config>::Event>;
|
type Event: From<Event> + Into<<Self as frame_system::Config>::Event>;
|
||||||
|
|
||||||
@@ -144,24 +144,6 @@ decl_module! {
|
|||||||
// this is needed only if you are using events in your pallet
|
// this is needed only if you are using events in your pallet
|
||||||
fn deposit_event() = default;
|
fn deposit_event() = default;
|
||||||
|
|
||||||
// TODO: figure out a better weight than this
|
|
||||||
// TODO: Bring back the correct validation checks: #374
|
|
||||||
#[weight = (0, DispatchClass::Operational)]
|
|
||||||
pub fn schedule_upgrade(origin, validation_function: Vec<u8>) {
|
|
||||||
ensure_root(origin)?;
|
|
||||||
Self::schedule_upgrade_impl(validation_function)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Schedule a validation function upgrade without further checks.
|
|
||||||
///
|
|
||||||
/// Same as [`Module::schedule_upgrade`], but without checking that the new `validation_function`
|
|
||||||
/// is correct. This makes it more flexible, but also opens the door to easily brick the chain.
|
|
||||||
#[weight = (0, DispatchClass::Operational)]
|
|
||||||
pub fn schedule_upgrade_without_checks(origin, validation_function: Vec<u8>) {
|
|
||||||
ensure_root(origin)?;
|
|
||||||
Self::schedule_upgrade_impl(validation_function)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Force an already scheduled validation function upgrade to happen on a particular block.
|
/// Force an already scheduled validation function upgrade to happen on a particular block.
|
||||||
///
|
///
|
||||||
/// Note that coordinating this block for the upgrade has to happen independently on the relay
|
/// Note that coordinating this block for the upgrade has to happen independently on the relay
|
||||||
@@ -654,8 +636,8 @@ impl<T: Config> Module<T> {
|
|||||||
Some(vfp.relay_parent_number + cfg.validation_upgrade_delay)
|
Some(vfp.relay_parent_number + cfg.validation_upgrade_delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The implementation of the runtime upgrade scheduling.
|
/// The implementation of the runtime upgrade functionality for parachains.
|
||||||
fn schedule_upgrade_impl(validation_function: Vec<u8>) -> DispatchResult {
|
fn set_code_impl(validation_function: Vec<u8>) -> DispatchResult {
|
||||||
ensure!(
|
ensure!(
|
||||||
!PendingValidationFunction::exists(),
|
!PendingValidationFunction::exists(),
|
||||||
Error::<T>::OverlappingUpgrades
|
Error::<T>::OverlappingUpgrades
|
||||||
@@ -685,6 +667,14 @@ impl<T: Config> Module<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct ParachainSetCode<T>(sp_std::marker::PhantomData<T>);
|
||||||
|
|
||||||
|
impl<T: Config> frame_system::SetCode for ParachainSetCode<T> {
|
||||||
|
fn set_code(code: Vec<u8>) -> DispatchResult {
|
||||||
|
Module::<T>::set_code_impl(code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// This struct provides ability to extend a message queue chain (MQC) and compute a new head.
|
/// This struct provides ability to extend a message queue chain (MQC) and compute a new head.
|
||||||
///
|
///
|
||||||
/// MQC is an instance of a [hash chain] applied to a message queue. Using a hash chain it's possible
|
/// MQC is an instance of a [hash chain] applied to a message queue. Using a hash chain it's possible
|
||||||
@@ -975,6 +965,7 @@ mod tests {
|
|||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
|
type OnSetCode = ParachainSetCode<Self>;
|
||||||
}
|
}
|
||||||
impl Config for Test {
|
impl Config for Test {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
@@ -1242,26 +1233,6 @@ mod tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn requires_root() {
|
|
||||||
BlockTests::new().add(123, || {
|
|
||||||
assert_eq!(
|
|
||||||
ParachainSystem::schedule_upgrade(Origin::signed(1), Default::default()),
|
|
||||||
Err(sp_runtime::DispatchError::BadOrigin),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn requires_root_2() {
|
|
||||||
BlockTests::new().add(123, || {
|
|
||||||
assert_ok!(ParachainSystem::schedule_upgrade(
|
|
||||||
RawOrigin::Root.into(),
|
|
||||||
Default::default()
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn events() {
|
fn events() {
|
||||||
BlockTests::new()
|
BlockTests::new()
|
||||||
@@ -1271,7 +1242,7 @@ mod tests {
|
|||||||
.add_with_post_test(
|
.add_with_post_test(
|
||||||
123,
|
123,
|
||||||
|| {
|
|| {
|
||||||
assert_ok!(ParachainSystem::schedule_upgrade(
|
assert_ok!(System::set_code(
|
||||||
RawOrigin::Root.into(),
|
RawOrigin::Root.into(),
|
||||||
Default::default()
|
Default::default()
|
||||||
));
|
));
|
||||||
@@ -1304,14 +1275,14 @@ mod tests {
|
|||||||
builder.host_config.validation_upgrade_delay = 1000;
|
builder.host_config.validation_upgrade_delay = 1000;
|
||||||
})
|
})
|
||||||
.add(123, || {
|
.add(123, || {
|
||||||
assert_ok!(ParachainSystem::schedule_upgrade(
|
assert_ok!(System::set_code(
|
||||||
RawOrigin::Root.into(),
|
RawOrigin::Root.into(),
|
||||||
Default::default()
|
Default::default()
|
||||||
));
|
));
|
||||||
})
|
})
|
||||||
.add(234, || {
|
.add(234, || {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ParachainSystem::schedule_upgrade(RawOrigin::Root.into(), Default::default()),
|
System::set_code(RawOrigin::Root.into(), Default::default()),
|
||||||
Err(Error::<Test>::OverlappingUpgrades.into()),
|
Err(Error::<Test>::OverlappingUpgrades.into()),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@@ -1325,7 +1296,7 @@ mod tests {
|
|||||||
!PendingValidationFunction::exists(),
|
!PendingValidationFunction::exists(),
|
||||||
"validation function must not exist yet"
|
"validation function must not exist yet"
|
||||||
);
|
);
|
||||||
assert_ok!(ParachainSystem::schedule_upgrade(
|
assert_ok!(System::set_code(
|
||||||
RawOrigin::Root.into(),
|
RawOrigin::Root.into(),
|
||||||
Default::default()
|
Default::default()
|
||||||
));
|
));
|
||||||
@@ -1354,7 +1325,7 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.add(123, || {
|
.add(123, || {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ParachainSystem::schedule_upgrade(RawOrigin::Root.into(), vec![0; 64]),
|
System::set_code(RawOrigin::Root.into(), vec![0; 64]),
|
||||||
Err(Error::<Test>::TooBig.into()),
|
Err(Error::<Test>::TooBig.into()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ impl frame_system::Config for Runtime {
|
|||||||
type BlockWeights = RuntimeBlockWeights;
|
type BlockWeights = RuntimeBlockWeights;
|
||||||
type BlockLength = RuntimeBlockLength;
|
type BlockLength = RuntimeBlockLength;
|
||||||
type SS58Prefix = SS58Prefix;
|
type SS58Prefix = SS58Prefix;
|
||||||
|
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use sc_executor::native_executor_instance;
|
|||||||
pub use sc_executor::NativeExecutor;
|
pub use sc_executor::NativeExecutor;
|
||||||
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
|
||||||
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
|
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
|
||||||
use sp_core::Pair;
|
|
||||||
use sp_runtime::traits::BlakeTwo256;
|
use sp_runtime::traits::BlakeTwo256;
|
||||||
use sp_trie::PrefixedMemoryDB;
|
use sp_trie::PrefixedMemoryDB;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -154,7 +153,7 @@ where
|
|||||||
let polkadot_full_node =
|
let polkadot_full_node =
|
||||||
cumulus_client_service::build_polkadot_full_node(
|
cumulus_client_service::build_polkadot_full_node(
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
collator_key.public(),
|
collator_key.clone(),
|
||||||
telemetry_worker_handle,
|
telemetry_worker_handle,
|
||||||
)
|
)
|
||||||
.map_err(|e| match e {
|
.map_err(|e| match e {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use cumulus_primitives_core::PersistedValidationData;
|
|||||||
use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER};
|
use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER};
|
||||||
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
|
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
|
||||||
use cumulus_test_runtime::{Block, GetLastTimestamp};
|
use cumulus_test_runtime::{Block, GetLastTimestamp};
|
||||||
use polkadot_primitives::v1::BlockNumber as PBlockNumber;
|
use polkadot_primitives::v1::{BlockNumber as PBlockNumber, Hash as PHash};
|
||||||
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
|
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
|
||||||
use sp_api::ProvideRuntimeApi;
|
use sp_api::ProvideRuntimeApi;
|
||||||
use sp_runtime::generic::BlockId;
|
use sp_runtime::generic::BlockId;
|
||||||
@@ -35,7 +35,7 @@ pub trait InitBlockBuilder {
|
|||||||
/// just use a default one.
|
/// just use a default one.
|
||||||
fn init_block_builder(
|
fn init_block_builder(
|
||||||
&self,
|
&self,
|
||||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
|
||||||
relay_sproof_builder: RelayStateSproofBuilder,
|
relay_sproof_builder: RelayStateSproofBuilder,
|
||||||
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ pub trait InitBlockBuilder {
|
|||||||
fn init_block_builder_at(
|
fn init_block_builder_at(
|
||||||
&self,
|
&self,
|
||||||
at: &BlockId<Block>,
|
at: &BlockId<Block>,
|
||||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
|
||||||
relay_sproof_builder: RelayStateSproofBuilder,
|
relay_sproof_builder: RelayStateSproofBuilder,
|
||||||
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ pub trait InitBlockBuilder {
|
|||||||
impl InitBlockBuilder for Client {
|
impl InitBlockBuilder for Client {
|
||||||
fn init_block_builder(
|
fn init_block_builder(
|
||||||
&self,
|
&self,
|
||||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
|
||||||
relay_sproof_builder: RelayStateSproofBuilder,
|
relay_sproof_builder: RelayStateSproofBuilder,
|
||||||
) -> BlockBuilder<Block, Client, Backend> {
|
) -> BlockBuilder<Block, Client, Backend> {
|
||||||
let chain_info = self.chain_info();
|
let chain_info = self.chain_info();
|
||||||
@@ -68,7 +68,7 @@ impl InitBlockBuilder for Client {
|
|||||||
fn init_block_builder_at(
|
fn init_block_builder_at(
|
||||||
&self,
|
&self,
|
||||||
at: &BlockId<Block>,
|
at: &BlockId<Block>,
|
||||||
validation_data: Option<PersistedValidationData<PBlockNumber>>,
|
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
|
||||||
relay_sproof_builder: RelayStateSproofBuilder,
|
relay_sproof_builder: RelayStateSproofBuilder,
|
||||||
) -> BlockBuilder<Block, Client, Backend> {
|
) -> BlockBuilder<Block, Client, Backend> {
|
||||||
let mut block_builder = self
|
let mut block_builder = self
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ impl frame_system::Config for Runtime {
|
|||||||
type BlockWeights = RuntimeBlockWeights;
|
type BlockWeights = RuntimeBlockWeights;
|
||||||
type BlockLength = RuntimeBlockLength;
|
type BlockLength = RuntimeBlockLength;
|
||||||
type SS58Prefix = SS58Prefix;
|
type SS58Prefix = SS58Prefix;
|
||||||
|
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ where
|
|||||||
let relay_chain_full_node = polkadot_test_service::new_full(
|
let relay_chain_full_node = polkadot_test_service::new_full(
|
||||||
relay_chain_config,
|
relay_chain_config,
|
||||||
if let Some(ref key) = collator_key {
|
if let Some(ref key) = collator_key {
|
||||||
polkadot_service::IsCollator::Yes(key.public())
|
polkadot_service::IsCollator::Yes(key.clone())
|
||||||
} else {
|
} else {
|
||||||
polkadot_service::IsCollator::No
|
polkadot_service::IsCollator::No
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user