Skip to content

Commit b6de08f

Browse files
authored
change: Fix, recalculate and use bridge pallet WeightInfo (#992)
1 parent 5bb1440 commit b6de08f

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

toolkit/bridge/pallet/src/benchmarking.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ mod benchmarks {
3434
use super::*;
3535

3636
#[benchmark]
37-
fn handle_transfers(
38-
t: Linear<1, { T::MaxTransfersPerBlock::get() }>,
39-
s: Linear<1, { T::MaxTransfersPerBlock::get() }>,
40-
) {
37+
fn handle_transfers(t: Linear<1, { T::MaxTransfersPerBlock::get() }>) {
4138
assert_ok!(Pallet::<T>::set_main_chain_scripts(
4239
RawOrigin::Root.into(),
4340
T::BenchmarkHelper::main_chain_scripts(),

toolkit/bridge/pallet/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl<Recipient> TransferHandler<Recipient> for () {
3939
#[frame_support::pallet(dev_mode)]
4040
pub mod pallet {
4141
use super::*;
42+
use crate::weights::WeightInfo;
4243
use frame_support::pallet_prelude::*;
4344
use frame_system::{ensure_none, pallet_prelude::OriginFor};
4445
use parity_scale_codec::MaxEncodedLen;
@@ -112,7 +113,7 @@ pub mod pallet {
112113
impl<T: Config> Pallet<T> {
113114
/// Inherent extrinsic that handles all incoming transfers in the current block
114115
#[pallet::call_index(0)]
115-
#[pallet::weight(0)]
116+
#[pallet::weight(T::WeightInfo::handle_transfers(transfers.len() as u32))]
116117
pub fn handle_transfers(
117118
origin: OriginFor<T>,
118119
transfers: BoundedVec<BridgeTransferV1<T::Recipient>, T::MaxTransfersPerBlock>,
@@ -132,7 +133,7 @@ pub mod pallet {
132133
///
133134
///
134135
#[pallet::call_index(1)]
135-
#[pallet::weight(0)]
136+
#[pallet::weight(T::WeightInfo::set_main_chain_scripts())]
136137
pub fn set_main_chain_scripts(
137138
origin: OriginFor<T>,
138139
new_scripts: MainChainScripts,

toolkit/bridge/pallet/src/weights.rs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! Autogenerated weights for pallet_partner_chains_bridge
33
//!
44
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 50.0.0
5-
//! DATE: 2025-08-25, STEPS: `500`, REPEAT: `200`, LOW RANGE: `[]`, HIGH RANGE: `[]`
5+
//! DATE: 2025-09-10, STEPS: `500`, REPEAT: `200`, LOW RANGE: `[]`, HIGH RANGE: `[]`
66
//! WORST CASE MAP SIZE: `1000000`
77
//! HOSTNAME: `Nikolaoss-MacBook-Pro.local`, CPU: `<UNKNOWN>`
88
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
@@ -36,61 +36,65 @@ use core::marker::PhantomData;
3636

3737
/// Weight functions needed for pallet_partner_chains_bridge.
3838
pub trait WeightInfo {
39-
fn handle_transfers(t: u32, s: u32, ) -> Weight;
39+
fn handle_transfers(t: u32, ) -> Weight;
4040
fn set_main_chain_scripts() -> Weight;
4141
}
4242

4343
/// Weights for pallet_partner_chains_bridge using the Substrate node and recommended hardware.
4444
pub struct SubstrateWeight<T>(PhantomData<T>);
4545
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
46+
/// Storage: `Bridge::DataCheckpoint` (r:0 w:1)
47+
/// Proof: `Bridge::DataCheckpoint` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
4648
/// The range of component `t` is `[1, 256]`.
47-
/// The range of component `s` is `[1, 256]`.
48-
fn handle_transfers(t: u32, s: u32, ) -> Weight {
49+
fn handle_transfers(t: u32, ) -> Weight {
4950
// Proof Size summary in bytes:
5051
// Measured: `0`
5152
// Estimated: `0`
52-
// Minimum execution time: 1_000_000 picoseconds.
53-
Weight::from_parts(1_914_402, 0)
54-
// Standard Error: 8
55-
.saturating_add(Weight::from_parts(166, 0).saturating_mul(t.into()))
56-
// Standard Error: 8
57-
.saturating_add(Weight::from_parts(127, 0).saturating_mul(s.into()))
53+
// Minimum execution time: 2_000_000 picoseconds.
54+
Weight::from_parts(1_999_689, 0)
55+
// Standard Error: 4
56+
.saturating_add(Weight::from_parts(53, 0).saturating_mul(t.into()))
57+
.saturating_add(T::DbWeight::get().writes(1_u64))
5858
}
5959
/// Storage: `Bridge::MainChainScriptsConfiguration` (r:0 w:1)
6060
/// Proof: `Bridge::MainChainScriptsConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
61+
/// Storage: `Bridge::DataCheckpoint` (r:0 w:1)
62+
/// Proof: `Bridge::DataCheckpoint` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
6163
fn set_main_chain_scripts() -> Weight {
6264
// Proof Size summary in bytes:
6365
// Measured: `0`
6466
// Estimated: `0`
65-
// Minimum execution time: 1_000_000 picoseconds.
67+
// Minimum execution time: 2_000_000 picoseconds.
6668
Weight::from_parts(2_000_000, 0)
67-
.saturating_add(T::DbWeight::get().writes(1_u64))
69+
.saturating_add(T::DbWeight::get().writes(2_u64))
6870
}
6971
}
7072

7173
// For backwards compatibility and tests
7274
impl WeightInfo for () {
75+
/// Storage: `Bridge::DataCheckpoint` (r:0 w:1)
76+
/// Proof: `Bridge::DataCheckpoint` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
7377
/// The range of component `t` is `[1, 256]`.
74-
/// The range of component `s` is `[1, 256]`.
75-
fn handle_transfers(t: u32, s: u32, ) -> Weight {
78+
fn handle_transfers(t: u32, ) -> Weight {
7679
// Proof Size summary in bytes:
7780
// Measured: `0`
7881
// Estimated: `0`
79-
// Minimum execution time: 1_000_000 picoseconds.
80-
Weight::from_parts(1_914_402, 0)
81-
// Standard Error: 8
82-
.saturating_add(Weight::from_parts(166, 0).saturating_mul(t.into()))
83-
// Standard Error: 8
84-
.saturating_add(Weight::from_parts(127, 0).saturating_mul(s.into()))
82+
// Minimum execution time: 2_000_000 picoseconds.
83+
Weight::from_parts(1_999_689, 0)
84+
// Standard Error: 4
85+
.saturating_add(Weight::from_parts(53, 0).saturating_mul(t.into()))
86+
.saturating_add(RocksDbWeight::get().writes(1_u64))
8587
}
8688
/// Storage: `Bridge::MainChainScriptsConfiguration` (r:0 w:1)
8789
/// Proof: `Bridge::MainChainScriptsConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
90+
/// Storage: `Bridge::DataCheckpoint` (r:0 w:1)
91+
/// Proof: `Bridge::DataCheckpoint` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
8892
fn set_main_chain_scripts() -> Weight {
8993
// Proof Size summary in bytes:
9094
// Measured: `0`
9195
// Estimated: `0`
92-
// Minimum execution time: 1_000_000 picoseconds.
96+
// Minimum execution time: 2_000_000 picoseconds.
9397
Weight::from_parts(2_000_000, 0)
94-
.saturating_add(RocksDbWeight::get().writes(1_u64))
98+
.saturating_add(RocksDbWeight::get().writes(2_u64))
9599
}
96100
}

0 commit comments

Comments
 (0)