Browse Source

Merge branch 'olympia' into olympia_vnft_schema_mappings

ondratra 3 years ago
parent
commit
4f64183ca0
33 changed files with 548 additions and 921 deletions
  1. 0 0
      chain-metadata.json
  2. 13 59
      cli/src/Api.ts
  3. 14 12
      cli/src/ExitCodes.ts
  4. 1 1
      cli/src/base/AccountsCommandBase.ts
  5. 8 6
      cli/src/commands/working-groups/createOpening.ts
  6. 1 0
      devops/aws/templates/Playground-Caddyfile.j2
  7. 6 4
      distributor-node/src/command-base/ExitCodes.ts
  8. 0 8
      node/src/chain_spec/mod.rs
  9. 41 152
      runtime-modules/content/src/lib.rs
  10. 1 1
      runtime-modules/content/src/permissions/mod.rs
  11. 0 36
      runtime-modules/content/src/tests/fixtures.rs
  12. 0 166
      runtime-modules/content/src/tests/migration.rs
  13. 2 27
      runtime-modules/content/src/tests/mock.rs
  14. 0 1
      runtime-modules/content/src/tests/mod.rs
  15. 6 6
      runtime-modules/staking-handler/src/lib.rs
  16. 2 0
      runtime-modules/staking-handler/src/mock.rs
  17. 34 0
      runtime-modules/staking-handler/src/test.rs
  18. 2 10
      runtime-modules/utility/src/lib.rs
  19. 0 9
      runtime-modules/utility/src/tests/mocks.rs
  20. 4 4
      runtime-modules/working-group/src/checks.rs
  21. 5 2
      runtime-modules/working-group/src/tests/mod.rs
  22. 11 135
      runtime/src/constants.rs
  23. 60 40
      runtime/src/lib.rs
  24. 0 4
      runtime/src/runtime_api.rs
  25. 64 0
      runtime/src/tests/locks.rs
  26. 12 9
      runtime/src/tests/mod.rs
  27. 39 9
      runtime/src/tests/proposals_integration/mod.rs
  28. 2 0
      storage-node/src/command-base/ExitCodes.ts
  29. 0 8
      types/augment/all/defs.json
  30. 0 12
      types/augment/all/types.ts
  31. 0 11
      types/src/content/index.ts
  32. 1 2
      utils/api-scripts/src/initialize-lead.ts
  33. 219 187
      yarn.lock

File diff suppressed because it is too large
+ 0 - 0
chain-metadata.json


+ 13 - 59
cli/src/Api.ts

@@ -16,7 +16,6 @@ import {
   OpeningDetails,
   UnaugmentedApiPromise,
   MemberDetails,
-  AvailableGroups,
 } from './Types'
 import { DeriveBalancesAll } from '@polkadot/api-derive/types'
 import { CLIError } from '@oclif/errors'
@@ -464,70 +463,25 @@ export default class Api {
     return !existingMeber.isEmpty
   }
 
-  allowedLockCombinations(): { [lockId: string]: LockIdentifier[] } {
-    // TODO: Fetch from runtime once exposed
-    const invitedMemberLockId = this._api.consts.members.invitedMemberLockId
-    const candidacyLockId = this._api.consts.council.candidacyLockId
+  nonRivalrousLocks(): LockIdentifier[] {
     const votingLockId = this._api.consts.referendum.stakingHandlerLockId
-    const councilorLockId = this._api.consts.council.councilorLockId
-    const stakingCandidateLockId = this._api.consts.members.stakingCandidateLockId
-    const proposalsLockId = this._api.consts.proposalsEngine.stakingHandlerLockId
-    const groupLockIds: { group: WorkingGroups; lockId: LockIdentifier }[] = AvailableGroups.map((group) => ({
-      group,
-      lockId: this._api.consts[apiModuleByGroup[group]].stakingHandlerLockId,
-    }))
-    const bountyLockId = this._api.consts.bounty.bountyLockId
-
-    const lockCombinationsByWorkingGroupLockId: { [groupLockId: string]: LockIdentifier[] } = {}
-    groupLockIds.forEach(
-      ({ lockId }) =>
-        (lockCombinationsByWorkingGroupLockId[lockId.toString()] = [
-          invitedMemberLockId,
-          votingLockId,
-          stakingCandidateLockId,
-        ])
-    )
+    const boundStakingAccountLockId = this._api.consts.members.stakingCandidateLockId
+    const invitedMemberLockId = this._api.consts.members.invitedMemberLockId
+    const vestigLockId = this._api.createType('LockIdentifier', 'vesting ')
 
-    return {
-      [invitedMemberLockId.toString()]: [
-        votingLockId,
-        candidacyLockId,
-        councilorLockId,
-        // STAKING_LOCK_ID,
-        proposalsLockId,
-        stakingCandidateLockId,
-        ...groupLockIds.map(({ lockId }) => lockId),
-      ],
-      [stakingCandidateLockId.toString()]: [
-        votingLockId,
-        candidacyLockId,
-        councilorLockId,
-        // STAKING_LOCK_ID,
-        proposalsLockId,
-        invitedMemberLockId,
-        ...groupLockIds.map(({ lockId }) => lockId),
-      ],
-      [votingLockId.toString()]: [
-        invitedMemberLockId,
-        candidacyLockId,
-        councilorLockId,
-        // STAKING_LOCK_ID,
-        proposalsLockId,
-        stakingCandidateLockId,
-        ...groupLockIds.map(({ lockId }) => lockId),
-      ],
-      [candidacyLockId.toString()]: [invitedMemberLockId, votingLockId, councilorLockId, stakingCandidateLockId],
-      [councilorLockId.toString()]: [invitedMemberLockId, votingLockId, candidacyLockId, stakingCandidateLockId],
-      [proposalsLockId.toString()]: [invitedMemberLockId, votingLockId, stakingCandidateLockId],
-      ...lockCombinationsByWorkingGroupLockId,
-      [bountyLockId.toString()]: [votingLockId, stakingCandidateLockId],
-    }
+    return [votingLockId, boundStakingAccountLockId, invitedMemberLockId, vestigLockId]
+  }
+
+  isLockRivalrous(lockId: LockIdentifier): boolean {
+    const nonRivalrousLocks = this.nonRivalrousLocks()
+    return !nonRivalrousLocks.some((nonRivalrousLockId) => nonRivalrousLockId.eq(lockId))
   }
 
   async areAccountLocksCompatibleWith(account: AccountId | string, lockId: LockIdentifier): Promise<boolean> {
     const accountLocks = await this._api.query.balances.locks(account)
-    const allowedLocks = this.allowedLockCombinations()[lockId.toString()]
-    return accountLocks.every((l) => allowedLocks.some((allowedLock) => allowedLock.eq(l.id)))
+    const accountHasRivalrousLock = accountLocks.some(({ id }) => this.isLockRivalrous(id))
+
+    return !this.isLockRivalrous(lockId) || !accountHasRivalrousLock
   }
 
   async forumCategoryExists(categoryId: CategoryId | number): Promise<boolean> {

+ 14 - 12
cli/src/ExitCodes.ts

@@ -1,18 +1,20 @@
 enum ExitCodes {
   OK = 0,
 
-  InvalidInput = 400,
-  FileNotFound = 401,
-  InvalidFile = 402,
-  NoAccountFound = 403,
-  NoAccountSelected = 404,
-  AccessDenied = 405,
+  InvalidInput = 40,
+  FileNotFound = 41,
+  InvalidFile = 42,
+  NoAccountFound = 43,
+  NoAccountSelected = 44,
+  AccessDenied = 45,
 
-  UnexpectedException = 500,
-  FsOperationFailed = 501,
-  ApiError = 502,
-  StorageNodeError = 503,
-  ActionCurrentlyUnavailable = 504,
-  QueryNodeError = 505,
+  UnexpectedException = 50,
+  FsOperationFailed = 51,
+  ApiError = 52,
+  StorageNodeError = 53,
+  ActionCurrentlyUnavailable = 54,
+  QueryNodeError = 55,
+
+  // NOTE: never exceed exit code 255 or it will be modulated by `256` and create problems
 }
 export = ExitCodes

+ 1 - 1
cli/src/base/AccountsCommandBase.ts

@@ -381,7 +381,7 @@ export default abstract class AccountsCommandBase extends ApiCommandBase {
     const requiredStakingAccountBalance = !stakingStatus
       ? requiredStake.add(candidateTxFee).add(STAKING_ACCOUNT_CANDIDATE_STAKE)
       : requiredStake
-    const missingStakingAccountBalance = requiredStakingAccountBalance.sub(balances.availableBalance)
+    const missingStakingAccountBalance = requiredStakingAccountBalance.sub(balances.freeBalance)
     if (missingStakingAccountBalance.gtn(0)) {
       this.warn(
         `Not enough available staking account balance! Missing: ${chalk.cyanBright(

+ 8 - 6
cli/src/commands/working-groups/createOpening.ts

@@ -104,12 +104,14 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
     return getInputJson<WorkingGroupOpeningInputParameters>(filePath, WorkingGroupOpeningInputSchema)
   }
 
-  async promptForStakeTopUp(stakingAccount: string, fundsSource?: string): Promise<void> {
-    const requiredStake = this.getOriginalApi().consts[apiModuleByGroup[this.group]].leaderOpeningStake
-    this.log(`You need to stake ${chalk.bold(formatBalance(requiredStake))} in order to create a new opening.`)
+  async promptForStakeTopUp({ stake, stakingAccount }: GroupMember, fundsSource?: string): Promise<void> {
+    const newStake = this.getOriginalApi().consts[apiModuleByGroup[this.group]].leaderOpeningStake.add(stake)
+    this.log(
+      `You need to increase your lead stake to ${chalk.bold(formatBalance(newStake))} in order to create a new opening.`
+    )
 
-    const [balances] = await this.getApi().getAccountsBalancesInfo([stakingAccount])
-    const missingBalance = requiredStake.sub(balances.availableBalance)
+    const [balances] = await this.getApi().getAccountsBalancesInfo([stakingAccount.toString()])
+    const missingBalance = newStake.sub(balances.freeBalance)
     if (missingBalance.gtn(0)) {
       await this.requireConfirmation(
         `Do you wish to transfer remaining ${chalk.bold(
@@ -250,7 +252,7 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
       rememberedInput = openingJson
 
       if (!upcoming) {
-        await this.promptForStakeTopUp(lead.stakingAccount.toString(), stakeTopUpSource)
+        await this.promptForStakeTopUp(lead, stakeTopUpSource)
       }
 
       const createUpcomingOpeningActionMeta = this.prepareCreateUpcomingOpeningMetadata(

+ 1 - 0
devops/aws/templates/Playground-Caddyfile.j2

@@ -51,6 +51,7 @@ wss://{{ nip_domain }}/query-node/server* {
 {{ nip_domain }}/network/config.json {
     header /* {
       Access-Control-Allow-Origin *
+      Cache-Control: no-cache
     }
     root * /home/ubuntu
     rewrite * /config.json

+ 6 - 4
distributor-node/src/command-base/ExitCodes.ts

@@ -1,9 +1,11 @@
 enum ExitCodes {
   OK = 0,
   Error = 1,
-  ApiError = 200,
-  InvalidInput = 400,
-  FileNotFound = 401,
-  InvalidFile = 402,
+  ApiError = 20,
+  InvalidInput = 40,
+  FileNotFound = 41,
+  InvalidFile = 42,
+
+  // NOTE: never exceed exit code 255 or it will be modulated by `256` and create problems
 }
 export = ExitCodes

+ 0 - 8
node/src/chain_spec/mod.rs

@@ -277,14 +277,6 @@ pub fn testnet_genesis(
                 next_video_category_id: 1,
                 next_video_id: 1,
                 next_video_post_id: 1,
-                video_migration: node_runtime::content::MigrationConfigRecord {
-                    current_id: 1,
-                    final_id: 1,
-                },
-                channel_migration: node_runtime::content::MigrationConfigRecord {
-                    current_id: 1,
-                    final_id: 1,
-                },
                 max_reward_allowed: 1000,
                 min_cashout_allowed: 1,
                 min_auction_duration: 3,

+ 41 - 152
runtime-modules/content/src/lib.rs

@@ -104,12 +104,6 @@ pub trait Trait:
 
     /// Refund cap during cleanup
     type BloatBondCap: Get<u32>;
-
-    /// Video migrated in each block during migration
-    type VideosMigrationsEachBlock: Get<u64>;
-
-    /// Channel migrated in each block during migration
-    type ChannelsMigrationsEachBlock: Get<u64>;
 }
 
 decl_storage! {
@@ -142,10 +136,6 @@ decl_storage! {
 
         pub NextVideoPostId get(fn next_video_post_id) config(): T::VideoPostId;
 
-        pub ChannelMigration get(fn channel_migration) config(): ChannelMigrationConfig<T>;
-
-        pub VideoMigration get(fn video_migration) config(): VideoMigrationConfig<T>;
-
         pub Commitment get(fn commitment): <T as frame_system::Trait>::Hash;
 
         pub MaxRewardAllowed get(fn max_reward_allowed) config(): BalanceOf<T>;
@@ -346,9 +336,6 @@ decl_module! {
             actor: ContentActor<T::CuratorGroupId, T::CuratorId, T::MemberId>,
             params: ChannelCreationParameters<T>,
         ) {
-            // ensure migration is done
-            ensure!(Self::is_migration_done(), Error::<T>::MigrationNotFinished);
-
             // channel creator account
             let sender = ensure_signed(origin)?;
 
@@ -451,7 +438,7 @@ decl_module! {
             let sender = ensure_signed(origin)?;
 
             // check that channel exists
-            let mut channel = Self::ensure_channel_validity(&channel_id)?;
+            let mut channel = Self::ensure_channel_exists(&channel_id)?;
 
             ensure_actor_authorized_to_update_channel_assets::<T>(
                 &sender,
@@ -530,7 +517,7 @@ decl_module! {
             let sender = ensure_signed(origin)?;
 
             // check that channel exists
-            let channel = Self::ensure_channel_validity(&channel_id)?;
+            let channel = Self::ensure_channel_exists(&channel_id)?;
 
             ensure_actor_authorized_to_delete_channel::<T>(
                 &sender,
@@ -609,7 +596,7 @@ decl_module! {
             rationale: Vec<u8>,
         ) {
             // check that channel exists
-            let channel = Self::ensure_channel_validity(&channel_id)?;
+            let channel = Self::ensure_channel_exists(&channel_id)?;
 
             ensure_actor_authorized_to_censor::<T>(
                 origin,
@@ -700,7 +687,7 @@ decl_module! {
             let sender = ensure_signed(origin)?;
 
             // check that channel exists
-            let channel = Self::ensure_channel_validity(&channel_id)?;
+            let channel = Self::ensure_channel_exists(&channel_id)?;
 
             ensure_actor_authorized_to_update_channel_assets::<T>(
                 &sender,
@@ -768,7 +755,7 @@ decl_module! {
         ) {
             let sender = ensure_signed(origin)?;
             // check that video exists, retrieve corresponding channel id.
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             let channel_id = video.in_channel;
             let channel = ChannelById::<T>::get(&channel_id);
@@ -830,7 +817,7 @@ decl_module! {
             let sender = ensure_signed(origin)?;
 
             // check that video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // get information regarding channel
             let channel_id = video.in_channel;
@@ -970,7 +957,7 @@ decl_module! {
             rationale: Vec<u8>,
         ) -> DispatchResult {
             // check that video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             ensure_actor_authorized_to_censor::<T>(
                 origin,
@@ -1012,7 +999,7 @@ decl_module! {
             let sender = ensure_signed(origin)?;
 
             // ensure channel is valid
-            let video = Self::ensure_video_validity(&params.video_reference)?;
+            let video = Self::ensure_video_exists(&params.video_reference)?;
             let owner = ChannelById::<T>::get(video.in_channel).owner;
 
             match params.post_type {
@@ -1220,7 +1207,7 @@ decl_module! {
         ) {
             // ensure (origin, actor) is channel owner
             let sender = ensure_signed(origin)?;
-            let owner = Self::ensure_channel_validity(&channel_id)?.owner;
+            let owner = Self::ensure_channel_exists(&channel_id)?.owner;
 
             ensure_actor_can_manage_moderators::<T>(
                 &sender,
@@ -1243,12 +1230,6 @@ decl_module! {
                 ));
         }
 
-        fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight {
-            Self::perform_video_migration();
-            Self::perform_channel_migration();
-            10_000_000 // TODO: adjust Weight
-        }
-
         #[weight = 10_000_000] // TODO: adjust Weight
         pub fn update_commitment(
             origin,
@@ -1268,7 +1249,7 @@ decl_module! {
             proof: Vec<ProofElement<T>>,
             item: PullPayment<T>,
         ) -> DispatchResult {
-            let channel = Self::ensure_channel_validity(&item.channel_id)?;
+            let channel = Self::ensure_channel_exists(&item.channel_id)?;
 
             ensure!(channel.reward_account.is_some(), Error::<T>::RewardAccountIsNotSet);
             ensure_actor_authorized_to_claim_payment::<T>(origin, &actor, &channel.owner)?;
@@ -1323,7 +1304,7 @@ decl_module! {
             let sender = ensure_signed(origin)?;
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure have not been issued yet
             video.ensure_nft_is_not_issued::<T>()?;
@@ -1331,7 +1312,7 @@ decl_module! {
             let channel_id = video.in_channel;
 
             // Ensure channel exists, retrieve channel owner
-            let channel = Self::ensure_channel_validity(&channel_id)?;
+            let channel = Self::ensure_channel_exists(&channel_id)?;
 
             ensure_actor_authorized_to_update_channel_assets::<T>(&sender, &actor, &channel)?;
 
@@ -1364,7 +1345,7 @@ decl_module! {
             auction_params: AuctionParams<T::BlockNumber, CurrencyOf<T>, T::MemberId>,
         ) {
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1408,7 +1389,7 @@ decl_module! {
             video_id: T::VideoId,
         ) {
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1444,7 +1425,7 @@ decl_module! {
             video_id: T::VideoId,
         ) {
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1477,7 +1458,7 @@ decl_module! {
             video_id: T::VideoId,
         ) {
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1519,7 +1500,7 @@ decl_module! {
             Self::ensure_has_sufficient_balance(&participant_account_id, bid)?;
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1599,7 +1580,7 @@ decl_module! {
             ensure_member_auth_success::<T>(&participant_account_id, &participant_id)?;
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1640,7 +1621,7 @@ decl_module! {
             ensure_member_auth_success::<T>(&account_id, &member_id)?;
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1683,7 +1664,7 @@ decl_module! {
         ) {
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1727,7 +1708,7 @@ decl_module! {
         ) {
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1761,7 +1742,7 @@ decl_module! {
         ) {
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1795,7 +1776,7 @@ decl_module! {
             let receiver_account_id = ensure_signed(origin)?;
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1829,7 +1810,7 @@ decl_module! {
         ) {
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1867,7 +1848,7 @@ decl_module! {
             ensure_member_auth_success::<T>(&participant_account_id, &participant_id)?;
 
             // Ensure given video exists
-            let video = Self::ensure_video_validity(&video_id)?;
+            let video = Self::ensure_video_exists(&video_id)?;
 
             // Ensure nft is already issued
             let nft = video.ensure_nft_is_issued::<T>()?;
@@ -1894,83 +1875,6 @@ decl_module! {
 }
 
 impl<T: Trait> Module<T> {
-    /// Migrate Videos
-    fn perform_video_migration() {
-        let MigrationConfigRecord {
-            current_id,
-            final_id,
-        } = <VideoMigration<T>>::get();
-
-        if current_id < final_id {
-            // perform migration procedure
-            let next_id = sp_std::cmp::min(
-                current_id + T::VideosMigrationsEachBlock::get().into(),
-                final_id,
-            );
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // clear maps: (iterator are lazy and do nothing unless consumed)
-            for id in current_id.into()..next_id.into() {
-                <VideoById<T>>::remove(T::VideoId::from(id));
-            }
-
-            // edit the current id
-            <VideoMigration<T>>::mutate(|value| value.current_id = next_id);
-        }
-    }
-
-    /// Migrate Channels
-    fn perform_channel_migration() {
-        let MigrationConfigRecord {
-            current_id,
-            final_id,
-        } = <ChannelMigration<T>>::get();
-
-        if current_id < final_id {
-            // perform migration procedure
-            let next_id = sp_std::cmp::min(
-                current_id + T::ChannelsMigrationsEachBlock::get().into(),
-                final_id,
-            );
-
-            //
-            // == MUTATION SAFE ==
-            //
-
-            // clear maps: (iterator are lazy and do nothing unless consumed)
-            for id in current_id.into()..next_id.into() {
-                <ChannelById<T>>::remove(T::ChannelId::from(id));
-            }
-
-            // edit the current id
-            <ChannelMigration<T>>::mutate(|value| value.current_id = next_id);
-        }
-    }
-
-    /// Ensure Channel Migration Finished
-
-    /// Ensure Video Migration Finished
-    fn is_migration_done() -> bool {
-        let MigrationConfigRecord {
-            current_id,
-            final_id,
-        } = <VideoMigration<T>>::get();
-
-        let video_migration_done = current_id == final_id;
-
-        let MigrationConfigRecord {
-            current_id,
-            final_id,
-        } = <ChannelMigration<T>>::get();
-
-        let channel_migration_done = current_id == final_id;
-
-        video_migration_done && channel_migration_done
-    }
-
     /// Ensure `CuratorGroup` under given id exists
     fn ensure_curator_group_under_given_id_exists(
         curator_group_id: &T::CuratorGroupId,
@@ -1990,30 +1894,6 @@ impl<T: Trait> Module<T> {
         Ok(Self::curator_group_by_id(curator_group_id))
     }
 
-    fn ensure_channel_validity(channel_id: &T::ChannelId) -> Result<Channel<T>, Error<T>> {
-        // ensure migration is done
-        ensure!(Self::is_migration_done(), Error::<T>::MigrationNotFinished,);
-
-        // ensure channel exists
-        ensure!(
-            ChannelById::<T>::contains_key(channel_id),
-            Error::<T>::ChannelDoesNotExist
-        );
-        Ok(ChannelById::<T>::get(channel_id))
-    }
-
-    fn ensure_video_validity(video_id: &T::VideoId) -> Result<Video<T>, Error<T>> {
-        // ensure migration is done
-        ensure!(Self::is_migration_done(), Error::<T>::MigrationNotFinished,);
-
-        // ensure video exists
-        ensure!(
-            VideoById::<T>::contains_key(video_id),
-            Error::<T>::VideoDoesNotExist
-        );
-        Ok(VideoById::<T>::get(video_id))
-    }
-
     fn ensure_channel_category_exists(
         channel_category_id: &T::ChannelCategoryId,
     ) -> Result<ChannelCategory, Error<T>> {
@@ -2034,6 +1914,22 @@ impl<T: Trait> Module<T> {
         Ok(VideoCategoryById::<T>::get(video_category_id))
     }
 
+    fn ensure_video_exists(video_id: &T::VideoId) -> Result<Video<T>, Error<T>> {
+        ensure!(
+            VideoById::<T>::contains_key(video_id),
+            Error::<T>::VideoDoesNotExist
+        );
+        Ok(VideoById::<T>::get(video_id))
+    }
+
+    fn ensure_channel_exists(channel_id: &T::ChannelId) -> Result<Channel<T>, Error<T>> {
+        ensure!(
+            ChannelById::<T>::contains_key(channel_id),
+            Error::<T>::ChannelDoesNotExist
+        );
+        Ok(ChannelById::<T>::get(channel_id))
+    }
+
     fn ensure_post_exists(
         video_id: T::VideoId,
         post_id: T::VideoPostId,
@@ -2208,13 +2104,6 @@ impl<T: Trait> Module<T> {
 
         Ok(())
     }
-
-    // Reset Videos and Channels on runtime upgrade but preserving next ids and categories.
-    pub fn on_runtime_upgrade() {
-        // setting final index triggers migration
-        <VideoMigration<T>>::mutate(|config| config.final_id = <NextVideoId<T>>::get());
-        <ChannelMigration<T>>::mutate(|config| config.final_id = <NextChannelId<T>>::get());
-    }
 }
 
 decl_event!(

+ 1 - 1
runtime-modules/content/src/permissions/mod.rs

@@ -270,7 +270,7 @@ pub fn ensure_actor_authorized_to_manage_nft<T: Trait>(
         );
     } else {
         // Ensure curator group is the channel owner.
-        let channel_owner = Module::<T>::ensure_channel_validity(&in_channel)?.owner;
+        let channel_owner = Module::<T>::ensure_channel_exists(&in_channel)?.owner;
 
         match actor {
             ContentActor::Lead => {

+ 0 - 36
runtime-modules/content/src/tests/fixtures.rs

@@ -1457,42 +1457,6 @@ pub fn create_default_curator_owned_channel_with_video() {
         .call_and_assert(Ok(()));
 }
 
-pub fn create_default_member_owned_channels_with_videos() -> (u64, u64) {
-    for _ in 0..OUTSTANDING_CHANNELS {
-        create_default_member_owned_channel();
-    }
-
-    for i in 0..OUTSTANDING_VIDEOS {
-        CreateVideoFixture::default()
-            .with_sender(DEFAULT_MEMBER_ACCOUNT_ID)
-            .with_actor(ContentActor::Member(DEFAULT_MEMBER_ID))
-            .with_assets(StorageAssets::<Test> {
-                expected_data_size_fee: Storage::<Test>::data_object_per_mega_byte_fee(),
-                object_creation_list: create_data_objects_helper(),
-            })
-            .with_channel_id(i % OUTSTANDING_CHANNELS + 1)
-            .call_and_assert(Ok(()));
-    }
-
-    // assert that the specified channels have been created
-    assert_eq!(VideoById::<Test>::iter().count() as u64, OUTSTANDING_VIDEOS);
-    assert_eq!(
-        ChannelById::<Test>::iter().count() as u64,
-        OUTSTANDING_CHANNELS
-    );
-
-    let channels_migrations_per_block = <Test as Trait>::ChannelsMigrationsEachBlock::get();
-    let videos_migrations_per_block = <Test as Trait>::VideosMigrationsEachBlock::get();
-
-    // return the number of blocks required for migration
-    let divide_with_ceiling =
-        |x: u64, y: u64| (x / y) + ((x.checked_rem(y).unwrap_or_default() > 0u64) as u64);
-    (
-        divide_with_ceiling(OUTSTANDING_CHANNELS, channels_migrations_per_block),
-        divide_with_ceiling(OUTSTANDING_VIDEOS, videos_migrations_per_block),
-    )
-}
-
 pub fn create_default_member_owned_channel_with_video_and_post() {
     create_default_member_owned_channel_with_video();
     CreatePostFixture::default().call_and_assert(Ok(()));

+ 0 - 166
runtime-modules/content/src/tests/migration.rs

@@ -1,166 +0,0 @@
-#![cfg(test)]
-use super::fixtures::*;
-use super::mock::*;
-use crate::*;
-
-fn assert_video_and_channel_existrinsics_with(result: DispatchResult) {
-    let params = VideoCreationParametersRecord {
-        assets: None,
-        meta: None,
-        enable_comments: true,
-        auto_issue_nft: None,
-    };
-
-    // attempt to create valid channel if result is ok, otherwise id does not matter
-    let channel_id = if result.is_ok() {
-        Content::next_channel_id()
-    } else {
-        <Test as storage::Trait>::ChannelId::one()
-    };
-
-    // attempt to create valid video if result is ok, otherwise id does not matter
-    let video_id = if result.is_ok() {
-        Content::next_video_id()
-    } else {
-        <Test as Trait>::VideoId::one()
-    };
-
-    assert_eq!(
-        Content::create_channel(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            ChannelCreationParametersRecord {
-                assets: None,
-                meta: Some(vec![]),
-                reward_account: None,
-                collaborators: BTreeSet::new(),
-                moderators: BTreeSet::new(),
-            },
-        ),
-        result
-    );
-
-    assert_eq!(
-        Content::create_video(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            channel_id.clone(),
-            params.clone()
-        ),
-        result
-    );
-    assert_eq!(
-        Content::update_channel(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            channel_id.clone(),
-            ChannelUpdateParametersRecord {
-                assets_to_upload: None,
-                new_meta: Some(vec![]),
-                reward_account: None,
-                assets_to_remove: BTreeSet::new(),
-                collaborators: None,
-            },
-        ),
-        result
-    );
-    assert_eq!(
-        Content::update_video(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            video_id.clone(),
-            VideoUpdateParametersRecord {
-                assets_to_upload: None,
-                new_meta: Some(vec![]),
-                assets_to_remove: BTreeSet::new(),
-                enable_comments: None,
-            },
-        ),
-        result
-    );
-
-    assert_eq!(
-        Content::update_channel_censorship_status(
-            Origin::signed(LEAD_ACCOUNT_ID),
-            ContentActor::Lead,
-            channel_id.clone(),
-            true,
-            b"test".to_vec()
-        ),
-        result
-    );
-
-    assert_eq!(
-        Content::update_video_censorship_status(
-            Origin::signed(LEAD_ACCOUNT_ID),
-            ContentActor::Lead,
-            video_id.clone(),
-            true,
-            b"test".to_vec()
-        ),
-        result
-    );
-
-    assert_eq!(
-        Content::delete_video(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            video_id.clone(),
-            BTreeSet::new(),
-        ),
-        result
-    );
-    assert_eq!(
-        Content::delete_channel(
-            Origin::signed(DEFAULT_MEMBER_ACCOUNT_ID),
-            ContentActor::Member(DEFAULT_MEMBER_ID),
-            channel_id.clone(),
-            0u64,
-        ),
-        result
-    );
-}
-
-#[test]
-fn migration_test() {
-    with_default_mock_builder(|| {
-        run_to_block(START_MIGRATION_AT_BLOCK);
-
-        // setup scenario
-        increase_account_balance_helper(DEFAULT_MEMBER_ACCOUNT_ID, INITIAL_BALANCE);
-        create_initial_storage_buckets_helper();
-        let (blocks_channels, blocks_videos) = create_default_member_owned_channels_with_videos();
-
-        // block at which all migrations should be completed
-        let last_migration_block = std::cmp::max(blocks_channels, blocks_videos);
-
-        // ensure we have setup scenario to properly test migration over multiple blocks
-        println!("last migration block:\t{:?}", last_migration_block);
-        assert!(last_migration_block > START_MIGRATION_AT_BLOCK);
-
-        // triggering migration
-        Content::on_runtime_upgrade();
-
-        // migration should have started
-        assert!(!Content::is_migration_done());
-
-        // migration is not complete all extrinsics should fail
-        assert_video_and_channel_existrinsics_with(Err(Error::<Test>::MigrationNotFinished.into()));
-
-        // make progress with migration but should not be complete yet
-        run_to_block(last_migration_block);
-        assert!(!Content::is_migration_done());
-        assert_video_and_channel_existrinsics_with(Err(Error::<Test>::MigrationNotFinished.into()));
-
-        // run migration to expected completion block
-        run_to_block(last_migration_block + 1);
-
-        // assert that maps are cleared & migration is done
-        assert!(Content::is_migration_done());
-        assert_eq!(VideoById::<Test>::iter().count(), 0);
-        assert_eq!(ChannelById::<Test>::iter().count(), 0);
-
-        // video and channel extr. now succeed
-        assert_video_and_channel_existrinsics_with(Ok(()));
-    })
-}

+ 2 - 27
runtime-modules/content/src/tests/mock.rs

@@ -57,18 +57,12 @@ pub const UNAUTHORIZED_COLLABORATOR_MEMBER_ID: u64 = 214;
 pub const UNAUTHORIZED_MODERATOR_ID: u64 = 215;
 pub const SECOND_MEMBER_ID: u64 = 216;
 
-// Storage module & migration parameters
-// # objects in a channel == # objects in a video is assumed, changing this will make tests fail
-
 pub const DATA_OBJECT_DELETION_PRIZE: u64 = 5;
 pub const DEFAULT_OBJECT_SIZE: u64 = 5;
 pub const DATA_OBJECTS_NUMBER: u64 = 10;
-pub const VIDEO_MIGRATIONS_PER_BLOCK: u64 = 2;
-pub const CHANNEL_MIGRATIONS_PER_BLOCK: u64 = 1;
-pub const MIGRATION_BLOCKS: u64 = 4;
 
-pub const OUTSTANDING_VIDEOS: u64 = MIGRATION_BLOCKS * VIDEO_MIGRATIONS_PER_BLOCK;
-pub const OUTSTANDING_CHANNELS: u64 = MIGRATION_BLOCKS * CHANNEL_MIGRATIONS_PER_BLOCK;
+pub const OUTSTANDING_VIDEOS: u64 = 5;
+pub const OUTSTANDING_CHANNELS: u64 = 3;
 pub const TOTAL_OBJECTS_NUMBER: u64 =
     DATA_OBJECTS_NUMBER * (OUTSTANDING_VIDEOS + OUTSTANDING_CHANNELS);
 pub const TOTAL_BALANCE_REQUIRED: u64 = TOTAL_OBJECTS_NUMBER * DATA_OBJECT_DELETION_PRIZE;
@@ -81,7 +75,6 @@ pub const VOUCHER_OBJECTS_NUMBER_LIMIT: u64 = 2 * STORAGE_BUCKET_OBJECTS_NUMBER_
 pub const VOUCHER_OBJECTS_SIZE_LIMIT: u64 = VOUCHER_OBJECTS_NUMBER_LIMIT * DEFAULT_OBJECT_SIZE;
 pub const INITIAL_BALANCE: u64 = TOTAL_BALANCE_REQUIRED;
 
-pub const START_MIGRATION_AT_BLOCK: u64 = 1;
 pub const MEMBERS_COUNT: u64 = 10;
 pub const PAYMENTS_NUMBER: u64 = 10;
 pub const DEFAULT_PAYOUT_CLAIMED: u64 = 10;
@@ -399,8 +392,6 @@ parameter_types! {
     pub const PricePerByte: u32 = 2;
     pub const VideoCommentsModuleId: ModuleId = ModuleId(*b"m0:forum"); // module : forum
     pub const BloatBondCap: u32 = 1000;
-    pub const VideosMigrationsEachBlock: u64 = VIDEO_MIGRATIONS_PER_BLOCK;
-    pub const ChannelsMigrationsEachBlock: u64 = CHANNEL_MIGRATIONS_PER_BLOCK;
 }
 
 impl Trait for Test {
@@ -445,10 +436,6 @@ impl Trait for Test {
 
     /// module id
     type ModuleId = ContentModuleId;
-
-    type VideosMigrationsEachBlock = VideosMigrationsEachBlock;
-
-    type ChannelsMigrationsEachBlock = ChannelsMigrationsEachBlock;
 }
 
 // #[derive (Default)]
@@ -459,8 +446,6 @@ pub struct ExtBuilder {
     next_video_id: u64,
     next_curator_group_id: u64,
     next_video_post_id: u64,
-    video_migration: VideoMigrationConfig<Test>,
-    channel_migration: ChannelMigrationConfig<Test>,
     max_reward_allowed: BalanceOf<Test>,
     min_cashout_allowed: BalanceOf<Test>,
     min_auction_duration: u64,
@@ -490,14 +475,6 @@ impl Default for ExtBuilder {
             next_video_id: 1,
             next_curator_group_id: 1,
             next_video_post_id: 1,
-            video_migration: MigrationConfigRecord {
-                current_id: 1,
-                final_id: 1,
-            },
-            channel_migration: MigrationConfigRecord {
-                current_id: 1,
-                final_id: 1,
-            },
             max_reward_allowed: BalanceOf::<Test>::from(1_000u32),
             min_cashout_allowed: BalanceOf::<Test>::from(1u32),
             min_auction_duration: 5,
@@ -533,8 +510,6 @@ impl ExtBuilder {
             next_video_id: self.next_video_id,
             next_curator_group_id: self.next_curator_group_id,
             next_video_post_id: self.next_video_post_id,
-            video_migration: self.video_migration,
-            channel_migration: self.channel_migration,
             max_reward_allowed: self.max_reward_allowed,
             min_cashout_allowed: self.min_cashout_allowed,
             min_auction_duration: self.min_auction_duration,

+ 0 - 1
runtime-modules/content/src/tests/mod.rs

@@ -4,7 +4,6 @@ mod channels;
 mod curators;
 mod fixtures;
 mod merkle;
-mod migration;
 mod mock;
 mod nft;
 mod posts;

+ 6 - 6
runtime-modules/staking-handler/src/lib.rs

@@ -7,6 +7,7 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use frame_support::dispatch::{DispatchError, DispatchResult};
+use frame_support::ensure;
 use frame_support::traits::{Currency, Get, LockIdentifier, LockableCurrency, WithdrawReasons};
 use sp_arithmetic::traits::Zero;
 use sp_std::marker::PhantomData;
@@ -152,11 +153,10 @@ impl<
             return Ok(());
         }
 
-        let usable_balance = <pallet_balances::Module<T>>::usable_balance(account_id);
-
-        if new_stake > current_stake + usable_balance {
-            return Err(DispatchError::Other("Not enough balance for a new stake."));
-        }
+        ensure!(
+            Self::is_enough_balance_for_stake(account_id, new_stake),
+            DispatchError::Other("Not enough balance for a new stake.")
+        );
 
         Self::lock(account_id, new_stake);
 
@@ -175,7 +175,7 @@ impl<
         account_id: &<T as frame_system::Trait>::AccountId,
         amount: <T as pallet_balances::Trait>::Balance,
     ) -> bool {
-        <pallet_balances::Module<T>>::usable_balance(account_id) >= amount
+        <pallet_balances::Module<T>>::free_balance(account_id) >= amount
     }
 
     fn lock_id() -> LockIdentifier {

+ 2 - 0
runtime-modules/staking-handler/src/mock.rs

@@ -91,12 +91,14 @@ impl pallet_timestamp::Trait for Test {
 pub type Balances = pallet_balances::Module<Test>;
 pub type System = frame_system::Module<Test>;
 pub type TestStakingManager = crate::StakingManager<Test, LockId>;
+pub type TestStakingManager2 = crate::StakingManager<Test, LockId2>;
 
 parameter_types! {
     pub const RewardPeriod: u32 = 2;
     pub const MaxWorkerNumberLimit: u32 = 3;
     pub const MinUnstakingPeriodLimit: u64 = 3;
     pub const LockId: [u8; 8] = [1; 8];
+    pub const LockId2: [u8; 8] = [2; 8];
 }
 
 pub fn build_test_externalities() -> sp_io::TestExternalities {

+ 34 - 0
runtime-modules/staking-handler/src/test.rs

@@ -200,3 +200,37 @@ fn set_stake_succeeds() {
         assert_eq!(TestStakingManager::current_stake(&account_id), stake);
     });
 }
+
+#[test]
+fn is_enough_balance_for_stake_succeeds_with_two_stakes() {
+    build_test_externalities().execute_with(|| {
+        let account_id = 1;
+        let total_amount = 200;
+        let stake1 = 100;
+        let stake2 = 200;
+
+        increase_total_balance_issuance_using_account_id(account_id, total_amount);
+
+        assert!(TestStakingManager::set_stake(&account_id, stake1).is_ok());
+
+        assert!(TestStakingManager2::is_enough_balance_for_stake(
+            &account_id,
+            stake2
+        ));
+    });
+}
+
+#[test]
+fn set_stake_succeeds_with_two_stakes() {
+    build_test_externalities().execute_with(|| {
+        let account_id = 1;
+        let total_amount = 200;
+        let stake1 = 100;
+        let stake2 = 200;
+
+        increase_total_balance_issuance_using_account_id(account_id, total_amount);
+
+        assert!(TestStakingManager::set_stake(&account_id, stake1).is_ok());
+        assert!(TestStakingManager2::set_stake(&account_id, stake2).is_ok());
+    });
+}

+ 2 - 10
runtime-modules/utility/src/lib.rs

@@ -24,16 +24,15 @@ pub(crate) mod tests;
 
 mod benchmarking;
 
-use common::{working_group::WorkingGroup, AllowedLockCombinationProvider, BalanceKind};
+use common::{working_group::WorkingGroup, BalanceKind};
 use council::Module as Council;
-use frame_support::traits::{Currency, Get, LockIdentifier};
+use frame_support::traits::{Currency, Get};
 use frame_support::weights::{DispatchClass, Weight};
 use frame_support::{decl_error, decl_event, decl_module, ensure, print};
 use frame_system::{ensure_root, ensure_signed};
 use sp_arithmetic::traits::Zero;
 use sp_runtime::traits::Saturating;
 use sp_runtime::SaturatedConversion;
-use sp_std::collections::btree_set::BTreeSet;
 use sp_std::vec::Vec;
 
 type BalanceOf<T> = <T as balances::Trait>::Balance;
@@ -50,9 +49,6 @@ pub trait Trait: frame_system::Trait + balances::Trait + council::Trait {
 
     /// Weight information for extrinsics in this pallet.
     type WeightInfo: WeightInfo;
-
-    /// Exposes allowed lock combinations from the runtime level.
-    type AllowedLockCombinationProvider: AllowedLockCombinationProvider;
 }
 
 /// Utility WeightInfo.
@@ -119,10 +115,6 @@ decl_module! {
         /// Predefined errors
         type Error = Error<T>;
 
-        /// Exposes allowed lock combinations from the runtime level.
-        const AllowedLockCombinations: BTreeSet<(LockIdentifier, LockIdentifier)> =
-            T::AllowedLockCombinationProvider::get_allowed_lock_combinations();
-
         /// Signal proposal extrinsic. Should be used as callable object to pass to the `engine` module.
         ///
         /// <weight>

+ 0 - 9
runtime-modules/utility/src/tests/mocks.rs

@@ -206,15 +206,6 @@ impl Trait for Test {
     fn set_working_group_budget(working_group: WorkingGroup, budget: BalanceOf<Test>) {
         call_wg!(working_group<Test>, set_budget, budget)
     }
-
-    type AllowedLockCombinationProvider = AllowedLockCombinationProvider;
-}
-
-pub struct AllowedLockCombinationProvider;
-impl common::AllowedLockCombinationProvider for AllowedLockCombinationProvider {
-    fn get_allowed_lock_combinations() -> BTreeSet<(LockIdentifier, LockIdentifier)> {
-        Default::default()
-    }
 }
 
 impl WeightInfo for () {

+ 4 - 4
runtime-modules/working-group/src/checks.rs

@@ -45,11 +45,11 @@ pub(crate) fn ensure_stake_for_opening_type<T: Trait<I>, I: Instance>(
         ensure_origin_is_active_leader::<T, I>(origin)?;
         let lead = crate::Module::<T, I>::worker_by_id(ensure_lead_is_set::<T, I>()?);
 
+        let new_stake = T::LeaderOpeningStake::get()
+            + T::StakingHandler::current_stake(&lead.staking_account_id);
+
         ensure!(
-            T::StakingHandler::is_enough_balance_for_stake(
-                &lead.staking_account_id,
-                T::LeaderOpeningStake::get()
-            ),
+            T::StakingHandler::is_enough_balance_for_stake(&lead.staking_account_id, new_stake),
             Error::<T, I>::InsufficientBalanceToCoverStake
         );
     }

+ 5 - 2
runtime-modules/working-group/src/tests/mod.rs

@@ -115,10 +115,13 @@ fn add_opening_fails_with_zero_reward() {
 fn add_opening_fails_with_insufficient_balance() {
     build_test_externalities().execute_with(|| {
         HireLeadFixture::default()
-            .with_initial_balance(<Test as Trait>::MinimumApplicationStake::get() + 1)
+            .with_initial_balance(<Test as Trait>::MinimumApplicationStake::get())
             .hire_lead();
 
-        let add_opening_fixture = AddOpeningFixture::default();
+        let add_opening_fixture = AddOpeningFixture::default().with_stake_policy(StakePolicy {
+            stake_amount: <Test as Trait>::MinimumApplicationStake::get(),
+            leaving_unstaking_period: <Test as Trait>::MinUnstakingPeriodLimit::get() + 1,
+        });
 
         add_opening_fixture.call_and_assert(Err(
             Error::<Test, DefaultInstance>::InsufficientBalanceToCoverStake.into(),

+ 11 - 135
runtime/src/constants.rs

@@ -2,7 +2,7 @@ use super::Balance;
 use crate::{BlockNumber, Moment};
 use frame_support::parameter_types;
 use frame_support::traits::LockIdentifier;
-use sp_std::collections::btree_set::BTreeSet;
+use sp_std::vec::Vec;
 
 /// Constants for Babe.
 
@@ -111,7 +111,7 @@ parameter_types! {
     pub const ForumGroupLockId: LockIdentifier = *b"wg-forum";
     pub const MembershipWorkingGroupLockId: LockIdentifier = *b"wg-membr";
     pub const InvitedMemberLockId: LockIdentifier = *b"invitemb";
-    pub const StakingCandidateLockId: LockIdentifier = *b"stakcand";
+    pub const BoundStakingAccountLockId: LockIdentifier = *b"boundsta";
     pub const BountyLockId: LockIdentifier = *b"bounty  ";
     pub const OperationsWorkingGroupAlphaLockId: LockIdentifier = *b"wg-opera";
     pub const GatewayWorkingGroupLockId: LockIdentifier = *b"wg-gatew";
@@ -122,142 +122,18 @@ parameter_types! {
 
 // Staking lock ID used by nomination and validation in the staking pallet.
 // This is a copye because the current Substrate staking lock ID is not exported.
-const STAKING_LOCK_ID: LockIdentifier = *b"staking ";
+pub const STAKING_LOCK_ID: LockIdentifier = *b"staking ";
+
+pub const VESTING_LOCK_ID: LockIdentifier = *b"vesting ";
 
 lazy_static! {
-    // pairs of allowed lock combinations
-    pub static ref ALLOWED_LOCK_COMBINATIONS: BTreeSet<(LockIdentifier, LockIdentifier)> = [
-        // format: `(lock_id, [all_compatible_lock_ids, ...])`
-        (InvitedMemberLockId::get(), [
-            VotingLockId::get(),
-            CandidacyLockId::get(),
-            CouncilorLockId::get(),
-            STAKING_LOCK_ID,
-            ProposalsLockId::get(),
-            ForumGroupLockId::get(),
-            ContentWorkingGroupLockId::get(),
-            StorageWorkingGroupLockId::get(),
-            MembershipWorkingGroupLockId::get(),
-            GatewayWorkingGroupLockId::get(),
-            OperationsWorkingGroupAlphaLockId::get(),
-            OperationsWorkingGroupBetaLockId::get(),
-            OperationsWorkingGroupGammaLockId::get(),
-            DistributionWorkingGroupLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (StakingCandidateLockId::get(), [
-            VotingLockId::get(),
-            CandidacyLockId::get(),
-            CouncilorLockId::get(),
-            STAKING_LOCK_ID,
-            ProposalsLockId::get(),
-            ForumGroupLockId::get(),
-            ContentWorkingGroupLockId::get(),
-            StorageWorkingGroupLockId::get(),
-            MembershipWorkingGroupLockId::get(),
-            GatewayWorkingGroupLockId::get(),
-            DistributionWorkingGroupLockId::get(),
-            OperationsWorkingGroupAlphaLockId::get(),
-            OperationsWorkingGroupBetaLockId::get(),
-            OperationsWorkingGroupGammaLockId::get(),
-            InvitedMemberLockId::get(),
-        ].to_vec()),
-        (VotingLockId::get(), [
-            InvitedMemberLockId::get(),
-            CandidacyLockId::get(),
-            CouncilorLockId::get(),
-            STAKING_LOCK_ID,
-            ProposalsLockId::get(),
-            ForumGroupLockId::get(),
-            ContentWorkingGroupLockId::get(),
-            StorageWorkingGroupLockId::get(),
-            MembershipWorkingGroupLockId::get(),
-            GatewayWorkingGroupLockId::get(),
-            DistributionWorkingGroupLockId::get(),
-            OperationsWorkingGroupAlphaLockId::get(),
-            OperationsWorkingGroupBetaLockId::get(),
-            OperationsWorkingGroupGammaLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (CandidacyLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            CouncilorLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (CouncilorLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            CandidacyLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        // Proposals
-        (ProposalsLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        // Working Groups
-        (ForumGroupLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (ContentWorkingGroupLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (StorageWorkingGroupLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (MembershipWorkingGroupLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (GatewayWorkingGroupLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (DistributionWorkingGroupLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (OperationsWorkingGroupAlphaLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (OperationsWorkingGroupBetaLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        (OperationsWorkingGroupGammaLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
-        // Bounty
-        (BountyLockId::get(), [
-            InvitedMemberLockId::get(),
-            VotingLockId::get(),
-            StakingCandidateLockId::get(),
-        ].to_vec()),
+    pub static ref NON_RIVALROUS_LOCKS: Vec<LockIdentifier> = [
+        VotingLockId::get(),
+        VESTING_LOCK_ID,
+        InvitedMemberLockId::get(),
+        BoundStakingAccountLockId::get(),
     ]
-    .iter()
-    .fold(BTreeSet::new(), |mut acc, item| {
-        for lock_id in &item.1 {
-            acc.insert((item.0, *lock_id));
-        }
-
-        acc
-    });
+    .to_vec();
 }
 
 // Change it when changing the currency constants!

+ 60 - 40
runtime/src/lib.rs

@@ -39,13 +39,12 @@ mod weights; // Runtime integration tests
 extern crate lazy_static; // for proposals_configuration module
 
 use frame_support::dispatch::DispatchResult;
-use frame_support::traits::{
-    Currency, Imbalance, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced,
-};
+use frame_support::traits::{Currency, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced};
 use frame_support::weights::{
     constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
     Weight,
 };
+use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial};
 use frame_support::{construct_runtime, parameter_types};
 use frame_system::{EnsureOneOf, EnsureRoot, EnsureSigned};
 use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
@@ -58,7 +57,6 @@ use sp_runtime::curve::PiecewiseLinear;
 use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating};
 use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, ModuleId, Perbill};
 use sp_std::boxed::Box;
-use sp_std::collections::btree_set::BTreeSet;
 use sp_std::vec::Vec;
 #[cfg(feature = "std")]
 use sp_version::NativeVersion;
@@ -72,7 +70,6 @@ pub use runtime_api::*;
 use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder};
 
 use common::working_group::{WorkingGroup, WorkingGroupAuthenticator, WorkingGroupBudgetHandler};
-use common::AllowedLockCombinationProvider;
 use council::ReferendumConnection;
 use referendum::{CastVote, OptionResult};
 use staking_handler::{LockComparator, StakingManager};
@@ -265,9 +262,15 @@ impl pallet_balances::Trait for Runtime {
 }
 
 parameter_types! {
-    pub const TransactionByteFee: Balance = 1;
+    pub const TransactionByteFee: Balance = 0;
 }
 
+// Temporary commented for Olympia: https://github.com/Joystream/joystream/issues/3237
+// TODO: Restore after the Olympia release
+// parameter_types! {
+//     pub const TransactionByteFee: Balance = 1;
+// }
+
 type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
 
 pub struct Author;
@@ -276,30 +279,55 @@ impl OnUnbalanced<NegativeImbalance> for Author {
         Balances::resolve_creating(&Authorship::author(), amount);
     }
 }
+// Temporary commented for Olympia: https://github.com/Joystream/joystream/issues/3237
+// TODO: Restore after the Olympia release
+// pub struct DealWithFees;
+// impl OnUnbalanced<NegativeImbalance> for DealWithFees {
+//     fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
+//         if let Some(fees) = fees_then_tips.next() {
+//             // for fees, 20% to author, for now we don't have treasury so the 80% is ignored
+//             let mut split = fees.ration(80, 20);
+//             if let Some(tips) = fees_then_tips.next() {
+//                 // For tips %100 are for the author
+//                 tips.ration_merge_into(0, 100, &mut split);
+//             }
+//             Author::on_unbalanced(split.1);
+//         }
+//     }
+// }
+
+/// Stub for zero transaction weights.
+pub struct NoWeights;
+impl WeightToFeePolynomial for NoWeights {
+    type Balance = Balance;
 
-pub struct DealWithFees;
-impl OnUnbalanced<NegativeImbalance> for DealWithFees {
-    fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
-        if let Some(fees) = fees_then_tips.next() {
-            // for fees, 20% to author, for now we don't have treasury so the 80% is ignored
-            let mut split = fees.ration(80, 20);
-            if let Some(tips) = fees_then_tips.next() {
-                // For tips %100 are for the author
-                tips.ration_merge_into(0, 100, &mut split);
-            }
-            Author::on_unbalanced(split.1);
-        }
+    fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
+        Default::default()
+    }
+
+    fn calc(_weight: &u64) -> Self::Balance {
+        Default::default()
     }
 }
 
 impl pallet_transaction_payment::Trait for Runtime {
     type Currency = Balances;
-    type OnTransactionPayment = DealWithFees;
+    type OnTransactionPayment = ();
     type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = constants::fees::WeightToFee;
-    type FeeMultiplierUpdate = constants::fees::SlowAdjustingFeeUpdate<Self>;
+    type WeightToFee = NoWeights;
+    type FeeMultiplierUpdate = ();
 }
 
+// Temporary commented for Olympia: https://github.com/Joystream/joystream/issues/3237
+// TODO: Restore after the Olympia release
+// impl pallet_transaction_payment::Trait for Runtime {
+//     type Currency = Balances;
+//     type OnTransactionPayment = DealWithFees;
+//     type TransactionByteFee = TransactionByteFee;
+//     type WeightToFee = constants::fees::WeightToFee;
+//     type FeeMultiplierUpdate = constants::fees::SlowAdjustingFeeUpdate<Self>;
+// }
+
 impl pallet_sudo::Trait for Runtime {
     type Event = Event;
     type Call = Call;
@@ -452,8 +480,6 @@ parameter_types! {
     pub const PricePerByte: u32 = 2; // TODO: update
     pub const ContentModuleId: ModuleId = ModuleId(*b"mContent"); // module content
     pub const BloatBondCap: u32 = 1000;  // TODO: update
-    pub const VideosMigrationsEachBlock: u64 = 100;
-    pub const ChannelsMigrationsEachBlock: u64 = 25;
 }
 
 impl content::Trait for Runtime {
@@ -471,8 +497,6 @@ impl content::Trait for Runtime {
     type CleanupMargin = CleanupMargin;
     type CleanupCost = CleanupCost;
     type ModuleId = ContentModuleId;
-    type VideosMigrationsEachBlock = VideosMigrationsEachBlock;
-    type ChannelsMigrationsEachBlock = ChannelsMigrationsEachBlock;
 }
 
 // The referendum instance alias.
@@ -502,7 +526,7 @@ parameter_types! {
 impl referendum::Trait<ReferendumInstance> for Runtime {
     type Event = Event;
     type MaxSaltLength = MaxSaltLength;
-    type StakingHandler = staking_handler::StakingManager<Self, VotingLockId>;
+    type StakingHandler = VotingStakingManager;
     type ManagerOrigin =
         EnsureOneOf<Self::AccountId, EnsureSigned<Self::AccountId>, EnsureRoot<Self::AccountId>>;
     type VotePower = Balance;
@@ -664,7 +688,7 @@ impl membership::Trait for Runtime {
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
     type InvitedMemberStakingHandler = InvitedMemberStakingManager;
-    type StakingCandidateStakingHandler = StakingCandidateStakingHandler;
+    type StakingCandidateStakingHandler = BoundStakingAccountStakingManager;
     type WorkingGroup = MembershipWorkingGroup;
     type WeightInfo = weights::membership::WeightInfo;
     type ReferralCutMaximumPercent = ReferralCutMaximumPercent;
@@ -716,9 +740,13 @@ impl forum::Trait for Runtime {
 
 impl LockComparator<<Runtime as pallet_balances::Trait>::Balance> for Runtime {
     fn are_locks_conflicting(new_lock: &LockIdentifier, existing_locks: &[LockIdentifier]) -> bool {
-        existing_locks
+        let other_locks_present = !existing_locks.is_empty();
+        let new_lock_is_rivalrous = !NON_RIVALROUS_LOCKS.contains(new_lock);
+        let existing_locks_contain_rivalrous_lock = existing_locks
             .iter()
-            .any(|lock| !ALLOWED_LOCK_COMBINATIONS.contains(&(*new_lock, *lock)))
+            .any(|lock_id| !NON_RIVALROUS_LOCKS.contains(lock_id));
+
+        other_locks_present && new_lock_is_rivalrous && existing_locks_contain_rivalrous_lock
     }
 }
 
@@ -747,6 +775,7 @@ parameter_types! {
 // Staking managers type aliases.
 pub type ForumWorkingGroupStakingManager =
     staking_handler::StakingManager<Runtime, ForumGroupLockId>;
+pub type VotingStakingManager = staking_handler::StakingManager<Runtime, VotingLockId>;
 pub type ContentWorkingGroupStakingManager =
     staking_handler::StakingManager<Runtime, ContentWorkingGroupLockId>;
 pub type StorageWorkingGroupStakingManager =
@@ -755,8 +784,8 @@ pub type MembershipWorkingGroupStakingManager =
     staking_handler::StakingManager<Runtime, MembershipWorkingGroupLockId>;
 pub type InvitedMemberStakingManager =
     staking_handler::StakingManager<Runtime, InvitedMemberLockId>;
-pub type StakingCandidateStakingHandler =
-    staking_handler::StakingManager<Runtime, StakingCandidateLockId>;
+pub type BoundStakingAccountStakingManager =
+    staking_handler::StakingManager<Runtime, BoundStakingAccountLockId>;
 pub type GatewayWorkingGroupStakingManager =
     staking_handler::StakingManager<Runtime, GatewayWorkingGroupLockId>;
 pub type OperationsWorkingGroupAlphaStakingManager =
@@ -981,18 +1010,9 @@ impl proposals_discussion::Trait for Runtime {
     type PostLifeTime = ForumPostLifeTime;
 }
 
-pub struct LockCombinationProvider;
-impl AllowedLockCombinationProvider for LockCombinationProvider {
-    fn get_allowed_lock_combinations() -> BTreeSet<(LockIdentifier, LockIdentifier)> {
-        ALLOWED_LOCK_COMBINATIONS.clone()
-    }
-}
-
 impl joystream_utility::Trait for Runtime {
     type Event = Event;
 
-    type AllowedLockCombinationProvider = LockCombinationProvider;
-
     type WeightInfo = weights::joystream_utility::WeightInfo;
 
     fn get_working_group_budget(working_group: WorkingGroup) -> Balance {

+ 0 - 4
runtime/src/runtime_api.rs

@@ -82,10 +82,6 @@ pub struct CustomOnRuntimeUpgrade;
 impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
     fn on_runtime_upgrade() -> Weight {
         ProposalsEngine::cancel_active_and_pending_proposals();
-
-        // initialize content module
-        content::Module::<Runtime>::on_runtime_upgrade();
-
         10_000_000 // TODO: adjust weight
     }
 }

+ 64 - 0
runtime/src/tests/locks.rs

@@ -0,0 +1,64 @@
+use super::{increase_total_balance_issuance_using_account_id, initial_test_ext};
+use crate::{
+    BoundStakingAccountStakingManager, ContentWorkingGroupStakingManager,
+    GatewayWorkingGroupStakingManager,
+};
+use frame_support::sp_runtime::AccountId32;
+use staking_handler::StakingHandler;
+
+#[test]
+fn compatible_stakes_check_passed_successfully() {
+    initial_test_ext().execute_with(|| {
+        let account_id = AccountId32::default();
+        let total_amout = 10000;
+        let stake_amount = 100;
+
+        increase_total_balance_issuance_using_account_id(account_id.clone().into(), total_amout);
+
+        assert_eq!(
+            BoundStakingAccountStakingManager::set_stake(&account_id, stake_amount),
+            Ok(())
+        );
+        assert!(
+            ContentWorkingGroupStakingManager::is_account_free_of_conflicting_stakes(&account_id)
+        );
+    });
+}
+
+#[test]
+fn compatible_stakes_check_reversed_order_passed_successfully() {
+    initial_test_ext().execute_with(|| {
+        let account_id = AccountId32::default();
+        let total_amout = 10000;
+        let stake_amount = 100;
+
+        increase_total_balance_issuance_using_account_id(account_id.clone().into(), total_amout);
+
+        assert_eq!(
+            ContentWorkingGroupStakingManager::set_stake(&account_id, stake_amount),
+            Ok(())
+        );
+        assert!(
+            BoundStakingAccountStakingManager::is_account_free_of_conflicting_stakes(&account_id)
+        );
+    });
+}
+
+#[test]
+fn incompatible_stakes_check_passed_successfully() {
+    initial_test_ext().execute_with(|| {
+        let account_id = AccountId32::default();
+        let total_amout = 10000;
+        let stake_amount = 100;
+
+        increase_total_balance_issuance_using_account_id(account_id.clone().into(), total_amout);
+
+        assert_eq!(
+            GatewayWorkingGroupStakingManager::set_stake(&account_id, stake_amount),
+            Ok(())
+        );
+        assert!(
+            !ContentWorkingGroupStakingManager::is_account_free_of_conflicting_stakes(&account_id)
+        );
+    });
+}

+ 12 - 9
runtime/src/tests/mod.rs

@@ -4,7 +4,11 @@
 #[macro_use]
 
 mod proposals_integration;
-mod fee_tests;
+mod locks;
+
+// Temporary commented for Olympia: https://github.com/Joystream/joystream/issues/3237
+// TODO: Restore after the Olympia release
+//mod fee_tests;
 
 use crate::{BlockNumber, ReferendumInstance, Runtime};
 use frame_support::traits::{Currency, OnFinalize, OnInitialize};
@@ -43,21 +47,21 @@ fn get_account_membership(account: AccountId32, i: usize) -> u64 {
     member_id
 }
 
-pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
+// council = Vec<(ID - membership handle helper, ACCOUNT_ID)>
+pub(crate) fn elect_council(council: Vec<(u8, AccountId32)>, cycle_id: u64) {
     let mut voters = Vec::<AccountId32>::new();
 
     let councilor_stake: u128 = <Runtime as council::Trait>::MinCandidateStake::get().into();
     let extra_candidates = <Runtime as council::Trait>::MinNumberOfExtraCandidates::get() + 1;
     let mut council_member_ids = Vec::new();
 
-    for (i, councilor) in council.iter().enumerate() {
+    for (i, councilor) in council.iter() {
         increase_total_balance_issuance_using_account_id(
             councilor.clone().into(),
             councilor_stake + 1,
         );
 
-        let member_id = get_account_membership(councilor.clone(), i);
-
+        let member_id = get_account_membership(councilor.clone(), *i as usize);
         Council::announce_candidacy(
             RawOrigin::Signed(councilor.clone()).into(),
             member_id,
@@ -69,13 +73,13 @@ pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
         // Make sure to use different voters in each election cycle to prevent problems with
         // staking
         voters.push(
-            [(council.len() as u8 + extra_candidates as u8) * (cycle_id as u8 + 1) + i as u8; 32]
-                .into(),
+            [(council.len() as u8 + extra_candidates as u8) * (cycle_id as u8 + 1) + *i; 32].into(),
         );
         council_member_ids.push(member_id);
     }
 
-    for i in council.len()..(council.len() + extra_candidates as usize) {
+    let council_index = (council.clone().last().unwrap().0 + 10) as usize;
+    for i in council_index..(council_index + extra_candidates as usize) {
         let extra_councilor: AccountId32 = [i as u8; 32].into();
 
         let member_id = get_account_membership(extra_councilor.clone(), i);
@@ -88,7 +92,6 @@ pub(crate) fn elect_council(council: Vec<AccountId32>, cycle_id: u64) {
             extra_councilor.clone().into(),
             councilor_stake + 1,
         );
-
         Council::announce_candidacy(
             RawOrigin::Signed(extra_councilor.clone()).into(),
             member_id,

+ 39 - 9
runtime/src/tests/proposals_integration/mod.rs

@@ -49,11 +49,40 @@ fn setup_members(count: u8) {
 
 // Max Council size is 3
 fn setup_council(cycle_id: u64) {
-    let councilor0 = AccountId32::default();
-    let councilor1: [u8; 32] = [1; 32];
-    let councilor2: [u8; 32] = [2; 32];
+    let id0 = 0u8;
+    let id1 = 1u8;
+    let id2 = 2u8;
+
+    let councilor0: [u8; 32] = [id0; 32];
+    let councilor1: [u8; 32] = [id1; 32];
+    let councilor2: [u8; 32] = [id2; 32];
+
     elect_council(
-        vec![councilor0, councilor1.into(), councilor2.into()],
+        vec![
+            (id0, councilor0.into()),
+            (id1, councilor1.into()),
+            (id2, councilor2.into()),
+        ],
+        cycle_id,
+    );
+}
+
+// Max Council size is 3
+fn setup_different_council(cycle_id: u64) {
+    let id3 = 3u8;
+    let id4 = 4u8;
+    let id5 = 5u8;
+
+    let councilor3: [u8; 32] = [id3; 32];
+    let councilor4: [u8; 32] = [id4; 32];
+    let councilor5: [u8; 32] = [id5; 32];
+
+    elect_council(
+        vec![
+            (id3, councilor3.into()),
+            (id4, councilor4.into()),
+            (id5, councilor5.into()),
+        ],
         cycle_id,
     );
 }
@@ -322,8 +351,9 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() {
 #[test]
 fn proposal_reset_succeeds() {
     initial_test_ext().execute_with(|| {
-        setup_members(4);
+        setup_members(30);
         setup_council(0);
+
         // create proposal
         let dummy_proposal = DummyProposalFixture::default().with_voting_period(100);
         let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
@@ -367,7 +397,7 @@ fn proposal_reset_succeeds() {
         //<Runtime as governance::election::Trait>::CouncilElected::council_elected(Vec::new(), 10);
 
         end_idle_period();
-        setup_council(1);
+        setup_different_council(1);
 
         let updated_proposal = ProposalsEngine::proposals(proposal_id);
 
@@ -573,7 +603,7 @@ fn funding_request_proposal_execution_succeeds() {
         let council_budget = 5_000_000;
         let funding = 5000;
 
-        let target_account_id: [u8; 32] = [12; 32];
+        let target_account_id: [u8; 32] = [111; 32];
         let target_account_id: AccountId32 = target_account_id.clone().into();
 
         assert!(Council::set_budget(RawOrigin::Root.into(), council_budget).is_ok());
@@ -1122,7 +1152,7 @@ fn set_councilor_reward_proposal_succeds() {
 #[test]
 fn proposal_reactivation_succeeds() {
     initial_test_ext().execute_with(|| {
-        setup_members(5);
+        setup_members(25);
         setup_council(0);
 
         let starting_block = System::block_number();
@@ -1155,7 +1185,7 @@ fn proposal_reactivation_succeeds() {
         assert_eq!(CouncilManager::<Runtime>::total_voters_count(), 3);
 
         end_idle_period();
-        setup_council(1);
+        setup_different_council(1);
 
         run_to_block(10);
 

+ 2 - 0
storage-node/src/command-base/ExitCodes.ts

@@ -13,6 +13,8 @@ enum ExitCodes {
   ServerError,
   ApiError = 200,
   UnsuccessfulRuntimeCall,
+
+  // NOTE: never exceed exit code 255 or it will be modulated by `256` and create problems
 }
 
 export = ExitCodes

+ 0 - 8
types/augment/all/defs.json

@@ -704,14 +704,6 @@
     },
     "MaxNumber": "u32",
     "IsCensored": "bool",
-    "VideoMigrationConfig": {
-        "current_id": "VideoId",
-        "final_id": "VideoId"
-    },
-    "ChannelMigrationConfig": {
-        "current_id": "ChannelId",
-        "final_id": "ChannelId"
-    },
     "VideoPostId": "u64",
     "ReactionId": "u64",
     "VideoPostType": {

+ 0 - 12
types/augment/all/types.ts

@@ -519,12 +519,6 @@ export interface ChannelCreationParameters extends Struct {
 /** @name ChannelId */
 export interface ChannelId extends u64 {}
 
-/** @name ChannelMigrationConfig */
-export interface ChannelMigrationConfig extends Struct {
-  readonly current_id: ChannelId;
-  readonly final_id: ChannelId;
-}
-
 /** @name ChannelOwner */
 export interface ChannelOwner extends Enum {
   readonly isMember: boolean;
@@ -1132,12 +1126,6 @@ export interface VideoCreationParameters extends Struct {
 /** @name VideoId */
 export interface VideoId extends u64 {}
 
-/** @name VideoMigrationConfig */
-export interface VideoMigrationConfig extends Struct {
-  readonly current_id: VideoId;
-  readonly final_id: VideoId;
-}
-
 /** @name VideoPost */
 export interface VideoPost extends Struct {
   readonly author: ContentActor;

+ 0 - 11
types/src/content/index.ts

@@ -195,15 +195,6 @@ export class VideoUpdateParameters extends JoyStructDecorated({
   enable_comments: Option.with(bool),
 }) {}
 
-export class VideoMigrationConfig extends JoyStructDecorated({
-  current_id: VideoId,
-  final_id: VideoId,
-}) {}
-export class ChannelMigrationConfig extends JoyStructDecorated({
-  current_id: ChannelId,
-  final_id: ChannelId,
-}) {}
-
 export class VideoPostType extends JoyEnum({
   Description: Null,
   Comment: VideoPostId,
@@ -292,8 +283,6 @@ export const contentTypes = {
   VideoUpdateParameters,
   MaxNumber,
   IsCensored,
-  VideoMigrationConfig,
-  ChannelMigrationConfig,
   // Added in Olympia:
   VideoPostId,
   ReactionId,

+ 1 - 2
utils/api-scripts/src/initialize-lead.ts

@@ -22,7 +22,6 @@ const workingGroupModules = [
 type WorkingGroupModuleName = typeof workingGroupModules[number]
 
 const MIN_APPLICATION_STAKE = new BN(2000)
-const STAKING_ACCOUNT_CANDIDATE_STAKE = new BN(200)
 
 async function main() {
   // Init api
@@ -102,7 +101,7 @@ async function main() {
     // Set up stake account
     const addCandidateTx = api.tx.members.addStakingAccountCandidate(memberId)
     const addCandidateFee = (await addCandidateTx.paymentInfo(StakeKeyPair.address)).partialFee
-    const stakingAccountBalance = MIN_APPLICATION_STAKE.add(STAKING_ACCOUNT_CANDIDATE_STAKE).add(addCandidateFee)
+    const stakingAccountBalance = MIN_APPLICATION_STAKE.add(addCandidateFee)
     console.log('Setting up staking account...')
     await txHelper.sendAndCheck(
       LeadKeyPair,

File diff suppressed because it is too large
+ 219 - 187
yarn.lock


Some files were not shown because too many files changed in this diff