Skip to content

Commit

Permalink
Add millau specific messages weights (#2097)
Browse files Browse the repository at this point in the history
* refactor weights a bit

* post cherry-pick fixes

* do not run spellcheck on new weight files

* fix
  • Loading branch information
svyatonik authored May 1, 2023
1 parent 6ad0bd1 commit ae44c6b
Show file tree
Hide file tree
Showing 14 changed files with 461 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ spellcheck:
<<: *docker-env
<<: *test-refs
script:
- cargo spellcheck check --cfg=.config/spellcheck.toml --checkers hunspell -m 1 $(find . -type f -name '*.rs' ! -path "./target/*" ! -name 'codegen_runtime.rs' ! -name 'weights.rs')
- cargo spellcheck check --cfg=.config/spellcheck.toml --checkers hunspell -m 1 $(find . -type f -name '*.rs' ! -path "./target/*" ! -path "./bin/millau/runtime/src/weights/*" ! -name 'codegen_runtime.rs' ! -name 'weights.rs')

check:
stage: test
Expand Down
File renamed without changes.
57 changes: 22 additions & 35 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod rialto_messages;
pub mod rialto_parachain_messages;
pub mod weights;
pub mod xcm_config;

use bp_parachains::SingleParaStoredHeaderDataBuilder;
Expand Down Expand Up @@ -442,7 +443,7 @@ pub type WithRialtoMessagesInstance = ();

impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_bridge_messages::weights::BridgeWeight<Runtime>;
type WeightInfo = weights::RialtoMessagesWeightInfo<Runtime>;
type ActiveOutboundLanes = RialtoActiveOutboundLanes;
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;
Expand Down Expand Up @@ -472,7 +473,7 @@ pub type WithRialtoParachainMessagesInstance = pallet_bridge_messages::Instance1

impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_bridge_messages::weights::BridgeWeight<Runtime>;
type WeightInfo = weights::RialtoParachainMessagesWeightInfo<Runtime>;
type ActiveOutboundLanes = RialtoParachainActiveOutboundLanes;
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;
Expand Down Expand Up @@ -598,7 +599,7 @@ generate_bridge_reject_obsolete_headers_and_messages! {

bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs);
/// Signed extension that refunds relayers that are delivering messages from the Rialto parachain.
pub type PriorityBoostPerMessage = ConstU64<921_900_294>;
pub type PriorityBoostPerMessage = ConstU64<699_683_285>;
pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages<
Runtime,
RefundableParachain<WithRialtoParachainsInstance, RialtoParachainId>,
Expand Down Expand Up @@ -647,6 +648,17 @@ pub type Executive = frame_executive::Executive<
AllPalletsWithSystem,
>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
[pallet_bridge_messages, MessagesBench::<Runtime, WithRialtoMessagesInstance>]
[pallet_bridge_messages, MessagesBench::<Runtime, WithRialtoParachainMessagesInstance>]
[pallet_bridge_grandpa, BridgeRialtoGrandpa]
[pallet_bridge_parachains, ParachainsBench::<Runtime, WithRialtoParachainsInstance>]
[pallet_bridge_relayers, RelayersBench::<Runtime>]
);
}

impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
Expand Down Expand Up @@ -954,30 +966,24 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>,
) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;

use pallet_bridge_messages::benchmarking::Pallet as MessagesBench;
use pallet_bridge_parachains::benchmarking::Pallet as ParachainsBench;
use pallet_bridge_relayers::benchmarking::Pallet as RelayersBench;

let mut list = Vec::<BenchmarkList>::new();

list_benchmark!(list, extra, RialtoParachainMessages, MessagesBench::<Runtime, WithRialtoParachainMessagesInstance>);
list_benchmark!(list, extra, RialtoMessages, MessagesBench::<Runtime, WithRialtoMessagesInstance>);
list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeRialtoGrandpa);
list_benchmark!(list, extra, pallet_bridge_parachains, ParachainsBench::<Runtime, WithRialtoParachainsInstance>);
list_benchmark!(list, extra, pallet_bridge_relayers, RelayersBench::<Runtime>);
list_benchmarks!(list, extra);

let storage_info = AllPalletsWithSystem::storage_info();

return (list, storage_info)
}

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig,
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
Expand All @@ -992,9 +998,6 @@ impl_runtime_apis! {
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec().into(),
];

let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

use bridge_runtime_common::messages_benchmarking::{
prepare_message_delivery_proof_from_grandpa_chain,
prepare_message_delivery_proof_from_parachain,
Expand Down Expand Up @@ -1125,26 +1128,10 @@ impl_runtime_apis! {
}
}

add_benchmark!(
params,
batches,
RialtoParachainMessages,
MessagesBench::<Runtime, WithRialtoParachainMessagesInstance>
);
add_benchmark!(
params,
batches,
RialtoMessages,
MessagesBench::<Runtime, WithRialtoMessagesInstance>
);
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeRialtoGrandpa);
add_benchmark!(
params,
batches,
pallet_bridge_parachains,
ParachainsBench::<Runtime, WithRialtoParachainsInstance>
);
add_benchmark!(params, batches, pallet_bridge_relayers, RelayersBench::<Runtime>);
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

add_benchmarks!(params, batches);

Ok(batches)
}
Expand Down
6 changes: 6 additions & 0 deletions bin/millau/runtime/src/rialto_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ impl XcmBlobHauler for ToRialtoXcmBlobHauler {
}
}

impl pallet_bridge_messages::WeightInfoExt for crate::weights::RialtoMessagesWeightInfo<Runtime> {
fn expected_extra_storage_proof_size() -> u32 {
bp_rialto::EXTRA_STORAGE_PROOF_SIZE
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
8 changes: 8 additions & 0 deletions bin/millau/runtime/src/rialto_parachain_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler {
}
}

impl pallet_bridge_messages::WeightInfoExt
for crate::weights::RialtoParachainMessagesWeightInfo<Runtime>
{
fn expected_extra_storage_proof_size() -> u32 {
bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
21 changes: 21 additions & 0 deletions bin/millau/runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.

// Parity Bridges Common 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.

// Parity Bridges Common 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 Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

mod pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance;
mod pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance;

pub use pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance::WeightInfo as RialtoMessagesWeightInfo;
pub use pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance::WeightInfo as RialtoParachainMessagesWeightInfo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@

//! Autogenerated weights for `pallet_bridge_messages`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-05-01, 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

// Executed Command:
// target/release/millau-bridge-node
// benchmark
// pallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_bridge_messages
// --extrinsic=*
// --execution=wasm
// --wasm-execution=Compiled
// --heap-pages=4096
// --output=./bin/millau/runtime/src/weights/

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

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

/// Weight functions for `pallet_bridge_messages`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_bridge_messages::WeightInfo for WeightInfo<T> {
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen)
fn receive_single_message_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `490`
// Estimated: `57170`
// Minimum execution time: 51_189_000 picoseconds.
Weight::from_parts(52_881_000, 0)
.saturating_add(Weight::from_parts(0, 57170))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen)
fn receive_two_messages_proof() -> Weight {
// Proof Size summary in bytes:
// Measured: `490`
// Estimated: `57170`
// Minimum execution time: 65_083_000 picoseconds.
Weight::from_parts(66_878_000, 0)
.saturating_add(Weight::from_parts(0, 57170))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen)
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
// Proof Size summary in bytes:
// Measured: `490`
// Estimated: `57170`
// Minimum execution time: 57_919_000 picoseconds.
Weight::from_parts(58_927_000, 0)
.saturating_add(Weight::from_parts(0, 57170))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen)
fn receive_single_message_proof_1_kb() -> Weight {
// Proof Size summary in bytes:
// Measured: `490`
// Estimated: `57170`
// Minimum execution time: 52_202_000 picoseconds.
Weight::from_parts(53_617_000, 0)
.saturating_add(Weight::from_parts(0, 57170))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen)
fn receive_single_message_proof_16_kb() -> Weight {
// Proof Size summary in bytes:
// Measured: `490`
// Estimated: `57170`
// Minimum execution time: 74_726_000 picoseconds.
Weight::from_parts(76_379_000, 0)
.saturating_add(Weight::from_parts(0, 57170))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen)
/// Storage: BridgeRelayers RelayerRewards (r:1 w:1)
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
fn receive_delivery_proof_for_single_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `515`
// Estimated: `9584`
// Minimum execution time: 45_156_000 picoseconds.
Weight::from_parts(46_535_000, 0)
.saturating_add(Weight::from_parts(0, 9584))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen)
/// Storage: BridgeRelayers RelayerRewards (r:1 w:1)
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
// Proof Size summary in bytes:
// Measured: `532`
// Estimated: `9584`
// Minimum execution time: 44_104_000 picoseconds.
Weight::from_parts(45_602_000, 0)
.saturating_add(Weight::from_parts(0, 9584))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen)
/// Storage: BridgeRelayers RelayerRewards (r:2 w:2)
/// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
// Proof Size summary in bytes:
// Measured: `532`
// Estimated: `12124`
// Minimum execution time: 46_880_000 picoseconds.
Weight::from_parts(48_472_000, 0)
.saturating_add(Weight::from_parts(0, 12124))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0)
/// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen)
/// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0)
/// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen)
/// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1)
/// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen)
/// The range of component `i` is `[128, 2048]`.
/// The range of component `i` is `[128, 2048]`.
fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `490`
// Estimated: `57170`
// Minimum execution time: 107_297_000 picoseconds.
Weight::from_parts(98_819_194, 0)
.saturating_add(Weight::from_parts(0, 57170))
// Standard Error: 2_195
.saturating_add(Weight::from_parts(448_268, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
}
Loading

0 comments on commit ae44c6b

Please sign in to comment.