mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 04:17:57 +00:00
Allow council to slash treasury tip (#7753)
* wk2051 | D4 |Allow council to slash treasury tip | p1 * Update frame/tips/src/lib.rs Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> * wk2051 | D5 |Allow council to slash treasury tip | p2 * wk2051 | D5 |Allow council to slash treasury tip | p3 * wk2051 | D5 |Allow council to slash treasury tip | p4 * wk2051 | D5 |Allow council to slash treasury tip | p5 * random change * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_tips --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/tips/src/weights.rs --template=./.maintain/frame-weight-template.hbs * fix typo * Update frame/tips/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/tips/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/tips/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/tips/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/tips/src/tests.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * wk2052 | D1 | Allow council to slash treasury tip | p6 Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Parity Benchmarking Bot <admin@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -77,7 +77,7 @@ fn create_bounty<T: Config>() -> Result<(
|
|||||||
Ok((curator_lookup, bounty_id))
|
Ok((curator_lookup, bounty_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_pod_account<T: Config>() {
|
fn setup_pot_account<T: Config>() {
|
||||||
let pot_account = Bounties::<T>::account_id();
|
let pot_account = Bounties::<T>::account_id();
|
||||||
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
||||||
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
||||||
@@ -109,7 +109,7 @@ benchmarks! {
|
|||||||
}: _(RawOrigin::Root, bounty_id)
|
}: _(RawOrigin::Root, bounty_id)
|
||||||
|
|
||||||
propose_curator {
|
propose_curator {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
|
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
|
||||||
let curator_lookup = T::Lookup::unlookup(curator.clone());
|
let curator_lookup = T::Lookup::unlookup(curator.clone());
|
||||||
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
||||||
@@ -120,7 +120,7 @@ benchmarks! {
|
|||||||
|
|
||||||
// Worst case when curator is inactive and any sender unassigns the curator.
|
// Worst case when curator is inactive and any sender unassigns the curator.
|
||||||
unassign_curator {
|
unassign_curator {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
||||||
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
||||||
let bounty_id = BountyCount::get() - 1;
|
let bounty_id = BountyCount::get() - 1;
|
||||||
@@ -129,7 +129,7 @@ benchmarks! {
|
|||||||
}: _(RawOrigin::Signed(caller), bounty_id)
|
}: _(RawOrigin::Signed(caller), bounty_id)
|
||||||
|
|
||||||
accept_curator {
|
accept_curator {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
|
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
|
||||||
let curator_lookup = T::Lookup::unlookup(curator.clone());
|
let curator_lookup = T::Lookup::unlookup(curator.clone());
|
||||||
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
||||||
@@ -140,7 +140,7 @@ benchmarks! {
|
|||||||
}: _(RawOrigin::Signed(curator), bounty_id)
|
}: _(RawOrigin::Signed(curator), bounty_id)
|
||||||
|
|
||||||
award_bounty {
|
award_bounty {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
||||||
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ benchmarks! {
|
|||||||
}: _(RawOrigin::Signed(curator), bounty_id, beneficiary)
|
}: _(RawOrigin::Signed(curator), bounty_id, beneficiary)
|
||||||
|
|
||||||
claim_bounty {
|
claim_bounty {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
||||||
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
||||||
|
|
||||||
@@ -170,14 +170,14 @@ benchmarks! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
close_bounty_proposed {
|
close_bounty_proposed {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, 0);
|
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, 0);
|
||||||
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
||||||
let bounty_id = BountyCount::get() - 1;
|
let bounty_id = BountyCount::get() - 1;
|
||||||
}: close_bounty(RawOrigin::Root, bounty_id)
|
}: close_bounty(RawOrigin::Root, bounty_id)
|
||||||
|
|
||||||
close_bounty_active {
|
close_bounty_active {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
||||||
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
||||||
let bounty_id = BountyCount::get() - 1;
|
let bounty_id = BountyCount::get() - 1;
|
||||||
@@ -187,7 +187,7 @@ benchmarks! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extend_bounty_expiry {
|
extend_bounty_expiry {
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
|
||||||
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
Bounties::<T>::on_initialize(T::BlockNumber::zero());
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ benchmarks! {
|
|||||||
|
|
||||||
spend_funds {
|
spend_funds {
|
||||||
let b in 1 .. 100;
|
let b in 1 .. 100;
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
create_approved_bounties::<T>(b)?;
|
create_approved_bounties::<T>(b)?;
|
||||||
|
|
||||||
let mut budget_remaining = BalanceOf::<T>::max_value();
|
let mut budget_remaining = BalanceOf::<T>::max_value();
|
||||||
|
|||||||
@@ -30,3 +30,4 @@ any finders fee, in case of a public (and bonded) original report.
|
|||||||
- `tip_new` - Report an item worthy of a tip and declare a specific amount to tip.
|
- `tip_new` - Report an item worthy of a tip and declare a specific amount to tip.
|
||||||
- `tip` - Declare or redeclare an amount to tip for a particular reason.
|
- `tip` - Declare or redeclare an amount to tip for a particular reason.
|
||||||
- `close_tip` - Close and pay out a tip.
|
- `close_tip` - Close and pay out a tip.
|
||||||
|
- `slash_tip` - Remove and slash an already-open tip.
|
||||||
@@ -79,7 +79,7 @@ fn create_tips<T: Config>(t: u32, hash: T::Hash, value: BalanceOf<T>) ->
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_pod_account<T: Config>() {
|
fn setup_pot_account<T: Config>() {
|
||||||
let pot_account = TipsMod::<T>::account_id();
|
let pot_account = TipsMod::<T>::account_id();
|
||||||
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
||||||
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
||||||
@@ -148,7 +148,7 @@ benchmarks! {
|
|||||||
let t in 1 .. MAX_TIPPERS;
|
let t in 1 .. MAX_TIPPERS;
|
||||||
|
|
||||||
// Make sure pot is funded
|
// Make sure pot is funded
|
||||||
setup_pod_account::<T>();
|
setup_pot_account::<T>();
|
||||||
|
|
||||||
// Set up a new tip proposal
|
// Set up a new tip proposal
|
||||||
let (member, reason, beneficiary, value) = setup_tip::<T>(0, t)?;
|
let (member, reason, beneficiary, value) = setup_tip::<T>(0, t)?;
|
||||||
@@ -164,6 +164,7 @@ benchmarks! {
|
|||||||
let reason_hash = T::Hashing::hash(&reason[..]);
|
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||||
let hash = T::Hashing::hash_of(&(&reason_hash, &beneficiary));
|
let hash = T::Hashing::hash_of(&(&reason_hash, &beneficiary));
|
||||||
ensure!(Tips::<T>::contains_key(hash), "tip does not exist");
|
ensure!(Tips::<T>::contains_key(hash), "tip does not exist");
|
||||||
|
|
||||||
create_tips::<T>(t, hash.clone(), value)?;
|
create_tips::<T>(t, hash.clone(), value)?;
|
||||||
|
|
||||||
let caller = account("caller", t, SEED);
|
let caller = account("caller", t, SEED);
|
||||||
@@ -172,6 +173,26 @@ benchmarks! {
|
|||||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||||
}: _(RawOrigin::Signed(caller), hash)
|
}: _(RawOrigin::Signed(caller), hash)
|
||||||
|
|
||||||
|
slash_tip {
|
||||||
|
let t in 1 .. MAX_TIPPERS;
|
||||||
|
|
||||||
|
// Make sure pot is funded
|
||||||
|
setup_pot_account::<T>();
|
||||||
|
|
||||||
|
// Set up a new tip proposal
|
||||||
|
let (member, reason, beneficiary, value) = setup_tip::<T>(0, t)?;
|
||||||
|
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
|
||||||
|
TipsMod::<T>::tip_new(
|
||||||
|
RawOrigin::Signed(member).into(),
|
||||||
|
reason.clone(),
|
||||||
|
beneficiary.clone(),
|
||||||
|
value
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let reason_hash = T::Hashing::hash(&reason[..]);
|
||||||
|
let hash = T::Hashing::hash_of(&(&reason_hash, &beneficiary));
|
||||||
|
ensure!(Tips::<T>::contains_key(hash), "tip does not exist");
|
||||||
|
}: _(RawOrigin::Root, hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -188,6 +209,7 @@ mod tests {
|
|||||||
assert_ok!(test_benchmark_tip_new::<Test>());
|
assert_ok!(test_benchmark_tip_new::<Test>());
|
||||||
assert_ok!(test_benchmark_tip::<Test>());
|
assert_ok!(test_benchmark_tip::<Test>());
|
||||||
assert_ok!(test_benchmark_close_tip::<Test>());
|
assert_ok!(test_benchmark_close_tip::<Test>());
|
||||||
|
assert_ok!(test_benchmark_slash_tip::<Test>());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ mod tests;
|
|||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
pub mod weights;
|
pub mod weights;
|
||||||
|
|
||||||
use sp_std::if_std;
|
|
||||||
|
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use frame_support::{decl_module, decl_storage, decl_event, ensure, decl_error, Parameter};
|
use frame_support::{decl_module, decl_storage, decl_event, ensure, decl_error, Parameter};
|
||||||
use frame_support::traits::{
|
use frame_support::traits::{
|
||||||
@@ -70,8 +68,7 @@ use frame_support::traits::{
|
|||||||
use sp_runtime::{ Percent, RuntimeDebug, traits::{
|
use sp_runtime::{ Percent, RuntimeDebug, traits::{
|
||||||
Zero, AccountIdConversion, Hash, BadOrigin
|
Zero, AccountIdConversion, Hash, BadOrigin
|
||||||
}};
|
}};
|
||||||
|
use frame_support::traits::{Contains, ContainsLengthBound, OnUnbalanced, EnsureOrigin};
|
||||||
use frame_support::traits::{Contains, ContainsLengthBound};
|
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use frame_system::{self as system, ensure_signed};
|
use frame_system::{self as system, ensure_signed};
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
@@ -170,6 +167,8 @@ decl_event!(
|
|||||||
TipClosed(Hash, AccountId, Balance),
|
TipClosed(Hash, AccountId, Balance),
|
||||||
/// A tip suggestion has been retracted. \[tip_hash\]
|
/// A tip suggestion has been retracted. \[tip_hash\]
|
||||||
TipRetracted(Hash),
|
TipRetracted(Hash),
|
||||||
|
/// A tip suggestion has been slashed. \[tip_hash, finder, deposit\]
|
||||||
|
TipSlashed(Hash, AccountId, Balance),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -408,6 +407,32 @@ decl_module! {
|
|||||||
Tips::<T>::remove(hash);
|
Tips::<T>::remove(hash);
|
||||||
Self::payout_tip(hash, tip);
|
Self::payout_tip(hash, tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove and slash an already-open tip.
|
||||||
|
///
|
||||||
|
/// May only be called from `T::RejectOrigin`.
|
||||||
|
///
|
||||||
|
/// As a result, the finder is slashed and the deposits are lost.
|
||||||
|
///
|
||||||
|
/// Emits `TipSlashed` if successful.
|
||||||
|
///
|
||||||
|
/// # <weight>
|
||||||
|
/// `T` is charged as upper bound given by `ContainsLengthBound`.
|
||||||
|
/// The actual cost depends on the implementation of `T::Tippers`.
|
||||||
|
/// # </weight>
|
||||||
|
#[weight = <T as Config>::WeightInfo::slash_tip(T::Tippers::max_len() as u32)]
|
||||||
|
fn slash_tip(origin, hash: T::Hash) {
|
||||||
|
T::RejectOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
|
let tip = Tips::<T>::take(hash).ok_or(Error::<T>::UnknownTip)?;
|
||||||
|
|
||||||
|
if !tip.deposit.is_zero() {
|
||||||
|
let imbalance = T::Currency::slash_reserved(&tip.finder, tip.deposit).0;
|
||||||
|
T::OnSlash::on_unbalanced(imbalance);
|
||||||
|
}
|
||||||
|
Reasons::<T>::remove(&tip.reason);
|
||||||
|
Self::deposit_event(RawEvent::TipSlashed(hash, tip.finder, tip.deposit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,10 +548,6 @@ impl<T: Config> Module<T> {
|
|||||||
|
|
||||||
use frame_support::{Twox64Concat, migration::StorageKeyIterator};
|
use frame_support::{Twox64Concat, migration::StorageKeyIterator};
|
||||||
|
|
||||||
if_std! {
|
|
||||||
println!("Inside migrate_retract_tip_for_tip_new()!");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (hash, old_tip) in StorageKeyIterator::<
|
for (hash, old_tip) in StorageKeyIterator::<
|
||||||
T::Hash,
|
T::Hash,
|
||||||
OldOpenTip<T::AccountId, BalanceOf<T>, T::BlockNumber, T::Hash>,
|
OldOpenTip<T::AccountId, BalanceOf<T>, T::BlockNumber, T::Hash>,
|
||||||
@@ -534,25 +555,11 @@ impl<T: Config> Module<T> {
|
|||||||
>::new(b"Treasury", b"Tips").drain()
|
>::new(b"Treasury", b"Tips").drain()
|
||||||
{
|
{
|
||||||
|
|
||||||
if_std! {
|
|
||||||
println!("Inside loop migrate_retract_tip_for_tip_new()!");
|
|
||||||
}
|
|
||||||
|
|
||||||
let (finder, deposit, finders_fee) = match old_tip.finder {
|
let (finder, deposit, finders_fee) = match old_tip.finder {
|
||||||
Some((finder, deposit)) => {
|
Some((finder, deposit)) => {
|
||||||
if_std! {
|
|
||||||
// This code is only being compiled and executed when the `std` feature is enabled.
|
|
||||||
println!("OK case!");
|
|
||||||
println!("value is: {:#?},{:#?}", finder, deposit);
|
|
||||||
}
|
|
||||||
(finder, deposit, true)
|
(finder, deposit, true)
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
if_std! {
|
|
||||||
// This code is only being compiled and executed when the `std` feature is enabled.
|
|
||||||
println!("None case!");
|
|
||||||
// println!("value is: {:#?},{:#?}", T::AccountId::default(), Zero::zero());
|
|
||||||
}
|
|
||||||
(T::AccountId::default(), Zero::zero(), false)
|
(T::AccountId::default(), Zero::zero(), false)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -567,10 +574,5 @@ impl<T: Config> Module<T> {
|
|||||||
};
|
};
|
||||||
Tips::<T>::insert(hash, new_tip)
|
Tips::<T>::insert(hash, new_tip)
|
||||||
}
|
}
|
||||||
|
|
||||||
if_std! {
|
|
||||||
println!("Exit migrate_retract_tip_for_tip_new()!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,6 +286,40 @@ fn close_tip_works() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn slash_tip_works() {
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
System::set_block_number(1);
|
||||||
|
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||||
|
assert_eq!(Treasury::pot(), 100);
|
||||||
|
|
||||||
|
assert_eq!(Balances::reserved_balance(0), 0);
|
||||||
|
assert_eq!(Balances::free_balance(0), 100);
|
||||||
|
|
||||||
|
assert_ok!(TipsModTestInst::report_awesome(Origin::signed(0), b"awesome.dot".to_vec(), 3));
|
||||||
|
|
||||||
|
assert_eq!(Balances::reserved_balance(0), 12);
|
||||||
|
assert_eq!(Balances::free_balance(0), 88);
|
||||||
|
|
||||||
|
let h = tip_hash();
|
||||||
|
assert_eq!(last_event(), RawEvent::NewTip(h));
|
||||||
|
|
||||||
|
// can't remove from any origin
|
||||||
|
assert_noop!(
|
||||||
|
TipsModTestInst::slash_tip(Origin::signed(0), h.clone()),
|
||||||
|
BadOrigin,
|
||||||
|
);
|
||||||
|
|
||||||
|
// can remove from root.
|
||||||
|
assert_ok!(TipsModTestInst::slash_tip(Origin::root(), h.clone()));
|
||||||
|
assert_eq!(last_event(), RawEvent::TipSlashed(h, 0, 12));
|
||||||
|
|
||||||
|
// tipper slashed
|
||||||
|
assert_eq!(Balances::reserved_balance(0), 0);
|
||||||
|
assert_eq!(Balances::free_balance(0), 88);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn retract_tip_works() {
|
fn retract_tip_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
@@ -409,12 +443,8 @@ fn test_last_reward_migration() {
|
|||||||
|
|
||||||
s.top = data.into_iter().collect();
|
s.top = data.into_iter().collect();
|
||||||
|
|
||||||
println!("Executing the test!");
|
|
||||||
|
|
||||||
sp_io::TestExternalities::new(s).execute_with(|| {
|
sp_io::TestExternalities::new(s).execute_with(|| {
|
||||||
|
|
||||||
println!("Calling migrate_retract_tip_for_tip_new()!");
|
|
||||||
|
|
||||||
TipsModTestInst::migrate_retract_tip_for_tip_new();
|
TipsModTestInst::migrate_retract_tip_for_tip_new();
|
||||||
|
|
||||||
// Test w/ finder
|
// Test w/ finder
|
||||||
|
|||||||
@@ -18,11 +18,11 @@
|
|||||||
//! Autogenerated weights for pallet_tips
|
//! Autogenerated weights for pallet_tips
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
|
||||||
//! DATE: 2020-12-16, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
|
//! DATE: 2020-12-20, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// ./target/release/substrate
|
// target/release/substrate
|
||||||
// benchmark
|
// benchmark
|
||||||
// --chain=dev
|
// --chain=dev
|
||||||
// --steps=50
|
// --steps=50
|
||||||
@@ -49,83 +49,98 @@ pub trait WeightInfo {
|
|||||||
fn tip_new(r: u32, t: u32, ) -> Weight;
|
fn tip_new(r: u32, t: u32, ) -> Weight;
|
||||||
fn tip(t: u32, ) -> Weight;
|
fn tip(t: u32, ) -> Weight;
|
||||||
fn close_tip(t: u32, ) -> Weight;
|
fn close_tip(t: u32, ) -> Weight;
|
||||||
|
fn slash_tip(t: u32, ) -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weights for pallet_tips using the Substrate node and recommended hardware.
|
/// Weights for pallet_tips using the Substrate node and recommended hardware.
|
||||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||||
fn report_awesome(r: u32, ) -> Weight {
|
fn report_awesome(r: u32, ) -> Weight {
|
||||||
(74_814_000 as Weight)
|
(73_795_000 as Weight)
|
||||||
// Standard Error: 0
|
// Standard Error: 0
|
||||||
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
.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().reads(2 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
fn retract_tip() -> Weight {
|
fn retract_tip() -> Weight {
|
||||||
(62_962_000 as Weight)
|
(61_753_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
fn tip_new(r: u32, t: u32, ) -> Weight {
|
fn tip_new(r: u32, t: u32, ) -> Weight {
|
||||||
(48_132_000 as Weight)
|
(47_731_000 as Weight)
|
||||||
// Standard Error: 0
|
// Standard Error: 0
|
||||||
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
||||||
// Standard Error: 0
|
// Standard Error: 0
|
||||||
.saturating_add((155_000 as Weight).saturating_mul(t as Weight))
|
.saturating_add((154_000 as Weight).saturating_mul(t as Weight))
|
||||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
fn tip(t: u32, ) -> Weight {
|
fn tip(t: u32, ) -> Weight {
|
||||||
(36_168_000 as Weight)
|
(35_215_000 as Weight)
|
||||||
// Standard Error: 1_000
|
// Standard Error: 1_000
|
||||||
.saturating_add((695_000 as Weight).saturating_mul(t as Weight))
|
.saturating_add((712_000 as Weight).saturating_mul(t as Weight))
|
||||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
fn close_tip(t: u32, ) -> Weight {
|
fn close_tip(t: u32, ) -> Weight {
|
||||||
(119_313_000 as Weight)
|
(117_027_000 as Weight)
|
||||||
// Standard Error: 1_000
|
// Standard Error: 1_000
|
||||||
.saturating_add((372_000 as Weight).saturating_mul(t as Weight))
|
.saturating_add((375_000 as Weight).saturating_mul(t as Weight))
|
||||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
|
fn slash_tip(t: u32, ) -> Weight {
|
||||||
|
(37_184_000 as Weight)
|
||||||
|
// Standard Error: 0
|
||||||
|
.saturating_add((11_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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For backwards compatibility and tests
|
// For backwards compatibility and tests
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
fn report_awesome(r: u32, ) -> Weight {
|
fn report_awesome(r: u32, ) -> Weight {
|
||||||
(74_814_000 as Weight)
|
(73_795_000 as Weight)
|
||||||
// Standard Error: 0
|
// Standard Error: 0
|
||||||
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
fn retract_tip() -> Weight {
|
fn retract_tip() -> Weight {
|
||||||
(62_962_000 as Weight)
|
(61_753_000 as Weight)
|
||||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
fn tip_new(r: u32, t: u32, ) -> Weight {
|
fn tip_new(r: u32, t: u32, ) -> Weight {
|
||||||
(48_132_000 as Weight)
|
(47_731_000 as Weight)
|
||||||
// Standard Error: 0
|
// Standard Error: 0
|
||||||
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
.saturating_add((2_000 as Weight).saturating_mul(r as Weight))
|
||||||
// Standard Error: 0
|
// Standard Error: 0
|
||||||
.saturating_add((155_000 as Weight).saturating_mul(t as Weight))
|
.saturating_add((154_000 as Weight).saturating_mul(t as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
fn tip(t: u32, ) -> Weight {
|
fn tip(t: u32, ) -> Weight {
|
||||||
(36_168_000 as Weight)
|
(35_215_000 as Weight)
|
||||||
// Standard Error: 1_000
|
// Standard Error: 1_000
|
||||||
.saturating_add((695_000 as Weight).saturating_mul(t as Weight))
|
.saturating_add((712_000 as Weight).saturating_mul(t as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
fn close_tip(t: u32, ) -> Weight {
|
fn close_tip(t: u32, ) -> Weight {
|
||||||
(119_313_000 as Weight)
|
(117_027_000 as Weight)
|
||||||
// Standard Error: 1_000
|
// Standard Error: 1_000
|
||||||
.saturating_add((372_000 as Weight).saturating_mul(t as Weight))
|
.saturating_add((375_000 as Weight).saturating_mul(t as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||||
}
|
}
|
||||||
|
fn slash_tip(t: u32, ) -> Weight {
|
||||||
|
(37_184_000 as Weight)
|
||||||
|
// Standard Error: 0
|
||||||
|
.saturating_add((11_000 as Weight).saturating_mul(t as Weight))
|
||||||
|
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||||
|
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ fn create_approved_proposals<T: Config<I>, I: Instance>(n: u32) -> Result<(), &'
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_pod_account<T: Config<I>, I: Instance>() {
|
fn setup_pot_account<T: Config<I>, I: Instance>() {
|
||||||
let pot_account = Treasury::<T, I>::account_id();
|
let pot_account = Treasury::<T, I>::account_id();
|
||||||
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into());
|
||||||
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
let _ = T::Currency::make_free_balance_be(&pot_account, value);
|
||||||
@@ -97,7 +97,7 @@ benchmarks_instance! {
|
|||||||
|
|
||||||
on_initialize_proposals {
|
on_initialize_proposals {
|
||||||
let p in 0 .. 100;
|
let p in 0 .. 100;
|
||||||
setup_pod_account::<T, _>();
|
setup_pot_account::<T, _>();
|
||||||
create_approved_proposals::<T, _>(p)?;
|
create_approved_proposals::<T, _>(p)?;
|
||||||
}: {
|
}: {
|
||||||
Treasury::<T, _>::on_initialize(T::BlockNumber::zero());
|
Treasury::<T, _>::on_initialize(T::BlockNumber::zero());
|
||||||
|
|||||||
Reference in New Issue
Block a user