-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add tips pallet #352
Changes from all commits
3c3ae9b
96bb827
3718748
6d4705e
31eaad3
5bad501
f519ff1
1b469d9
d135a77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ use frame_support::{ | |
parameter_types, | ||
weights::{constants::WEIGHT_PER_SECOND, Weight}, | ||
}; | ||
use sp_runtime::{Perbill, Perquintill}; | ||
use sp_runtime::{Perbill, Percent, Perquintill}; | ||
|
||
use parachain_staking::InflationInfo; | ||
|
||
|
@@ -408,6 +408,17 @@ pub mod preimage { | |
} | ||
} | ||
|
||
pub mod tips { | ||
use super::*; | ||
|
||
parameter_types! { | ||
pub const MaximumReasonLength: u32 = 16384; | ||
pub const TipCountdown: BlockNumber = DAYS; | ||
pub const TipFindersFee: Percent = Percent::from_percent(20); | ||
pub const TipReportDepositBase: Balance = deposit(1, 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Polkadot, this is set to 1 Dollar. However, I wanted to align with our other deposits. |
||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -462,7 +462,8 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime { | |
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>; | ||
} | ||
|
||
impl pallet_membership::Config for Runtime { | ||
type TechnicalMembershipProvider = pallet_membership::Instance1; | ||
impl pallet_membership::Config<TechnicalMembershipProvider> for Runtime { | ||
type Event = Event; | ||
type AddOrigin = MoreThanHalfCouncil; | ||
type RemoveOrigin = MoreThanHalfCouncil; | ||
|
@@ -475,6 +476,31 @@ impl pallet_membership::Config for Runtime { | |
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>; | ||
} | ||
|
||
type TipsMembershipProvider = pallet_membership::Instance2; | ||
impl pallet_membership::Config<TipsMembershipProvider> for Runtime { | ||
type Event = Event; | ||
type AddOrigin = MoreThanHalfCouncil; | ||
type RemoveOrigin = MoreThanHalfCouncil; | ||
type SwapOrigin = MoreThanHalfCouncil; | ||
type ResetOrigin = MoreThanHalfCouncil; | ||
type PrimeOrigin = MoreThanHalfCouncil; | ||
type MembershipInitialized = (); | ||
type MembershipChanged = (); | ||
Comment on lines
+487
to
+488
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two receivers can be kept empty for Tippers IMO as we don't need to handle membership change anywhere else in contrast to the Technical Committee which also needs to apply it to the collective pallet. |
||
type MaxMembers = constants::governance::TechnicalMaxMembers; | ||
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>; | ||
} | ||
|
||
impl pallet_tips::Config for Runtime { | ||
type MaximumReasonLength = constants::tips::MaximumReasonLength; | ||
type DataDepositPerByte = constants::ByteDeposit; | ||
type Tippers = runtime_common::Tippers<Runtime, TipsMembershipProvider>; | ||
type TipCountdown = constants::tips::TipCountdown; | ||
type TipFindersFee = constants::tips::TipFindersFee; | ||
type TipReportDepositBase = constants::tips::TipReportDepositBase; | ||
type Event = Event; | ||
type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>; | ||
} | ||
|
||
impl attestation::Config for Runtime { | ||
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>; | ||
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>; | ||
|
@@ -700,6 +726,7 @@ impl InstanceFilter<Call> for ProxyType { | |
| Call::System(..) | ||
| Call::TechnicalCommittee(..) | ||
| Call::TechnicalMembership(..) | ||
| Call::TipsMembership(..) | ||
| Call::Timestamp(..) | ||
| Call::Treasury(..) | ||
| Call::Utility(..) | ||
|
@@ -780,6 +807,7 @@ impl InstanceFilter<Call> for ProxyType { | |
| Call::Democracy(..) | ||
| Call::TechnicalCommittee(..) | ||
| Call::TechnicalMembership(..) | ||
| Call::TipsMembership(..) | ||
| Call::Treasury(..) | Call::Utility(..) | ||
), | ||
ProxyType::ParachainStaking => { | ||
|
@@ -850,7 +878,7 @@ construct_runtime! { | |
Council: pallet_collective::<Instance1> = 31, | ||
TechnicalCommittee: pallet_collective::<Instance2> = 32, | ||
// placeholder: parachain council election = 33, | ||
TechnicalMembership: pallet_membership = 34, | ||
TechnicalMembership: pallet_membership::<Instance1> = 34, | ||
Treasury: pallet_treasury = 35, | ||
|
||
// Utility module. | ||
|
@@ -868,6 +896,10 @@ construct_runtime! { | |
// Preimage registrar | ||
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 44, | ||
|
||
// Tips module to reward contributions to the ecosystem with small amount of KILTs. | ||
TipsMembership: pallet_membership::<Instance2> = 45, | ||
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 46, | ||
|
||
// KILT Pallets. Start indices 60 to leave room | ||
KiltLaunch: kilt_launch = 60, | ||
Ctype: ctype = 61, | ||
|
@@ -1098,6 +1130,7 @@ impl_runtime_apis! { | |
list_benchmark!(list, extra, pallet_preimage, Preimage); | ||
list_benchmark!(list, extra, pallet_scheduler, Scheduler); | ||
list_benchmark!(list, extra, pallet_timestamp, Timestamp); | ||
list_benchmark!(list, extra, pallet_tips, Tips); | ||
list_benchmark!(list, extra, pallet_treasury, Treasury); | ||
list_benchmark!(list, extra, pallet_utility, Utility); | ||
list_benchmark!(list, extra, pallet_vesting, Vesting); | ||
|
@@ -1166,6 +1199,7 @@ impl_runtime_apis! { | |
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>); | ||
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>); | ||
add_benchmark!(params, batches, pallet_timestamp, Timestamp); | ||
add_benchmark!(params, batches, pallet_tips, Tips); | ||
add_benchmark!(params, batches, pallet_treasury, Treasury); | ||
add_benchmark!(params, batches, pallet_utility, Utility); | ||
add_benchmark!(params, batches, pallet_vesting, Vesting); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// KILT Blockchain – https://botlabs.org | ||
// Copyright (C) 2019-2022 BOTLabs GmbH | ||
|
||
// The KILT Blockchain 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. | ||
|
||
// The KILT Blockchain 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
// If you feel like getting in touch with us, you can do so at info@botlabs.org | ||
|
||
//! Autogenerated weights for pallet_tips | ||
//! | ||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev | ||
//! DATE: 2022-04-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` | ||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 | ||
|
||
// Executed Command: | ||
// target/release/kilt-parachain | ||
// benchmark | ||
// --chain=dev | ||
// --steps=50 | ||
// --repeat=20 | ||
// --pallet=pallet-tips | ||
// --extrinsic=* | ||
// --execution=wasm | ||
// --wasm-execution=compiled | ||
// --heap-pages=4096 | ||
// --output=./runtimes/peregrine/src/weights/pallet_tips.rs | ||
// --template=.maintain/runtime-weight-template.hbs | ||
|
||
#![cfg_attr(rustfmt, rustfmt_skip)] | ||
#![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_tips`. | ||
pub struct WeightInfo<T>(PhantomData<T>); | ||
impl<T: frame_system::Config> pallet_tips::WeightInfo for WeightInfo<T> { | ||
// Storage: Tips Reasons (r:1 w:1) | ||
// Storage: Tips Tips (r:1 w:1) | ||
fn report_awesome(r: u32, ) -> Weight { | ||
(40_320_000 as Weight) | ||
// Standard Error: 0 | ||
.saturating_add((2_000 as Weight).saturating_mul(r as Weight)) | ||
.saturating_add(T::DbWeight::get().reads(2 as Weight)) | ||
.saturating_add(T::DbWeight::get().writes(2 as Weight)) | ||
} | ||
// Storage: Tips Tips (r:1 w:1) | ||
// Storage: Tips Reasons (r:0 w:1) | ||
fn retract_tip() -> Weight { | ||
(36_908_000 as Weight) | ||
.saturating_add(T::DbWeight::get().reads(1 as Weight)) | ||
.saturating_add(T::DbWeight::get().writes(2 as Weight)) | ||
} | ||
// Storage: TipsMembership Members (r:1 w:0) | ||
// Storage: Tips Reasons (r:1 w:1) | ||
// Storage: Tips Tips (r:0 w:1) | ||
fn tip_new(r: u32, t: u32, ) -> Weight { | ||
(26_418_000 as Weight) | ||
// Standard Error: 0 | ||
.saturating_add((2_000 as Weight).saturating_mul(r as Weight)) | ||
// Standard Error: 0 | ||
.saturating_add((102_000 as Weight).saturating_mul(t as Weight)) | ||
.saturating_add(T::DbWeight::get().reads(2 as Weight)) | ||
.saturating_add(T::DbWeight::get().writes(2 as Weight)) | ||
} | ||
// Storage: TipsMembership Members (r:1 w:0) | ||
// Storage: Tips Tips (r:1 w:1) | ||
fn tip(t: u32, ) -> Weight { | ||
(15_519_000 as Weight) | ||
// Standard Error: 0 | ||
.saturating_add((457_000 as Weight).saturating_mul(t as Weight)) | ||
.saturating_add(T::DbWeight::get().reads(2 as Weight)) | ||
.saturating_add(T::DbWeight::get().writes(1 as Weight)) | ||
} | ||
// Storage: Tips Tips (r:1 w:1) | ||
// Storage: TipsMembership Members (r:1 w:0) | ||
// Storage: System Account (r:2 w:2) | ||
// Storage: Tips Reasons (r:0 w:1) | ||
fn close_tip(t: u32, ) -> Weight { | ||
(64_426_000 as Weight) | ||
// Standard Error: 0 | ||
.saturating_add((300_000 as Weight).saturating_mul(t as Weight)) | ||
.saturating_add(T::DbWeight::get().reads(4 as Weight)) | ||
.saturating_add(T::DbWeight::get().writes(4 as Weight)) | ||
} | ||
// Storage: Tips Tips (r:1 w:1) | ||
// Storage: Tips Reasons (r:0 w:1) | ||
fn slash_tip(t: u32, ) -> Weight { | ||
(22_294_000 as Weight) | ||
// Standard Error: 0 | ||
.saturating_add((6_000 as Weight).saturating_mul(t as Weight)) | ||
.saturating_add(T::DbWeight::get().reads(1 as Weight)) | ||
.saturating_add(T::DbWeight::get().writes(2 as Weight)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is naively taken from Kusama configuration, I could not find any information where this value comes from unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we were told once that there is a threshold up to which a storage entry size doesn't influence the weights. If this threshold is passed, the storage needs to be taken into account when doing benchmarks. Maybe the value is related to that?