Skip to content
Snippets Groups Projects
Commit 59ded47e authored by Éloïs's avatar Éloïs
Browse files

fix(weights): define safe manual weights for pallets babe & grandpa

parent fec47e37
No related branches found
No related tags found
1 merge request!47Set manually all weights for ğdev
...@@ -832,10 +832,10 @@ dependencies = [ ...@@ -832,10 +832,10 @@ dependencies = [
"log", "log",
"pallet-authority-members", "pallet-authority-members",
"pallet-babe", "pallet-babe",
"pallet-balances",
"pallet-certification", "pallet-certification",
"pallet-duniter-account", "pallet-duniter-account",
"pallet-duniter-wot", "pallet-duniter-wot",
"pallet-grandpa",
"pallet-identity", "pallet-identity",
"pallet-membership", "pallet-membership",
"pallet-provide-randomness", "pallet-provide-randomness",
......
...@@ -24,10 +24,10 @@ std = [ ...@@ -24,10 +24,10 @@ std = [
'log/std', 'log/std',
'pallet-authority-members/std', 'pallet-authority-members/std',
'pallet-babe/std', 'pallet-babe/std',
'pallet-balances/std',
'pallet-certification/std', 'pallet-certification/std',
'pallet-duniter-account/std', 'pallet-duniter-account/std',
'pallet-duniter-wot/std', 'pallet-duniter-wot/std',
'pallet-grandpa/std',
'pallet-identity/std', 'pallet-identity/std',
'pallet-membership/std', 'pallet-membership/std',
'pallet-provide-randomness/std', 'pallet-provide-randomness/std',
...@@ -79,7 +79,7 @@ default-features = false ...@@ -79,7 +79,7 @@ default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-02' branch = 'duniter-monthly-2022-02'
[dependencies.pallet-balances] [dependencies.pallet-grandpa]
default-features = false default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-02' branch = 'duniter-monthly-2022-02'
......
...@@ -133,7 +133,7 @@ macro_rules! pallets_config { ...@@ -133,7 +133,7 @@ macro_rules! pallets_config {
type HandleEquivocation = type HandleEquivocation =
pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>; pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
type WeightInfo = (); type WeightInfo = common_runtime::weights::pallet_babe::WeightInfo<Runtime>;
type MaxAuthorities = MaxAuthorities; type MaxAuthorities = MaxAuthorities;
} }
...@@ -252,7 +252,7 @@ macro_rules! pallets_config { ...@@ -252,7 +252,7 @@ macro_rules! pallets_config {
type HandleEquivocation = (); type HandleEquivocation = ();
type WeightInfo = (); type WeightInfo = common_runtime::weights::pallet_grandpa::WeightInfo<Runtime>;
type MaxAuthorities = MaxAuthorities; type MaxAuthorities = MaxAuthorities;
} }
......
...@@ -14,4 +14,5 @@ ...@@ -14,4 +14,5 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
pub mod pallet_balances; pub mod pallet_babe;
pub mod pallet_grandpa;
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
//! Manual weights for the GRANDPA Pallet in duniter runtimes
//! This file was not auto-generated.
use frame_support::{
traits::Get,
weights::{
constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS},
Weight,
},
};
use sp_std::marker::PhantomData;
/// Weight functions for `pallet_babe`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_babe::WeightInfo for WeightInfo<T> {
fn plan_config_change() -> Weight {
T::DbWeight::get().writes(1)
}
fn report_equivocation(validator_count: u32) -> Weight {
// we take the validator set count from the membership proof to
// calculate the weight but we set a floor of 100 validators.
let validator_count = validator_count.max(100) as u64;
// checking membership proof
(35 * WEIGHT_PER_MICROS)
.saturating_add((175 * WEIGHT_PER_NANOS).saturating_mul(validator_count))
.saturating_add(T::DbWeight::get().reads(5))
// check equivocation proof
.saturating_add(110 * WEIGHT_PER_MICROS)
// report offence
.saturating_add(110 * WEIGHT_PER_MICROS)
.saturating_add(T::DbWeight::get().writes(3))
}
}
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
//! Manually written file for temporary weights (polkadot x 10)
// TODO regenerate thi file with benchmarks:
//
// Executed Command:
// target/release/duniter
// benchmark
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_balances
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/gdev/src/weights/
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;
/// Weight functions for `pallet_balances`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
fn transfer() -> Weight {
(688_850_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn transfer_keep_alive() -> Weight {
(514_410_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_balance_creating() -> Weight {
(277_360_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_balance_killing() -> Weight {
(329_990_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn force_transfer() -> Weight {
(674_510_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn transfer_all() -> Weight {
(633_590_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: System Account (r:1 w:1)
fn force_unreserve() -> Weight {
(277_660_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
//! Manual weights for the GRANDPA Pallet in duniter runtimes
//! This file was not auto-generated.
use frame_support::{
traits::Get,
weights::{
constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS},
Weight,
},
};
use sp_std::marker::PhantomData;
/// Weight functions for `pallet_grandpa`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_grandpa::WeightInfo for WeightInfo<T> {
fn report_equivocation(validator_count: u32) -> Weight {
// we take the validator set count from the membership proof to
// calculate the weight but we set a floor of 100 validators.
let validator_count = validator_count.max(100) as u64;
// checking membership proof
(35 * WEIGHT_PER_MICROS)
.saturating_add((175 * WEIGHT_PER_NANOS).saturating_mul(validator_count))
.saturating_add(T::DbWeight::get().reads(5))
// check equivocation proof
.saturating_add(95 * WEIGHT_PER_MICROS)
// report offence
.saturating_add(110 * WEIGHT_PER_MICROS)
.saturating_add(T::DbWeight::get().writes(3))
// fetching set id -> session index mappings
.saturating_add(T::DbWeight::get().reads(2))
}
fn note_stalled() -> Weight {
(3 * WEIGHT_PER_MICROS).saturating_add(T::DbWeight::get().writes(1))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment