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 import-queue-refact…
Browse files Browse the repository at this point in the history
…oring
  • Loading branch information
parity-processbot committed Dec 9, 2022
2 parents d26dde7 + f3847ea commit 3035931
Show file tree
Hide file tree
Showing 107 changed files with 1,877 additions and 1,817 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ variables:
- cargo +nightly --version
- bash --version
tags:
- linux-docker
- linux-docker-vm-c2

.kubernetes-env:
image: "${CI_IMAGE}"
Expand Down
545 changes: 267 additions & 278 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pallets/dmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use codec::{Decode, DecodeLimit, Encode};
use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler};
use frame_support::{
traits::EnsureOrigin,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};
pub use pallet::*;
use scale_info::TypeInfo;
Expand All @@ -52,8 +52,8 @@ impl Default for ConfigData {
fn default() -> Self {
Self {
max_individual: Weight::from_parts(
10u64 * WEIGHT_PER_MILLIS.ref_time(), // 10 ms of execution time maximum by default
DEFAULT_POV_SIZE, // 64 KB of proof size by default
10u64 * WEIGHT_REF_TIME_PER_MILLIS, // 10 ms of execution time maximum by default
DEFAULT_POV_SIZE, // 64 KB of proof size by default
),
}
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/dmp-queue/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{Config, Pallet, Store, DEFAULT_POV_SIZE};
use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};
use xcm::latest::Weight as XcmWeight;

Expand Down Expand Up @@ -51,7 +51,7 @@ mod v0 {

impl Default for ConfigData {
fn default() -> Self {
ConfigData { max_individual: 10u64 * WEIGHT_PER_MILLIS.ref_time() }
ConfigData { max_individual: 10u64 * WEIGHT_REF_TIME_PER_MILLIS }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use cumulus_primitives_core::{
};
use frame_support::{
traits::EnsureOrigin,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};
use rand_chacha::{
rand_core::{RngCore, SeedableRng},
Expand Down Expand Up @@ -464,7 +464,7 @@ impl Default for QueueConfigData {
threshold_weight: Weight::from_ref_time(100_000),
weight_restrict_decay: Weight::from_ref_time(2),
xcmp_max_individual_weight: Weight::from_parts(
20u64 * WEIGHT_PER_MILLIS.ref_time(),
20u64 * WEIGHT_REF_TIME_PER_MILLIS,
DEFAULT_POV_SIZE,
),
}
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 @@ -20,7 +20,7 @@ use crate::{Config, Pallet, Store, DEFAULT_POV_SIZE};
use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};
use xcm::latest::Weight as XcmWeight;

Expand Down Expand Up @@ -62,7 +62,7 @@ mod v1 {
resume_threshold: 1,
threshold_weight: 100_000,
weight_restrict_decay: 2,
xcmp_max_individual_weight: 20u64 * WEIGHT_PER_MILLIS.ref_time(),
xcmp_max_individual_weight: 20u64 * WEIGHT_REF_TIME_PER_MILLIS,
}
}
}
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 @@ -220,21 +220,24 @@ fn update_xcmp_max_individual_weight() {
let data: QueueConfigData = <QueueConfig<Test>>::get();
assert_eq!(
data.xcmp_max_individual_weight,
Weight::from_parts(20u64 * WEIGHT_PER_MILLIS.ref_time(), DEFAULT_POV_SIZE),
Weight::from_parts(20u64 * WEIGHT_REF_TIME_PER_MILLIS, DEFAULT_POV_SIZE),
);
assert_ok!(XcmpQueue::update_xcmp_max_individual_weight(
RuntimeOrigin::root(),
30u64 * WEIGHT_PER_MILLIS.ref_time()
30u64 * WEIGHT_REF_TIME_PER_MILLIS
));
assert_noop!(
XcmpQueue::update_xcmp_max_individual_weight(
RuntimeOrigin::signed(3),
10u64 * WEIGHT_PER_MILLIS.ref_time()
10u64 * WEIGHT_REF_TIME_PER_MILLIS
),
BadOrigin
);
let data: QueueConfigData = <QueueConfig<Test>>::get();

assert_eq!(data.xcmp_max_individual_weight, 30u64 * WEIGHT_PER_MILLIS);
assert_eq!(
data.xcmp_max_individual_weight,
Weight::from_ref_time(30u64 * WEIGHT_REF_TIME_PER_MILLIS)
);
});
}
9 changes: 5 additions & 4 deletions parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, ConstU8, Everything},
weights::{
constants::WEIGHT_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
PalletId,
Expand Down Expand Up @@ -217,9 +217,10 @@ 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
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64,
);

/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
Expand Down
7 changes: 4 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,8 @@ pub mod constants {

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

#[cfg(test)]
Expand All @@ -39,12 +40,12 @@ pub mod constants {

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

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

#[cfg(test)]
Expand All @@ -39,12 +40,12 @@ pub mod constants {

// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
Expand Down
12 changes: 6 additions & 6 deletions parachain-template/runtime/src/weights/paritydb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub mod constants {
/// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights
/// are available for brave runtime engineers who may want to try this out as default.
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(),
write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(),
read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}

Expand All @@ -42,20 +42,20 @@ pub mod constants {
fn sane() {
// At least 1 µs.
assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs."
);
assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs."
);
// At most 1 ms.
assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms."
);
assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms."
);
}
Expand Down
12 changes: 6 additions & 6 deletions parachain-template/runtime/src/weights/rocksdb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub mod constants {
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
/// the runtime.
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(),
write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(),
read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}

Expand All @@ -42,20 +42,20 @@ pub mod constants {
fn sane() {
// At least 1 µs.
assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs."
);
assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs."
);
// At most 1 ms.
assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms."
);
assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms."
);
}
Expand Down
9 changes: 5 additions & 4 deletions parachains/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod types {
/// Common constants of parachains.
mod constants {
use super::types::BlockNumber;
use frame_support::weights::{constants::WEIGHT_PER_SECOND, Weight};
use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
use sp_runtime::Perbill;
/// This determines the average expected block time that we are targeting. Blocks will be
/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by
Expand All @@ -92,9 +92,10 @@ 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
.saturating_div(2)
.set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64);
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
polkadot_primitives::v2::MAX_POV_SIZE as u64,
);
}

/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
Expand Down
8 changes: 4 additions & 4 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 9320,
spec_version: 9330,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 9,
transaction_version: 10,
state_version: 1,
};

Expand All @@ -101,10 +101,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 9320,
spec_version: 9330,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 9,
transaction_version: 10,
state_version: 0,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub mod constants {

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

#[cfg(test)]
Expand All @@ -39,12 +40,12 @@ pub mod constants {

// At least 100 µs.
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms."
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//! Autogenerated weights for `cumulus_pallet_xcmp_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-08-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! DATE: 2022-12-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024

// Executed Command:
Expand All @@ -34,7 +34,7 @@
// --repeat=20
// --json
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/statemine/src/weights
// --output=./parachains/runtimes/assets/statemine/src/weights/cumulus_pallet_xcmp_queue.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -48,13 +48,15 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> cumulus_pallet_xcmp_queue::WeightInfo for WeightInfo<T> {
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_u32() -> Weight {
Weight::from_ref_time(5_634_000 as u64)
// Minimum execution time: 7_953 nanoseconds.
Weight::from_ref_time(8_268_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_weight() -> Weight {
Weight::from_ref_time(5_559_000 as u64)
// Minimum execution time: 7_825 nanoseconds.
Weight::from_ref_time(8_190_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub mod constants {

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

#[cfg(test)]
Expand All @@ -39,12 +40,12 @@ pub mod constants {

// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
Expand Down
Loading

0 comments on commit 3035931

Please sign in to comment.