فهرست منبع

Merge pull request #2769 from ignazio-bovo/runtime_migration

Working group migration
Mokhtar Naamani 3 سال پیش
والد
کامیت
3d37200d17

+ 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
+    container_name: joystream-node-giza
     volumes:
       - /data
     command: --dev --alice --validator --unsafe-ws-external --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors=all --log runtime --base-path /data

+ 59 - 0
runtime/src/runtime_api.rs

@@ -20,6 +20,11 @@ use crate::{
     AllModules, AuthorityDiscovery, Babe, Call, Grandpa, Historical, InherentDataExt,
     RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment,
 };
+
+use crate::{
+    ContentWorkingGroupInstance, OperationsWorkingGroupInstanceAlpha,
+    OperationsWorkingGroupInstanceBeta, OperationsWorkingGroupInstanceGamma,
+};
 use frame_support::weights::Weight;
 
 /// The SignedExtension to the basic transaction logic.
@@ -54,10 +59,64 @@ pub type BlockId = generic::BlockId<Block>;
 /// Unchecked extrinsic type as expected by this runtime.
 pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Call, Signature, SignedExtra>;
 
+// Alias for the alpha operationsworking group
+pub(crate) type OperationsWorkingGroupAlpha<T> =
+    working_group::Module<T, OperationsWorkingGroupInstanceAlpha>;
+
+// Alias for the beta operations working group
+pub(crate) type OperationsWorkingGroupBeta<T> =
+    working_group::Module<T, OperationsWorkingGroupInstanceBeta>;
+
+// Alias for the gamma operations working group
+pub(crate) type OperationsWorkingGroupGamma<T> =
+    working_group::Module<T, OperationsWorkingGroupInstanceGamma>;
+
+pub(crate) type ContentWorkingGroup<T> = working_group::Module<T, ContentWorkingGroupInstance>;
+
 /// Custom runtime upgrade handler.
 pub struct CustomOnRuntimeUpgrade;
 impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
     fn on_runtime_upgrade() -> Weight {
+        // Initialize new groups
+        let default_text_constraint = crate::working_group::default_text_constraint();
+
+        let default_storage_size_constraint =
+            crate::working_group::default_storage_size_constraint();
+
+        let default_content_working_group_mint_capacity = 0;
+
+        OperationsWorkingGroupAlpha::<Runtime>::initialize_working_group(
+            default_text_constraint,
+            default_text_constraint,
+            default_text_constraint,
+            default_storage_size_constraint,
+            default_content_working_group_mint_capacity,
+        );
+
+        OperationsWorkingGroupBeta::<Runtime>::initialize_working_group(
+            default_text_constraint,
+            default_text_constraint,
+            default_text_constraint,
+            default_storage_size_constraint,
+            default_content_working_group_mint_capacity,
+        );
+
+        OperationsWorkingGroupGamma::<Runtime>::initialize_working_group(
+            default_text_constraint,
+            default_text_constraint,
+            default_text_constraint,
+            default_storage_size_constraint,
+            default_content_working_group_mint_capacity,
+        );
+
+        ContentWorkingGroup::<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
     }
 }

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

@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+set -e
+
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+# verify existence of the three new groups
+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
+

+ 5 - 1
tests/network-tests/run-tests.sh

@@ -90,9 +90,13 @@ else
     src/dev-set-runtime-code.ts -- ${DATA_PATH}/runtime.compact.wasm
 
   echo "Runtime upgraded."
+
+  echo "Performing migration tests"
+  ./run-migration-tests.sh $1
+  echo "Done with migrations tests"
 fi
 
 # Display runtime version
 yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime
 
-./run-test-scenario.sh $1
+# ./run-test-scenario.sh $1

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

@@ -70,6 +70,17 @@
     "FailedAt": "Null",
     "IPNSIdentity": "Null",
     "ServiceProviderRecord": "Null",
+    "ContentId": "Null",
+    "ContentParameters": "Null",
+    "DataObjectStorageRelationship": "Null",
+    "DataObjectStorageRelationshipId": "Null",
+    "DataObjectType": "Null",
+    "DataObjectTypeId": "Null",
+    "NewAsset": "Null",
+    "ObjectOwner": "Null",
+    "StorageObjectOwner": "Null",
+    "UploadingStatus": "Null",
+    "VoucherLimit": "Null",
     "BlockAndTime": {
         "block": "u32",
         "time": "u64"

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

@@ -311,9 +311,15 @@ export interface ContentActor extends Enum {
   readonly isLead: boolean;
 }
 
+/** @name ContentId */
+export interface ContentId extends Null {}
+
 /** @name ContentIdSet */
 export interface ContentIdSet extends BTreeSet<Cid> {}
 
+/** @name ContentParameters */
+export interface ContentParameters extends Null {}
+
 /** @name CreateEntityOperation */
 export interface CreateEntityOperation extends Null {}
 
@@ -380,6 +386,18 @@ export interface DataObjectIdMap extends BTreeMap<DataObjectId, DataObject> {}
 /** @name DataObjectIdSet */
 export interface DataObjectIdSet extends BTreeSet<DataObjectId> {}
 
+/** @name DataObjectStorageRelationship */
+export interface DataObjectStorageRelationship extends Null {}
+
+/** @name DataObjectStorageRelationshipId */
+export interface DataObjectStorageRelationshipId extends Null {}
+
+/** @name DataObjectType */
+export interface DataObjectType extends Null {}
+
+/** @name DataObjectTypeId */
+export interface DataObjectTypeId extends Null {}
+
 /** @name Deactivated */
 export interface Deactivated extends Struct {
   readonly cause: OpeningDeactivationCause;
@@ -651,6 +669,9 @@ export interface ModerationAction extends Struct {
   readonly rationale: Text;
 }
 
+/** @name NewAsset */
+export interface NewAsset extends Null {}
+
 /** @name NextAdjustment */
 export interface NextAdjustment extends Struct {
   readonly adjustment: AdjustOnInterval;
@@ -660,6 +681,9 @@ export interface NextAdjustment extends Struct {
 /** @name Nonce */
 export interface Nonce extends Null {}
 
+/** @name ObjectOwner */
+export interface ObjectOwner extends Null {}
+
 /** @name Opening */
 export interface Opening extends Struct {
   readonly created: u32;
@@ -1229,6 +1253,9 @@ export interface StorageBucketsPerBagValueConstraint extends Struct {
   readonly max_min_diff: u64;
 }
 
+/** @name StorageObjectOwner */
+export interface StorageObjectOwner extends Null {}
+
 /** @name StorageProviderId */
 export interface StorageProviderId extends u64 {}
 
@@ -1296,6 +1323,9 @@ export interface UnstakingApplicationStage extends Struct {
 /** @name UpdatePropertyValuesOperation */
 export interface UpdatePropertyValuesOperation extends Null {}
 
+/** @name UploadingStatus */
+export interface UploadingStatus extends Null {}
+
 /** @name UploadParameters */
 export interface UploadParameters extends Struct {
   readonly bagId: BagId;
@@ -1382,6 +1412,9 @@ export interface Voucher extends Struct {
   readonly objectsUsed: u64;
 }
 
+/** @name VoucherLimit */
+export interface VoucherLimit extends Null {}
+
 /** @name WaitingToBeingOpeningStageVariant */
 export interface WaitingToBeingOpeningStageVariant extends Struct {
   readonly begins_at_block: u32;

+ 22 - 0
types/src/legacy.ts

@@ -88,6 +88,17 @@ export class Operation extends Null {}
 export class ReferenceConstraint extends Null {}
 export class InputEntityValuesMap extends Null {}
 export class FailedAt extends Null {}
+export class ContentId extends Null {}
+export class ContentParameters extends Null {}
+export class DataObjectStorageRelationship extends Null {}
+export class DataObjectStorageRelationshipId extends Null {}
+export class DataObjectType extends Null {}
+export class DataObjectTypeId extends Null {}
+export class NewAsset extends Null {}
+export class ObjectOwner extends Null {}
+export class StorageObjectOwner extends Null {}
+export class UploadingStatus extends Null {}
+export class VoucherLimit extends Null {}
 
 // From discovery_service
 export class IPNSIdentity extends Null {}
@@ -165,6 +176,17 @@ export const legacyTypes: RegistryTypes = {
   FailedAt,
   IPNSIdentity,
   ServiceProviderRecord,
+  ContentId,
+  ContentParameters,
+  DataObjectStorageRelationship,
+  DataObjectStorageRelationshipId,
+  DataObjectType,
+  DataObjectTypeId,
+  NewAsset,
+  ObjectOwner,
+  StorageObjectOwner,
+  UploadingStatus,
+  VoucherLimit,
 }
 
 export default legacyTypes

+ 2 - 2
utils/api-scripts/src/dev-set-runtime-code.ts

@@ -79,8 +79,8 @@ async function main() {
             const err = result.asError
             console.log('Error:', err.toHuman())
             if (err.isModule) {
-              const { name, docs } = (api.registry as TypeRegistry).findMetaError(err.asModule)
-              console.log(`${name}\n${docs.join(', ')}`)
+              const { name } = (api.registry as TypeRegistry).findMetaError(err.asModule)
+              console.log(`${name}\n`)
             }
             process.exit(5)
           } else {