Skip to content

Commit

Permalink
chore: update to polkadot 0.9.38 (#480)
Browse files Browse the repository at this point in the history
fixes KILTprotocol/ticket#2464
Fixes #481 -> see issue
description for a complete list of PRs.

- paritytech/polkadot#4097 (XCM v3)
- paritytech/polkadot#6490 (root origin can
issue grants on behalf of the treasury)
- paritytech/substrate#13214 (we used in the the
staking pallet but we never called the `set` function, so we don't need
to do anything)
- paritytech/substrate#13216 (removes all calls
and intrinsics from the authorship pallet)

Release analysis:
https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-38/2122

If any of the runtimes is complied with just the `runtime-benchmarks`
features, there is a compilation issue due to some nested dependencies.
Linked issue: paritytech/cumulus#2230.

---------

Co-authored-by: Tino Rusch <tino@kilt.io>
  • Loading branch information
2 people authored and Ad96el committed Mar 20, 2023
1 parent cb3db21 commit 38e33eb
Show file tree
Hide file tree
Showing 25 changed files with 689 additions and 13,740 deletions.
13,506 changes: 0 additions & 13,506 deletions Cargo.lock

This file was deleted.

202 changes: 101 additions & 101 deletions Cargo.toml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions nodes/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ runtime-benchmarks = [
"peregrine-runtime/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"spiritnet-runtime/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks"
]
try-runtime = [
"peregrine-runtime/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions nodes/parachain/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::{ops::Deref, path::PathBuf};
pub(crate) const DEFAULT_RUNTIME: &str = "peregrine";

/// Sub-commands supported by the collator.
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Parser)]
pub(crate) enum Subcommand {
/// Build a chain specification.
Expand Down
10 changes: 4 additions & 6 deletions nodes/parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,12 @@ pub fn run() -> Result<()> {
let collator_options = cli.run.collator_options();

runner.run_node_until_exit(|config| async move {
let hwbench = if !cli.no_hardware_benchmarks {
let hwbench = (!cli.no_hardware_benchmarks).then_some(
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
None
};
})).flatten();


let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
Expand All @@ -405,7 +403,7 @@ pub fn run() -> Result<()> {
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account_truncating(&id);
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&id);

let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
let block: Block =
Expand Down
1 change: 1 addition & 0 deletions nodes/standalone/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct Cli {
pub run: RunCmd,
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Parser)]
pub enum Subcommand {
/// Key management cli utilities
Expand Down
2 changes: 1 addition & 1 deletion nodes/standalone/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn new_partial(config: &Configuration) -> Result<PartialComponents, ServiceE

let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
&(Arc::clone(&client) as Arc<_>),
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
)?;
Expand Down
2 changes: 1 addition & 1 deletion pallets/ctype/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ benchmarks! {
<T as Config>::Currency::make_free_balance_be(&caller, initial_balance);
let origin = T::EnsureOrigin::generate_origin(caller, did);
Pallet::<T>::add(origin, ctype).expect("CType creation should not fail.");
let overarching_origin = T::OverarchingOrigin::successful_origin();
let overarching_origin = T::OverarchingOrigin::try_successful_origin().expect("Successful origin creation should not fail.");

}: _<T::RuntimeOrigin>(overarching_origin, ctype_hash, new_block_number)
verify {
Expand Down
9 changes: 5 additions & 4 deletions pallets/did/src/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ where
}

#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> OuterOrigin {
fn try_successful_origin() -> Result<OuterOrigin, ()> {
let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed");

OuterOrigin::from(DidRawOrigin {
Ok(OuterOrigin::from(DidRawOrigin {
id: zero_account_id.clone().into(),
submitter: zero_account_id,
})
}))
}
}

Expand Down Expand Up @@ -97,7 +97,8 @@ mod tests {
use crate::mock::Test;
use frame_support::{assert_ok, traits::EnsureOrigin};

let origin: <Test as frame_system::Config>::RuntimeOrigin = EnsureDidOrigin::successful_origin();
let origin: <Test as frame_system::Config>::RuntimeOrigin =
EnsureDidOrigin::try_successful_origin().expect("Successful origin creation should not fail.");
assert_ok!(EnsureDidOrigin::try_origin(origin));
}
}
4 changes: 0 additions & 4 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2493,10 +2493,6 @@ pub mod pallet {
DispatchClass::Mandatory,
);
}

fn note_uncle(_author: T::AccountId, _age: T::BlockNumber) {
// we too are not caring.
}
}

impl<T: Config> pallet_session::SessionManager<T::AccountId> for Pallet<T> {
Expand Down
4 changes: 1 addition & 3 deletions pallets/parachain-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ construct_runtime!(
Aura: pallet_aura::{Pallet, Storage},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
StakePallet: stake::{Pallet, Call, Storage, Config<T>, Event<T>},
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
Authorship: pallet_authorship::{Pallet, Storage},
}
);

Expand Down Expand Up @@ -121,8 +121,6 @@ impl pallet_aura::Config for Test {

impl pallet_authorship::Config for Test {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type UncleGenerations = ();
type FilterUncle = ();
type EventHandler = Pallet<Test>;
}

Expand Down
7 changes: 4 additions & 3 deletions runtimes/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
/// used by Operational extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 0.5 seconds of compute with a 12 second average block time.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND)
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

pub const INFLATION_CONFIG: (Perquintill, Perquintill, Perquintill, Perquintill) = (
// max collator staking rate
Expand Down
4 changes: 1 addition & 3 deletions runtimes/common/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod tests {
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
Authorship: pallet_authorship::{Pallet, Storage},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
}
);
Expand Down Expand Up @@ -247,8 +247,6 @@ mod tests {
}
impl pallet_authorship::Config for Test {
type FindAuthor = OneAuthor;
type UncleGenerations = ();
type FilterUncle = ();
type EventHandler = ();
}

Expand Down
47 changes: 14 additions & 33 deletions runtimes/common/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
// If you feel like getting in touch with us, you can do so at info@botlabs.org

use core::marker::PhantomData;
use frame_support::{log, match_types, parameter_types};
use frame_support::{log, match_types, parameter_types, weights::Weight};
use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowUnpaidExecutionFrom, CurrencyAdapter, IsConcrete, ParentIsPreset,
SiblingParachainConvertsVia,
};
use xcm_builder::{AccountId32Aliases, CurrencyAdapter, IsConcrete, ParentIsPreset, SiblingParachainConvertsVia};
use xcm_executor::traits::ShouldExecute;

use crate::AccountId;

parameter_types! {
// One XCM operation is 1_000_000_000 weight, almost certainly a conservative estimate.
pub UnitWeightCost: u64 = 1_000_000_000;
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
}

match_types! {
Expand All @@ -54,41 +52,25 @@ where
{
fn should_execute<Call>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
max_weight: u64,
weight_credit: &mut u64,
instructions: &mut [Instruction<Call>],
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ()> {
Deny::should_execute(origin, message, max_weight, weight_credit)?;
Allow::should_execute(origin, message, max_weight, weight_credit)
Deny::should_execute(origin, instructions, max_weight, weight_credit)?;
Allow::should_execute(origin, instructions, max_weight, weight_credit)
}
}

/// Explicitly deny ReserveTransfer to the relay chain. Allow calls from the
/// relay chain governance.
pub type XcmBarrier = DenyThenTry<
DenyReserveTransferToRelayChain,
(
// We don't allow anything from any sibling chain, therefore the following is not included here:
// * TakeWeightCredit
// * AllowTopLevelPaidExecutionFrom<Everything>

// We allow everything from the relay chain if it was sent by the relay chain legislative (i.e., democracy
// vote). Since the relaychain doesn't own KILTs and missing fees shouldn't prevent calls from the relaychain
// legislative, we allow unpaid execution.
AllowUnpaidExecutionFrom<ParentLegislative>,
),
>;

/// Reserved funds to the relay chain can't return. See https://github.com/paritytech/polkadot/issues/5233
pub struct DenyReserveTransferToRelayChain;
impl ShouldExecute for DenyReserveTransferToRelayChain {
fn should_execute<Call>(
origin: &MultiLocation,
message: &mut Xcm<Call>,
_max_weight: u64,
_weight_credit: &mut u64,
instructions: &mut [Instruction<Call>],
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
if message.0.iter().any(|inst| {
if instructions.iter().any(|inst| {
matches!(
inst,
InitiateReserveWithdraw {
Expand Down Expand Up @@ -122,8 +104,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
parents: 1,
interior: Here
}
) && message
.0
) && instructions
.iter()
.any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
{
Expand Down
31 changes: 18 additions & 13 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_version: 11000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 5,
transaction_version: 6,
state_version: 0,
};

Expand Down Expand Up @@ -259,6 +259,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight<Self>;
type PriceForSiblingDelivery = ();
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
Expand All @@ -284,8 +285,6 @@ parameter_types! {

impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type UncleGenerations = UncleGenerations;
type FilterUncle = ();
type EventHandler = ParachainStaking;
}

Expand Down Expand Up @@ -742,7 +741,6 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::NonTransfer => matches!(
c,
RuntimeCall::Attestation(..)
| RuntimeCall::Authorship(..)
// Excludes `Balances`
| RuntimeCall::Council(..)
| RuntimeCall::Ctype(..)
Expand Down Expand Up @@ -787,7 +785,6 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
| attestation::Call::change_deposit_owner { .. }
| attestation::Call::update_deposit { .. }
)
| RuntimeCall::Authorship(..)
// Excludes `Balances`
| RuntimeCall::Council(..)
| RuntimeCall::Ctype(..)
Expand Down Expand Up @@ -936,7 +933,7 @@ construct_runtime! {
Aura: pallet_aura = 23,
Session: pallet_session = 22,
ParachainStaking: parachain_staking = 21,
Authorship: pallet_authorship::{Pallet, Call, Storage} = 20,
Authorship: pallet_authorship::{Pallet, Storage} = 20,
AuraExt: cumulus_pallet_aura_ext = 24,

// Governance stuff
Expand Down Expand Up @@ -1081,15 +1078,9 @@ pub type Executive = frame_executive::Executive<
pallet_did_lookup::migrations::EthereumMigration<Runtime>,
>;

// follows Substrate's non destructive way of eliminating otherwise required
// repetion: https://github.com/paritytech/substrate/pull/10592
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
// KILT
[attestation, Attestation]
[ctype, Ctype]
Expand Down Expand Up @@ -1118,6 +1109,7 @@ mod benches {
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_proxy, Proxy]
[pallet_xcm, PolkadotXcm]
);
}

Expand Down Expand Up @@ -1159,6 +1151,13 @@ impl_runtime_apis! {
fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_fee_details(uxt, len)
}

fn query_weight_to_fee(weight: Weight) -> Balance {
TransactionPayment::weight_to_fee(weight)
}
fn query_length_to_fee(length: u32) -> Balance {
TransactionPayment::length_to_fee(length)
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
Expand All @@ -1176,6 +1175,12 @@ impl_runtime_apis! {
) -> pallet_transaction_payment::FeeDetails<Balance> {
TransactionPayment::query_call_fee_details(call, len)
}
fn query_weight_to_fee(weight: Weight) -> Balance {
TransactionPayment::weight_to_fee(weight)
}
fn query_length_to_fee(length: u32) -> Balance {
TransactionPayment::length_to_fee(length)
}
}

impl sp_block_builder::BlockBuilder<Block> for Runtime {
Expand Down
1 change: 1 addition & 0 deletions runtimes/peregrine/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod pallet_web3_names;
pub mod pallet_xcm;
pub mod parachain_staking;
pub mod public_credentials;
Loading

0 comments on commit 38e33eb

Please sign in to comment.