Skip to content
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

project config #212

Closed
wants to merge 71 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
71ba443
bump version, new template pallet
f-gate Jun 20, 2023
41811b3
fellowship pallet-skeleton
f-gate Jun 20, 2023
1daa8c7
add to fellowship, improv traits, documentation
f-gate Jun 21, 2023
a06b7e3
slash and leave fellowship
f-gate Jun 22, 2023
4c98000
progress
f-gate Jun 22, 2023
a78e438
remake ensurefellowship + add_candidate
f-gate Jun 26, 2023
276c354
fix
f-gate Jun 27, 2023
9578780
fix build
f-gate Jun 27, 2023
d6102f5
pending fellows extrinsic
f-gate Jun 27, 2023
97bb09b
add to fellowship after x blocks
f-gate Jun 27, 2023
3ac1ff5
mock
f-gate Jun 27, 2023
2d64d1e
fix
f-gate Jun 28, 2023
2604374
benchmark 1
f-gate Jun 28, 2023
644aabf
Merge branch 'main' of github.com:ImbueNetwork/imbue into pallet-fell…
f-gate Jul 14, 2023
a44a221
organisiation, distribute fees
f-gate Jul 17, 2023
60f546d
fix
f-gate Jul 19, 2023
f423545
loose coupling for projects
f-gate Jul 20, 2023
072b500
mega fixing
f-gate Jul 26, 2023
3c8f234
fix
f-gate Jul 26, 2023
932cd64
fail all the proposals tests
f-gate Jul 26, 2023
10b720d
tests :)
f-gate Jul 27, 2023
7639b9b
fmt
f-gate Jul 27, 2023
1b6f887
fellowship testing frame
f-gate Jul 27, 2023
3243999
role ranks, tests 1-6
f-gate Jul 27, 2023
6ff6ac7
implement the rank system in the pallet
f-gate Jul 27, 2023
6f9aafb
fmt
f-gate Jul 27, 2023
d0c404c
fix error return
f-gate Jul 28, 2023
5efe70c
fmt
f-gate Jul 28, 2023
24c0154
assoc type for deposit currency, test type alias, moar test
f-gate Jul 28, 2023
aeb6e0a
j keep testing
f-gate Aug 1, 2023
d5af853
ad infinitum
f-gate Aug 1, 2023
17006ba
fmt
f-gate Aug 3, 2023
6d49536
test
f-gate Aug 4, 2023
c4f8a7d
tests
f-gate Aug 5, 2023
a65aec8
basic tests done
f-gate Aug 7, 2023
5ac6727
fmt
f-gate Aug 7, 2023
9161cb2
finish impl
f-gate Aug 8, 2023
cc17dd3
fix mock add test
f-gate Aug 8, 2023
0fdc9d5
Merge branch 'main' of github.com:ImbueNetwork/imbue into pallet-fell…
f-gate Aug 8, 2023
32455ab
fix hook weight, tests, update dpenedancy version
f-gate Aug 8, 2023
2d23e9c
warning spring clean
f-gate Aug 8, 2023
b8b3e60
new into proposals function with config
f-gate Aug 10, 2023
67d8312
remove use of funding type for config refactor, fix build
f-gate Aug 10, 2023
19678a7
the beginings of the test refactor using config
f-gate Aug 11, 2023
ecef660
testing modifications
f-gate Aug 14, 2023
7a9fb56
updated test utils to match new format
f-gate Aug 19, 2023
367cc13
updated into proposals impl, new conversion for contributions
f-gate Aug 19, 2023
c328d78
trait definition, failing tests for new impls
f-gate Aug 19, 2023
638709f
fix convert to refunds, use from_rationsal
f-gate Aug 21, 2023
87a15bf
fix build but breaks all the test xd
f-gate Aug 21, 2023
d4b2223
fix that little err
f-gate Aug 21, 2023
2f0f9dc
todo files, more impl tests, removed unused config param
f-gate Aug 21, 2023
7bb94a9
remove the take from treasury idea and fmt
f-gate Aug 22, 2023
30cbe4b
add e2e test and more utils
f-gate Aug 22, 2023
1037698
on_initialise tests
f-gate Aug 22, 2023
7f040d1
and another one
f-gate Aug 22, 2023
657b380
weights
f-gate Aug 23, 2023
938e0ce
Merge branch 'main' of github.com:ImbueNetwork/imbue into pallet-fell…
f-gate Aug 23, 2023
443c6f6
remove TreasuryAccount, fix some benchmarks painfully
f-gate Aug 25, 2023
d51a826
add the correct weight fns to extrinsics
f-gate Aug 25, 2023
674e102
finally fixed the benchmarks
f-gate Aug 29, 2023
dda6a9f
fix up benchmarks
f-gate Aug 29, 2023
b193bac
benchmarks ready for testing
f-gate Aug 29, 2023
f4d9a02
fixes
f-gate Aug 29, 2023
dc29903
refactor locality again
f-gate Sep 4, 2023
2857ab4
fix proposals mock + tests
f-gate Sep 4, 2023
075b752
xd
f-gate Sep 7, 2023
fac3ec6
Merge branch 'main' of github.com:ImbueNetwork/imbue into project-con…
f-gate Sep 12, 2023
4aceaba
fix test, bound intoproposals trait
f-gate Sep 12, 2023
9f443f3
actually ensure bound
f-gate Sep 12, 2023
017f051
fix
f-gate Sep 12, 2023
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
29 changes: 25 additions & 4 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ members = [
'node',
"pallets/proposals",
"pallets/briefs",
"pallets/grants",
"pallets/crowdfunding",
"pallets/deposits",
"pallets/grants",
"pallets/crowdfunding",
"pallets/deposits",
"pallets/fellowship",
"runtime/integration-tests",
"runtime/imbue-kusama",
"runtime/common",
Expand Down
6 changes: 6 additions & 0 deletions libs/common-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,9 @@ pub trait TokenMetadata {

fn decimals(&self) -> u8;
}

/// Fallible conversion trait returning an [Option]. Generic over both source and destination types.
pub trait MaybeConvert<A, B> {
/// Attempt to make conversion.
fn maybe_convert(a: A) -> Option<B>;
}
2 changes: 1 addition & 1 deletion pallets/briefs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pallet-briefs"
authors = ['Imbue <https://github.com/ImbueNetwork>']
description = "Briefs pallet is used to create a piece of work (briefs) to be done by a freelancer"
version = '0.1.0'
version = '1.0.0'
license = 'Apache 2.0'
homepage = 'https://github.com/ImbueNetwork/imbue'
repository = "https://github.com/ImbueNetwork/imbue"
Expand Down
2 changes: 1 addition & 1 deletion pallets/briefs/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sp_std::{convert::TryInto, str, vec::Vec};

const SEED: u32 = 0;

#[benchmarks( where<T as frame_system::Config>::AccountId: AsRef<[u8]>,)]
#[benchmarks( where <T as frame_system::Config>::AccountId: AsRef<[u8]>,)]
mod benchmarks {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions pallets/briefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ pub mod pallet {
ensure!(who == brief.applicant, Error::<T>::MustBeApplicant);

let contributions = BriefContributions::<T>::get(brief_id);
let refund locations: Vec<(Multilocation, Percent)> = Vec::new();

<T as Config>::DepositHandler::return_deposit(brief.deposit_id)?;

Expand Down
14 changes: 0 additions & 14 deletions pallets/briefs/src/runtime_api.rs

This file was deleted.

3 changes: 3 additions & 0 deletions pallets/briefs/src/todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

add field on Brief for require fellowship
minimum contribution on a brief
2 changes: 1 addition & 1 deletion pallets/crowdfunding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-crowdfunding"
version = "0.1.0"
version = "1.0.0"
description = "Used to setup the state for a proposal to morph into a project."
authors = ['Imbue <https://github.com/ImbueNetwork>']
homepage = 'https://github.com/ImbueNetwork/imbue'
Expand Down
2 changes: 1 addition & 1 deletion pallets/deposits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-deposits"
version = "4.0.0-dev"
version = "1.0.0"
description = "A very simple pallet used to deal with storage deposits of a type."
authors = ["Imbue Network"]
homepage = 'https://github.com/ImbueNetwork/imbue'
Expand Down
56 changes: 56 additions & 0 deletions pallets/fellowship/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[package]
name = "pallet-fellowship"
version = "0.1.0"
description = "Used to map the accounts to a fellowship role. Encompasses all the functionality associated with fellowship decisions."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
license = 'Apache 2.0'
homepage = 'https://github.com/ImbueNetwork/imbue'
repository = "https://github.com/ImbueNetwork/imbue"
edition = '2018'
resolver = "2"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.43", default-features = false }
common-types = { path = "../../libs/common-types", default-features = false}
common-traits = { path = "../../libs/common-traits", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false}
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"}
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"}
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"}
common-types = { path = "../../libs/common-types"}
common-traits = { path = "../../libs/common-traits"}
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.43"}
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.43"}
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"}
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43"}

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
]

runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
]

try-runtime = ["frame-support/try-runtime"]
148 changes: 148 additions & 0 deletions pallets/fellowship/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use crate::Pallet as Fellowship;
use crate::{traits::FellowshipHandle, Config, Role};
use common_types::CurrencyId;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::Pallet as System;
use frame_system::RawOrigin;
use orml_traits::{MultiCurrency, MultiReservableCurrency};
use sp_runtime::SaturatedConversion;

#[benchmarks( where <T as frame_system::Config>::AccountId: AsRef<[u8]>, crate::Event::<T>: Into<<T as frame_system::Config>::RuntimeEvent>)]
#[benchmarks]
mod benchmarks {
use super::*;
#[benchmark]
fn add_to_fellowship() {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);

#[block]
{
<crate::Pallet<T> as FellowshipHandle<<T as frame_system::Config>::AccountId>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
}
System::<T>::assert_last_event(
Event::<T>::FellowshipAdded {
who: alice.clone(),
role: Role::Vetter,
}
.into(),
);
}

#[benchmark]
fn force_add_fellowship() {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
#[extrinsic_call]
force_add_fellowship(RawOrigin::Root, alice.clone(), Role::Freelancer, 10);
System::<T>::assert_last_event(
Event::<T>::FellowshipAdded {
who: alice.clone(),
role: Role::Vetter,
}
.into(),
);
}

#[benchmark]
fn leave_fellowship() {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<<T as frame_system::Config>::AccountId>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);

#[extrinsic_call]
leave_fellowship(RawOrigin::Signed(alice.clone()));

System::<T>::assert_last_event(Event::<T>::FellowshipRemoved { who: alice.clone() }.into());
}

#[benchmark]
fn force_remove_and_slash_fellowship() {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<<T as frame_system::Config>::AccountId>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);

#[extrinsic_call]
force_remove_and_slash_fellowship(RawOrigin::Root, alice.clone());
System::<T>::assert_last_event(Event::<T>::FellowshipRemoved { who: alice.clone() }.into());
}

#[benchmark]
fn add_candidate_to_shortlist() {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<<T as frame_system::Config>::AccountId>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);

#[extrinsic_call]
add_candidate_to_shortlist(RawOrigin::Signed(alice), bob.clone(), Role::Vetter, 10);
System::<T>::assert_last_event(
Event::<T>::CandidateAddedToShortlist { who: bob.clone() }.into(),
);
}

#[benchmark]
fn remove_candidate_from_shortlist() {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<<T as frame_system::Config>::AccountId>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
Fellowship::<T>::add_candidate_to_shortlist(
RawOrigin::Signed(alice.clone()).into(),
bob.clone(),
Role::Vetter,
10,
);

#[extrinsic_call]
remove_candidate_from_shortlist(RawOrigin::Signed(alice), bob.clone());
System::<T>::assert_last_event(
Event::<T>::CandidateRemovedFromShortlist { who: bob }.into(),
);
}

#[benchmark]
fn pay_deposit_to_remove_pending_status() {
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1);
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let charlie: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);

<crate::Pallet<T> as FellowshipHandle<<T as frame_system::Config>::AccountId>>::add_to_fellowship(&bob, Role::Vetter, 10, Some(&charlie), true);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);

#[extrinsic_call]
pay_deposit_to_remove_pending_status(RawOrigin::Signed(bob.clone()));
System::<T>::assert_last_event(
Event::<T>::FellowshipAdded {
who: bob,
role: Role::Vetter,
}
.into(),
);
}

impl_benchmark_test_suite!(Fellowship, crate::mock::new_test_ext(), crate::mock::Test);
}

pub fn create_funded_user<T: Config>(
seed: &'static str,
n: u32,
balance_factor: u128,
) -> T::AccountId {
let user = account(seed, n, 0);
assert_ok!(<T::MultiCurrency as MultiCurrency<
<T as frame_system::Config>::AccountId,
>>::deposit(
CurrencyId::Native, &user, balance_factor.saturated_into()
));
user
}
Loading