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

Commit

Permalink
Merge remote-tracking branch 'origin/master' into bkchr-fix-benchmark…
Browse files Browse the repository at this point in the history
…ing-companion
  • Loading branch information
parity-processbot committed Sep 2, 2022
2 parents 8bf3030 + 9faf9b1 commit 384d30a
Show file tree
Hide file tree
Showing 94 changed files with 2,500 additions and 605 deletions.
504 changes: 256 additions & 248 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pallets/aura-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ std = [
"sp-runtime/std",
"sp-std/std",
]
try-runtime = ["frame-support/try-runtime"]
26 changes: 10 additions & 16 deletions pallets/collator-selection/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
Weight::from_ref_time(18_563_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add(
Weight::from_ref_time(68_000 as RefTimeWeight)
.scalar_saturating_mul(b as RefTimeWeight),
Weight::from_ref_time(68_000 as RefTimeWeight).saturating_mul(b as RefTimeWeight),
)
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
Expand All @@ -59,8 +58,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
Weight::from_ref_time(71_196_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add(
Weight::from_ref_time(198_000 as RefTimeWeight)
.scalar_saturating_mul(c as RefTimeWeight),
Weight::from_ref_time(198_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight),
)
.saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight))
Expand All @@ -69,8 +67,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
Weight::from_ref_time(55_336_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add(
Weight::from_ref_time(151_000 as RefTimeWeight)
.scalar_saturating_mul(c as RefTimeWeight),
Weight::from_ref_time(151_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight),
)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight))
Expand All @@ -85,12 +82,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Standard Error: 1_010_000
.saturating_add(
Weight::from_ref_time(109_961_000 as RefTimeWeight)
.scalar_saturating_mul(r as RefTimeWeight),
.saturating_mul(r as RefTimeWeight),
)
// Standard Error: 1_010_000
.saturating_add(
Weight::from_ref_time(151_952_000 as RefTimeWeight)
.scalar_saturating_mul(c as RefTimeWeight),
.saturating_mul(c as RefTimeWeight),
)
.saturating_add(
T::DbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight)),
Expand All @@ -113,8 +110,7 @@ impl WeightInfo for () {
Weight::from_ref_time(18_563_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add(
Weight::from_ref_time(68_000 as RefTimeWeight)
.scalar_saturating_mul(b as RefTimeWeight),
Weight::from_ref_time(68_000 as RefTimeWeight).saturating_mul(b as RefTimeWeight),
)
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
}
Expand All @@ -130,8 +126,7 @@ impl WeightInfo for () {
Weight::from_ref_time(71_196_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add(
Weight::from_ref_time(198_000 as RefTimeWeight)
.scalar_saturating_mul(c as RefTimeWeight),
Weight::from_ref_time(198_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight),
)
.saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight))
Expand All @@ -140,8 +135,7 @@ impl WeightInfo for () {
Weight::from_ref_time(55_336_000 as RefTimeWeight)
// Standard Error: 0
.saturating_add(
Weight::from_ref_time(151_000 as RefTimeWeight)
.scalar_saturating_mul(c as RefTimeWeight),
Weight::from_ref_time(151_000 as RefTimeWeight).saturating_mul(c as RefTimeWeight),
)
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight))
Expand All @@ -156,12 +150,12 @@ impl WeightInfo for () {
// Standard Error: 1_010_000
.saturating_add(
Weight::from_ref_time(109_961_000 as RefTimeWeight)
.scalar_saturating_mul(r as RefTimeWeight),
.saturating_mul(r as RefTimeWeight),
)
// Standard Error: 1_010_000
.saturating_add(
Weight::from_ref_time(151_952_000 as RefTimeWeight)
.scalar_saturating_mul(c as RefTimeWeight),
.saturating_mul(c as RefTimeWeight),
)
.saturating_add(
RocksDbWeight::get().reads((1 as RefTimeWeight).saturating_mul(r as RefTimeWeight)),
Expand Down
1 change: 1 addition & 0 deletions pallets/dmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ std = [
"xcm/std",
"cumulus-primitives-core/std",
]
try-runtime = ["frame-support/try-runtime"]
4 changes: 2 additions & 2 deletions pallets/dmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct ConfigData {
impl Default for ConfigData {
fn default() -> Self {
Self {
max_individual: 10 * WEIGHT_PER_MILLIS, // 10 ms of execution time maximum by default
max_individual: 10u64 * WEIGHT_PER_MILLIS, // 10 ms of execution time maximum by default
}
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ pub mod pallet {
/// Exactly equivalent to `service_queue` but expects a mutable `page_index` to be passed
/// in and any changes stored.
fn do_service_queue(limit: Weight, page_index: &mut PageIndexData) -> Weight {
let mut used = Weight::new();
let mut used = Weight::zero();
while page_index.begin_used < page_index.end_used {
let page = Pages::<T>::take(page_index.begin_used);
for (i, &(sent_at, ref data)) in page.iter().enumerate() {
Expand Down
2 changes: 2 additions & 0 deletions pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ std = [
runtime-benchmarks = [
"sp-runtime/runtime-benchmarks"
]

try-runtime = ["frame-support/try-runtime"]
4 changes: 2 additions & 2 deletions pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub mod pallet {
}

fn on_initialize(_n: T::BlockNumber) -> Weight {
let mut weight = Weight::new();
let mut weight = Weight::zero();

// To prevent removing `NewValidationCode` that was set by another `on_initialize`
// like for example from scheduler, we only kill the storage entry if it was not yet
Expand Down Expand Up @@ -808,7 +808,7 @@ impl<T: Config> Pallet<T> {
let dm_count = downward_messages.len() as u32;
let mut dmq_head = <LastDmqMqcHead<T>>::get();

let mut weight_used = Weight::new();
let mut weight_used = Weight::zero();
if dm_count != 0 {
Self::deposit_event(Event::DownwardMessagesReceived { count: dm_count });
let max_weight =
Expand Down
2 changes: 1 addition & 1 deletion pallets/parachain-system/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

/// Call this during the next runtime upgrade for this module.
pub fn on_runtime_upgrade<T: Config>() -> Weight {
let mut weight: Weight = Weight::new();
let mut weight: Weight = Weight::zero();

if StorageVersion::get::<Pallet<T>>() == 0 {
weight = weight
Expand Down
1 change: 1 addition & 0 deletions pallets/solo-to-para/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ std = [
"sp-runtime/std",
"sp-std/std",
]
try-runtime = ["frame-support/try-runtime"]
1 change: 1 addition & 0 deletions pallets/xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ std = [
"frame-support/std",
"frame-system/std",
]
try-runtime = ["frame-support/try-runtime"]
4 changes: 2 additions & 2 deletions pallets/xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
limit: Weight,
) -> Weight {
let mut used = Weight::new();
let mut used = Weight::zero();
for (_sent_at, data) in iter {
let id = sp_io::hashing::twox_64(&data[..]);
let msg = VersionedXcm::<T::Call>::decode_all_with_depth_limit(
Expand Down Expand Up @@ -144,7 +144,7 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
limit: Weight,
) -> Weight {
let mut used = Weight::new();
let mut used = Weight::zero();
for (_sent_at, data) in iter {
let id = sp_io::hashing::twox_64(&data[..]);
let msg = VersionedXcm::<T::Call>::decode_all_with_depth_limit(
Expand Down
1 change: 1 addition & 0 deletions pallets/xcmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
6 changes: 3 additions & 3 deletions pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl Default for QueueConfigData {
resume_threshold: 1,
threshold_weight: Weight::from_ref_time(100_000),
weight_restrict_decay: Weight::from_ref_time(2),
xcmp_max_individual_weight: 20 * WEIGHT_PER_MILLIS,
xcmp_max_individual_weight: 20u64 * WEIGHT_PER_MILLIS,
}
}
}
Expand Down Expand Up @@ -795,8 +795,8 @@ impl<T: Config> Pallet<T> {
} = <QueueConfig<T>>::get();

let mut shuffled = Self::create_shuffle(status.len());
let mut weight_used = Weight::new();
let mut weight_available = Weight::new();
let mut weight_used = Weight::zero();
let mut weight_available = Weight::zero();

// We don't want the possibility of a chain sending a series of really heavy messages and
// tying up the block's execution time from other chains. Therefore we execute any remaining
Expand Down
4 changes: 2 additions & 2 deletions pallets/xcmp-queue/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
/// Migrates the pallet storage to the most recent version, checking and setting the
/// `StorageVersion`.
pub fn migrate_to_latest<T: Config>() -> Weight {
let mut weight = Weight::new();
let mut weight = Weight::zero();

if StorageVersion::get::<Pallet<T>>() == 0 {
weight += migrate_to_v1::<T>();
Expand Down Expand Up @@ -103,7 +103,7 @@ mod tests {
drop_threshold: 12,
resume_threshold: 3,
threshold_weight: Weight::from_ref_time(333_333),
weight_restrict_decay: Weight::one(),
weight_restrict_decay: Weight::from_ref_time(1),
};

new_test_ext().execute_with(|| {
Expand Down
11 changes: 7 additions & 4 deletions pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,20 @@ fn update_weight_restrict_decay_works() {
fn update_xcmp_max_individual_weight() {
new_test_ext().execute_with(|| {
let data: QueueConfigData = <QueueConfig<Test>>::get();
assert_eq!(data.xcmp_max_individual_weight, 20 * WEIGHT_PER_MILLIS);
assert_eq!(data.xcmp_max_individual_weight, 20u64 * WEIGHT_PER_MILLIS);
assert_ok!(XcmpQueue::update_xcmp_max_individual_weight(
Origin::root(),
30 * WEIGHT_PER_MILLIS
30u64 * WEIGHT_PER_MILLIS
));
assert_noop!(
XcmpQueue::update_xcmp_max_individual_weight(Origin::signed(3), 10 * WEIGHT_PER_MILLIS),
XcmpQueue::update_xcmp_max_individual_weight(
Origin::signed(3),
10u64 * WEIGHT_PER_MILLIS
),
BadOrigin
);
let data: QueueConfigData = <QueueConfig<Test>>::get();

assert_eq!(data.xcmp_max_individual_weight, 30 * WEIGHT_PER_MILLIS);
assert_eq!(data.xcmp_max_individual_weight, 30u64 * WEIGHT_PER_MILLIS);
});
}
17 changes: 17 additions & 0 deletions parachain-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ runtime-benchmarks = [
]

try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
"cumulus-pallet-parachain-system/try-runtime",
"cumulus-pallet-xcm/try-runtime",
"cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-template/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
]
17 changes: 12 additions & 5 deletions parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 0.5 of a second of compute with a 12 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.scalar_div(2);
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2);

/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
Expand Down Expand Up @@ -363,8 +363,8 @@ impl pallet_transaction_payment::Config for Runtime {
}

parameter_types! {
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.scalar_div(4);
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.scalar_div(4);
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
}

impl cumulus_pallet_parachain_system::Config for Runtime {
Expand Down Expand Up @@ -644,8 +644,15 @@ impl_runtime_apis! {
(weight, RuntimeBlockWeights::get().max_block)
}

fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::parachain-template", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
}
}

Expand Down
9 changes: 6 additions & 3 deletions parachain-template/runtime/src/weights/block_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod constants {

parameter_types! {
/// Importing a block with 0 Extrinsics.
pub const BlockExecutionWeight: Weight = constants::WEIGHT_PER_NANOS.scalar_saturating_mul(5_000_000);
pub const BlockExecutionWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(5_000_000);
}

#[cfg(test)]
Expand All @@ -38,9 +38,12 @@ pub mod constants {
let w = super::constants::BlockExecutionWeight::get();

// At least 100 µs.
assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs.");
assert!(
w >= 100u64 * constants::WEIGHT_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms.");
assert!(w <= 50u64 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms.");
}
}
}
4 changes: 2 additions & 2 deletions parachain-template/runtime/src/weights/extrinsic_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod constants {

parameter_types! {
/// Executing a NO-OP `System::remarks` Extrinsic.
pub const ExtrinsicBaseWeight: Weight = constants::WEIGHT_PER_NANOS.scalar_saturating_mul(125_000);
pub const ExtrinsicBaseWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(125_000);
}

#[cfg(test)]
Expand All @@ -38,7 +38,7 @@ pub mod constants {
let w = super::constants::ExtrinsicBaseWeight::get();

// At least 10 µs.
assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs.");
assert!(w >= 10u64 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs.");
// At most 1 ms.
assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms.");
}
Expand Down
2 changes: 1 addition & 1 deletion parachains/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod constants {
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 0.5 seconds of compute with a 6 second average block time.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.scalar_div(2);
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2);
}

/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
Expand Down
1 change: 1 addition & 0 deletions parachains/pallets/parachain-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ std = [
"frame-support/std",
"frame-system/std",
]
try-runtime = ["frame-support/try-runtime"]
Loading

0 comments on commit 384d30a

Please sign in to comment.