Ver código fonte

Merge pull request #2784 from mnaamani/runtime_upgrade_final

Giza runtime upgrade final
Mokhtar Naamani 3 anos atrás
pai
commit
4bce529f02

+ 1 - 1
docker-compose.yml

@@ -10,7 +10,7 @@ services:
       context: .
       # dockerfile is relative to the context
       dockerfile: joystream-node.Dockerfile
-    container_name: joystream-node-giza
+    container_name: joystream-node
     volumes:
       - /data
     command: --dev --alice --validator --unsafe-ws-external --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors=all --log runtime --base-path /data

+ 0 - 2
package.json

@@ -19,9 +19,7 @@
     "cli",
     "types",
     "storage-node-v2",
-    "storage-node",
     "distributor-node",
-    "storage-node/packages/*",
     "devops/eslint-config",
     "devops/prettier-config",
     "pioneer",

+ 11 - 0
runtime-modules/content/src/lib.rs

@@ -1409,6 +1409,17 @@ impl<T: Trait> Module<T> {
     }
 }
 
+// Giza:
+// Reset Videos and Channels on runtime upgrade but preserving next ids and categories.
+impl<T: Trait> Module<T> {
+    pub fn on_runtime_upgrade() {
+        // Clear VideoById map
+        <VideoById<T>>::remove_all();
+        // Clear ChannelById map
+        <ChannelById<T>>::remove_all();
+    }
+}
+
 decl_event!(
     pub enum Event<T>
     where

+ 17 - 2
runtime/src/runtime_api.rs

@@ -22,8 +22,9 @@ use crate::{
 };
 
 use crate::{
-    ContentWorkingGroupInstance, OperationsWorkingGroupInstanceAlpha,
-    OperationsWorkingGroupInstanceBeta, OperationsWorkingGroupInstanceGamma,
+    ContentWorkingGroupInstance, DistributionWorkingGroupInstance,
+    OperationsWorkingGroupInstanceAlpha, OperationsWorkingGroupInstanceBeta,
+    OperationsWorkingGroupInstanceGamma,
 };
 use frame_support::weights::Weight;
 
@@ -73,10 +74,16 @@ pub(crate) type OperationsWorkingGroupGamma<T> =
 
 pub(crate) type ContentWorkingGroup<T> = working_group::Module<T, ContentWorkingGroupInstance>;
 
+pub(crate) type DistributionWorkingGroup<T> =
+    working_group::Module<T, DistributionWorkingGroupInstance>;
+
 /// Custom runtime upgrade handler.
 pub struct CustomOnRuntimeUpgrade;
 impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
     fn on_runtime_upgrade() -> Weight {
+        // initialize content module
+        content::Module::<Runtime>::on_runtime_upgrade();
+
         // Initialize new groups
         let default_text_constraint = crate::working_group::default_text_constraint();
 
@@ -117,6 +124,14 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
             default_content_working_group_mint_capacity,
         );
 
+        DistributionWorkingGroup::<Runtime>::initialize_working_group(
+            default_text_constraint,
+            default_text_constraint,
+            default_text_constraint,
+            default_storage_size_constraint,
+            default_content_working_group_mint_capacity,
+        );
+
         10_000_000 // TODO: adjust weight
     }
 }

+ 1 - 0
tests/network-tests/run-migration-tests.sh

@@ -9,4 +9,5 @@ yarn joystream-cli working-groups:overview --group=operationsAlpha
 yarn joystream-cli working-groups:overview --group=operationsBeta
 yarn joystream-cli working-groups:overview --group=operationsGamma
 yarn joystream-cli working-groups:overview --group=curators
+yarn joystream-cli working-groups:overview --group=distributors
 

+ 4 - 4
yarn.lock

@@ -2932,7 +2932,7 @@
     yaml "^1.10.0"
     yaml-validator "^3.0.0"
 
-"@joystream/sumer-types@npm:@joystream/types@^0.16.0", "@joystream/types@^0.16.1":
+"@joystream/sumer-types@npm:@joystream/types@^0.16.0":
   version "0.16.1"
   resolved "https://registry.yarnpkg.com/@joystream/types/-/types-0.16.1.tgz#40f5014a9b64928ccea634a1f0f5d2b0392de293"
   integrity sha512-Jz8M6F4oRKH4WtEn8kpZvSMi0mVbfGSmjt38CcEu2946TYmCwlC3Ad1RFH8Wlcylqz/fMLL+pe0z1Dvo6dfzJA==
@@ -4227,7 +4227,7 @@
     "@polkadot/util-crypto" "^7.3.1"
     rxjs "^7.3.0"
 
-"@polkadot/api@5.9.1":
+"@polkadot/api@4.2.1", "@polkadot/api@5.9.1":
   version "5.9.1"
   resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-5.9.1.tgz#ce314cc34f0a47098d039db7b9036bb491c2898c"
   integrity sha512-POpIXn/Ao+NLB0uMldXdXU44dVbRr6+6Ax77Z0R285M8Z2EiF5jl2K3SPvlowLo4SntxiCSaHQxCekYhUcJKlw==
@@ -4355,7 +4355,7 @@
     "@polkadot/util" "7.4.1"
     "@zondax/ledger-substrate" "^0.18.0"
 
-"@polkadot/keyring@7.3.1", "@polkadot/keyring@^7.3.1", "@polkadot/keyring@^7.4.1":
+"@polkadot/keyring@7.3.1", "@polkadot/keyring@^6.0.5", "@polkadot/keyring@^7.3.1", "@polkadot/keyring@^7.4.1":
   version "7.3.1"
   resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-7.3.1.tgz#bf36115cfb395567bec9cf13c8e3fc0fb39c802a"
   integrity sha512-3lbwIjUql8yjs6AR2fMdCgmTc5D9ne7+y2jqHmGjyzVQFz1w1jiHb+N38L0pwl9/23UxmzC3aVvHLfl3gEGSIQ==
@@ -4459,7 +4459,7 @@
     "@babel/runtime" "^7.15.4"
     "@polkadot/util" "^7.3.1"
 
-"@polkadot/types@5.9.1":
+"@polkadot/types@4.2.1", "@polkadot/types@5.9.1":
   version "5.9.1"
   resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-5.9.1.tgz#74cf4695795f2aa365ff85d3873e22c430100bc9"
   integrity sha512-30vcSlNBxPyWYZaxKDr/BoMhfLCRKB265XxpnnNJmbdZZsL+N4Zp2mJR9/UbA6ypmJBkUjD7b1s9AYsLwUs+8w==