Skip to content

Commit

Permalink
Merge pull request #5072 from ignazio-bovo/luxor/vested-wg-spending
Browse files Browse the repository at this point in the history
Luxor/vested wg spending
  • Loading branch information
mnaamani committed Apr 3, 2024
2 parents ab93b73 + 210773e commit aed16d0
Show file tree
Hide file tree
Showing 32 changed files with 1,365 additions and 532 deletions.
8 changes: 7 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion chain-metadata.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start": "./start.sh",
"test": "./tests/network-tests/run-tests.sh",
"cargo-checks": "./scripts/cargo-checks.sh",
"cargo-checks-with-benchmarking": "./scripts/cargo-checks-with-benchmarking.sh",
"cargo-build": "./scripts/cargo-build.sh",
"lint": "./scripts/lint-typescript.sh",
"update-chain-metadata": "./scripts/fetch-chain-metadata.sh | tee chain-metadata.json query-node/chain-metadata/$(./scripts/fetch-chain-spec-version.sh).json >/dev/null",
Expand Down
2 changes: 1 addition & 1 deletion query-node/chain-metadata/2003.json

Large diffs are not rendered by default.

60 changes: 34 additions & 26 deletions runtime-modules/content/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,46 @@ authors = ['Joystream contributors']
edition = '2018'

[dependencies]
sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
codec = { package = 'parity-scale-codec', version = '3.1.2', default-features = false, features = ['derive'] }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
serde = {version = '1.0.101', features = ['derive'], optional = true}
strum = {version = "0.19", optional = true}
strum_macros = {version = "0.19", optional = true}
common = { package = 'pallet-common', default-features = false, path = '../common'}
storage = { package = 'pallet-storage', default-features = false, path = '../storage'}
membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
project-token = { package = 'pallet-project-token', default-features = false, path = '../project-token'}
sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
codec = { package = 'parity-scale-codec', version = '3.1.2', default-features = false, features = [
'derive',
] }
scale-info = { version = "2.1.2", default-features = false, features = [
"derive",
] }
serde = { version = '1.0.101', features = ['derive'], optional = true }
strum = { version = "0.19", optional = true }
strum_macros = { version = "0.19", optional = true }
common = { package = 'pallet-common', default-features = false, path = '../common' }
storage = { package = 'pallet-storage', default-features = false, path = '../storage' }
membership = { package = 'pallet-membership', default-features = false, path = '../membership' }
balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
project-token = { package = 'pallet-project-token', default-features = false, path = '../project-token' }
varaint-count = { version = '1.1.0', package = 'variant_count' }

# Benchmarking
frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9', optional = true}
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group', optional = true}
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9', optional = true }
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group', optional = true }
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }

# util
log = { version = "0.4.17", default-features = false }

[dev-dependencies]
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
randomness-collective-flip = { package = 'pallet-insecure-randomness-collective-flip', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler'}
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
derive-fixture = { package = 'derive-fixture', default-features = false, path = '../support/derive-fixture'}
common = { package = 'pallet-common', default-features = false, features = ['test'], path = '../common'}
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
randomness-collective-flip = { package = 'pallet-insecure-randomness-collective-flip', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler' }
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group' }
derive-fixture = { package = 'derive-fixture', default-features = false, path = '../support/derive-fixture' }
common = { package = 'pallet-common', default-features = false, features = [
'test',
], path = '../common' }
vesting = { package = 'pallet-vesting', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
derive-new = "0.5"

[features]
Expand All @@ -64,8 +71,9 @@ std = [
'storage/std',
'balances/std',
'membership/std',
'vesting/std',
'project-token/std',
'scale-info/std',
'frame-benchmarking?/std',
]
try-runtime = [ "frame-support/try-runtime"]
try-runtime = ["frame-support/try-runtime"]
38 changes: 37 additions & 1 deletion runtime-modules/content/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use common::membership::MemberOriginValidator;
use common::working_group::WorkingGroupAuthenticator;
use frame_support::dispatch::DispatchResult;
use frame_support::traits::{
ConstU16, ConstU32, ConstU64, LockIdentifier, OnFinalize, OnInitialize,
ConstU16, ConstU32, ConstU64, LockIdentifier, OnFinalize, OnInitialize, WithdrawReasons,
};
use frame_support::{parameter_types, PalletId};
pub use membership::WeightInfo;
use sp_core::{H256, U256};
use sp_runtime::traits::Convert;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Expand All @@ -17,6 +18,7 @@ use sp_runtime::{
use sp_std::cell::RefCell;
use sp_std::convert::{TryFrom, TryInto};
use staking_handler::LockComparator;
use working_group::VestingBalanceOf;

use crate::Config;
use crate::ContentActorAuthenticator;
Expand Down Expand Up @@ -154,6 +156,7 @@ frame_support::construct_runtime!(
DistributionWorkingGroup: working_group::<Instance9>::{Pallet, Call, Storage, Event<T, I>},
StorageWorkingGroup: working_group::<Instance2>::{Pallet, Call, Storage, Event<T, I>},
ContentWorkingGroup: working_group::<Instance3>::{Pallet, Call, Storage, Event<T, I>},
Vesting: vesting::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -476,6 +479,12 @@ impl common::council::CouncilBudgetManager<U256, u64> for CouncilBudgetManager {
}
}

parameter_types! {
pub const MinVestedTransfer: u64 = 10;
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}

// The storage working group instance alias.
pub type StorageWorkingGroupInstance = working_group::Instance2;

Expand All @@ -490,6 +499,7 @@ impl working_group::Config<StorageWorkingGroupInstance> for Test {
type WeightInfo = ();
type MinimumApplicationStake = MinimumApplicationStake;
type LeaderOpeningStake = LeaderOpeningStake;
type VestingBalanceToBalance = BalanceConverter;
}
// The distribution working group instance alias.
pub type DistributionWorkingGroupInstance = working_group::Instance9;
Expand All @@ -505,6 +515,31 @@ impl working_group::Config<DistributionWorkingGroupInstance> for Test {
type WeightInfo = ();
type MinimumApplicationStake = MinimumApplicationStake;
type LeaderOpeningStake = LeaderOpeningStake;
type VestingBalanceToBalance = BalanceConverter;
}

pub struct BlockNumberToBalance();
impl Convert<<Test as frame_system::Config>::BlockNumber, BalanceOf<Test>>
for BlockNumberToBalance
{
fn convert(block: <Test as frame_system::Config>::BlockNumber) -> BalanceOf<Test> {
block as u64
}
}
pub struct BalanceConverter();
impl Convert<BalanceOf<Test>, VestingBalanceOf<Test>> for BalanceConverter {
fn convert(balance: BalanceOf<Test>) -> VestingBalanceOf<Test> {
balance as u64
}
}
impl vesting::Config for Test {
type BlockNumberToBalance = BlockNumberToBalance;
type Currency = Balances;
type RuntimeEvent = RuntimeEvent;
const MAX_VESTING_SCHEDULES: u32 = 3;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = ();
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
}

// Content working group instance alias.
Expand All @@ -521,6 +556,7 @@ impl working_group::Config<ContentWorkingGroupInstance> for Test {
type WeightInfo = ();
type MinimumApplicationStake = MinimumApplicationStake;
type LeaderOpeningStake = LeaderOpeningStake;
type VestingBalanceToBalance = BalanceConverter;
}

impl common::membership::MemberOriginValidator<RuntimeOrigin, u64, U256> for () {
Expand Down
54 changes: 30 additions & 24 deletions runtime-modules/forum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,45 @@ edition = '2018'

[dependencies]
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = 'parity-scale-codec', version = '3.1.2', default-features = false, features = ['derive'] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
common = { package = 'pallet-common', default-features = false, path = '../common'}
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
codec = { package = 'parity-scale-codec', version = '3.1.2', default-features = false, features = [
'derive',
] }
scale-info = { version = "2.1.1", default-features = false, features = [
"derive",
] }
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
sp-std = { package = 'sp-std', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
common = { package = 'pallet-common', default-features = false, path = '../common' }
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }

# Benchmarking dependencies
frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9', optional = true}
membership = { package = 'pallet-membership', default-features = false, path = '../membership', optional = true}
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group', optional = true}
staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler', optional = true}
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9', optional = true}
frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9', optional = true }
membership = { package = 'pallet-membership', default-features = false, path = '../membership', optional = true }
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group', optional = true }
staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler', optional = true }
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9', optional = true }

[dev-dependencies]
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9'}
membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group'}
staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler'}
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
vesting = { package = 'pallet-vesting', default-features = false, git = 'https://github.com/joystream/substrate.git', rev = '1d0eefca86ef31b9e7727df01a6ed23ad65491e9' }
membership = { package = 'pallet-membership', default-features = false, path = '../membership' }
working-group = { package = 'pallet-working-group', default-features = false, path = '../working-group' }
staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler' }


[features]
default = ['std']
runtime-benchmarks = [
'frame-benchmarking/runtime-benchmarks',
'frame-benchmarking/runtime-benchmarks',
'membership/runtime-benchmarks',
'working-group/runtime-benchmarks',
'staking-handler',
'sp-core',
'sp-core',
'common/runtime-benchmarks',
]
std = [
Expand All @@ -52,10 +58,10 @@ std = [
'sp-io/std',
'pallet-timestamp/std',
'common/std',
'balances/std',
'balances/std',
'membership/std',
'working-group/std',
'scale-info/std',
'frame-benchmarking?/std',
]
try-runtime = [ "frame-support/try-runtime"]
try-runtime = ["frame-support/try-runtime"]
Loading

0 comments on commit aed16d0

Please sign in to comment.