Browse Source

Merge pull request #3235 from ignazio-bovo/olympia_fix_NoMigration

Olympia fix no migration
Mokhtar Naamani 3 years ago
parent
commit
42c25ceeb0

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


+ 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,
@@ -769,7 +756,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);
@@ -831,7 +818,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;
@@ -971,7 +958,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,
@@ -1013,7 +1000,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 {
@@ -1221,7 +1208,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,
@@ -1244,12 +1231,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,
@@ -1269,7 +1250,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)?;
@@ -1324,7 +1305,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>()?;
@@ -1332,7 +1313,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)?;
 
@@ -1368,7 +1349,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>()?;
@@ -1412,7 +1393,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>()?;
@@ -1448,7 +1429,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>()?;
@@ -1481,7 +1462,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>()?;
@@ -1523,7 +1504,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>()?;
@@ -1603,7 +1584,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>()?;
@@ -1644,7 +1625,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>()?;
@@ -1687,7 +1668,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>()?;
@@ -1731,7 +1712,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>()?;
@@ -1765,7 +1746,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>()?;
@@ -1799,7 +1780,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>()?;
@@ -1833,7 +1814,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>()?;
@@ -1871,7 +1852,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>()?;
@@ -1898,83 +1879,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,
@@ -1994,30 +1898,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>> {
@@ -2038,6 +1918,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,
@@ -2212,13 +2108,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;

+ 0 - 4
runtime/src/lib.rs

@@ -450,8 +450,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 {
@@ -469,8 +467,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.

+ 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
     }
 }

+ 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

@@ -240,12 +240,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;
@@ -1104,12 +1098,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,
@@ -269,8 +260,6 @@ export const contentTypes = {
   VideoUpdateParameters,
   MaxNumber,
   IsCensored,
-  VideoMigrationConfig,
-  ChannelMigrationConfig,
   // Added in Olympia:
   VideoPostId,
   ReactionId,

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