Skip to content

Commit

Permalink
get rid of obsolete weight functions (#1926)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Mar 2, 2023
1 parent 9b3b00e commit 4161b51
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 105 deletions.
16 changes: 4 additions & 12 deletions .maintain/millau-weight-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds.
{{#if (ne benchmark.base_calculated_proof_size "0")}}
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
{{else}}
Weight::from_ref_time({{underscore benchmark.base_weight}})
{{/if}}
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into()))
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
Expand All @@ -91,7 +87,7 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into()))
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
}
{{/each}}
Expand All @@ -117,14 +113,10 @@ impl WeightInfo for () {
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds.
{{#if (ne benchmark.base_calculated_proof_size "0")}}
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
{{else}}
Weight::from_ref_time({{underscore benchmark.base_weight}})
{{/if}}
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into()))
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}_u64))
Expand All @@ -139,7 +131,7 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into()))
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
}
{{/each}}
Expand Down
6 changes: 4 additions & 2 deletions bin/runtime-common/src/refund_relayer_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,9 @@ mod tests {

fn dispatch_info() -> DispatchInfo {
DispatchInfo {
weight: Weight::from_ref_time(
weight: Weight::from_parts(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND,
0,
),
class: frame_support::dispatch::DispatchClass::Normal,
pays_fee: frame_support::dispatch::Pays::Yes,
Expand Down Expand Up @@ -1037,8 +1038,9 @@ mod tests {
initialize_environment(200, 200, [1u8; 32].into(), 200);

let mut dispatch_info = dispatch_info();
dispatch_info.weight = Weight::from_ref_time(
dispatch_info.weight = Weight::from_parts(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2,
0,
);

// without any size/weight refund: we expect regular reward
Expand Down
2 changes: 1 addition & 1 deletion modules/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub mod pallet {
fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight {
<RequestCount<T, I>>::mutate(|count| *count = count.saturating_sub(1));

Weight::from_ref_time(0)
Weight::from_parts(0, 0)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand Down
2 changes: 1 addition & 1 deletion modules/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ construct_runtime! {
}

parameter_types! {
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
Expand Down
2 changes: 1 addition & 1 deletion modules/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ construct_runtime! {
}

parameter_types! {
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
Expand Down
26 changes: 13 additions & 13 deletions modules/grandpa/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Autogenerated weights for pallet_bridge_grandpa
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
Expand Down Expand Up @@ -100,12 +100,12 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `394 + p * (60 ±0)`
// Estimated: `4745`
// Minimum execution time: 221_810 nanoseconds.
Weight::from_parts(33_157_392, 4745)
// Standard Error: 109_045
.saturating_add(Weight::from_ref_time(41_100_656).saturating_mul(p.into()))
// Standard Error: 7_754
.saturating_add(Weight::from_ref_time(1_534_466).saturating_mul(v.into()))
// Minimum execution time: 228_072 nanoseconds.
Weight::from_parts(57_853_228, 4745)
// Standard Error: 149_421
.saturating_add(Weight::from_parts(36_708_702, 0).saturating_mul(p.into()))
// Standard Error: 10_625
.saturating_add(Weight::from_parts(1_469_032, 0).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
Expand Down Expand Up @@ -155,12 +155,12 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `394 + p * (60 ±0)`
// Estimated: `4745`
// Minimum execution time: 221_810 nanoseconds.
Weight::from_parts(33_157_392, 4745)
// Standard Error: 109_045
.saturating_add(Weight::from_ref_time(41_100_656).saturating_mul(p.into()))
// Standard Error: 7_754
.saturating_add(Weight::from_ref_time(1_534_466).saturating_mul(v.into()))
// Minimum execution time: 228_072 nanoseconds.
Weight::from_parts(57_853_228, 4745)
// Standard Error: 149_421
.saturating_add(Weight::from_parts(36_708_702, 0).saturating_mul(p.into()))
// Standard Error: 10_625
.saturating_add(Weight::from_parts(1_469_032, 0).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
Expand Down
6 changes: 3 additions & 3 deletions modules/messages/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ frame_support::construct_runtime! {

parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
Expand Down Expand Up @@ -410,7 +410,7 @@ pub const fn message_payload(id: u64, declared_weight: u64) -> TestPayload {
TestPayload {
id,
reject_by_lane_verifier: false,
declared_weight: Weight::from_ref_time(declared_weight),
declared_weight: Weight::from_parts(declared_weight, 0),
dispatch_result: dispatch_result(0),
extra: Vec::new(),
}
Expand All @@ -421,7 +421,7 @@ pub const fn dispatch_result(
unspent_weight: u64,
) -> MessageDispatchResult<TestDispatchLevelResult> {
MessageDispatchResult {
unspent_weight: Weight::from_ref_time(unspent_weight),
unspent_weight: Weight::from_parts(unspent_weight, 0),
dispatch_level_result: (),
}
}
Expand Down
74 changes: 37 additions & 37 deletions modules/messages/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

//! Autogenerated weights for pallet_bridge_messages
//! Autogenerated weights for RialtoMessages
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-03-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
Expand All @@ -29,7 +29,7 @@
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_bridge_messages
// --pallet=RialtoMessages
// --extrinsic=*
// --execution=wasm
// --wasm-execution=Compiled
Expand All @@ -48,7 +48,7 @@ use frame_support::{
};
use sp_std::marker::PhantomData;

/// Weight functions needed for pallet_bridge_messages.
/// Weight functions needed for RialtoMessages.
pub trait WeightInfo {
fn receive_single_message_proof() -> Weight;
fn receive_two_messages_proof() -> Weight;
Expand All @@ -60,7 +60,7 @@ pub trait WeightInfo {
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight;
}

/// Weights for `pallet_bridge_messages` that are generated using one of the Bridge testnets.
/// Weights for `RialtoMessages` that are generated using one of the Bridge testnets.
///
/// Those weights are test only and must never be used in production.
pub struct BridgeWeight<T>(PhantomData<T>);
Expand Down Expand Up @@ -88,8 +88,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 48_426 nanoseconds.
Weight::from_parts(50_113_000, 54703)
// Minimum execution time: 48_058 nanoseconds.
Weight::from_parts(50_422_000, 54703)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -116,8 +116,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 59_739 nanoseconds.
Weight::from_parts(61_704_000, 54703)
// Minimum execution time: 59_371 nanoseconds.
Weight::from_parts(61_726_000, 54703)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -144,8 +144,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 53_760 nanoseconds.
Weight::from_parts(55_645_000, 54703)
// Minimum execution time: 53_398 nanoseconds.
Weight::from_parts(54_351_000, 54703)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -167,8 +167,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 49_582 nanoseconds.
Weight::from_parts(51_250_000, 54200)
// Minimum execution time: 50_064 nanoseconds.
Weight::from_parts(51_306_000, 54200)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -190,8 +190,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 76_418 nanoseconds.
Weight::from_parts(77_877_000, 54200)
// Minimum execution time: 75_403 nanoseconds.
Weight::from_parts(77_006_000, 54200)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -218,8 +218,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `579`
// Estimated: `5624`
// Minimum execution time: 41_795 nanoseconds.
Weight::from_parts(43_683_000, 5624)
// Minimum execution time: 41_670 nanoseconds.
Weight::from_parts(42_863_000, 5624)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -246,8 +246,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `5624`
// Minimum execution time: 39_946 nanoseconds.
Weight::from_parts(41_509_000, 5624)
// Minimum execution time: 40_928 nanoseconds.
Weight::from_parts(42_165_000, 5624)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -274,8 +274,8 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `8164`
// Minimum execution time: 42_882 nanoseconds.
Weight::from_parts(44_367_000, 8164)
// Minimum execution time: 44_022 nanoseconds.
Weight::from_parts(44_657_000, 8164)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand Down Expand Up @@ -306,8 +306,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 48_426 nanoseconds.
Weight::from_parts(50_113_000, 54703)
// Minimum execution time: 48_058 nanoseconds.
Weight::from_parts(50_422_000, 54703)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -334,8 +334,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 59_739 nanoseconds.
Weight::from_parts(61_704_000, 54703)
// Minimum execution time: 59_371 nanoseconds.
Weight::from_parts(61_726_000, 54703)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -362,8 +362,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `54703`
// Minimum execution time: 53_760 nanoseconds.
Weight::from_parts(55_645_000, 54703)
// Minimum execution time: 53_398 nanoseconds.
Weight::from_parts(54_351_000, 54703)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -385,8 +385,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 49_582 nanoseconds.
Weight::from_parts(51_250_000, 54200)
// Minimum execution time: 50_064 nanoseconds.
Weight::from_parts(51_306_000, 54200)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -408,8 +408,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `618`
// Estimated: `54200`
// Minimum execution time: 76_418 nanoseconds.
Weight::from_parts(77_877_000, 54200)
// Minimum execution time: 75_403 nanoseconds.
Weight::from_parts(77_006_000, 54200)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -436,8 +436,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `579`
// Estimated: `5624`
// Minimum execution time: 41_795 nanoseconds.
Weight::from_parts(43_683_000, 5624)
// Minimum execution time: 41_670 nanoseconds.
Weight::from_parts(42_863_000, 5624)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -464,8 +464,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `5624`
// Minimum execution time: 39_946 nanoseconds.
Weight::from_parts(41_509_000, 5624)
// Minimum execution time: 40_928 nanoseconds.
Weight::from_parts(42_165_000, 5624)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -492,8 +492,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `596`
// Estimated: `8164`
// Minimum execution time: 42_882 nanoseconds.
Weight::from_parts(44_367_000, 8164)
// Minimum execution time: 44_022 nanoseconds.
Weight::from_parts(44_657_000, 8164)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand Down
2 changes: 1 addition & 1 deletion modules/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ construct_runtime! {

parameter_types! {
pub const BlockHashCount: TestNumber = 250;
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
Expand Down
Loading

0 comments on commit 4161b51

Please sign in to comment.