Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into temporary-malus
Browse files Browse the repository at this point in the history
* master:
  Companion for Generate storage info for pallet grandpa #9817 (#3892)
  add tracing to assignment criteria (#3886)
  Add benchmarking for parachain runtime paras pallet (#3888)
  companion for substrate#9788 (#3858)
  Substrate Companion for #9566 (#3704)
  • Loading branch information
ordian committed Sep 22, 2021
2 parents 5f55ac1 + 6ce805b commit 819ac1c
Show file tree
Hide file tree
Showing 23 changed files with 781 additions and 176 deletions.
315 changes: 161 additions & 154 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ impl pallet_grandpa::Config for Runtime {
type HandleEquivocation = ();
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
}

parameter_types! {
Expand Down
19 changes: 18 additions & 1 deletion node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ pub(crate) fn compute_assignments(
config.assignment_keys.is_empty() ||
config.validator_groups.is_empty()
{
tracing::trace!(
target: LOG_TARGET,
n_cores = config.n_cores,
has_assignment_keys = !config.assignment_keys.is_empty(),
has_validator_groups = !config.validator_groups.is_empty(),
"Not producing assignments because config is degenerate",
);

return HashMap::new()
}

Expand All @@ -254,7 +262,10 @@ pub(crate) fn compute_assignments(
});

match key {
None => return Default::default(),
None => {
tracing::trace!(target: LOG_TARGET, "No assignment key");
return Default::default()
},
Some(k) => k,
}
};
Expand All @@ -266,6 +277,12 @@ pub(crate) fn compute_assignments(
.map(|(c_hash, core, _)| (c_hash, core))
.collect::<Vec<_>>();

tracing::trace!(
target: LOG_TARGET,
assignable_cores = leaving_cores.len(),
"Assigning to candidates from different backing groups"
);

let assignments_key: &sp_application_crypto::sr25519::Pair = assignments_key.as_ref();
let assignments_key: &schnorrkel::Keypair = assignments_key.as_ref();

Expand Down
7 changes: 7 additions & 0 deletions primitives/src/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ pub const ASSIGNMENT_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"asgn");
/// * when detecting a code decompression bomb in the client
pub const MAX_CODE_SIZE: u32 = 3 * 1024 * 1024;

/// Maximum head data size we support right now.
///
/// Used for:
/// * initial genesis for the Parachains configuration
/// * checking updates to this stored runtime configuration do not exceed this limit
pub const MAX_HEAD_DATA_SIZE: u32 = 1 * 1024 * 1024;

/// Maximum PoV size we support right now.
///
/// Used for:
Expand Down
1 change: 1 addition & 0 deletions runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl shared::Config for Test {}
impl paras::Config for Test {
type Origin = Origin;
type Event = Event;
type WeightInfo = paras::weights::WeightInfo<Test>;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ mod tests {
impl paras::Config for Test {
type Origin = Origin;
type Event = Event;
type WeightInfo = paras::weights::WeightInfo<Test>;
}

impl configuration::Config for Test {
Expand Down
51 changes: 48 additions & 3 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ impl pallet_grandpa::Config for Runtime {
>;

type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
}

/// Submits transaction with the node's public and signature type. Adheres to the signed extension
Expand Down Expand Up @@ -1149,6 +1150,7 @@ impl parachains_inclusion::Config for Runtime {
impl parachains_paras::Config for Runtime {
type Origin = Origin;
type Event = Event;
type WeightInfo = weights::runtime_parachains_paras::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -1555,12 +1557,50 @@ pub type Executive = frame_executive::Executive<
TechnicalCommitteeStoragePrefixMigration,
TechnicalMembershipStoragePrefixMigration,
MigrateTipsPalletPrefix,
BountiesPrefixMigration,
StakingBagsListMigrationV8,
),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

const BOUNTIES_OLD_PREFIX: &str = "Treasury";

/// Migrate from 'Treasury' to the new prefix 'Bounties'
pub struct BountiesPrefixMigration;

impl OnRuntimeUpgrade for BountiesPrefixMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::migrate::<Runtime, Bounties, _>(BOUNTIES_OLD_PREFIX, name)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::pre_migration::<Runtime, Bounties, _>(
BOUNTIES_OLD_PREFIX,
name,
);
Ok(())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Bounties>()
.expect("Bounties is part of runtime, so it has a name; qed");
pallet_bounties::migrations::v4::post_migration::<Runtime, Bounties, _>(
BOUNTIES_OLD_PREFIX,
name,
);
Ok(())
}
}

const COUNCIL_OLD_PREFIX: &str = "Instance1Collective";
/// Migrate from `Instance1Collective` to the new pallet prefix `Council`
pub struct CouncilStoragePrefixMigration;
Expand Down Expand Up @@ -1978,10 +2018,13 @@ sp_api::impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
fn on_runtime_upgrade() -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade kusama.");
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)
}
}

Expand Down Expand Up @@ -2009,6 +2052,7 @@ sp_api::impl_runtime_apis! {
list_benchmark!(list, extra, runtime_common::slots, Slots);
list_benchmark!(list, extra, runtime_common::paras_registrar, Registrar);
list_benchmark!(list, extra, runtime_parachains::configuration, Configuration);
list_benchmark!(list, extra, runtime_parachains::paras, Paras);
// Substrate
list_benchmark!(list, extra, pallet_bags_list, BagsList);
list_benchmark!(list, extra, pallet_balances, Balances);
Expand Down Expand Up @@ -2084,6 +2128,7 @@ sp_api::impl_runtime_apis! {
add_benchmark!(params, batches, runtime_common::slots, Slots);
add_benchmark!(params, batches, runtime_common::paras_registrar, Registrar);
add_benchmark!(params, batches, runtime_parachains::configuration, Configuration);
add_benchmark!(params, batches, runtime_parachains::paras, Paras);
// Substrate
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_bags_list, BagsList);
Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ pub mod runtime_common_crowdloan;
pub mod runtime_common_paras_registrar;
pub mod runtime_common_slots;
pub mod runtime_parachains_configuration;
pub mod runtime_parachains_paras;
106 changes: 106 additions & 0 deletions runtime/kusama/src/weights/runtime_parachains_paras.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `runtime_parachains::paras`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-09-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128

// Executed Command:
// target/release/polkadot
// benchmark
// --chain=kusama-dev
// --steps=50
// --repeat=20
// --pallet=runtime_parachains::paras
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/runtime_parachains_paras.rs


#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for `runtime_parachains::paras`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::paras::WeightInfo for WeightInfo<T> {
// Storage: Paras CurrentCodeHash (r:1 w:1)
// Storage: Paras CodeByHashRefs (r:1 w:1)
// Storage: Paras PastCodeMeta (r:1 w:1)
// Storage: Paras PastCodePruning (r:1 w:1)
// Storage: Paras PastCodeHash (r:0 w:1)
// Storage: Paras CodeByHash (r:0 w:1)
fn force_set_current_code(c: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 0
.saturating_add((3_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Paras Heads (r:0 w:1)
fn force_set_current_head(s: u32, ) -> Weight {
(16_088_000 as Weight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: Paras FutureCodeUpgrades (r:1 w:1)
// Storage: Paras UpcomingUpgrades (r:1 w:1)
// Storage: Paras UpgradeCooldowns (r:1 w:1)
// Storage: System Digest (r:1 w:1)
// Storage: Paras CodeByHashRefs (r:1 w:1)
// Storage: Paras CodeByHash (r:0 w:1)
// Storage: Paras FutureCodeHash (r:0 w:1)
// Storage: Paras UpgradeRestrictionSignal (r:0 w:1)
fn force_schedule_code_upgrade(c: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 0
.saturating_add((3_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
// Storage: Paras FutureCodeUpgrades (r:1 w:1)
// Storage: Paras FutureCodeHash (r:1 w:1)
// Storage: Paras CurrentCodeHash (r:1 w:1)
// Storage: System Digest (r:1 w:1)
// Storage: Paras PastCodeMeta (r:1 w:1)
// Storage: Paras PastCodePruning (r:1 w:1)
// Storage: Paras Heads (r:0 w:1)
// Storage: Paras PastCodeHash (r:0 w:1)
// Storage: Paras UpgradeGoAheadSignal (r:0 w:1)
fn force_note_new_head(s: u32, ) -> Weight {
(69_114_000 as Weight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(9 as Weight))
}
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
// Storage: Paras ActionsQueue (r:1 w:1)
fn force_queue_action() -> Weight {
(26_752_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
10 changes: 9 additions & 1 deletion runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::shared;
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_PER_MILLIS};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE};
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE};
use sp_runtime::traits::Zero;
use sp_std::prelude::*;

Expand Down Expand Up @@ -256,6 +256,13 @@ impl<BlockNumber: Zero> HostConfiguration<BlockNumber> {
)
}

if self.max_head_data_size > MAX_HEAD_DATA_SIZE {
panic!(
"`max_head_data_size` ({}) is bigger than allowed by the client ({})",
self.max_head_data_size, MAX_HEAD_DATA_SIZE
)
}

if self.max_pov_size > MAX_POV_SIZE {
panic!("`max_pov_size` is bigger than allowed by the client")
}
Expand Down Expand Up @@ -390,6 +397,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::set_config_with_u32())]
pub fn set_max_head_data_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_HEAD_DATA_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_head_data_size, new) != new
});
Expand Down
5 changes: 3 additions & 2 deletions runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ impl fmt::Debug for OutboundHrmpAcceptanceErr {
"more HRMP messages than permitted by config ({} > {})",
sent, permitted,
),
NotSorted { idx } =>
write!(fmt, "the HRMP messages are not sorted (first unsorted is at index {})", idx,),
NotSorted { idx } => {
write!(fmt, "the HRMP messages are not sorted (first unsorted is at index {})", idx,)
},
NoSuchChannel { idx, channel_id } => write!(
fmt,
"the HRMP message at index {} is sent to a non existent channel {:?}->{:?}",
Expand Down
1 change: 1 addition & 0 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl crate::shared::Config for Test {}
impl crate::paras::Config for Test {
type Origin = Origin;
type Event = Event;
type WeightInfo = crate::paras::weights::WeightInfo<Test>;
}

impl crate::dmp::Config for Test {}
Expand Down
Loading

0 comments on commit 819ac1c

Please sign in to comment.