Skip to content

Commit a78759c

Browse files
f-gatesamelaminmshankarrao
authored
project configs (#233)
* add back sudo to rococo * runtime api * runtime-api-wiring * some dummy log statements * attempt 1 to add try-runtime * second attempt * add to the cli * fix warn issue * on initialise, remove on runtime upgrade proposasl * add the new storage version migration * pick runtime * new migration for proposals * fmt * fix v3-v4 migration test * fix 2 * fix brief migration test * clippy * fmt * new MilestoneVote implementation * fix implementation * get project individual votes * remove total votes api * fmt * ummm * new format for Individual votes * boom baby, and a fmt * clippy * fix build * fmt * bump spec version * 1 * individual votes impl with storage * fix buggy impl * define immutability, update on vote * use individual votes for oninit and submit and close voting + update migration * fixing build * seperated test files, tested ImmutableVotes * fix runtime api, reorg proposals * fmt * fmt * clippy * migration, err handling * fix migration * fmt * fix * clippy * update executive and spec version * fmt * remove todos * remove wrong comment * fix failing test * fmt * rip the proposals changes * merge and fix tests * remove unused config items, reorg them, add test cases * actually add decent documentation in pallet-proposals * run on gcp * bump to rebuild * use self hosted runner * already installed on runner * attempt auto scaling runner * increase disk size * bump to build again * dont delete at the end of the job * remove unused directories * bump * change region * split the jobs * add -y flag * test menually installing rust * -y flag * more -y * remove double install of protobugf * -y * trial 1 * fix * fix2 * fix3 * bump up * bump * change zone * bump * lol -y * bump * bump 2 * set home directory * try to run as user * init commit * commit 2 * test * test 3 * attempt 4 * bump * bump * bump * bump * bump * reduce image size * bump * bump * bump again * add clippy * build essentials * lock * clang * refactor * typo * typo 2 * make zone configurable * project voting data api (#224) * add back sudo to rococo * runtime api * runtime-api-wiring * some dummy log statements * attempt 1 to add try-runtime * second attempt * add to the cli * fix warn issue * on initialise, remove on runtime upgrade proposasl * add the new storage version migration * pick runtime * new migration for proposals * fmt * fix v3-v4 migration test * fix 2 * fix brief migration test * clippy * fmt * new MilestoneVote implementation * fix implementation * get project individual votes * remove total votes api * fmt * ummm * new format for Individual votes * boom baby, and a fmt * clippy * fix build * fmt * bump spec version * 1 * individual votes impl with storage * fix buggy impl * define immutability, update on vote * use individual votes for oninit and submit and close voting + update migration * fixing build * seperated test files, tested ImmutableVotes * fix runtime api, reorg proposals * fmt * fmt * clippy * migration, err handling * fix migration * fmt * fix * clippy * update executive and spec version * fmt * remove todos * remove wrong comment * fix failing test * fmt * run on gcp * bump to rebuild * use self hosted runner * already installed on runner * attempt auto scaling runner * increase disk size * bump to build again * dont delete at the end of the job * remove unused directories * bump * change region * split the jobs * add -y flag * test menually installing rust * -y flag * more -y * remove double install of protobugf * -y * trial 1 * fix * fix2 * fix3 * bump up * bump * change zone * bump * lol -y * bump * bump 2 * set home directory * try to run as user * init commit * commit 2 * test * test 3 * attempt 4 * bump * bump * bump * bump * bump * reduce image size * bump * bump * bump again * add clippy * build essentials * clang * refactor * typo * typo 2 * make zone configurable --------- Co-authored-by: samelamin <[email protected]> * refactoring * mark the no_confidence as deprecated with the introduction of pallet-disputes * migration for new fields * add to runtime with dummy weights * add genesis config * removed everything about no-confidence logic * fixed the format check as it was failing in the build * add fellowship migration, add migration to runtime * move migration to v7 after rococo upgrade * fix migration * fix accountid trait bounds * fix dependancy issue: #252 * add fellowship to runtime benchmarks * generate fellowship weights * remove test test * fmt * add jury selector trait * run gcp on all pushes * restore * select a random jury given a jury length * fix randomer * select jury tests * refactor minor * remove genesis, add permissions, FellowshipPermissions trait * permissions impl, mock impl * fix tests * organise tests, add permissions tests * add new config to runtime * fmt * add jury selector into migration * dispute hooks draft, pallet-dispute in runtime * raise disputes and hooks skeleton * forgot * trait bounds impl, todos * bugs * fix * tests * track dispute per milestone instead of per project * minor fixes * update withdrawn to use is_withdrawn * fix * fix * more todos! Jury selector fix * tests, refund extrinsic * mindbending fix * try_mutate_exists instead * fixing just keep fixing * another one * marching * my fingers hurt * green stuff has appeared! * grants fixes * fixrs * fix * optimise refund extrinsics * add non zero arith check, deposit event, refund benchmark * fix * raise dispute benchmark * migration madness * fix migration and tests * jury selector move around * fix bloomin proposals * fix briefs * fix grants * fiix runtime * fix integration test, rewrite get jury * generate dispute weights * fix all but deposits * fix xcm tranfers * trying * fix grants benchmark tests * fix for proposal benchmark tests * cargo fmt * fix for failing benchmark tests * audit warnings * minor fix * remove generic param for run to block felloship * clippy * weights * proposal benchmark fixes + weights * change balance type proposals mock to u128 to prevent overflow * fmt --------- Co-authored-by: samelamin <[email protected]> Co-authored-by: Shankar Rao Mata <[email protected]>
1 parent 691fff9 commit a78759c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2738
-1291
lines changed

Cargo.lock

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/common-types/src/milestone_origin.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
use codec::{Decode, Encode, MaxEncodedLen};
2+
use frame_support::{sp_runtime::traits::AccountIdConversion, PalletId};
23
use scale_info::TypeInfo;
34
use xcm::latest::{Junction, Junctions::*, MultiLocation};
45

56
/// A wrapper around
6-
pub trait TreasuryOriginConverter<AccountId: Into<[u8; 32]>> {
7-
fn get_multi_location(
8-
&self,
9-
recipiant: AccountId,
10-
) -> Result<MultiLocation, TreasuryOriginError>;
7+
pub trait TreasuryOriginConverter {
8+
fn get_multi_location(&self) -> Result<MultiLocation, TreasuryOriginError>;
119
}
1210

13-
impl<AccountId: Into<[u8; 32]>> TreasuryOriginConverter<AccountId> for TreasuryOrigin {
14-
fn get_multi_location(
15-
&self,
16-
recipiant: AccountId,
17-
) -> Result<MultiLocation, TreasuryOriginError> {
11+
impl TreasuryOriginConverter for TreasuryOrigin {
12+
fn get_multi_location(&self) -> Result<MultiLocation, TreasuryOriginError> {
1813
match &self {
1914
TreasuryOrigin::Kusama => Ok(MultiLocation::new(
2015
1,
2116
X1(Junction::AccountId32 {
22-
id: recipiant.into(),
17+
id: PalletId(*b"py/trsry").into_account_truncating(),
2318
network: None,
2419
}),
2520
)),
2621
TreasuryOrigin::Imbue => Ok(MultiLocation::new(
2722
0,
2823
X1(Junction::AccountId32 {
29-
id: recipiant.into(),
24+
id: PalletId(*b"py/trsry").into_account_truncating(),
3025
network: None,
3126
}),
3227
)),
@@ -43,15 +38,6 @@ pub enum TreasuryOriginError {
4338
NetworkUnsupported,
4439
}
4540

46-
#[derive(
47-
Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
48-
)]
49-
pub enum FundingType {
50-
Proposal,
51-
Brief,
52-
Grant(TreasuryOrigin),
53-
}
54-
5541
#[derive(
5642
Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
5743
)]

pallets/briefs/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
3333
common-traits = { path = "../../libs/common-traits", default-features = false }
3434
common-types = { path = "../../libs/common-types", default-features = false }
3535
pallet-deposits = {path= "../deposits", default-features = false }
36+
pallet-fellowship = { path = "../fellowship", default-features = false }
3637
pallet-proposals = {path= "../proposals", default-features = false }
3738

3839
[dev-dependencies]
@@ -54,7 +55,7 @@ common-types = { path = "../../libs/common-types" }
5455
common-runtime = { path = "../../runtime/common"}
5556
pallet-proposals = {path= "../proposals"}
5657
pallet-deposits = {path= "../deposits"}
57-
58+
pallet-disputes = {path= "../disputes"}
5859

5960
[features]
6061
default = [ 'std' ]
@@ -70,7 +71,7 @@ std = [
7071
"pallet-balances/std",
7172
"pallet-deposits/std",
7273
"pallet-proposals/std",
73-
"pallet-timestamp/std",
74+
"pallet-fellowship/std",
7475
"scale-info/std",
7576
"serde/std",
7677
"sp-api/std",
@@ -102,6 +103,7 @@ try-runtime = [
102103
"pallet-proposals/try-runtime",
103104
"pallet-timestamp/try-runtime",
104105
"pallet-transaction-payment/try-runtime",
106+
"pallet-fellowship/try-runtime",
105107
"pallet-xcm/try-runtime",
106108
"sp-runtime/try-runtime",
107109
]

pallets/briefs/src/lib.rs

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ mod benchmarking;
2020
#[cfg(any(feature = "runtime-benchmarks", test))]
2121
mod test_utils;
2222

23-
pub mod migrations;
23+
//pub mod migrations;
2424

2525
#[frame_support::pallet]
2626
pub mod pallet {
27-
use common_types::{milestone_origin::FundingType, CurrencyId};
27+
use common_types::CurrencyId;
2828
use frame_support::{
2929
pallet_prelude::*, sp_runtime::Saturating, traits::Get, weights::Weight, BoundedBTreeMap,
3030
};
3131
use frame_system::pallet_prelude::*;
3232
use orml_traits::{MultiCurrency, MultiReservableCurrency};
3333
use pallet_deposits::traits::DepositHandler;
34+
use pallet_fellowship::traits::SelectJury;
3435
use pallet_proposals::traits::IntoProposal;
35-
use pallet_proposals::{Contribution, ProposedMilestone};
36+
use pallet_proposals::{Contribution, FundingPath, ProposedMilestone};
3637
use sp_arithmetic::per_things::Percent;
3738
use sp_core::H256;
3839
use sp_runtime::traits::Zero;
@@ -70,8 +71,8 @@ pub mod pallet {
7071
#[pallet::config]
7172
pub trait Config: frame_system::Config {
7273
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
74+
/// The currency type.
7375
type RMultiCurrency: MultiReservableCurrency<AccountIdOf<Self>, CurrencyId = CurrencyId>;
74-
type AuthorityOrigin: EnsureOrigin<Self::RuntimeOrigin>;
7576
/// The type that allows for evolution from brief to proposal.
7677
type IntoProposal: IntoProposal<AccountIdOf<Self>, BalanceOf<Self>, BlockNumberFor<Self>>;
7778
/// The maximum amount of owners to a brief.
@@ -82,7 +83,9 @@ pub mod pallet {
8283
/// Storage deposits.
8384
type BriefStorageItem: Get<StorageItemOf<Self>>;
8485
type DepositHandler: DepositHandler<BalanceOf<Self>, AccountIdOf<Self>>;
85-
86+
/// The type that selects a list of jury members.
87+
type JurySelector: SelectJury<AccountIdOf<Self>>;
88+
/// The weight info for the extrinsics.
8689
type WeightInfo: WeightInfoT;
8790
}
8891

@@ -147,6 +150,8 @@ pub mod pallet {
147150
FreelancerApprovalRequired,
148151
/// Milestones total do not add up to 100%.
149152
MilestonesTotalPercentageMustEqual100,
153+
/// too many milestones here mate fixed with https://github.com/ImbueNetwork/imbue/issues/267
154+
TooManyMilestones,
150155
}
151156

152157
#[pallet::call]
@@ -291,13 +296,35 @@ pub mod pallet {
291296
let contributions = BriefContributions::<T>::get(brief_id);
292297

293298
<T as Config>::DepositHandler::return_deposit(brief.deposit_id)?;
299+
300+
let refund_locations =
301+
<T as Config>::IntoProposal::convert_contributions_to_refund_locations(
302+
&contributions
303+
.clone()
304+
.into_inner()
305+
.try_into()
306+
.map_err(|_| Error::<T>::TooManyBriefOwners)?,
307+
);
308+
294309
<T as Config>::IntoProposal::convert_to_proposal(
295310
brief.currency_id,
296-
contributions.into_inner(),
311+
contributions
312+
.into_inner()
313+
.try_into()
314+
.map_err(|_| Error::<T>::TooManyBriefOwners)?,
297315
brief_id,
298316
brief.applicant,
299-
brief.milestones.into(),
300-
FundingType::Brief,
317+
brief
318+
.milestones
319+
.to_vec()
320+
.try_into()
321+
.map_err(|_| Error::<T>::TooManyMilestones)?,
322+
refund_locations,
323+
<T::JurySelector as SelectJury<AccountIdOf<T>>>::select_jury()
324+
.to_vec()
325+
.try_into()
326+
.map_err(|_| Error::<T>::TooManyMilestones)?,
327+
FundingPath::TakeFromReserved,
301328
)?;
302329

303330
BriefContributions::<T>::remove(brief_id);

pallets/briefs/src/mock.rs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,17 @@ parameter_types! {
202202
impl pallet_briefs::Config for Test {
203203
type RuntimeEvent = RuntimeEvent;
204204
type RMultiCurrency = Tokens;
205-
type AuthorityOrigin = EnsureRoot<AccountId>;
206205
type IntoProposal = pallet_proposals::Pallet<Test>;
207206
type MaxBriefOwners = MaxBriefOwners;
208207
type MaxMilestonesPerBrief = MaxMilestonesPerProject;
209208
type BriefStorageItem = BriefStorageItem;
210209
type DepositHandler = MockDepositHandler;
211210
type WeightInfo = pallet_briefs::WeightInfo<Self>;
211+
type JurySelector = MockJurySelector;
212212
}
213213

214214
parameter_types! {
215-
pub const TwoWeekBlockUnit: u32 = 100800u32;
216215
pub const ProposalsPalletId: PalletId = PalletId(*b"imbgrant");
217-
pub NoConfidenceTimeLimit: BlockNumber = 100800u32.into();
218216
pub PercentRequiredForVoteToPass: Percent = Percent::from_percent(75u8);
219217
pub MaximumContributorsPerProject: u32 = 50;
220218
pub RefundsPerBlock: u8 = 2;
@@ -226,30 +224,31 @@ parameter_types! {
226224
pub ExpiringProjectRoundsPerBlock: u32 = 10;
227225
pub ProjectStorageItem: StorageItem = StorageItem::Project;
228226
pub MaxProjectsPerAccount: u16 = 100;
229-
pub PercentRequiredForVoteNoConfidenceToPass: Percent = Percent::from_percent(75u8);
227+
pub ImbueFeeAccount: AccountId = TREASURY;
228+
pub MaxJuryMembers: u32 = 100;
230229
}
231230

232231
impl pallet_proposals::Config for Test {
233232
type RuntimeEvent = RuntimeEvent;
234233
type PalletId = ProposalsPalletId;
235-
type AuthorityOrigin = EnsureRoot<AccountId>;
236234
type MultiCurrency = Tokens;
237235
type WeightInfo = pallet_proposals::WeightInfo<Self>;
238-
// Adding 2 weeks as th expiration time
239-
type MaxWithdrawalExpiration = TwoWeekBlockUnit;
240-
type NoConfidenceTimeLimit = NoConfidenceTimeLimit;
241236
type PercentRequiredForVoteToPass = PercentRequiredForVoteToPass;
242237
type MaximumContributorsPerProject = MaximumContributorsPerProject;
243238
type MilestoneVotingWindow = MilestoneVotingWindow;
244-
type RefundHandler = pallet_proposals::traits::MockRefundHandler<Test>;
239+
type ExternalRefundHandler = pallet_proposals::traits::MockRefundHandler<Test>;
245240
type MaxMilestonesPerProject = MaxMilestonesPerProject;
246241
type ImbueFee = ImbueFee;
242+
type ImbueFeeAccount = ImbueFeeAccount;
247243
type ExpiringProjectRoundsPerBlock = ExpiringProjectRoundsPerBlock;
248-
type ProjectStorageItem = ProjectStorageItem;
249244
type DepositHandler = MockDepositHandler;
245+
type ProjectStorageItem = ProjectStorageItem;
250246
type MaxProjectsPerAccount = MaxProjectsPerAccount;
251-
type PercentRequiredForVoteNoConfidenceToPass = PercentRequiredForVoteNoConfidenceToPass;
247+
type DisputeRaiser = MockDisputeRaiser;
248+
type JurySelector = MockJurySelector;
249+
type AssetSignerOrigin = EnsureRoot<AccountId>;
252250
}
251+
253252
parameter_types! {
254253
pub const BasicDeposit: u64 = 10;
255254
pub const FieldDeposit: u64 = 10;
@@ -281,6 +280,7 @@ parameter_types! {
281280
pub static ALICE: AccountId = 125;
282281
pub static BOB: AccountId = 126;
283282
pub static CHARLIE: AccountId = 127;
283+
pub static TREASURY: AccountId = 200;
284284

285285
pub(crate) fn build_test_externality() -> sp_io::TestExternalities {
286286
let mut t = frame_system::GenesisConfig::<Test>::default()
@@ -307,3 +307,27 @@ pub(crate) fn build_test_externality() -> sp_io::TestExternalities {
307307
});
308308
ext
309309
}
310+
311+
pub struct MockJurySelector;
312+
impl pallet_fellowship::traits::SelectJury<AccountId> for MockJurySelector {
313+
type JurySize = MaxJuryMembers;
314+
fn select_jury() -> BoundedVec<AccountId, Self::JurySize> {
315+
BoundedVec::new()
316+
}
317+
}
318+
319+
pub struct MockDisputeRaiser;
320+
impl pallet_disputes::traits::DisputeRaiser<AccountId> for MockDisputeRaiser {
321+
type DisputeKey = u32;
322+
type SpecificId = u32;
323+
type MaxJurySize = MaxJuryMembers;
324+
type MaxSpecifics = MaxMilestonesPerProject;
325+
fn raise_dispute(
326+
_dispute_key: Self::DisputeKey,
327+
_raised_by: AccountId,
328+
_jury: BoundedVec<AccountId, Self::MaxJurySize>,
329+
_specific_ids: BoundedVec<Self::SpecificId, Self::MaxSpecifics>,
330+
) -> Result<(), DispatchError> {
331+
Ok(())
332+
}
333+
}

0 commit comments

Comments
 (0)