Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Bounties Pallet to FrameV2 #9566

Merged
31 commits merged into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e2cb211
migrate bounties pallet
ferrell-code Aug 14, 2021
c1f5a7f
events in tests
ferrell-code Aug 14, 2021
b87bac1
test import event
ferrell-code Aug 14, 2021
bd25714
Update frame/bounties/src/lib.rs
ferrell-code Aug 14, 2021
91073a3
cargo fmt
ferrell-code Aug 14, 2021
f3f4704
Merge branch 'fer-bounties-framev2' of https://github.com/ferrell-cod…
ferrell-code Aug 14, 2021
cb168bd
line width
ferrell-code Aug 14, 2021
8c98911
benchmarks compile
ferrell-code Aug 14, 2021
4436610
add migrations
ferrell-code Aug 20, 2021
7d328eb
fmt
ferrell-code Aug 24, 2021
5054cf3
Merge remote-tracking branch 'upstream/master' into fer-bounties-framev2
ferrell-code Aug 24, 2021
dc2932d
comments
ferrell-code Aug 24, 2021
31c82d1
mod migrations
ferrell-code Aug 24, 2021
5ca7058
fix Cargo.toml
ferrell-code Aug 24, 2021
95f7a85
never remember cargo fmt
ferrell-code Aug 24, 2021
06d14df
Merge remote-tracking branch 'upstream/master' into fer-bounties-framev2
ferrell-code Aug 26, 2021
17e8181
Merge remote-tracking branch 'upstream/master' into fer-bounties-framev2
ferrell-code Aug 30, 2021
02d5f11
Merge remote-tracking branch 'upstream/master' into fer-bounties-framev2
ferrell-code Aug 30, 2021
4b5f866
fix migration
ferrell-code Sep 7, 2021
c41ab94
Merge remote-tracking branch 'upstream/master' into fer-bounties-framev2
ferrell-code Sep 7, 2021
41a917f
migrations and test
ferrell-code Sep 8, 2021
166e70a
change checks in migration
ferrell-code Sep 9, 2021
f5b10e1
remove unused values
ferrell-code Sep 9, 2021
2065e69
Update frame/bounties/src/migrations/v4.rs
gui1117 Sep 9, 2021
9a22c3e
Merge remote-tracking branch 'origin/master' into 9566
gui1117 Sep 9, 2021
d3fb552
cargo fmt
ferrell-code Sep 10, 2021
1d1331b
conflicts
ferrell-code Sep 13, 2021
1c3e5d9
fix benchmarking
ferrell-code Sep 13, 2021
9383226
Merge remote-tracking branch 'upstream/master' into fer-bounties-framev2
ferrell-code Sep 15, 2021
c1fa13b
conflict and remove metadata due to new typeing
ferrell-code Sep 15, 2021
1b955e3
trigger ci
ferrell-code Sep 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions frame/bounties/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,26 @@ sp-runtime = { version = "4.0.0-dev", default-features = false, path = "../../pr
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
pallet-treasury = { version = "4.0.0-dev", default-features = false, path = "../treasury" }

sp-io = { version = "4.0.0-dev", path = "../../primitives/io", default-features = false }
sp-core = { version = "4.0.0-dev", path = "../../primitives/core", default-features = false }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../benchmarking", optional = true }
log = { version = "0.4.14", default-features = false }

[dev-dependencies]
sp-io = { version = "4.0.0-dev", path = "../../primitives/io" }
sp-core = { version = "4.0.0-dev", path = "../../primitives/core" }
pallet-balances = { version = "4.0.0-dev", path = "../balances" }

[features]
default = ["std"]
std = [
"codec/std",
"sp-core/std",
"sp-io/std",
"sp-std/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"pallet-treasury/std",
"log/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down
33 changes: 16 additions & 17 deletions frame/bounties/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
use super::*;

use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_support::traits::OnInitialize;
use frame_system::RawOrigin;
use sp_runtime::traits::Bounded;

use crate::Module as Bounties;
use crate::Pallet as Bounties;
use pallet_treasury::Pallet as Treasury;

const SEED: u32 = 0;
Expand All @@ -36,10 +35,10 @@ fn create_approved_bounties<T: Config>(n: u32) -> Result<(), &'static str> {
for i in 0..n {
let (caller, _curator, _fee, value, reason) = setup_bounty::<T>(i, MAX_BYTES);
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
Bounties::<T>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
}
ensure!(BountyApprovals::get().len() == n as usize, "Not all bounty approved");
ensure!(BountyApprovals::<T>::get().len() == n as usize, "Not all bounty approved");
Ok(())
}

Expand All @@ -64,7 +63,7 @@ fn create_bounty<T: Config>(
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
Bounties::<T>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
Treasury::<T>::on_initialize(T::BlockNumber::zero());
Bounties::<T>::propose_curator(RawOrigin::Root.into(), bounty_id, curator_lookup.clone(), fee)?;
Expand Down Expand Up @@ -94,15 +93,15 @@ benchmarks! {
approve_bounty {
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
}: _(RawOrigin::Root, bounty_id)

propose_curator {
setup_pot_account::<T>();
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
Bounties::<T>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());
}: _(RawOrigin::Root, bounty_id, curator_lookup, fee)
Expand All @@ -112,7 +111,7 @@ benchmarks! {
setup_pot_account::<T>();
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
frame_system::Pallet::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into());
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), bounty_id)
Expand All @@ -122,7 +121,7 @@ benchmarks! {
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, MAX_BYTES);
let curator_lookup = T::Lookup::unlookup(curator.clone());
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
Bounties::<T>::approve_bounty(RawOrigin::Root.into(), bounty_id)?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());
Bounties::<T>::propose_curator(RawOrigin::Root.into(), bounty_id, curator_lookup, fee)?;
Expand All @@ -133,7 +132,7 @@ benchmarks! {
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());

let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
let curator = T::Lookup::lookup(curator_lookup)?;
let beneficiary = T::Lookup::unlookup(account("beneficiary", 0, SEED));
}: _(RawOrigin::Signed(curator), bounty_id, beneficiary)
Expand All @@ -143,7 +142,7 @@ benchmarks! {
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());

let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
let curator = T::Lookup::lookup(curator_lookup)?;

let beneficiary_account: T::AccountId = account("beneficiary", 0, SEED);
Expand All @@ -162,29 +161,29 @@ benchmarks! {
setup_pot_account::<T>();
let (caller, curator, fee, value, reason) = setup_bounty::<T>(0, 0);
Bounties::<T>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
}: close_bounty(RawOrigin::Root, bounty_id)

close_bounty_active {
setup_pot_account::<T>();
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
}: close_bounty(RawOrigin::Root, bounty_id)
verify {
assert_last_event::<T>(RawEvent::BountyCanceled(bounty_id).into())
assert_last_event::<T>(Event::BountyCanceled(bounty_id).into())
}

extend_bounty_expiry {
setup_pot_account::<T>();
let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero());

let bounty_id = BountyCount::get() - 1;
let bounty_id = BountyCount::<T>::get() - 1;
let curator = T::Lookup::lookup(curator_lookup)?;
}: _(RawOrigin::Signed(curator), bounty_id, Vec::new())
verify {
assert_last_event::<T>(RawEvent::BountyExtended(bounty_id).into())
assert_last_event::<T>(Event::BountyExtended(bounty_id).into())
}

spend_funds {
Expand All @@ -207,7 +206,7 @@ benchmarks! {
verify {
ensure!(budget_remaining < BalanceOf::<T>::max_value(), "Budget not used");
ensure!(missed_any == false, "Missed some");
assert_last_event::<T>(RawEvent::BountyBecameActive(b - 1).into())
assert_last_event::<T>(Event::BountyBecameActive(b - 1).into())
}
}

Expand Down
Loading