From 4d4f3e8efd5a4c1173eda28ff3afaf9f24b4f63b Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 18 Jan 2023 14:12:05 +0300 Subject: [PATCH 01/15] fix benchmarks compilation and add bridges benchmarks (prototype) to RBH/WBH --- Cargo.lock | 1 + .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 10 +- .../src/bridge_hub_rococo_config.rs | 13 +- .../src/bridge_hub_wococo_config.rs | 16 ++- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 135 +++++++++++++++++- 5 files changed, 164 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16890d2bf27..b85ef8cb6ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1002,6 +1002,7 @@ dependencies = [ "bp-bridge-hub-wococo", "bp-messages", "bp-parachains", + "bp-polkadot-core", "bp-rococo", "bp-runtime", "bp-wococo", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 5fe796f1cd0..f0591b3f2f5 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -76,6 +76,7 @@ bp-bridge-hub-rococo = { path = "../../../../bridges/primitives/chain-bridge-hub bp-bridge-hub-wococo = { path = "../../../../bridges/primitives/chain-bridge-hub-wococo", default-features = false } bp-messages = { path = "../../../../bridges/primitives/messages", default-features = false } bp-parachains = { path = "../../../../bridges/primitives/parachains", default-features = false } +bp-polkadot-core = { path = "../../../../bridges/primitives/polkadot-core", default-features = false } bp-runtime = { path = "../../../../bridges/primitives/runtime", default-features = false } bp-rococo = { path = "../../../../bridges/primitives/chain-rococo", default-features = false } bp-wococo = { path = "../../../../bridges/primitives/chain-wococo", default-features = false } @@ -97,6 +98,7 @@ std = [ "bp-bridge-hub-wococo/std", "bp-messages/std", "bp-parachains/std", + "bp-polkadot-core/std", "bp-runtime/std", "bp-rococo/std", "bp-wococo/std", @@ -156,15 +158,21 @@ std = [ ] runtime-benchmarks = [ + "bridge-runtime-common/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", + "pallet-bridge-grandpa/runtime-benchmarks", + "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", + "pallet-bridge-relayers/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs index 47131b0d565..ed8c02789c2 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs @@ -27,8 +27,8 @@ use bp_runtime::ChainId; use bridge_runtime_common::{ messages, messages::{ - target::FromBridgedChainMessagesProof, MessageBridge, ThisChainWithMessages, - UnderlyingChainProvider, + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + MessageBridge, ThisChainWithMessages, UnderlyingChainProvider, }, }; use frame_support::{parameter_types, RuntimeDebug}; @@ -50,6 +50,13 @@ parameter_types! { pub ActiveOutboundLanesToBridgeHubWococo: &'static [bp_messages::LaneId] = &[DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO]; } +/// Proof of messages, coming from Wococo. +pub type FromWococoBridgeHubMessagesProof = + FromBridgedChainMessagesProof; +/// Messages delivery proof for Rococo Bridge Hub -> Wococo Bridge Hub messages. +pub type ToWococoBridgeHubMessagesDeliveryProof = + FromBridgedChainMessagesDeliveryProof; + /// Dispatches received XCM messages from other bridge pub type OnBridgeHubRococoBlobDispatcher = BridgeBlobDispatcher; @@ -109,7 +116,7 @@ impl UnderlyingChainProvider for BridgeHubWococo { impl SourceHeaderChain for BridgeHubWococo { type Error = &'static str; - type MessagesProof = FromBridgedChainMessagesProof; + type MessagesProof = FromWococoBridgeHubMessagesProof; fn verify_messages_proof( proof: Self::MessagesProof, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs index a7077734e15..d4ffd13744e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs @@ -27,8 +27,8 @@ use bp_runtime::ChainId; use bridge_runtime_common::{ messages, messages::{ - target::FromBridgedChainMessagesProof, MessageBridge, ThisChainWithMessages, - UnderlyingChainProvider, + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + MessageBridge, ThisChainWithMessages, UnderlyingChainProvider, }, }; use frame_support::{parameter_types, RuntimeDebug}; @@ -50,6 +50,13 @@ parameter_types! { pub ActiveOutboundLanesToBridgeHubRococo: &'static [bp_messages::LaneId] = &[DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO]; } +/// Proof of messages, coming from Rococo. +pub type FromRococoBridgeHubMessagesProof = + FromBridgedChainMessagesProof; +/// Messages delivery proof for Rococo Bridge Hub -> Wococo Bridge Hub messages. +pub type ToRococoBridgeHubMessagesDeliveryProof = + FromBridgedChainMessagesDeliveryProof; + /// Dispatches received XCM messages from other bridge pub type OnBridgeHubWococoBlobDispatcher = BridgeBlobDispatcher; @@ -109,7 +116,7 @@ impl UnderlyingChainProvider for BridgeHubRococo { impl SourceHeaderChain for BridgeHubRococo { type Error = &'static str; - type MessagesProof = FromBridgedChainMessagesProof; + type MessagesProof = FromRococoBridgeHubMessagesProof; fn verify_messages_proof( proof: Self::MessagesProof, @@ -124,8 +131,7 @@ impl SourceHeaderChain for BridgeHubRococo { impl TargetHeaderChain for BridgeHubRococo { type Error = &'static str; - type MessagesDeliveryProof = - messages::source::FromBridgedChainMessagesDeliveryProof; + type MessagesDeliveryProof = ToRococoBridgeHubMessagesDeliveryProof; fn verify_message(payload: &XcmAsPlainPayload) -> Result<(), Self::Error> { messages::source::verify_chain_message::(payload) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 12dbd4f869a..45ed56e133f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -554,12 +554,16 @@ construct_runtime!( // TODO:check-parameter - change back to 41 a align bridge pallets Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 36, - // Wococo bridge modules + // Rococo and Wococo Bridge Hubs are sharing the runtime, so this runtime has two sets of + // bridge pallets. Both are deployed at both runtimes, but only one set is actually used + // at particular runtime. + + // With-Wococo bridge modules that are active (used) at Rococo Bridge Hub runtime. BridgeWococoGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Storage, Config} = 41, BridgeWococoParachain: pallet_bridge_parachains::::{Pallet, Call, Storage, Event} = 42, BridgeWococoMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config} = 46, - // Rococo bridge modules + // With-Rococo bridge modules that are active (used) at Wococo Bridge Hub runtime. BridgeRococoGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Storage, Config} = 43, BridgeRococoParachain: pallet_bridge_parachains::::{Pallet, Call, Storage, Event} = 44, BridgeRococoMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config} = 45, @@ -597,6 +601,14 @@ mod benches { // NOTE: Make sure you point to the individual modules below. [pallet_xcm_benchmarks::fungible, XcmBalances] [pallet_xcm_benchmarks::generic, XcmGeneric] + // Bridge pallets at Rococo + [pallet_bridge_grandpa, BridgeWococoGrandpa] + [pallet_bridge_parachains, BridgeParachainsBench::] + [pallet_bridge_messages, BridgeMessagesBench::] + // Bridge pallets at Wococo + [pallet_bridge_grandpa, BridgeRococoGrandpa] + [pallet_bridge_parachains, BridgeParachainsBench::] + [pallet_bridge_messages, BridgeMessagesBench::] ); } @@ -824,6 +836,9 @@ impl_runtime_apis! { type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + use pallet_bridge_parachains::benchmarking::Pallet as BridgeParachainsBench; + use pallet_bridge_messages::benchmarking::Pallet as BridgeMessagesBench; + let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -923,6 +938,122 @@ impl_runtime_apis! { type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + use bridge_runtime_common::messages_benchmarking::{prepare_message_delivery_proof, prepare_message_proof}; + use pallet_bridge_messages::benchmarking::{ + Config as BridgeMessagesConfig, + Pallet as BridgeMessagesBench, + MessageDeliveryProofParams, + MessageProofParams, + }; + + impl BridgeMessagesConfig for Runtime { + // TODO: remove me after bridges subtree update + fn bridged_relayer_id() -> AccountId { [0u8; 32].into() } + fn endow_account(_: &AccountId) {} + fn is_message_dispatched(_: bp_messages::MessageNonce) -> bool { true } + + fn prepare_message_proof( + params: MessageProofParams, + ) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) { + prepare_message_proof::< + Runtime, + (), + BridgeGrandpaWococoInstance, + bridge_hub_rococo_config::WithBridgeHubWococoMessageBridge, + bp_bridge_hub_wococo::Header, + bp_bridge_hub_wococo::Hasher, + >(params) + } + + fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams, + ) -> bridge_hub_rococo_config::ToWococoBridgeHubMessagesDeliveryProof { + prepare_message_delivery_proof::< + Runtime, + BridgeGrandpaWococoInstance, + bridge_hub_rococo_config::WithBridgeHubWococoMessageBridge, + bp_bridge_hub_wococo::Header, + bp_bridge_hub_wococo::Hasher, + >(params) + } + } + + impl BridgeMessagesConfig for Runtime { + // TODO: remove me after bridges subtree update + fn bridged_relayer_id() -> AccountId { [0u8; 32].into() } + fn endow_account(_: &AccountId) {} + fn is_message_dispatched(_: bp_messages::MessageNonce) -> bool { true } + + fn prepare_message_proof( + params: MessageProofParams, + ) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) { + prepare_message_proof::< + Runtime, + (), + BridgeGrandpaRococoInstance, + bridge_hub_wococo_config::WithBridgeHubRococoMessageBridge, + bp_bridge_hub_rococo::Header, + bp_bridge_hub_rococo::Hasher, + >(params) + } + + fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams, + ) -> bridge_hub_wococo_config::ToRococoBridgeHubMessagesDeliveryProof { + prepare_message_delivery_proof::< + Runtime, + BridgeGrandpaRococoInstance, + bridge_hub_wococo_config::WithBridgeHubRococoMessageBridge, + bp_bridge_hub_rococo::Header, + bp_bridge_hub_rococo::Hasher, + >(params) + } + } + + use bridge_runtime_common::parachains_benchmarking::prepare_parachain_heads_proof; + use pallet_bridge_parachains::benchmarking::{ + Config as BridgeParachainsConfig, + Pallet as BridgeParachainsBench, + }; + + impl BridgeParachainsConfig for Runtime { + fn prepare_parachain_heads_proof( + parachains: &[bp_polkadot_core::parachains::ParaId], + parachain_head_size: u32, + proof_size: bp_runtime::StorageProofSize, + ) -> ( + pallet_bridge_parachains::RelayBlockNumber, + pallet_bridge_parachains::RelayBlockHash, + bp_polkadot_core::parachains::ParaHeadsProof, + Vec<(bp_polkadot_core::parachains::ParaId, bp_polkadot_core::parachains::ParaHash)>, + ) { + prepare_parachain_heads_proof::( + parachains, + parachain_head_size, + proof_size, + ) + } + } + + impl BridgeParachainsConfig for Runtime { + fn prepare_parachain_heads_proof( + parachains: &[bp_polkadot_core::parachains::ParaId], + parachain_head_size: u32, + proof_size: bp_runtime::StorageProofSize, + ) -> ( + pallet_bridge_parachains::RelayBlockNumber, + pallet_bridge_parachains::RelayBlockHash, + bp_polkadot_core::parachains::ParaHeadsProof, + Vec<(bp_polkadot_core::parachains::ParaId, bp_polkadot_core::parachains::ParaHash)>, + ) { + prepare_parachain_heads_proof::( + parachains, + parachain_head_size, + proof_size, + ) + } + } + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), From b8dfb61797d5518b9d6210f278e1da1b25c0066a Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 19 Jan 2023 14:12:12 +0300 Subject: [PATCH 02/15] post-merge fixes --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 45ed56e133f..a9960be1c49 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -952,6 +952,11 @@ impl_runtime_apis! { fn endow_account(_: &AccountId) {} fn is_message_dispatched(_: bp_messages::MessageNonce) -> bool { true } + fn is_relayer_rewarded(_: &Self::AccountId) -> bool { + // TODO: implement me properly + true + } + fn prepare_message_proof( params: MessageProofParams, ) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) { @@ -984,6 +989,11 @@ impl_runtime_apis! { fn endow_account(_: &AccountId) {} fn is_message_dispatched(_: bp_messages::MessageNonce) -> bool { true } + fn is_relayer_rewarded(_: &Self::AccountId) -> bool { + // TODO: implement me properly + true + } + fn prepare_message_proof( params: MessageProofParams, ) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) { @@ -1017,6 +1027,11 @@ impl_runtime_apis! { }; impl BridgeParachainsConfig for Runtime { + fn parachains() -> Vec { + use bp_runtime::Parachain; + vec![bp_polkadot_core::parachains::ParaId(bp_bridge_hub_wococo::BridgeHubWococo::PARACHAIN_ID)] + } + fn prepare_parachain_heads_proof( parachains: &[bp_polkadot_core::parachains::ParaId], parachain_head_size: u32, @@ -1036,6 +1051,11 @@ impl_runtime_apis! { } impl BridgeParachainsConfig for Runtime { + fn parachains() -> Vec { + use bp_runtime::Parachain; + vec![bp_polkadot_core::parachains::ParaId(bp_bridge_hub_rococo::BridgeHubRococo::PARACHAIN_ID)] + } + fn prepare_parachain_heads_proof( parachains: &[bp_polkadot_core::parachains::ParaId], parachain_head_size: u32, From 89f72fbbe9a2b218bcfbb5ce686f15457ebe9a57 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 19 Jan 2023 14:19:56 +0300 Subject: [PATCH 03/15] remove duplicate "pallet-collator-selection/runtime-benchmarks" --- parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index f0591b3f2f5..44d9f8f7387 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -169,7 +169,6 @@ runtime-benchmarks = [ "pallet-bridge-parachains/runtime-benchmarks", "pallet-bridge-relayers/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", From 29d714023fcce1480b9caa34ddfd2363ac4bad85 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sun, 22 Jan 2023 22:16:12 +0000 Subject: [PATCH 04/15] ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo bridge-hubs pallet_bridge_grandpa --- ...et_bridge_grandpa_bridge_rococo_grandpa.rs | 71 +++++++++++++++++++ ...et_bridge_grandpa_bridge_wococo_grandpa.rs | 71 +++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs new file mode 100644 index 00000000000..9dfa44f562c --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs @@ -0,0 +1,71 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_grandpa` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_grandpa +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![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 `pallet_bridge_grandpa`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_grandpa::WeightInfo for WeightInfo { + // Storage: BridgeRococoGrandpa PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoGrandpa RequestCount (r:1 w:1) + // Storage: BridgeRococoGrandpa BestFinalized (r:1 w:1) + // Storage: BridgeRococoGrandpa CurrentAuthoritySet (r:1 w:0) + // Storage: BridgeRococoGrandpa ImportedHashesPointer (r:1 w:1) + // Storage: BridgeRococoGrandpa ImportedHashes (r:1 w:1) + // Storage: BridgeRococoGrandpa ImportedHeaders (r:0 w:2) + /// The range of component `p` is `[51, 102]`. + /// The range of component `v` is `[50, 100]`. + /// The range of component `p` is `[51, 102]`. + /// The range of component `v` is `[50, 100]`. + fn submit_finality_proof(p: u32, v: u32, ) -> Weight { + // Minimum execution time: 2_561_902 nanoseconds. + Weight::from_ref_time(86_419_230) + // Standard Error: 32_880 + .saturating_add(Weight::from_ref_time(46_938_159).saturating_mul(p.into())) + // Standard Error: 33_661 + .saturating_add(Weight::from_ref_time(1_134_973).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs new file mode 100644 index 00000000000..a22269e2a7c --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs @@ -0,0 +1,71 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_grandpa` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_grandpa +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![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 `pallet_bridge_grandpa`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_grandpa::WeightInfo for WeightInfo { + // Storage: BridgeWococoGrandpa PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoGrandpa RequestCount (r:1 w:1) + // Storage: BridgeWococoGrandpa BestFinalized (r:1 w:1) + // Storage: BridgeWococoGrandpa CurrentAuthoritySet (r:1 w:0) + // Storage: BridgeWococoGrandpa ImportedHashesPointer (r:1 w:1) + // Storage: BridgeWococoGrandpa ImportedHashes (r:1 w:1) + // Storage: BridgeWococoGrandpa ImportedHeaders (r:0 w:2) + /// The range of component `p` is `[51, 102]`. + /// The range of component `v` is `[50, 100]`. + /// The range of component `p` is `[51, 102]`. + /// The range of component `v` is `[50, 100]`. + fn submit_finality_proof(p: u32, v: u32, ) -> Weight { + // Minimum execution time: 2_565_169 nanoseconds. + Weight::from_ref_time(67_834_502) + // Standard Error: 35_710 + .saturating_add(Weight::from_ref_time(47_043_118).saturating_mul(p.into())) + // Standard Error: 36_557 + .saturating_add(Weight::from_ref_time(1_301_551).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) + } +} From d17ce7c33cd65889696d40d6e1478b122b97aafd Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 23 Jan 2023 09:18:06 +0000 Subject: [PATCH 05/15] ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo bridge-hubs pallet_bridge_parachains --- ...untime_bridge_parachain_rococo_instance.rs | 85 ++++++++++++++++++ ...untime_bridge_parachain_wococo_instance.rs | 87 +++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs new file mode 100644 index 00000000000..056617988d5 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs @@ -0,0 +1,85 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_parachains` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_parachains +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![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 `pallet_bridge_parachains`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_parachains::WeightInfo for WeightInfo { + // Storage: BridgeRococoParachain PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoGrandpa ImportedHeaders (r:1 w:0) + // Storage: BridgeRococoParachain ParasInfo (r:1 w:1) + // Storage: BridgeRococoParachain ImportedParaHashes (r:1 w:1) + // Storage: BridgeRococoParachain ImportedParaHeads (r:0 w:1) + /// The range of component `p` is `[1, 2]`. + /// The range of component `p` is `[1, 2]`. + fn submit_parachain_heads_with_n_parachains(_p: u32, ) -> Weight { + // Minimum execution time: 34_955 nanoseconds. + Weight::from_ref_time(36_400_062) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: BridgeRococoParachain PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoGrandpa ImportedHeaders (r:1 w:0) + // Storage: BridgeRococoParachain ParasInfo (r:1 w:1) + // Storage: BridgeRococoParachain ImportedParaHashes (r:1 w:1) + // Storage: BridgeRococoParachain ImportedParaHeads (r:0 w:1) + fn submit_parachain_heads_with_1kb_proof() -> Weight { + // Minimum execution time: 44_024 nanoseconds. + Weight::from_ref_time(44_604_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: BridgeRococoParachain PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoGrandpa ImportedHeaders (r:1 w:0) + // Storage: BridgeRococoParachain ParasInfo (r:1 w:1) + // Storage: BridgeRococoParachain ImportedParaHashes (r:1 w:1) + // Storage: BridgeRococoParachain ImportedParaHeads (r:0 w:1) + fn submit_parachain_heads_with_16kb_proof() -> Weight { + // Minimum execution time: 96_346 nanoseconds. + Weight::from_ref_time(98_207_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs new file mode 100644 index 00000000000..6a4b86a6def --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs @@ -0,0 +1,87 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_parachains` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// /home/benchbot/cargo_target_dir/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_parachains +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![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 `pallet_bridge_parachains`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_parachains::WeightInfo for WeightInfo { + // Storage: BridgeWococoParachain PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoGrandpa ImportedHeaders (r:1 w:0) + // Storage: BridgeWococoParachain ParasInfo (r:1 w:1) + // Storage: BridgeWococoParachain ImportedParaHashes (r:1 w:1) + // Storage: BridgeWococoParachain ImportedParaHeads (r:0 w:1) + /// The range of component `p` is `[1, 2]`. + /// The range of component `p` is `[1, 2]`. + fn submit_parachain_heads_with_n_parachains(p: u32, ) -> Weight { + // Minimum execution time: 36_411 nanoseconds. + Weight::from_ref_time(37_604_452) + // Standard Error: 57_620 + .saturating_add(Weight::from_ref_time(248_648).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: BridgeWococoParachain PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoGrandpa ImportedHeaders (r:1 w:0) + // Storage: BridgeWococoParachain ParasInfo (r:1 w:1) + // Storage: BridgeWococoParachain ImportedParaHashes (r:1 w:1) + // Storage: BridgeWococoParachain ImportedParaHeads (r:0 w:1) + fn submit_parachain_heads_with_1kb_proof() -> Weight { + // Minimum execution time: 45_107 nanoseconds. + Weight::from_ref_time(45_916_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: BridgeWococoParachain PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoGrandpa ImportedHeaders (r:1 w:0) + // Storage: BridgeWococoParachain ParasInfo (r:1 w:1) + // Storage: BridgeWococoParachain ImportedParaHashes (r:1 w:1) + // Storage: BridgeWococoParachain ImportedParaHeads (r:0 w:1) + fn submit_parachain_heads_with_16kb_proof() -> Weight { + // Minimum execution time: 97_738 nanoseconds. + Weight::from_ref_time(100_381_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} From 8ff50de9f73896cc44c86a533779c10837bdb0d3 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 09:37:07 +0300 Subject: [PATCH 06/15] remove methods that are no longer required --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 99c775aa378..f48e1f12875 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -946,11 +946,6 @@ impl_runtime_apis! { }; impl BridgeMessagesConfig for Runtime { - // TODO: remove me after bridges subtree update - fn bridged_relayer_id() -> AccountId { [0u8; 32].into() } - fn endow_account(_: &AccountId) {} - fn is_message_dispatched(_: bp_messages::MessageNonce) -> bool { true } - fn is_relayer_rewarded(_: &Self::AccountId) -> bool { // TODO: implement me properly true @@ -983,11 +978,6 @@ impl_runtime_apis! { } impl BridgeMessagesConfig for Runtime { - // TODO: remove me after bridges subtree update - fn bridged_relayer_id() -> AccountId { [0u8; 32].into() } - fn endow_account(_: &AccountId) {} - fn is_message_dispatched(_: bp_messages::MessageNonce) -> bool { true } - fn is_relayer_rewarded(_: &Self::AccountId) -> bool { // TODO: implement me properly true From a1894314690bfcba0fdbcfb437599669c853fd1d Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 15:10:28 +0300 Subject: [PATCH 07/15] fixed helpers used in bridge hub messages palelt benchmarks --- .../src/messages_benchmarking.rs | 201 ++++++++++++++---- bridges/modules/parachains/src/lib.rs | 27 ++- .../src/bridge_hub_rococo_config.rs | 2 + .../src/bridge_hub_wococo_config.rs | 2 + .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 20 +- 5 files changed, 190 insertions(+), 62 deletions(-) diff --git a/bridges/bin/runtime-common/src/messages_benchmarking.rs b/bridges/bin/runtime-common/src/messages_benchmarking.rs index afe95422d18..e7ca26d952e 100644 --- a/bridges/bin/runtime-common/src/messages_benchmarking.rs +++ b/bridges/bin/runtime-common/src/messages_benchmarking.rs @@ -22,7 +22,7 @@ use crate::{ messages::{ source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, - AccountIdOf, BalanceOf, BridgedChain, CallOf, HashOf, MessageBridge, ThisChain, + AccountIdOf, BridgedChain, HashOf, HasherOf, MessageBridge, RawStorageProof, ThisChain, }, messages_generation::{ encode_all_messages, encode_lane_data, grow_trie, prepare_messages_storage_proof, @@ -30,52 +30,46 @@ use crate::{ }; use bp_messages::storage_keys; -use bp_runtime::{record_all_trie_keys, StorageProofSize}; +use bp_polkadot_core::parachains::ParaHash; +use bp_runtime::{record_all_trie_keys, Chain, Parachain, StorageProofSize, UnderlyingChainOf}; use codec::Encode; -use frame_support::{dispatch::GetDispatchInfo, weights::Weight}; +use frame_support::weights::Weight; use pallet_bridge_messages::benchmarking::{MessageDeliveryProofParams, MessageProofParams}; -use sp_core::Hasher; -use sp_runtime::traits::{Header, MaybeSerializeDeserialize, Zero}; -use sp_std::{fmt::Debug, prelude::*}; +use sp_runtime::traits::{Header, Zero}; +use sp_std::prelude::*; use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, Recorder, TrieMut}; /// Prepare proof of messages for the `receive_messages_proof` call. /// /// In addition to returning valid messages proof, environment is prepared to verify this message /// proof. -pub fn prepare_message_proof( +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses GRANDPA finality. For parachains, please use the `prepare_message_proof_from_parachain` +/// function. +pub fn prepare_message_proof_from_grandpa_chain( params: MessageProofParams, ) -> (FromBridgedChainMessagesProof>>, Weight) where - R: frame_system::Config>> - + pallet_bridge_grandpa::Config, - R::BridgedChain: bp_runtime::Chain>, Header = BH>, - B: MessageBridge, - BI: 'static, + R: pallet_bridge_grandpa::Config>>, FI: 'static, - BH: Header>>, - BHH: Hasher>>, - AccountIdOf>: PartialEq + sp_std::fmt::Debug, - AccountIdOf>: From<[u8; 32]>, - BalanceOf>: Debug + MaybeSerializeDeserialize, - CallOf>: From> + GetDispatchInfo, - HashOf>: Copy + Default, + B: MessageBridge, { - let message_payload = match params.size { - StorageProofSize::Minimal(ref size) => vec![0u8; *size as _], - _ => vec![], - }; - - // finally - prepare storage proof and update environment + // prepare storage proof let (state_root, storage_proof) = prepare_messages_storage_proof::( params.lane, params.message_nonces.clone(), params.outbound_lane_data, params.size, - message_payload, + match params.size { + StorageProofSize::Minimal(ref size) => vec![0u8; *size as _], + _ => vec![], + }, encode_all_messages, encode_lane_data, ); + + // update runtime storage let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(state_root); ( @@ -90,18 +84,115 @@ where ) } +/// Prepare proof of messages for the `receive_messages_proof` call. +/// +/// In addition to returning valid messages proof, environment is prepared to verify this message +/// proof. +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses parachain finality. For GRANDPA chains, please use the +/// `prepare_message_proof_from_grandpa_chain` function. +pub fn prepare_message_proof_from_parachain( + params: MessageProofParams, +) -> (FromBridgedChainMessagesProof>>, Weight) +where + R: pallet_bridge_parachains::Config, + PI: 'static, + B: MessageBridge, + UnderlyingChainOf>: Chain + Parachain, +{ + // prepare storage proof + let (state_root, storage_proof) = prepare_messages_storage_proof::( + params.lane, + params.message_nonces.clone(), + params.outbound_lane_data, + params.size, + match params.size { + StorageProofSize::Minimal(ref size) => vec![0u8; *size as _], + _ => vec![], + }, + encode_all_messages, + encode_lane_data, + ); + + // update runtime storage + let (_, bridged_header_hash) = + insert_header_to_parachains_pallet::>>(state_root); + + ( + FromBridgedChainMessagesProof { + bridged_header_hash, + storage_proof, + lane: params.lane, + nonces_start: *params.message_nonces.start(), + nonces_end: *params.message_nonces.end(), + }, + Weight::zero(), + ) +} + /// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call. -pub fn prepare_message_delivery_proof( +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses GRANDPA finality. For parachains, please use the +/// `prepare_message_delivery_proof_from_parachain` function. +pub fn prepare_message_delivery_proof_from_grandpa_chain( params: MessageDeliveryProofParams>>, ) -> FromBridgedChainMessagesDeliveryProof>> where - R: pallet_bridge_grandpa::Config, - R::BridgedChain: bp_runtime::Chain>, Header = BH>, + R: pallet_bridge_grandpa::Config>>, FI: 'static, B: MessageBridge, - BH: Header>>, - BHH: Hasher>>, - HashOf>: Copy + Default, +{ + // prepare storage proof + let lane = params.lane; + let (state_root, storage_proof) = prepare_message_delivery_proof::(params); + + // update runtime storage + let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(state_root); + + FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: bridged_header_hash.into(), + storage_proof, + lane, + } +} + +/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call. +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses parachain finality. For GRANDPA chains, please use the +/// `prepare_message_delivery_proof_from_grandpa_chain` function. +pub fn prepare_message_delivery_proof_from_parachain( + params: MessageDeliveryProofParams>>, +) -> FromBridgedChainMessagesDeliveryProof>> +where + R: pallet_bridge_parachains::Config, + PI: 'static, + B: MessageBridge, + UnderlyingChainOf>: Chain + Parachain, +{ + // prepare storage proof + let lane = params.lane; + let (state_root, storage_proof) = prepare_message_delivery_proof::(params); + + // update runtime storage + let (_, bridged_header_hash) = + insert_header_to_parachains_pallet::>>(state_root); + + FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: bridged_header_hash.into(), + storage_proof, + lane, + } +} + +/// Prepare in-memory message delivery proof, without inserting anything to the runtime storage. +fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams>>, +) -> (HashOf>, RawStorageProof) +where + B: MessageBridge, { // prepare Bridged chain storage with inbound lane state let storage_key = @@ -109,7 +200,8 @@ where let mut root = Default::default(); let mut mdb = MemoryDB::default(); { - let mut trie = TrieDBMutBuilderV1::::new(&mut mdb, &mut root).build(); + let mut trie = + TrieDBMutBuilderV1::>>::new(&mut mdb, &mut root).build(); trie.insert(&storage_key, ¶ms.inbound_lane_data.encode()) .map_err(|_| "TrieMut::insert has failed") .expect("TrieMut::insert should not fail in benchmarks"); @@ -117,20 +209,17 @@ where root = grow_trie(root, &mut mdb, params.size); // generate storage proof to be delivered to This chain - let mut proof_recorder = Recorder::>::new(); - record_all_trie_keys::, _>(&mdb, &root, &mut proof_recorder) - .map_err(|_| "record_all_trie_keys has failed") - .expect("record_all_trie_keys should not fail in benchmarks"); + let mut proof_recorder = Recorder::>>>::new(); + record_all_trie_keys::>>, _>( + &mdb, + &root, + &mut proof_recorder, + ) + .map_err(|_| "record_all_trie_keys has failed") + .expect("record_all_trie_keys should not fail in benchmarks"); let storage_proof = proof_recorder.drain().into_iter().map(|n| n.data.to_vec()).collect(); - // finally insert header with given state root to our storage - let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(root); - - FromBridgedChainMessagesDeliveryProof { - bridged_header_hash: bridged_header_hash.into(), - storage_proof, - lane: params.lane, - } + (root, storage_proof) } /// Insert header to the bridge GRANDPA pallet. @@ -154,3 +243,25 @@ where pallet_bridge_grandpa::initialize_for_benchmarks::(bridged_header); (bridged_block_number, bridged_header_hash) } + +/// Insert header to the bridge parachains pallet. +pub(crate) fn insert_header_to_parachains_pallet( + state_root: bp_runtime::HashOf, +) -> (bp_runtime::BlockNumberOf, bp_runtime::HashOf) +where + R: pallet_bridge_parachains::Config, + PI: 'static, + PC: Chain + Parachain, +{ + let bridged_block_number = Zero::zero(); + let bridged_header = bp_runtime::HeaderOf::::new( + bridged_block_number, + Default::default(), + state_root, + Default::default(), + Default::default(), + ); + let bridged_header_hash = bridged_header.hash(); + pallet_bridge_parachains::initialize_for_benchmarks::(bridged_header); + (bridged_block_number, bridged_header_hash) +} diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index 47ab91928c7..4d2528c6c37 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -27,9 +27,13 @@ pub use weights::WeightInfo; pub use weights_ext::WeightInfoExt; use bp_header_chain::HeaderChain; -use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData}; +use bp_parachains::{ + parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData, + ParaStoredHeaderDataBuilder, +}; use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; -use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, Parachain, StorageProofError}; +use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, HeaderOf, Parachain, StorageProofError}; +use codec::Encode; use frame_support::dispatch::PostDispatchInfo; use sp_std::{marker::PhantomData, vec::Vec}; @@ -654,6 +658,25 @@ impl, I: 'static, C: Parachain> HeaderChain } } +/// (Re)initialize pallet with given header for using it in `pallet-bridge-messages` benchmarks. +#[cfg(feature = "runtime-benchmarks")] +pub fn initialize_for_benchmarks, I: 'static, PC: Parachain>( + header: HeaderOf, +) { + let parachain = ParaId(PC::PARACHAIN_ID); + let parachain_head = ParaHead(header.encode()); + let updated_head_data = T::ParaStoredHeaderDataBuilder::try_build(parachain, ¶chain_head) + .expect("failed to build stored parachain head in benchmarks"); + Pallet::::update_parachain_head( + parachain, + None, + 0, + updated_head_data, + parachain_head.hash(), + ) + .expect("failed to insert parachain head in benchmarks"); +} + #[cfg(test)] mod tests { use super::*; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs index ed8c02789c2..99aff05d232 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . +//! Bridge definitions that are used on Rococo to bridge with Wococo. + use crate::{ BridgeParachainWococoInstance, ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, XcmRouter, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs index d4ffd13744e..6d172f4287f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . +//! Bridge definitions that are used on Wococo to bridge with Rococo. + use crate::{ BridgeParachainRococoInstance, ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, XcmRouter, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index f48e1f12875..3fe3c4c7872 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -937,7 +937,7 @@ impl_runtime_apis! { type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; - use bridge_runtime_common::messages_benchmarking::{prepare_message_delivery_proof, prepare_message_proof}; + use bridge_runtime_common::messages_benchmarking::{prepare_message_delivery_proof_from_parachain, prepare_message_proof_from_parachain}; use pallet_bridge_messages::benchmarking::{ Config as BridgeMessagesConfig, Pallet as BridgeMessagesBench, @@ -954,25 +954,20 @@ impl_runtime_apis! { fn prepare_message_proof( params: MessageProofParams, ) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) { - prepare_message_proof::< + prepare_message_proof_from_parachain::< Runtime, - (), BridgeGrandpaWococoInstance, bridge_hub_rococo_config::WithBridgeHubWococoMessageBridge, - bp_bridge_hub_wococo::Header, - bp_bridge_hub_wococo::Hasher, >(params) } fn prepare_message_delivery_proof( params: MessageDeliveryProofParams, ) -> bridge_hub_rococo_config::ToWococoBridgeHubMessagesDeliveryProof { - prepare_message_delivery_proof::< + prepare_message_delivery_proof_from_parachain::< Runtime, BridgeGrandpaWococoInstance, bridge_hub_rococo_config::WithBridgeHubWococoMessageBridge, - bp_bridge_hub_wococo::Header, - bp_bridge_hub_wococo::Hasher, >(params) } } @@ -986,25 +981,20 @@ impl_runtime_apis! { fn prepare_message_proof( params: MessageProofParams, ) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) { - prepare_message_proof::< + prepare_message_proof_from_parachain::< Runtime, - (), BridgeGrandpaRococoInstance, bridge_hub_wococo_config::WithBridgeHubRococoMessageBridge, - bp_bridge_hub_rococo::Header, - bp_bridge_hub_rococo::Hasher, >(params) } fn prepare_message_delivery_proof( params: MessageDeliveryProofParams, ) -> bridge_hub_wococo_config::ToRococoBridgeHubMessagesDeliveryProof { - prepare_message_delivery_proof::< + prepare_message_delivery_proof_from_parachain::< Runtime, BridgeGrandpaRococoInstance, bridge_hub_wococo_config::WithBridgeHubRococoMessageBridge, - bp_bridge_hub_rococo::Header, - bp_bridge_hub_rococo::Hasher, >(params) } } From c11f2f444d9a84df93f94934c39fb3330a024fbd Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 15:22:10 +0300 Subject: [PATCH 08/15] unused imports --- bridges/modules/parachains/src/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index 4d2528c6c37..7b10e59976a 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -27,16 +27,19 @@ pub use weights::WeightInfo; pub use weights_ext::WeightInfoExt; use bp_header_chain::HeaderChain; -use bp_parachains::{ - parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData, - ParaStoredHeaderDataBuilder, -}; +use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData}; use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, HeaderOf, Parachain, StorageProofError}; -use codec::Encode; use frame_support::dispatch::PostDispatchInfo; use sp_std::{marker::PhantomData, vec::Vec}; +#[cfg(feature = "runtime-benchmarks")] +use bp_parachains::ParaStoredHeaderDataBuilder; +#[cfg(feature = "runtime-benchmarks")] +use bp_runtime::HeaderOf; +#[cfg(feature = "runtime-benchmarks")] +use codec::Encode; + // Re-export in crate namespace for `construct_runtime!`. pub use pallet::*; From 4c705f48d122ee83d08ddd6c1c5fc87278b53854 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 15:32:39 +0300 Subject: [PATCH 09/15] compilation --- bridges/modules/parachains/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index 7b10e59976a..06a1f82e7b0 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -29,7 +29,7 @@ pub use weights_ext::WeightInfoExt; use bp_header_chain::HeaderChain; use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData}; use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; -use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, HeaderOf, Parachain, StorageProofError}; +use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, Parachain, StorageProofError}; use frame_support::dispatch::PostDispatchInfo; use sp_std::{marker::PhantomData, vec::Vec}; From c819dfb5acf4a38e95a30126433f6254761bcf0d Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 15:40:13 +0300 Subject: [PATCH 10/15] compilation --- bridges/bin/runtime-common/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index 9e8e6b29db2..7d538671646 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -82,6 +82,7 @@ std = [ runtime-benchmarks = [ "pallet-bridge-grandpa/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", "xcm-builder/runtime-benchmarks", ] integrity-test = [ From e7f13ec75cd63c81af358e57b8460b06bbc20eb0 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 15:50:36 +0300 Subject: [PATCH 11/15] benchmarks-ci.sh --- scripts/benchmarks-ci.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/benchmarks-ci.sh b/scripts/benchmarks-ci.sh index d4ad99d7bbe..b97373b390c 100755 --- a/scripts/benchmarks-ci.sh +++ b/scripts/benchmarks-ci.sh @@ -51,6 +51,9 @@ elif [[ $runtimeName == "bridge-hub-rococo" ]] || [[ $runtimeName == "bridge-hub cumulus_pallet_xcmp_queue pallet_xcm_benchmarks::generic pallet_xcm_benchmarks::fungible + pallet_bridge_grandpa + pallet_bridge_parachains + pallet_bridge_messages ) else echo "$runtimeName pallet list not found in benchmarks-ci.sh" From 5a7fb541e9ce763c3a56cf253fad957f13aa7be2 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 25 Jan 2023 14:11:00 +0000 Subject: [PATCH 12/15] ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-rococo bridge-hubs pallet_bridge_messages --- ...ith_bridge_hub_rococo_messages_instance.rs | 125 ++++++++++++++++++ ...ith_bridge_hub_wococo_messages_instance.rs | 125 ++++++++++++++++++ 2 files changed, 250 insertions(+) create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs create mode 100644 parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs new file mode 100644 index 00000000000..65a1858a231 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs @@ -0,0 +1,125 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_messages` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `runner-b3zmxxc-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_messages +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![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 `pallet_bridge_messages`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_messages::WeightInfo for WeightInfo { + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + // Storage: ParachainInfo ParachainId (r:1 w:0) + fn receive_single_message_proof() -> Weight { + // Minimum execution time: 48_515 nanoseconds. + Weight::from_ref_time(50_641_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + // Storage: ParachainInfo ParachainId (r:1 w:0) + fn receive_two_messages_proof() -> Weight { + // Minimum execution time: 62_891 nanoseconds. + Weight::from_ref_time(66_039_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + // Storage: ParachainInfo ParachainId (r:1 w:0) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Minimum execution time: 53_010 nanoseconds. + Weight::from_ref_time(53_855_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + fn receive_single_message_proof_1_kb() -> Weight { + // Minimum execution time: 50_491 nanoseconds. + Weight::from_ref_time(52_570_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + fn receive_single_message_proof_16_kb() -> Weight { + // Minimum execution time: 116_072 nanoseconds. + Weight::from_ref_time(119_185_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages OutboundLanes (r:1 w:1) + fn receive_delivery_proof_for_single_message() -> Weight { + // Minimum execution time: 31_075 nanoseconds. + Weight::from_ref_time(32_055_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages OutboundLanes (r:1 w:1) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Minimum execution time: 31_524 nanoseconds. + Weight::from_ref_time(32_149_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeRococoMessages OutboundLanes (r:1 w:1) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Minimum execution time: 31_723 nanoseconds. + Weight::from_ref_time(32_355_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs new file mode 100644 index 00000000000..eaff561d629 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs @@ -0,0 +1,125 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_messages` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `runner-b3zmxxc-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_messages +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![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 `pallet_bridge_messages`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_messages::WeightInfo for WeightInfo { + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + // Storage: ParachainInfo ParachainId (r:1 w:0) + fn receive_single_message_proof() -> Weight { + // Minimum execution time: 49_348 nanoseconds. + Weight::from_ref_time(52_687_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + // Storage: ParachainInfo ParachainId (r:1 w:0) + fn receive_two_messages_proof() -> Weight { + // Minimum execution time: 63_755 nanoseconds. + Weight::from_ref_time(67_615_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + // Storage: ParachainInfo ParachainId (r:1 w:0) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Minimum execution time: 54_597 nanoseconds. + Weight::from_ref_time(56_472_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + fn receive_single_message_proof_1_kb() -> Weight { + // Minimum execution time: 51_363 nanoseconds. + Weight::from_ref_time(54_025_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + fn receive_single_message_proof_16_kb() -> Weight { + // Minimum execution time: 119_727 nanoseconds. + Weight::from_ref_time(123_138_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + fn receive_delivery_proof_for_single_message() -> Weight { + // Minimum execution time: 32_525 nanoseconds. + Weight::from_ref_time(33_410_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Minimum execution time: 32_310 nanoseconds. + Weight::from_ref_time(33_208_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + // Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Minimum execution time: 32_594 nanoseconds. + Weight::from_ref_time(33_449_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} From 29bfcb5b8b748ad5fac6a633c2272f185882cfbc Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 17:15:43 +0300 Subject: [PATCH 13/15] use generated weights in pallets configuration --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 0b9e458e0e7..02f211987af 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -399,7 +399,7 @@ impl pallet_bridge_grandpa::Config for Runtime { type HeadersToKeep = RelayChainHeadersToKeep; type MaxBridgedAuthorities = frame_support::traits::ConstU32<{ bp_wococo::MAX_AUTHORITIES_COUNT }>; - type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; + type WeightInfo = weights::pallet_bridge_grandpa_bridge_wococo_grandpa::WeightInfo; } /// Add granda bridge pallet to track Rococo relay chain @@ -410,7 +410,7 @@ impl pallet_bridge_grandpa::Config for Runtime { type HeadersToKeep = RelayChainHeadersToKeep; type MaxBridgedAuthorities = frame_support::traits::ConstU32<{ bp_rococo::MAX_AUTHORITIES_COUNT }>; - type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; + type WeightInfo = weights::pallet_bridge_grandpa_bridge_rococo_grandpa::WeightInfo; } pub const ROCOCO_BRIDGE_PARA_PALLET_NAME: &str = "Paras"; @@ -430,7 +430,7 @@ parameter_types! { pub type BridgeParachainWococoInstance = pallet_bridge_parachains::Instance1; impl pallet_bridge_parachains::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight; + type WeightInfo = weights::pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance::WeightInfo; type BridgesGrandpaPalletInstance = BridgeGrandpaWococoInstance; type ParasPalletName = WococoBridgeParachainPalletName; type ParaStoredHeaderDataBuilder = @@ -443,7 +443,7 @@ impl pallet_bridge_parachains::Config for Runtime pub type BridgeParachainRococoInstance = pallet_bridge_parachains::Instance2; impl pallet_bridge_parachains::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight; + type WeightInfo = weights::pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance::WeightInfo; type BridgesGrandpaPalletInstance = BridgeGrandpaRococoInstance; type ParasPalletName = RococoBridgeParachainPalletName; type ParaStoredHeaderDataBuilder = @@ -456,7 +456,7 @@ impl pallet_bridge_parachains::Config for Runtime pub type WithBridgeHubWococoMessagesInstance = pallet_bridge_messages::Instance1; impl pallet_bridge_messages::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; + type WeightInfo = weights::pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance::WeightInfo; type BridgedChainId = bridge_hub_rococo_config::BridgeHubWococoChainId; type ActiveOutboundLanes = bridge_hub_rococo_config::ActiveOutboundLanesToBridgeHubWococo; type MaxUnrewardedRelayerEntriesAtInboundLane = @@ -490,7 +490,7 @@ impl pallet_bridge_messages::Config for Run pub type WithBridgeHubRococoMessagesInstance = pallet_bridge_messages::Instance2; impl pallet_bridge_messages::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; + type WeightInfo = weights::pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance::WeightInfo; type BridgedChainId = bridge_hub_wococo_config::BridgeHubRococoChainId; type ActiveOutboundLanes = bridge_hub_wococo_config::ActiveOutboundLanesToBridgeHubRococo; type MaxUnrewardedRelayerEntriesAtInboundLane = From 94d74d22765ef94e8dda1f6506793bc12368fa9c Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 17:46:20 +0300 Subject: [PATCH 14/15] add mod for new weights --- .../bridge-hubs/bridge-hub-rococo/src/weights/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs index d5722374def..db28e6f898e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs @@ -22,6 +22,12 @@ pub mod cumulus_pallet_xcmp_queue; pub mod extrinsic_weights; pub mod frame_system; pub mod pallet_balances; +pub mod pallet_bridge_grandpa_bridge_rococo_grandpa; +pub mod pallet_bridge_grandpa_bridge_wococo_grandpa; +pub mod pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance; +pub mod pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance; +pub mod pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance; +pub mod pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance; pub mod pallet_collator_selection; pub mod pallet_multisig; pub mod pallet_session; From a54c2dc990a05b819a2626af901c1fc82ab15415 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 25 Jan 2023 18:18:10 +0300 Subject: [PATCH 15/15] impl WeightInfoExt --- .../bridge-hub-rococo/src/weights/mod.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs index db28e6f898e..1eec4e5c18a 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs @@ -42,3 +42,27 @@ pub use block_weights::constants::BlockExecutionWeight; pub use extrinsic_weights::constants::ExtrinsicBaseWeight; pub use paritydb_weights::constants::ParityDbWeight; pub use rocksdb_weights::constants::RocksDbWeight; + +impl pallet_bridge_messages::WeightInfoExt for pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE + } +} + +impl pallet_bridge_messages::WeightInfoExt for pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE + } +} + +impl pallet_bridge_parachains::WeightInfoExt for pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE + } +} + +impl pallet_bridge_parachains::WeightInfoExt for pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE + } +}