Skip to content
Snippets Groups Projects
Unverified Commit 8c85d94a authored by bgallois's avatar bgallois
Browse files

feat: add pallet session benchmark

parent 39753d3b
No related branches found
No related tags found
No related merge requests found
Pipeline #31608 passed
...@@ -891,6 +891,7 @@ dependencies = [ ...@@ -891,6 +891,7 @@ dependencies = [
"pallet-proxy", "pallet-proxy",
"pallet-scheduler", "pallet-scheduler",
"pallet-session", "pallet-session",
"pallet-session-benchmarking",
"pallet-timestamp", "pallet-timestamp",
"pallet-treasury", "pallet-treasury",
"pallet-universal-dividend", "pallet-universal-dividend",
...@@ -2582,6 +2583,7 @@ dependencies = [ ...@@ -2582,6 +2583,7 @@ dependencies = [
"pallet-proxy", "pallet-proxy",
"pallet-scheduler", "pallet-scheduler",
"pallet-session", "pallet-session",
"pallet-session-benchmarking",
"pallet-sudo", "pallet-sudo",
"pallet-timestamp", "pallet-timestamp",
"pallet-transaction-payment", "pallet-transaction-payment",
...@@ -5417,6 +5419,26 @@ dependencies = [ ...@@ -5417,6 +5419,26 @@ dependencies = [
"sp-trie", "sp-trie",
] ]
[[package]]
name = "pallet-session-benchmarking"
version = "4.0.0-dev"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"pallet-authority-members",
"pallet-balances",
"pallet-session",
"pallet-timestamp",
"parity-scale-codec",
"scale-info",
"sp-core",
"sp-io",
"sp-runtime",
"sp-session",
"sp-std",
]
[[package]] [[package]]
name = "pallet-sudo" name = "pallet-sudo"
version = "4.0.0-dev" version = "4.0.0-dev"
......
...@@ -20,4 +20,5 @@ These pallets are at the core of Duniter/Ğ1 currency ...@@ -20,4 +20,5 @@ These pallets are at the core of Duniter/Ğ1 currency
- **`duniter-test-parameters`** Test parameters only used in ĞDev to allow tweaking parameters more easily. - **`duniter-test-parameters`** Test parameters only used in ĞDev to allow tweaking parameters more easily.
- **`oneshot-account`** Oneshot accounts are light accounts only used once for anonimity or convenience use case. - **`oneshot-account`** Oneshot accounts are light accounts only used once for anonimity or convenience use case.
- **`provide-randomness`** Lets blockchain users ask for a verifiable random number. - **`provide-randomness`** Lets blockchain users ask for a verifiable random number.
- **`session-benchmarking`** Benchmarks the session pallet.
- **`upgrade-origin`** Allows some origins to dispatch a call as root. - **`upgrade-origin`** Allows some origins to dispatch a call as root.
\ No newline at end of file
[package]
name = "pallet-session-benchmarking"
version = "4.0.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME sessions pallet benchmarking"
readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
pallet-authority-members = { path = "../authority-members", default-features = false }
[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/duniter/substrate'
optional = true
branch = 'duniter-substrate-v0.9.32'
[dependencies.frame-support]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.frame-system]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.pallet-session]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.sp-session]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.sp-std]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dependencies.parity-scale-codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = "3.1.5"
[dev-dependencies.pallet-balances]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dev-dependencies.pallet-timestamp]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dev-dependencies.sp-core]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[dev-dependencies.sp-io]
default-features = false
git = 'https://github.com/duniter/substrate'
branch = 'duniter-substrate-v0.9.32'
[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-session/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
]
runtime-benchmarks = [
'frame-benchmarking/runtime-benchmarks',
'frame-support/runtime-benchmarks',
'frame-system/runtime-benchmarks',
]
# Duniter session-benchmarking pallet
Benchmark crate for the `pallet-session` that is decoupled from the `staking-pallet` not used in Duniter.
In Duniter, the `SessionManager `and `SessionHandler` hooks are implemented in the `authority-members` pallet.
\ No newline at end of file
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S 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.
//
// Duniter-v2S 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 Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
//! Benchmarks for the Session Pallet.
// This is separated into its own crate due to cyclic dependency issues.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg(feature = "runtime-benchmarks")]
use parity_scale_codec::Decode;
use sp_std::{prelude::*, vec};
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_system::RawOrigin;
use pallet_session::*;
pub struct Pallet<T: Config>(pallet_session::Pallet<T>);
pub trait Config: pallet_session::Config {}
benchmarks! {
set_keys {
let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::inc_providers(&caller);
let keys = T::Keys::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap();
let proof: Vec<u8> = vec![0,1,2,3];
}: _(RawOrigin::Signed(caller), keys, proof)
purge_keys {
let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::inc_providers(&caller);
let keys = T::Keys::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap();
let proof: Vec<u8> = vec![0,1,2,3];
let _t = pallet_session::Pallet::<T>::set_keys(RawOrigin::Signed(caller.clone()).into(), keys, proof);
}: _(RawOrigin::Signed(caller))
}
...@@ -23,6 +23,7 @@ runtime-benchmarks = [ ...@@ -23,6 +23,7 @@ runtime-benchmarks = [
'pallet-multisig/runtime-benchmarks', 'pallet-multisig/runtime-benchmarks',
'pallet-proxy/runtime-benchmarks', 'pallet-proxy/runtime-benchmarks',
'pallet-preimage/runtime-benchmarks', 'pallet-preimage/runtime-benchmarks',
'pallet-session-benchmarking/runtime-benchmarks',
'pallet-treasury/runtime-benchmarks', 'pallet-treasury/runtime-benchmarks',
'pallet-upgrade-origin/runtime-benchmarks', 'pallet-upgrade-origin/runtime-benchmarks',
'sp-runtime/runtime-benchmarks', 'sp-runtime/runtime-benchmarks',
...@@ -77,6 +78,7 @@ pallet-oneshot-account = { path = '../../pallets/oneshot-account', default-featu ...@@ -77,6 +78,7 @@ pallet-oneshot-account = { path = '../../pallets/oneshot-account', default-featu
pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false } pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false }
pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false }
pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false }
pallet-session-benchmarking = { path = '../../pallets/session-benchmarking', default-features = false }
sp-membership = { path = '../../primitives/membership', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false }
# Crates.io # Crates.io
......
...@@ -239,6 +239,7 @@ macro_rules! runtime_apis { ...@@ -239,6 +239,7 @@ macro_rules! runtime_apis {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait; use frame_support::traits::StorageInfoTrait;
use pallet_session_benchmarking::Pallet as SessionBench;
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
use frame_benchmarking::baseline::Pallet as Baseline; use frame_benchmarking::baseline::Pallet as Baseline;
...@@ -258,9 +259,11 @@ macro_rules! runtime_apis { ...@@ -258,9 +259,11 @@ macro_rules! runtime_apis {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
// Trying to add benchmarks directly to some pallets caused cyclic dependency issues. // Trying to add benchmarks directly to some pallets caused cyclic dependency issues.
// To get around that, we separated the benchmarks into its own crate. // To get around that, we separated the benchmarks into its own crate.
use pallet_session_benchmarking::Pallet as SessionBench;
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
use frame_benchmarking::baseline::Pallet as Baseline; use frame_benchmarking::baseline::Pallet as Baseline;
impl pallet_session_benchmarking::Config for Runtime {}
impl frame_system_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {}
impl frame_benchmarking::baseline::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {}
......
...@@ -241,7 +241,7 @@ macro_rules! pallets_config { ...@@ -241,7 +241,7 @@ macro_rules! pallets_config {
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, AuthorityMembers>; type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, AuthorityMembers>;
type SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders; type SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = opaque::SessionKeys; type Keys = opaque::SessionKeys;
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>; type WeightInfo = common_runtime::weights::pallet_session::WeightInfo<Runtime>;
} }
impl pallet_session::historical::Config for Runtime { impl pallet_session::historical::Config for Runtime {
type FullIdentification = ValidatorFullIdentification; type FullIdentification = ValidatorFullIdentification;
......
...@@ -28,6 +28,7 @@ pub mod pallet_grandpa; ...@@ -28,6 +28,7 @@ pub mod pallet_grandpa;
pub mod pallet_im_online; pub mod pallet_im_online;
pub mod pallet_multisig; pub mod pallet_multisig;
pub mod pallet_proxy; pub mod pallet_proxy;
pub mod pallet_session;
pub mod pallet_scheduler; pub mod pallet_scheduler;
pub mod pallet_timestamp; pub mod pallet_timestamp;
pub mod pallet_treasury; pub mod pallet_treasury;
......
// Copyright 2021-2022 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S 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.
//
// Duniter-v2S 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 Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_session`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-05-04, STEPS: `5`, REPEAT: 2, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `benjamin-xps139380`, CPU: `Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// target/release/duniter
// benchmark
// pallet
// --chain=dev
// --steps=5
// --repeat=2
// --pallet=pallet_session
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/common/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_session`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_session::WeightInfo for WeightInfo<T> {
// Storage: Session NextKeys (r:1 w:1)
// Storage: Session KeyOwner (r:4 w:4)
fn set_keys() -> Weight {
// Minimum execution time: 127_407 nanoseconds.
Weight::from_ref_time(136_848_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}
// Storage: Session NextKeys (r:1 w:1)
// Storage: Session KeyOwner (r:0 w:4)
fn purge_keys() -> Weight {
// Minimum execution time: 161_605 nanoseconds.
Weight::from_ref_time(166_513_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}
}
...@@ -38,6 +38,7 @@ runtime-benchmarks = [ ...@@ -38,6 +38,7 @@ runtime-benchmarks = [
'pallet-multisig/runtime-benchmarks', 'pallet-multisig/runtime-benchmarks',
'pallet-oneshot-account/runtime-benchmarks', 'pallet-oneshot-account/runtime-benchmarks',
'pallet-preimage/runtime-benchmarks', 'pallet-preimage/runtime-benchmarks',
'pallet-session-benchmarking/runtime-benchmarks',
'pallet-proxy/runtime-benchmarks', 'pallet-proxy/runtime-benchmarks',
'pallet-scheduler/runtime-benchmarks', 'pallet-scheduler/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks',
...@@ -145,6 +146,7 @@ pallet-membership = { path = '../../pallets/membership', default-features = fals ...@@ -145,6 +146,7 @@ pallet-membership = { path = '../../pallets/membership', default-features = fals
pallet-oneshot-account = { path = '../../pallets/oneshot-account', default-features = false } pallet-oneshot-account = { path = '../../pallets/oneshot-account', default-features = false }
pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false } pallet-provide-randomness = { path = '../../pallets/provide-randomness', default-features = false }
pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false } pallet-universal-dividend = { path = '../../pallets/universal-dividend', default-features = false }
pallet-session-benchmarking = { path = '../../pallets/session-benchmarking', default-features = false }
pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false } pallet-upgrade-origin = { path = '../../pallets/upgrade-origin', default-features = false }
sp-membership = { path = '../../primitives/membership', default-features = false } sp-membership = { path = '../../primitives/membership', default-features = false }
......
...@@ -151,7 +151,7 @@ mod benches { ...@@ -151,7 +151,7 @@ mod benches {
[pallet_balances, Balances] [pallet_balances, Balances]
[frame_benchmarking::baseline, Baseline::<Runtime>] [frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_collective, TechnicalCommittee] [pallet_collective, TechnicalCommittee]
//[pallet_session, TransactionPayment] FIXME [pallet_session, SessionBench::<Runtime>]
[pallet_im_online, ImOnline] [pallet_im_online, ImOnline]
[pallet_multisig, Multisig] [pallet_multisig, Multisig]
[pallet_preimage, Preimage] [pallet_preimage, Preimage]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment