mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 09:31:02 +00:00
WIP: Update Substrate & Polkadot (#496)
* WIP: Update Substrate * Update Substrate & Polkadot * fixes * more fixes * few missing origins * use spawn_essential_handle * bump polkadot dep * remove newlines * fix test Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -42,7 +42,7 @@ frame_support::construct_runtime!(
|
||||
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
|
||||
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
|
||||
Aura: pallet_aura::{Pallet, Call, Storage, Config<T>},
|
||||
Aura: pallet_aura::{Pallet, Storage, Config<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
CollatorSelection: collator_selection::{Pallet, Call, Storage, Event<T>},
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
|
||||
|
||||
@@ -373,7 +373,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::weight((1_000, DispatchClass::Operational))]
|
||||
fn sudo_send_upward_message(
|
||||
pub fn sudo_send_upward_message(
|
||||
origin: OriginFor<T>,
|
||||
message: UpwardMessage,
|
||||
) -> DispatchResult {
|
||||
@@ -383,7 +383,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::weight((1_000_000, DispatchClass::Operational))]
|
||||
fn authorize_upgrade(origin: OriginFor<T>, code_hash: T::Hash) -> DispatchResult {
|
||||
pub fn authorize_upgrade(origin: OriginFor<T>, code_hash: T::Hash) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
AuthorizedUpgrade::<T>::put(&code_hash);
|
||||
@@ -393,7 +393,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::weight(1_000_000)]
|
||||
fn enact_authorized_upgrade(_: OriginFor<T>, code: Vec<u8>) -> DispatchResultWithPostInfo {
|
||||
pub fn enact_authorized_upgrade(_: OriginFor<T>, code: Vec<u8>) -> DispatchResultWithPostInfo {
|
||||
Self::validate_authorized_upgrade(&code[..])?;
|
||||
Self::set_code_impl(code)?;
|
||||
AuthorizedUpgrade::<T>::kill();
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use frame_support::traits::{ExecuteBlock, ExtrinsicCall, IsSubType, Get};
|
||||
use sp_runtime::traits::{Block as BlockT, Extrinsic, HashFor, Header as HeaderT, NumberFor};
|
||||
|
||||
use sp_io::KillChildStorageResult;
|
||||
use sp_io::KillStorageResult;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use polkadot_parachain::primitives::{HeadData, ValidationParams, ValidationResult};
|
||||
@@ -220,8 +220,14 @@ fn host_storage_root() -> Vec<u8> {
|
||||
with_externalities(|ext| ext.storage_root())
|
||||
}
|
||||
|
||||
fn host_storage_clear_prefix(prefix: &[u8]) {
|
||||
with_externalities(|ext| ext.clear_prefix(prefix))
|
||||
fn host_storage_clear_prefix(prefix: &[u8], limit: Option<u32>) -> KillStorageResult {
|
||||
with_externalities(|ext| {
|
||||
let (all_removed, num_removed) = ext.clear_prefix(prefix, limit);
|
||||
match all_removed {
|
||||
true => KillStorageResult::AllRemoved(num_removed),
|
||||
false => KillStorageResult::SomeRemaining(num_removed),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn host_storage_changes_root(parent_hash: &[u8]) -> Option<Vec<u8>> {
|
||||
@@ -289,13 +295,13 @@ fn host_default_child_storage_clear(storage_key: &[u8], key: &[u8]) {
|
||||
fn host_default_child_storage_storage_kill(
|
||||
storage_key: &[u8],
|
||||
limit: Option<u32>,
|
||||
) -> KillChildStorageResult {
|
||||
) -> KillStorageResult {
|
||||
let child_info = ChildInfo::new_default(storage_key);
|
||||
with_externalities(|ext| {
|
||||
let (all_removed, num_removed) = ext.kill_child_storage(&child_info, limit);
|
||||
match all_removed {
|
||||
true => KillChildStorageResult::AllRemoved(num_removed),
|
||||
false => KillChildStorageResult::SomeRemaining(num_removed),
|
||||
true => KillStorageResult::AllRemoved(num_removed),
|
||||
false => KillStorageResult::SomeRemaining(num_removed),
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -305,9 +311,15 @@ fn host_default_child_storage_exists(storage_key: &[u8], key: &[u8]) -> bool {
|
||||
with_externalities(|ext| ext.exists_child_storage(&child_info, key))
|
||||
}
|
||||
|
||||
fn host_default_child_storage_clear_prefix(storage_key: &[u8], prefix: &[u8]) {
|
||||
fn host_default_child_storage_clear_prefix(storage_key: &[u8], prefix: &[u8], limit: Option<u32>) -> KillStorageResult {
|
||||
let child_info = ChildInfo::new_default(storage_key);
|
||||
with_externalities(|ext| ext.clear_child_prefix(&child_info, prefix))
|
||||
with_externalities(|ext| {
|
||||
let (all_removed, num_removed) = ext.clear_child_prefix(&child_info, prefix, limit);
|
||||
match all_removed {
|
||||
true => KillStorageResult::AllRemoved(num_removed),
|
||||
false => KillStorageResult::SomeRemaining(num_removed),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn host_default_child_storage_root(storage_key: &[u8]) -> Vec<u8> {
|
||||
|
||||
@@ -72,6 +72,28 @@ pub mod pallet {
|
||||
/// \[ id, outcome \]
|
||||
ExecutedDownward([u8; 8], Outcome),
|
||||
}
|
||||
|
||||
/// Origin for the parachains module.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[pallet::origin]
|
||||
pub enum Origin {
|
||||
/// It comes from the (parent) relay chain.
|
||||
Relay,
|
||||
/// It comes from a (sibling) parachain.
|
||||
SiblingParachain(ParaId),
|
||||
}
|
||||
|
||||
impl From<ParaId> for Origin {
|
||||
fn from(id: ParaId) -> Origin {
|
||||
Origin::SiblingParachain(id)
|
||||
}
|
||||
}
|
||||
impl From<u32> for Origin {
|
||||
fn from(id: u32) -> Origin {
|
||||
Origin::SiblingParachain(id.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// For an incoming downward message, this just adapts an XCM executor and executes DMP messages
|
||||
@@ -137,27 +159,6 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Origin for the parachains module.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub enum Origin {
|
||||
/// It comes from the (parent) relay chain.
|
||||
Relay,
|
||||
/// It comes from a (sibling) parachain.
|
||||
SiblingParachain(ParaId),
|
||||
}
|
||||
|
||||
impl From<ParaId> for Origin {
|
||||
fn from(id: ParaId) -> Origin {
|
||||
Origin::SiblingParachain(id)
|
||||
}
|
||||
}
|
||||
impl From<u32> for Origin {
|
||||
fn from(id: u32) -> Origin {
|
||||
Origin::SiblingParachain(id.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensure that the origin `o` represents a sibling parachain.
|
||||
/// Returns `Ok` with the parachain ID of the sibling or an `Err` otherwise.
|
||||
pub fn ensure_sibling_para<OuterOrigin>(o: OuterOrigin) -> Result<ParaId, BadOrigin>
|
||||
|
||||
Reference in New Issue
Block a user