Browse Source

Merge pull request #3462 from Joystream/runtime-profiles

Runtime profiles
Mokhtar Naamani 3 years ago
parent
commit
e92cab642d
43 changed files with 1169 additions and 949 deletions
  1. 3 3
      .github/workflows/create-ami.yml
  2. 4 11
      .github/workflows/deploy-node-network.yml
  3. 3 3
      .github/workflows/deploy-playground.yml
  4. 0 47
      .github/workflows/joystream-node-benchmarks.yml
  5. 63 0
      .github/workflows/joystream-node-docker-dev.yml
  6. 1 0
      .github/workflows/joystream-node-docker.yml
  7. 99 0
      .github/workflows/joystream-node.yml
  8. 2 2
      .github/workflows/run-network-tests.yml
  9. 3 3
      .pipelines/deploy-node-network-inputs.json
  10. 3 3
      Cargo.lock
  11. 2 2
      README.md
  12. 8 6
      build-node-docker.sh
  13. 1 1
      devops/aws/deploy-infra.sample.cfg
  14. 2 2
      devops/aws/deploy-infra.sh
  15. 2 1
      devops/aws/deploy-playground-playbook.yml
  16. 1 1
      devops/aws/deploy-playground.sh
  17. 1 1
      devops/aws/deploy-single-node.sample.cfg
  18. 1 1
      devops/aws/roles/common/tasks/run-build.yml
  19. 1 1
      devops/git-hooks/pre-commit
  20. 7 2
      devops/git-hooks/pre-push
  21. 5 10
      joystream-node.Dockerfile
  22. 1 1
      node/Cargo.toml
  23. 0 36
      reproduce-giza-issue.sh
  24. 7 2
      runtime/Cargo.toml
  25. 13 3
      runtime/src/constants.rs
  26. 67 5
      runtime/src/lib.rs
  27. 41 41
      runtime/src/proposals_configuration/defaults.rs
  28. 68 306
      runtime/src/proposals_configuration/mod.rs
  29. 0 253
      runtime/src/proposals_configuration/sample_proposal_parameters.json
  30. 360 0
      runtime/src/proposals_configuration/staging.rs
  31. 361 0
      runtime/src/proposals_configuration/testing.rs
  32. 0 5
      runtime/src/proposals_configuration/tests.rs
  33. 6 2
      scripts/cargo-build.sh
  34. 7 2
      scripts/cargo-tests-with-networking.sh
  35. 12 0
      scripts/features.sh
  36. 9 3
      scripts/run-dev-chain.sh
  37. 0 5
      scripts/run-proposal-configuration-tests.sh
  38. 1 17
      scripts/runtime-code-shasum.sh
  39. 2 1
      setup.sh
  40. 0 61
      storage-playground-config.sh
  41. 0 104
      tests/network-tests/proposal-parameters.json
  42. 1 1
      tests/network-tests/run-test-node-docker.sh
  43. 1 1
      utils/chain-spec-builder/Cargo.toml

+ 3 - 3
.github/workflows/create-ami.yml

@@ -5,8 +5,8 @@ name: Create AWS AMI
 on:
   workflow_dispatch:
     inputs:
-      proposalParameters:
-        description: 'Proposal Parameters (refer to runtime/src/proposals_configuration/sample_proposal_parameters.json for sample)'
+      runtimeProfile:
+        description: 'STAGING | TESTING - leave blank for production build'
         required: false
 
 jobs:
@@ -64,7 +64,7 @@ jobs:
                           branch_name=${{ steps.extract_branch.outputs.branch }} \
                           instance_id=${{ steps.deploy_stack.outputs.InstanceId }} \
                           ami_name=${{ env.ami_name }} \
-                          proposal_parameters=${{ github.event.inputs.proposalParameters }}"
+                          runtime_profile=${{ github.event.inputs.runtimeProfile }}"
 
       - name: Delete CloudFormation Stack
         if: always()

+ 4 - 11
.github/workflows/deploy-node-network.yml

@@ -42,16 +42,9 @@ jobs:
           echo ::set-output name=volumeSize::$(echo $jsonInput | jq -r '.volumeSize.value')
           echo ::set-output name=rpcVolumeSize::$(echo $jsonInput | jq -r '.rpcVolumeSize.value')
           echo ::set-output name=skipChainSetup::$(echo $jsonInput | jq -r '.skipChainSetup.value')
+          echo ::set-output name=runtimeProfile::$(echo $jsonInput | jq -r '.runtimeProfile.value')
           initialBalancesFile=$(echo $jsonInput | jq -r '.initialBalancesFile.value')
           initialMembersFile=$(echo $jsonInput | jq -r '.initialMembersFile.value')
-          proposalParametersInput=$(echo $jsonInput | jq -r '.proposalParameters.value')
-
-          if [ $proposalParametersInput = "{}" ]
-          then
-            echo ::set-output name=proposalParameters::''
-          else
-            echo ::set-output name=proposalParameters::$proposalParametersInput
-          fi
 
           if [ -z "$initialBalancesFile" ]
           then
@@ -128,8 +121,8 @@ jobs:
 
       - name: Run playbook to setup all hosts and compile joystream-node
         uses: dawidd6/action-ansible-playbook@v2
-        # Build binaries if AMI not specified or a custom proposals parameter is passed
-        if: steps.myoutputs.outputs.ec2AMI == '' || steps.myoutputs.outputs.proposalParameters != ''
+        # Build binaries if AMI not specified
+        if: steps.myoutputs.outputs.ec2AMI == ''
         with:
           playbook: build-code.yml
           directory: devops/aws
@@ -139,7 +132,7 @@ jobs:
             --inventory inventory
             --extra-vars "branch_name=${{ steps.myoutputs.outputs.branchName }} \
                           git_repo=${{ steps.myoutputs.outputs.gitRepo }} data_path=mydata \
-                          proposal_parameters=${{ steps.myoutputs.outputs.proposalParameters }}"
+                          runtime_profile=${{ steps.myoutputs.outputs.runtimeProfile }}"
 
       - name: Run playbook to install additional utils on build server
         uses: dawidd6/action-ansible-playbook@v2

+ 3 - 3
.github/workflows/deploy-playground.yml

@@ -27,8 +27,8 @@ on:
         description: 'Optionally skip running newChainSetup script (true or false)'
         required: true
         default: 'false'
-      proposalParameters:
-        description: 'Proposal Parameters (refer to runtime/src/proposals_configuration/sample_proposal_parameters.json for sample)'
+      runtimeProfile:
+        description: 'STAGING | PLAYGROUND | TESTING - leave balnk for production'
         required: false
       # TODO: customDomain instead of ip_address.nip.io
       # customDomain:
@@ -93,7 +93,7 @@ jobs:
                           branch_name=${{ github.event.inputs.branchName }} \
                           skip_chain_setup=${{ github.event.inputs.skipChainSetup }} \
                           stack_name=${{ env.STACK_NAME }} \
-                          proposal_parameters=${{ github.event.inputs.proposalParameters }}"
+                          runtime_profile=${{ github.event.inputs.runtimeProfile }}"
 
       - name: Save the endpoints file as an artifact
         uses: actions/upload-artifact@v2

+ 0 - 47
.github/workflows/joystream-node-benchmarks.yml

@@ -1,47 +0,0 @@
-name: joystream-node
-on:
-  pull_request:
-
-jobs:
-  benchmarking:
-    name: Benchmarking
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v1
-      - uses: actions/setup-node@v1
-        with:
-          node-version: '14.x'
-      - uses: technote-space/get-diff-action@v3
-        with:
-          PREFIX_FILTER: |
-            node
-            runtime-modules
-            utils/chain-spec-builder
-          SUFFIX_FILTER: |
-            .rs
-          FILES: |
-            Cargo.lock
-            Cargo.toml
-
-      # TODO: Look for change in source code but no corresponding version bump of runtime or binaries
-      # - name: Check version modified correctly
-      #   if: env.GIT_DIFF
-
-      - name: Toolchains
-        run: |
-          ./setup.sh
-        if: env.GIT_DIFF
-
-      - name: Build
-        run: |
-          pushd node
-          WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 cargo +nightly-2021-02-20 build --release --features runtime-benchmarks
-          popd
-        if: env.GIT_DIFF
-
-      - name: Generate Weights
-        run: |
-          ./scripts/generate-weights.sh 5 2
-          # Show any changes in computed weights
-          git diff
-        if: env.GIT_DIFF

+ 63 - 0
.github/workflows/joystream-node-docker-dev.yml

@@ -0,0 +1,63 @@
+# Development builds of joystream-node (staging, testing, playground)
+# Only built for amd64 on ubuntu
+name: joystream-node-docker(dev)
+
+on: push
+
+env:
+  REPOSITORY: joystream/node
+
+jobs:
+  ubuntu:
+    name: Build joystream/node Docker image for amd64
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        runtime_profile: ['STAGING', 'PLAYGROUND', 'TESTING']
+        include:
+          - runtime_profile: 'STAGING'
+            cargo_features: 'staging_runtime'
+          - runtime_profile: 'PLAYGROUND'
+            cargo_features: 'playground_runtime'
+          - runtime_profile: 'TESTING'
+            cargo_features: 'testing_runtime'
+    env:
+      RUNTIME_PROFILE: ${{ matrix.runtime_profile }}
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - uses: actions/setup-node@v1
+        with:
+          node-version: '14.x'
+
+      - id: compute_shasum
+        name: Compute runtime code shasum
+        run: |
+          export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
+          echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_PASSWORD }}
+
+      - name: Check if we have pre-built image on Dockerhub
+        id: compute_image_exists
+        # Will output 0 if image exists and 1 if does not exists
+        run: |
+          export IMAGE_EXISTS=$(docker manifest inspect ${{ env.REPOSITORY }}:${{ steps.compute_shasum.outputs.shasum }} > /dev/null ; echo $?)
+          echo "::set-output name=image_exists::${IMAGE_EXISTS}"
+
+      - name: Build and push
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          file: joystream-node.Dockerfile
+          platforms: linux/amd64
+          build-args: CARGO_FEATURES=${{ matrix.cargo_features }}
+          push: true
+          tags: ${{ env.REPOSITORY }}:${{ steps.compute_shasum.outputs.shasum }}
+        if: ${{ steps.compute_image_exists.outputs.image_exists == 1 }}

+ 1 - 0
.github/workflows/joystream-node-docker.yml

@@ -1,3 +1,4 @@
+# Production runtime build of joystream-node
 name: joystream-node-docker
 
 on: push

+ 99 - 0
.github/workflows/joystream-node.yml

@@ -0,0 +1,99 @@
+name: joystream-node
+on:
+  pull_request:
+
+jobs:
+  benchmarking:
+    name: Benchmarking
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions/setup-node@v1
+        with:
+          node-version: '14.x'
+      - uses: technote-space/get-diff-action@v3
+        with:
+          PREFIX_FILTER: |
+            node
+            runtime-modules
+            utils/chain-spec-builder
+          SUFFIX_FILTER: |
+            .rs
+          FILES: |
+            Cargo.lock
+            Cargo.toml
+
+      # TODO: Look for change in source code but no corresponding version bump of runtime or binaries
+      # - name: Check version modified correctly
+      #   if: env.GIT_DIFF
+
+      - name: Toolchains
+        run: |
+          ./setup.sh
+        if: env.GIT_DIFF
+
+      - name: Build
+        run: |
+          pushd node
+          WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 cargo +nightly-2021-02-20 build --release --features runtime-benchmarks
+          popd
+        if: env.GIT_DIFF
+
+      - name: Generate Weights
+        run: |
+          ./scripts/generate-weights.sh 5 2
+          # Show any changes in computed weights
+          git diff
+        if: env.GIT_DIFF
+
+  # Build and test joystream-node with all runtime profiles
+  runtime_profiles:
+    name: Runtime Profiles
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v1
+      - uses: actions/setup-node@v1
+        with:
+          node-version: '14.x'
+      - uses: technote-space/get-diff-action@v3
+        with:
+          PREFIX_FILTER: |
+            node
+            runtime-modules
+            utils/chain-spec-builder
+          SUFFIX_FILTER: |
+            .rs
+          FILES: |
+            Cargo.lock
+            Cargo.toml
+  
+      - name: Toolchains
+        run: |
+          ./setup.sh
+        if: env.GIT_DIFF
+      - name: Production Runtime
+        run: |
+          yarn cargo-checks && yarn cargo-build
+          ./target/release/joystream-node --version
+        if: env.GIT_DIFF
+      - name: Staging Runtime
+        env:
+          RUNTIME_PROFILE: STAGING
+        run: |
+          yarn cargo-checks && yarn cargo-build
+          ./target/release/joystream-node --version
+        if: env.GIT_DIFF
+      - name: Playground Runtime
+        env:
+          RUNTIME_PROFILE: PLAYGROUND
+        run: |
+          yarn cargo-checks && yarn cargo-build
+          ./target/release/joystream-node --version
+        if: env.GIT_DIFF
+      - name: Testing Runtime
+        env:
+          RUNTIME_PROFILE: TESTING
+        run: |
+          yarn cargo-checks && yarn cargo-build
+          ./target/release/joystream-node --version
+        if: env.GIT_DIFF

+ 2 - 2
.github/workflows/run-network-tests.yml

@@ -30,7 +30,7 @@ jobs:
       - id: compute_shasum
         name: Compute runtime code shasum
         env:
-          TEST_NODE: true
+          RUNTIME_PROFILE: "TESTING"
         run: |
           export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
           echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
@@ -71,7 +71,7 @@ jobs:
             docker build .\
               --file joystream-node.Dockerfile\
               --tag joystream/node\
-              --build-arg TEST_NODE=true
+              --build-arg CARGO_FEATURES="testing_runtime"
             docker save --output joystream-node-docker-image.tar joystream/node
             gzip joystream-node-docker-image.tar
             cp joystream-node-docker-image.tar.gz ~/docker-images/

+ 3 - 3
.pipelines/deploy-node-network-inputs.json

@@ -59,9 +59,9 @@
     "description": "Password to encrypt the artifacts",
     "value": "password"
   },
-  "proposalParameters": {
-    "description": "Proposal Parameters",
-    "value": {}
+  "runtimeProfile": {
+    "description": "STAGING | PLAYGROUND| TESTING - leave empty for production",
+    "value": ""
   },
   "skipChainSetup": {
     "description": "Set to true to skip running setup new chain scenario",

+ 3 - 3
Cargo.lock

@@ -722,7 +722,7 @@ dependencies = [
 
 [[package]]
 name = "chain-spec-builder"
-version = "5.4.0"
+version = "6.5.0"
 dependencies = [
  "ansi_term 0.12.1",
  "enum-utils",
@@ -2278,7 +2278,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node"
-version = "6.4.0"
+version = "6.5.0"
 dependencies = [
  "frame-benchmarking",
  "frame-benchmarking-cli",
@@ -2339,7 +2339,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node-runtime"
-version = "10.4.0"
+version = "10.5.0"
 dependencies = [
  "frame-benchmarking",
  "frame-executive",

+ 2 - 2
README.md

@@ -81,10 +81,10 @@ A step by step guide to setup a full node and validator on the Joystream testnet
 yarn build:packages
 
 # Build the test joystream-node
-TEST_NODE=true yarn build:node:docker
+RUNTIME_PROFILE=TESTING yarn build:node:docker
 
 # Run tests
-./query-node/run-tests.sh
+./tests/network-tests/run-full-tests.sh
 ```
 
 ### Contributing

+ 8 - 6
build-node-docker.sh

@@ -1,15 +1,17 @@
 #!/usr/bin/env bash
-
 set -e
 
 # Looks for a cached joystream/node image matching code shasum.
 # Search order: local repo then dockerhub. If no cached image is found we build it.
 
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source scripts/features.sh
+
 CODE_HASH=`scripts/runtime-code-shasum.sh`
 IMAGE=joystream/node:${CODE_HASH}
 
-# TODO: Check for valid JSON in ALL_PROPOSALS_PARAMETERS_JSON ?
-
 # Look for image locally
 if ! docker inspect ${IMAGE} > /dev/null;
 then
@@ -21,9 +23,9 @@ then
   if ! docker inspect ${IMAGE} > /dev/null;
   then
     echo "Building ${IMAGE}.."
-    docker build . --file joystream-node.Dockerfile --tag ${IMAGE} \
-	    --build-arg TEST_NODE=${TEST_NODE} \
-	    --build-arg ALL_PROPOSALS_PARAMETERS_JSON=${ALL_PROPOSALS_PARAMETERS_JSON}
+    docker build . --file joystream-node.Dockerfile \
+      --tag ${IMAGE} \
+	    --build-arg CARGO_FEATURES=${FEATURES}
   fi
 else
   echo "Found ${IMAGE} in local repo"

+ 1 - 1
devops/aws/deploy-infra.sample.cfg

@@ -38,7 +38,7 @@ INITIAL_BALANCES_PATH=""
 GIT_REPO="https://github.com/Joystream/joystream.git"
 BRANCH_NAME=master
 
-ALL_PROPOSALS_PARAMETERS_JSON=""
+RUNTIME_PROFILE="STAGING"
 SKIP_CHAIN_SETUP="true"
 
 # If true will build LOCAL_CODE_PATH otherwise will pull from GIT_REPO:BRANCH_NAME

+ 2 - 2
devops/aws/deploy-infra.sh

@@ -72,12 +72,12 @@ if [ $? -eq 0 ]; then
   echo -e "[build]\n$BUILD_SERVER\n\n[validators]\n$VALIDATORS\n[rpc]\n$RPC_NODES" > $INVENTORY_PATH
 
   # Build binaries if AMI not specified or a custom proposals parameter is passed
-  if [ -z "$EC2_AMI_ID" ] || [ -n "$ALL_PROPOSALS_PARAMETERS_JSON" ]
+  if [ -z "$EC2_AMI_ID" ]
   then
     echo -e "\n\n=========== Compile joystream-node on build server ==========="
     ansible-playbook -i $INVENTORY_PATH --private-key $KEY_PATH build-code.yml \
       --extra-vars "branch_name=$BRANCH_NAME git_repo=$GIT_REPO build_local_code=$BUILD_LOCAL_CODE
-                    data_path=$DATA_PATH proposal_parameters=$ALL_PROPOSALS_PARAMETERS_JSON"
+                    data_path=$DATA_PATH runtime_profile=$RUNTIME_PROFILE"
   fi
 
   if [ -z "$EC2_AMI_ID" ]

+ 2 - 1
devops/aws/deploy-playground-playbook.yml

@@ -56,7 +56,7 @@
       args:
         chdir: '{{ remote_code_path }}'
       environment:
-        ALL_PROPOSALS_PARAMETERS_JSON: '{{ proposal_parameters }}'
+        RUNTIME_PROFILE: '{{ runtime_profile }}'
       async: 3600
       poll: 0
       register: node_build_result
@@ -76,6 +76,7 @@
       args:
         chdir: '{{ remote_code_path }}'
       environment:
+        RUNTIME_PROFILE: '{{ runtime_profile }}'
         PERSIST: 'true'
         COLOSSUS_1_URL: 'https://{{ inventory_hostname }}.nip.io/colossus-1/'
         DISTRIBUTOR_1_URL: 'https://{{ inventory_hostname }}.nip.io/distributor-1/'

+ 1 - 1
devops/aws/deploy-playground.sh

@@ -43,5 +43,5 @@ if [ $? -eq 0 ]; then
   echo -e "\n\n=========== Configuring node ==========="
   ansible-playbook -i $SERVER_IP, --private-key $KEY_PATH deploy-playground-playbook.yml \
     --extra-vars "branch_name=$BRANCH_NAME git_repo=$GIT_REPO skip_chain_setup=$SKIP_CHAIN_SETUP
-                  stack_name=$SINGLE_NODE_STACK_NAME proposal_parameters=$ALL_PROPOSALS_PARAMETERS_JSON"
+                  stack_name=$SINGLE_NODE_STACK_NAME runtime_profile=$RUNTIME_PROFILE"
 fi

+ 1 - 1
devops/aws/deploy-single-node.sample.cfg

@@ -21,4 +21,4 @@ CHAIN_SPEC_FILE="https://github.com/Joystream/joystream/releases/download/v9.14.
 GIT_REPO="https://github.com/Joystream/joystream.git"
 BRANCH_NAME="master"
 SKIP_CHAIN_SETUP="false"
-ALL_PROPOSALS_PARAMETERS_JSON=""
+RUNTIME_PROFILE="STAGING"

+ 1 - 1
devops/aws/roles/common/tasks/run-build.yml

@@ -6,7 +6,7 @@
   args:
     chdir: '{{ remote_code_path }}'
   environment:
-    ALL_PROPOSALS_PARAMETERS_JSON: '{{ proposal_parameters }}'
+    RUNTIME_PROFILE: '{{ runtime_profile }}'
   # Run in async fashion for max duration of 1 hr
   async: 3600
   poll: 0

+ 1 - 1
devops/git-hooks/pre-commit

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 set -e
 
 echo 'running rust-fmt'

+ 7 - 2
devops/git-hooks/pre-push

@@ -1,6 +1,11 @@
-#!/bin/sh
+#!/usr/bin/env bash
 set -e
 
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source ../../scripts/features.sh
+
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
 echo 'running clippy (rust linter)'
@@ -10,4 +15,4 @@ echo 'running clippy (rust linter)'
 BUILD_DUMMY_WASM_BINARY=1 cargo +nightly-2021-02-20 clippy --release --all -- -D warnings
 
 echo 'running cargo unit tests'
-cargo +nightly-2021-02-20 test --release --all
+cargo +nightly-2021-02-20 test --release --all --features "${FEATURES}"

+ 5 - 10
joystream-node.Dockerfile

@@ -14,17 +14,12 @@ COPY . /joystream
 
 # Build all cargo crates
 # Ensure our tests and linter pass before actual build
-ARG ALL_PROPOSALS_PARAMETERS_JSON
-ARG TEST_NODE
-RUN echo "TEST_NODE=$TEST_NODE"
-RUN test -n "$TEST_NODE" && sed -i 's/MILLISECS_PER_BLOCK: Moment = 6000/MILLISECS_PER_BLOCK: Moment = 1000/' ./runtime/src/constants.rs; exit 0
-RUN test -n "$TEST_NODE" && sed -i 's/SLOT_DURATION: Moment = 6000/SLOT_DURATION: Moment = 1000/' ./runtime/src/constants.rs; exit 0
-RUN test -n "$TEST_NODE" && export ALL_PROPOSALS_PARAMETERS_JSON="$(cat ./tests/network-tests/proposal-parameters.json)";\
-    echo "ALL_PROPOSALS_PARAMETERS_JSON=$ALL_PROPOSALS_PARAMETERS_JSON" && \
-    export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 && \
+ARG CARGO_FEATURES
+RUN echo "CARGO_FEATURES=$CARGO_FEATURES"
+RUN export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 && \
     BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --all -- -D warnings && \
-    cargo test --release --all && \
-    cargo build --release
+    cargo test --release --all --features "${CARGO_FEATURES}" && \
+    cargo build --release --features "${CARGO_FEATURES}"
 
 FROM ubuntu:21.04
 LABEL description="Joystream node"

+ 1 - 1
node/Cargo.toml

@@ -3,7 +3,7 @@ authors = ['Joystream contributors']
 build = 'build.rs'
 edition = '2018'
 name = 'joystream-node'
-version = '6.4.0'
+version = '6.5.0'
 default-run = "joystream-node"
 
 [[bin]]

+ 0 - 36
reproduce-giza-issue.sh

@@ -1,36 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-## Run a local development chain
-docker-compose up -d joystream-node
-
-# Init the chain with 2 storage buckets that have high limits set
-# The DynamicBagPolicy for Channel should be "numberOfStorageBuckets: 2" after this step is done
-./tests/network-tests/run-test-scenario.sh giza-issue-reproduction-setup
-
-# Set env for CLI's
-export AUTO_CONFIRM=true
-export ACCOUNT_URI=//testing//worker//Storage//0 # Storage lead account uri for storage CLI
-
-# Setup the CLI:
-yarn joystream-cli api:setUri ws://localhost:9944
-yarn joystream-cli account:choose --address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
-yarn joystream-cli api:setQueryNodeEndpoint http://localhost:8081/graphql
-
-# Set very low limits for storage bucket 0
-yarn storage-node leader:set-bucket-limits -i 0 -s 100 -o 1
-# Create a channel (the transaction will fail due to low limits of bucket 0)
-yarn joystream-cli content:createChannel --context Member -i ./cli/examples/content/CreateChannel.json || true
-# Update DynamicBagPolicy to 1 storage bucket per channel bag
-yarn storage-node leader:update-dynamic-bag-policy -t Channel -n 1
-# Disable storage bucket 0
-yarn storage-node leader:update-bucket-status -i 0 --set off
-# Create a channel (the transaction still fails, which is unexpected)
-yarn joystream-cli content:createChannel --context Member -i ./cli/examples/content/CreateChannel.json || true
-# Increase limits of bucket 0
-yarn storage-node leader:set-bucket-limits -i 0 -s 1000000000 -o 1000
-# Create a channel
-yarn joystream-cli content:createChannel --context Member -i ./cli/examples/content/CreateChannel.json
-# Notice that channel bag get's assigned to both bucket 0 and 1, even though:
-# 1. Bucket 0 is disabled
-# 2. DynamicBagPolicy for Channel has "numberOfStorageBuckets: 1"

+ 7 - 2
runtime/Cargo.toml

@@ -4,7 +4,7 @@ edition = '2018'
 name = 'joystream-node-runtime'
 # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1
 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion
-version = '10.4.0'
+version = '10.5.0'
 
 [dependencies]
 # Third-party dependencies
@@ -185,4 +185,9 @@ runtime-benchmarks = [
     "blog/runtime-benchmarks",
 ]
 
-
+# Staging and testing configurations
+# configuration suitable for staging networks and playground
+staging_runtime = []
+playground_runtime = ['staging_runtime']
+# configuration suitable for integration testing
+testing_runtime = []

+ 13 - 3
runtime/src/constants.rs

@@ -18,10 +18,20 @@ use sp_std::vec::Vec;
 /// `SLOT_DURATION` instead (like the timestamp module for calculating the
 /// minimum period).
 /// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
-pub const MILLISECS_PER_BLOCK: Moment = 6000;
-pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;
 
+// Normal 6s block interval
+#[cfg(not(feature = "testing_runtime"))]
+pub const MILLISECS_PER_BLOCK: Moment = 6000;
+#[cfg(not(feature = "testing_runtime"))]
 pub const SLOT_DURATION: Moment = 6000;
+
+// 1s block interval for integration testing
+#[cfg(feature = "testing_runtime")]
+pub const MILLISECS_PER_BLOCK: Moment = 1000;
+#[cfg(feature = "testing_runtime")]
+pub const SLOT_DURATION: Moment = 1000;
+
+pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;
 pub const BONDING_DURATION: u32 = 24 * 7;
 
 pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
@@ -138,7 +148,7 @@ lazy_static! {
 
 // Change it when changing the currency constants!
 parameter_types! {
-    pub const ExistentialDeposit: u128 = 10;
+    pub const ExistentialDeposit: u128 = 1;
 }
 
 pub mod currency {

+ 67 - 5
runtime/src/lib.rs

@@ -9,6 +9,10 @@
 #![allow(non_fmt_panic)]
 #![allow(clippy::from_over_into)]
 
+// Mutually exclusive feature check
+#[cfg(all(feature = "staging_runtime", feature = "testing_runtime"))]
+compile_error!("feature \"staging_runtime\" and feature \"testing_runtime\" cannot be enabled at the same time");
+
 // Make the WASM binary available.
 // This is required only by the node build.
 // A dummy wasm_binary.rs will be built for the IDE.
@@ -94,7 +98,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
     spec_name: create_runtime_str!("joystream-node"),
     impl_name: create_runtime_str!("joystream-node"),
     authoring_version: 10,
-    spec_version: 4,
+    spec_version: 5,
     impl_version: 0,
     apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS,
     transaction_version: 1,
@@ -503,6 +507,30 @@ pub type ReferendumInstance = referendum::Instance1;
 pub type ReferendumModule = referendum::Module<Runtime, ReferendumInstance>;
 pub type CouncilModule = council::Module<Runtime>;
 
+// Production coucil and elections configuration
+#[cfg(not(any(feature = "staging_runtime", feature = "testing_runtime")))]
+parameter_types! {
+    // referendum parameters
+    pub const MaxSaltLength: u64 = 32;
+    pub const VoteStageDuration: BlockNumber = 14400;
+    pub const RevealStageDuration: BlockNumber = 14400;
+    pub const MinimumVotingStake: u64 = 10000;
+
+    // council parameteres
+    pub const MinNumberOfExtraCandidates: u64 = 1;
+    pub const AnnouncingPeriodDuration: BlockNumber = 14400;
+    pub const IdlePeriodDuration: BlockNumber = 57600;
+    pub const CouncilSize: u64 = 5;
+    pub const MinCandidateStake: u64 = 11000;
+    pub const ElectedMemberRewardPeriod: BlockNumber = 14400;
+    pub const DefaultBudgetIncrement: u64 = 5000000;
+    pub const BudgetRefillPeriod: BlockNumber = 14400;
+    pub const MaxWinnerTargetCount: u64 = 10; // should be greater than council size
+}
+
+// Common staging and playground coucil and elections configuration
+// CouncilSize is defined separately
+#[cfg(feature = "staging_runtime")]
 parameter_types! {
     // referendum parameters
     pub const MaxSaltLength: u64 = 32;
@@ -514,11 +542,45 @@ parameter_types! {
     pub const MinNumberOfExtraCandidates: u64 = 1;
     pub const AnnouncingPeriodDuration: BlockNumber = 200;
     pub const IdlePeriodDuration: BlockNumber = 400;
+    pub const MinCandidateStake: u64 = 11000;
+    pub const ElectedMemberRewardPeriod: BlockNumber = 14400;
+    pub const DefaultBudgetIncrement: u64 = 10000000;
+    pub const BudgetRefillPeriod: BlockNumber = 1000;
+    pub const MaxWinnerTargetCount: u64 = 10;
+}
+
+// Staging council size
+#[cfg(feature = "staging_runtime")]
+#[cfg(not(feature = "playground_runtime"))]
+parameter_types! {
+    pub const CouncilSize: u64 = 5;
+}
+
+// Playground council size
+#[cfg(feature = "staging_runtime")]
+#[cfg(feature = "playground_runtime")]
+parameter_types! {
+    pub const CouncilSize: u64 = 1;
+}
+
+// Testing config
+#[cfg(feature = "testing_runtime")]
+parameter_types! {
+    // referendum parameters
+    pub const MaxSaltLength: u64 = 32;
+    pub const VoteStageDuration: BlockNumber = 20;
+    pub const RevealStageDuration: BlockNumber = 20;
+    pub const MinimumVotingStake: u64 = 10000;
+
+    // council parameteres
+    pub const MinNumberOfExtraCandidates: u64 = 1;
+    pub const AnnouncingPeriodDuration: BlockNumber = 20;
+    pub const IdlePeriodDuration: BlockNumber = 20;
     pub const CouncilSize: u64 = 5;
     pub const MinCandidateStake: u64 = 11000;
     pub const ElectedMemberRewardPeriod: BlockNumber = 14400;
     pub const DefaultBudgetIncrement: u64 = 10000000;
-    pub const BudgetRefillPeriod: BlockNumber = 14400;
+    pub const BudgetRefillPeriod: BlockNumber = 1000;
     pub const MaxWinnerTargetCount: u64 = 10;
 }
 
@@ -1048,9 +1110,9 @@ impl pallet_constitution::Trait for Runtime {
 parameter_types! {
     pub const BountyModuleId: ModuleId = ModuleId(*b"m:bounty"); // module : bounty
     pub const ClosedContractSizeLimit: u32 = 50;
-    pub const MinCherryLimit: Balance = 10;
-    pub const MinFundingLimit: Balance = 10;
-    pub const MinWorkEntrantStake: Balance = 100;
+    pub const MinCherryLimit: Balance = 1000;
+    pub const MinFundingLimit: Balance = 1000;
+    pub const MinWorkEntrantStake: Balance = 1000;
 }
 
 impl bounty::Trait for Runtime {

+ 41 - 41
runtime/src/proposals_configuration/defaults.rs

@@ -1,11 +1,11 @@
-//! This module contains default parameters for the runtime codex proposals.
+//! This module contains default "production" parameters configuration for the runtime codex proposals.
 
 use crate::{Balance, BlockNumber, ProposalParameters};
 
 // Proposal parameters for the 'Set Max Validator Count' proposal
 pub(crate) fn set_max_validator_count_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
@@ -19,13 +19,13 @@ pub(crate) fn set_max_validator_count_proposal() -> ProposalParameters<BlockNumb
 // Proposal parameters for the 'Runtime Upgrade' proposal
 pub(crate) fn runtime_upgrade_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 200,
+        voting_period: 28800,
+        grace_period: 14400,
         approval_quorum_percentage: 80,
         approval_threshold_percentage: 100,
         slashing_quorum_percentage: 60,
         slashing_threshold_percentage: 80,
-        required_stake: Some(1_000_000),
+        required_stake: Some(10_000_000),
         constitutionality: 1,
     }
 }
@@ -33,7 +33,7 @@ pub(crate) fn runtime_upgrade_proposal() -> ProposalParameters<BlockNumber, Bala
 // Proposal parameters for the 'Signal' proposal
 pub(crate) fn signal_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 72000,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
@@ -47,8 +47,8 @@ pub(crate) fn signal_proposal() -> ProposalParameters<BlockNumber, Balance> {
 // Proposal parameters for the 'Funding Request' proposal
 pub(crate) fn funding_request_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -61,7 +61,7 @@ pub(crate) fn funding_request_proposal() -> ProposalParameters<BlockNumber, Bala
 pub(crate) fn create_working_group_lead_opening_proposal(
 ) -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 72000,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
@@ -76,7 +76,7 @@ pub(crate) fn create_working_group_lead_opening_proposal(
 pub(crate) fn fill_working_group_lead_opening_proposal() -> ProposalParameters<BlockNumber, Balance>
 {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
@@ -90,7 +90,7 @@ pub(crate) fn fill_working_group_lead_opening_proposal() -> ProposalParameters<B
 // Proposal parameters for the 'Update Working Group Budget' proposal
 pub(crate) fn update_working_group_budget_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
@@ -105,7 +105,7 @@ pub(crate) fn update_working_group_budget_proposal() -> ProposalParameters<Block
 pub(crate) fn decrease_working_group_lead_stake_proposal(
 ) -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
@@ -119,7 +119,7 @@ pub(crate) fn decrease_working_group_lead_stake_proposal(
 // Proposal parameters for the 'Slash Working Group Lead' proposal
 pub fn slash_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
@@ -133,7 +133,7 @@ pub fn slash_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Ba
 // Proposal parameters for the 'Set Working Group Lead Reward' proposal
 pub(crate) fn set_working_group_lead_reward_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
@@ -147,7 +147,7 @@ pub(crate) fn set_working_group_lead_reward_proposal() -> ProposalParameters<Blo
 // Proposal parameters for the 'Terminate Working Group Lead' proposal
 pub(crate) fn terminate_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 72200,
         grace_period: 0,
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
@@ -161,8 +161,8 @@ pub(crate) fn terminate_working_group_lead_proposal() -> ProposalParameters<Bloc
 // Proposal parameters for the 'Amend Constitution' proposal
 pub(crate) fn amend_constitution_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72200,
+        grace_period: 14400,
         approval_quorum_percentage: 80,
         approval_threshold_percentage: 100,
         slashing_quorum_percentage: 60,
@@ -176,7 +176,7 @@ pub(crate) fn amend_constitution_proposal() -> ProposalParameters<BlockNumber, B
 pub(crate) fn cancel_working_group_lead_opening_proposal(
 ) -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
+        voting_period: 43200,
         grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
@@ -190,8 +190,8 @@ pub(crate) fn cancel_working_group_lead_opening_proposal(
 // Proposal parameters for the 'Set Membership Price' proposal
 pub(crate) fn set_membership_price_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 43200,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -204,8 +204,8 @@ pub(crate) fn set_membership_price_proposal() -> ProposalParameters<BlockNumber,
 // Proposal parameters for the 'Set Council Budget Increment' proposal
 pub(crate) fn set_council_budget_increment_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 100800,
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -218,8 +218,8 @@ pub(crate) fn set_council_budget_increment_proposal() -> ProposalParameters<Bloc
 // Proposal parameters for the 'Set Councilor Reward' proposal
 pub(crate) fn set_councilor_reward_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100, // A council term
+        voting_period: 72000,
+        grace_period: 100800,
         approval_quorum_percentage: 66,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -233,8 +233,8 @@ pub(crate) fn set_councilor_reward_proposal() -> ProposalParameters<BlockNumber,
 pub(crate) fn set_initial_invitation_balance_proposal() -> ProposalParameters<BlockNumber, Balance>
 {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -249,8 +249,8 @@ pub(crate) fn set_initial_invitation_balance_proposal() -> ProposalParameters<Bl
 pub(crate) fn set_membership_lead_invitation_quota_proposal(
 ) -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -263,8 +263,8 @@ pub(crate) fn set_membership_lead_invitation_quota_proposal(
 // Proposal parameters for the 'Set Referral Cut' proposal
 pub(crate) fn set_referral_cut_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 43200,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -277,8 +277,8 @@ pub(crate) fn set_referral_cut_proposal() -> ProposalParameters<BlockNumber, Bal
 // Proposal parameters for the 'Set Initial Invitation Count' proposal
 pub(crate) fn set_invitation_count_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 75,
         slashing_quorum_percentage: 60,
@@ -291,8 +291,8 @@ pub(crate) fn set_invitation_count_proposal() -> ProposalParameters<BlockNumber,
 // Proposal parameters for the 'Create Blog Post' proposal
 pub(crate) fn create_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -305,8 +305,8 @@ pub(crate) fn create_blog_post_proposal() -> ProposalParameters<BlockNumber, Bal
 // Proposal parameters for the 'Edit Blog Post' proposal
 pub(crate) fn edit_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -319,8 +319,8 @@ pub(crate) fn edit_blog_post_proposal() -> ProposalParameters<BlockNumber, Balan
 // Proposal parameters for the 'Lock Blog Post' proposal
 pub(crate) fn lock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -333,8 +333,8 @@ pub(crate) fn lock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balan
 // Proposal parameters for the 'Unlock Blog Post' proposal
 pub(crate) fn unlock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
-        voting_period: 200,
-        grace_period: 100,
+        voting_period: 72000,
+        grace_period: 0,
         approval_quorum_percentage: 60,
         approval_threshold_percentage: 80,
         slashing_quorum_percentage: 60,
@@ -348,7 +348,7 @@ pub(crate) fn unlock_blog_post_proposal() -> ProposalParameters<BlockNumber, Bal
 pub(crate) fn veto_proposal_proposal() -> ProposalParameters<BlockNumber, Balance> {
     ProposalParameters {
         // Doesn't make sense to be longer than longest grace period of all other proposals?
-        voting_period: 200,
+        voting_period: 100800,
         grace_period: 0,
         approval_quorum_percentage: 75,
         approval_threshold_percentage: 80,

+ 68 - 306
runtime/src/proposals_configuration/mod.rs

@@ -1,338 +1,100 @@
 //! This module defines a set of the parameters for each proposal in the runtime like
-//! _SetValidatorCountProposalParameters_. It is separated because we need to be able to configure
-//! these parameters during the compilation time. Main consumer of the conditional compilation planned
-//! to be the integration tests.
-//!
-//! The whole parameter set is initialized only once by deserializing JSON from the environment variable
-//! "ALL_PROPOSALS_PARAMETERS_JSON". If it doesn't exists the default parameters are returned.
-//! If some proposal section of the JSON file contains only
-//! partial object definition - default values are returned for missing fields.
-//! If passed JSON is invalid or expected numeric value is not a number it will panic!
+//! _SetValidatorCountProposalParameters_.
 
 use crate::{Balance, BlockNumber, ProposalParameters};
-use frame_support::dispatch::Vec;
 use frame_support::parameter_types;
-use frame_support::sp_runtime::SaturatedConversion;
-use lite_json::{JsonObject, JsonValue};
 
+// This is the default configuration, so only include it if neither staging or testing runtime feature is enabled
+#[cfg(not(any(feature = "staging_runtime", feature = "testing_runtime")))]
 mod defaults;
-#[cfg(test)]
-mod tests;
+#[cfg(not(any(feature = "staging_runtime", feature = "testing_runtime")))]
+use defaults::*;
+
+#[cfg(feature = "staging_runtime")]
+mod staging;
+#[cfg(feature = "staging_runtime")]
+use staging::*;
+
+#[cfg(feature = "testing_runtime")]
+mod testing;
+#[cfg(feature = "testing_runtime")]
+use testing::*;
 
 /////////// Proposal parameters definition
 
 parameter_types! {
     pub SetMaxValidatorCountProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_max_validator_count_proposal;
-    pub RuntimeUpgradeProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.runtime_upgrade_proposal;
-    pub SignalProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.signal_proposal;
+        set_max_validator_count_proposal();
+
+    pub RuntimeUpgradeProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        runtime_upgrade_proposal();
+
+    pub SignalProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        signal_proposal();
+
     pub FundingRequestProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.funding_request_proposal;
-    pub CreateWorkingGroupLeadOpeningProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.create_working_group_lead_opening_proposal;
-    pub FillWorkingGroupLeadOpeningProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.fill_working_group_lead_opening_proposal;
-    pub UpdateWorkingGroupBudgetProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.update_working_group_budget_proposal;
-    pub DecreaseWorkingGroupLeadStakeProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.decrease_working_group_lead_stake_proposal;
-    pub SlashWorkingGroupLeadProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.slash_working_group_lead_proposal;
-    pub SetWorkingGroupLeadRewardProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.set_working_group_lead_reward_proposal;
-    pub TerminateWorkingGroupLeadProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.terminate_working_group_lead_proposal;
-    pub AmendConstitutionProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.amend_constitution_proposal;
-    pub CancelWorkingGroupLeadOpeningProposalParameters: ProposalParameters<BlockNumber, Balance> = ALL_PROPOSALS_PARAMETERS.cancel_working_group_lead_opening_proposal;
-    pub SetMembershipPriceProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_membership_price_proposal;
-    pub SetCouncilBudgetIncrementProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_council_budget_increment_proposal;
-    pub SetCouncilorRewardProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_councilor_reward_proposal;
-    pub SetInitialInvitationBalanceProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_initial_invitation_balance_proposal;
-    pub SetMembershipLeadInvitationQuotaProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_membership_lead_invitation_quota_proposal;
-    pub SetReferralCutProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_referral_cut_proposal;
-    pub SetInvitationCountProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.set_invitation_count_proposal;
-    pub CreateBlogPostProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.create_blog_post_proposal;
-    pub EditBlogPostProoposalParamters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.edit_blog_post_proposal;
-    pub LockBlogPostProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.lock_blog_post_proposal;
-    pub UnlockBlogPostProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.unlock_blog_post_proposal;
-    pub VetoProposalProposalParameters: ProposalParameters<BlockNumber, Balance> =
-        ALL_PROPOSALS_PARAMETERS.veto_proposal_proposal;
-}
+        funding_request_proposal();
 
-///////////
+    pub CreateWorkingGroupLeadOpeningProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        create_working_group_lead_opening_proposal();
 
-struct AllProposalsParameters {
-    pub set_max_validator_count_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub runtime_upgrade_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub signal_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub funding_request_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub create_working_group_lead_opening_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub fill_working_group_lead_opening_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub update_working_group_budget_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub decrease_working_group_lead_stake_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub slash_working_group_lead_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_working_group_lead_reward_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub terminate_working_group_lead_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub amend_constitution_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub cancel_working_group_lead_opening_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_membership_price_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_council_budget_increment_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_councilor_reward_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_initial_invitation_balance_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_membership_lead_invitation_quota_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_referral_cut_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub set_invitation_count_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub create_blog_post_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub edit_blog_post_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub lock_blog_post_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub unlock_blog_post_proposal: ProposalParameters<BlockNumber, Balance>,
-    pub veto_proposal_proposal: ProposalParameters<BlockNumber, Balance>,
-}
+    pub FillWorkingGroupLeadOpeningProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        fill_working_group_lead_opening_proposal();
 
-// to initialize parameters only once.
-lazy_static! {
-    static ref ALL_PROPOSALS_PARAMETERS: AllProposalsParameters =
-        get_all_proposals_parameters_objects();
-}
+    pub UpdateWorkingGroupBudgetProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        update_working_group_budget_proposal();
+
+    pub DecreaseWorkingGroupLeadStakeProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        decrease_working_group_lead_stake_proposal();
 
-// We need to fail fast.
-#[allow(clippy::match_wild_err_arm)]
-// Composes AllProposalsParameters object from the JSON string.
-// It gets the JSON string from the environment variable and tries to parse it.
-// On error it will panic!
-fn get_all_proposals_parameters_objects() -> AllProposalsParameters {
-    let json_str: Option<&'static str> = option_env!("ALL_PROPOSALS_PARAMETERS_JSON");
+    pub SlashWorkingGroupLeadProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        slash_working_group_lead_proposal();
 
-    // Handle undefined variable (null) and variable set to empty string the same to work cross platform.
-    if json_str.map_or(true, str::is_empty) {
-        return default_parameters();
-    }
+    pub SetWorkingGroupLeadRewardProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_working_group_lead_reward_proposal();
 
-    json_str
-        .map(lite_json::parse_json)
-        .map(|res| match res {
-            Ok(json) => Some(json),
-            Err(_) => panic!("Invalid JSON with proposals parameters provided."),
-        })
-        .flatten()
-        .map(convert_json_object_to_proposal_parameters)
-        .unwrap_or_else(default_parameters)
-}
+    pub TerminateWorkingGroupLeadProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        terminate_working_group_lead_proposal();
 
-// Helper macro for initializing single ProposalParameters object for a specified field of the
-// AllProposalsParameters object. It helps to reduce duplication of the field names for
-// AllProposalsParameters field, JSON object field name and default value function.
-// Consider this as duplication example:
-//         parameters.set_validator_count_proposal = create_proposal_parameters_object(
-//             json_object,
-//             "set_validator_count_proposal",
-//             defaults::set_validator_count_proposal(),
-//         );
-macro_rules! init_proposal_parameter_object {
-    ($parameters_object:ident, $jsonObj:expr, $name:ident) => {
-        $parameters_object.$name =
-            create_proposal_parameters_object($jsonObj, stringify!($name), defaults::$name());
-    };
-}
+    pub AmendConstitutionProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        amend_constitution_proposal();
 
-// Tries to extract all proposal parameters from the parsed JSON object.
-fn convert_json_object_to_proposal_parameters(
-    json: lite_json::JsonValue,
-) -> AllProposalsParameters {
-    let mut params = default_parameters();
+    pub CancelWorkingGroupLeadOpeningProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        cancel_working_group_lead_opening_proposal();
 
-    if let lite_json::JsonValue::Object(jo) = json {
-        init_proposal_parameter_object!(params, jo.clone(), set_max_validator_count_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), runtime_upgrade_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), signal_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), funding_request_proposal);
-        init_proposal_parameter_object!(
-            params,
-            jo.clone(),
-            create_working_group_lead_opening_proposal
-        );
-        init_proposal_parameter_object!(
-            params,
-            jo.clone(),
-            fill_working_group_lead_opening_proposal
-        );
-        init_proposal_parameter_object!(params, jo.clone(), update_working_group_budget_proposal);
-        init_proposal_parameter_object!(
-            params,
-            jo.clone(),
-            decrease_working_group_lead_stake_proposal
-        );
-        init_proposal_parameter_object!(params, jo.clone(), slash_working_group_lead_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), set_working_group_lead_reward_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), terminate_working_group_lead_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), amend_constitution_proposal);
-        init_proposal_parameter_object!(
-            params,
-            jo.clone(),
-            cancel_working_group_lead_opening_proposal
-        );
-        init_proposal_parameter_object!(params, jo.clone(), set_membership_price_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), set_council_budget_increment_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), set_councilor_reward_proposal);
-        init_proposal_parameter_object!(
-            params,
-            jo.clone(),
-            set_initial_invitation_balance_proposal
-        );
-        init_proposal_parameter_object!(
-            params,
-            jo.clone(),
-            set_membership_lead_invitation_quota_proposal
-        );
-        init_proposal_parameter_object!(params, jo.clone(), set_referral_cut_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), set_invitation_count_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), create_blog_post_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), edit_blog_post_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), lock_blog_post_proposal);
-        init_proposal_parameter_object!(params, jo.clone(), unlock_blog_post_proposal);
-        init_proposal_parameter_object!(params, jo, veto_proposal_proposal);
-    }
+    pub SetMembershipPriceProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_membership_price_proposal();
 
-    params
-}
+    pub SetCouncilBudgetIncrementProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_council_budget_increment_proposal();
 
-// Tries to create specific ProposalParameters object from the parsed JSON object.
-// Returns default parameters on missing values.
-fn create_proposal_parameters_object(
-    json_object: JsonObject,
-    proposal_name: &'static str,
-    defaults: ProposalParameters<BlockNumber, Balance>,
-) -> ProposalParameters<BlockNumber, Balance> {
-    json_object
-        .iter()
-        .find(|(name_vec, _)| name_vec.eq(&proposal_name.chars().collect::<Vec<_>>()))
-        .map(|(_, params)| extract_proposal_parameters(params, defaults))
-        .unwrap_or(defaults)
-}
+    pub SetCouncilorRewardProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_councilor_reward_proposal();
 
-// Helper macro for initializing single field of the ProposalParameters object.
-// It helps to reduce duplication of the field names for ProposalParameters
-// field name, JSON object field name and default value field name.
-// Consider this as duplication example:
-//     ProposalParameters::<BlockNumber, Balance> {
-//         voting_period: extract_numeric_parameter(
-//             json_object,
-//             "voting_period",
-//             defaults.voting_period.saturated_into(),
-//         )
-//         .saturated_into(),
-//      ....
-//      }
-macro_rules! init_proposal_parameter_field {
-    ($parameters_object:ident, $jsonObj:expr, $default_object:ident, $name:ident) => {
-        $parameters_object.$name = extract_numeric_parameter(
-            $jsonObj,
-            stringify!($name),
-            $default_object.$name.saturated_into(),
-        )
-        .saturated_into();
-    };
-}
+    pub SetInitialInvitationBalanceProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_initial_invitation_balance_proposal();
 
-// Helper macro similar to init_proposal_parameter_field but for optional parameters.
-// Zero value is wrapped as None.
-macro_rules! init_proposal_parameter_optional_field {
-    ($parameters_object:ident, $jsonObj:expr, $default_object:ident, $name:ident) => {
-        let param_value = extract_numeric_parameter(
-            $jsonObj,
-            stringify!($name),
-            $default_object.$name.unwrap_or_default().saturated_into(),
-        )
-        .saturated_into();
-        let opt_value = if param_value == 0 {
-            None
-        } else {
-            Some(param_value)
-        };
+    pub SetMembershipLeadInvitationQuotaProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_membership_lead_invitation_quota_proposal();
 
-        $parameters_object.$name = opt_value;
-    };
-}
+    pub SetReferralCutProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_referral_cut_proposal();
 
-// Creates an error inside the macro when fixed.
-#[allow(clippy::field_reassign_with_default)]
-// Extracts proposal parameters from the parsed JSON object.
-fn extract_proposal_parameters(
-    json_object: &JsonValue,
-    defaults: ProposalParameters<BlockNumber, Balance>,
-) -> ProposalParameters<BlockNumber, Balance> {
-    let mut params = ProposalParameters::default();
+    pub SetInvitationCountProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        set_invitation_count_proposal();
 
-    init_proposal_parameter_field!(params, json_object, defaults, voting_period);
-    init_proposal_parameter_field!(params, json_object, defaults, grace_period);
-    init_proposal_parameter_field!(params, json_object, defaults, approval_quorum_percentage);
-    init_proposal_parameter_field!(params, json_object, defaults, approval_threshold_percentage);
-    init_proposal_parameter_field!(params, json_object, defaults, slashing_quorum_percentage);
-    init_proposal_parameter_field!(params, json_object, defaults, slashing_threshold_percentage);
-    init_proposal_parameter_optional_field!(params, json_object, defaults, required_stake);
-    init_proposal_parameter_field!(params, json_object, defaults, constitutionality);
+    pub CreateBlogPostProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        create_blog_post_proposal();
 
-    params
-}
+    pub EditBlogPostProoposalParamters: ProposalParameters<BlockNumber, Balance> =
+        edit_blog_post_proposal();
 
-// Extracts a specific numeric parameter from the parsed JSON object. Will panic if expected value is not numeric.
-fn extract_numeric_parameter(
-    json_object: &JsonValue,
-    parameter_name: &'static str,
-    default: u128,
-) -> u128 {
-    match json_object {
-        JsonValue::Object(json_object) => json_object
-            .iter()
-            .find(|(name_vec, _)| name_vec.eq(&parameter_name.chars().collect::<Vec<_>>()))
-            .map(|(_, value)| match value {
-                JsonValue::Number(number) => number.integer.saturated_into(),
-                _ => panic!("Incorrect JSON: not a number."),
-            })
-            .unwrap_or(default),
-        _ => default,
-    }
-}
+    pub LockBlogPostProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        lock_blog_post_proposal();
 
-// Returns all default proposal parameters.
-fn default_parameters() -> AllProposalsParameters {
-    AllProposalsParameters {
-        set_max_validator_count_proposal: defaults::set_max_validator_count_proposal(),
-        runtime_upgrade_proposal: defaults::runtime_upgrade_proposal(),
-        signal_proposal: defaults::signal_proposal(),
-        funding_request_proposal: defaults::funding_request_proposal(),
-        create_working_group_lead_opening_proposal:
-            defaults::create_working_group_lead_opening_proposal(),
-        fill_working_group_lead_opening_proposal:
-            defaults::fill_working_group_lead_opening_proposal(),
-        update_working_group_budget_proposal: defaults::update_working_group_budget_proposal(),
-        decrease_working_group_lead_stake_proposal:
-            defaults::decrease_working_group_lead_stake_proposal(),
-        slash_working_group_lead_proposal: defaults::slash_working_group_lead_proposal(),
-        set_working_group_lead_reward_proposal: defaults::set_working_group_lead_reward_proposal(),
-        terminate_working_group_lead_proposal: defaults::terminate_working_group_lead_proposal(),
-        amend_constitution_proposal: defaults::amend_constitution_proposal(),
-        cancel_working_group_lead_opening_proposal:
-            defaults::cancel_working_group_lead_opening_proposal(),
-        set_membership_price_proposal: defaults::set_membership_price_proposal(),
-        set_council_budget_increment_proposal: defaults::set_council_budget_increment_proposal(),
-        set_councilor_reward_proposal: defaults::set_councilor_reward_proposal(),
-        set_initial_invitation_balance_proposal: defaults::set_initial_invitation_balance_proposal(
-        ),
-        set_membership_lead_invitation_quota_proposal:
-            defaults::set_membership_lead_invitation_quota_proposal(),
-        set_referral_cut_proposal: defaults::set_referral_cut_proposal(),
-        set_invitation_count_proposal: defaults::set_invitation_count_proposal(),
-        create_blog_post_proposal: defaults::create_blog_post_proposal(),
-        edit_blog_post_proposal: defaults::edit_blog_post_proposal(),
-        lock_blog_post_proposal: defaults::lock_blog_post_proposal(),
-        unlock_blog_post_proposal: defaults::unlock_blog_post_proposal(),
-        veto_proposal_proposal: defaults::veto_proposal_proposal(),
-    }
+    pub UnlockBlogPostProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        unlock_blog_post_proposal();
+
+    pub VetoProposalProposalParameters: ProposalParameters<BlockNumber, Balance> =
+        veto_proposal_proposal();
 }

+ 0 - 253
runtime/src/proposals_configuration/sample_proposal_parameters.json

@@ -1,253 +0,0 @@
-{
-    "_comment": "This is a sample 'Proposal parameters' JSON file to enable conditional runtime compilation.",
-    "set_max_validator_count_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "runtime_upgrade_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "signal_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "funding_request_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "create_working_group_lead_opening_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "fill_working_group_lead_opening_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "update_working_group_budget_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "decrease_working_group_lead_stake_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "slash_working_group_lead_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_working_group_lead_reward_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "terminate_working_group_lead_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "amend_constitution_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "cancel_working_group_lead_opening_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_membership_price_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_council_budget_increment_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_councilor_reward_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_initial_invitation_balance_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_membership_lead_invitation_quota_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_referral_cut_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "set_invitation_count_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "create_blog_post_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "edit_blog_post_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "lock_blog_post_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "unlock_blog_post_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    },
-    "veto_proposal_proposal": {
-        "voting_period": 1,
-        "grace_period": 2,
-        "approval_quorum_percentage": 3,
-        "approval_threshold_percentage": 4,
-        "slashing_quorum_percentage": 5,
-        "slashing_threshold_percentage": 6,
-        "required_stake": 7,
-        "constitutionality": 8
-    }
-}

+ 360 - 0
runtime/src/proposals_configuration/staging.rs

@@ -0,0 +1,360 @@
+//! This module contains staging parameters for the runtime codex proposals.
+
+use crate::{Balance, BlockNumber, ProposalParameters};
+
+// Proposal parameters for the 'Set Max Validator Count' proposal
+pub(crate) fn set_max_validator_count_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(100_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Runtime Upgrade' proposal
+pub(crate) fn runtime_upgrade_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 200,
+        approval_quorum_percentage: 80,
+        approval_threshold_percentage: 100,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(1_000_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Signal' proposal
+pub(crate) fn signal_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Funding Request' proposal
+pub(crate) fn funding_request_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+// Proposal parameters for the 'Create Working Group Lead Opening' proposal
+pub(crate) fn create_working_group_lead_opening_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(100_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Fill Working Group Lead Opening' proposal
+pub(crate) fn fill_working_group_lead_opening_proposal() -> ProposalParameters<BlockNumber, Balance>
+{
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Update Working Group Budget' proposal
+pub(crate) fn update_working_group_budget_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Decrease Working Group Lead Stake' proposal
+pub(crate) fn decrease_working_group_lead_stake_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Slash Working Group Lead' proposal
+pub fn slash_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Working Group Lead Reward' proposal
+pub(crate) fn set_working_group_lead_reward_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Terminate Working Group Lead' proposal
+pub(crate) fn terminate_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(100_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Amend Constitution' proposal
+pub(crate) fn amend_constitution_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 80,
+        approval_threshold_percentage: 100,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(1_000_000),
+        constitutionality: 2,
+    }
+}
+
+// Proposal parameters for the 'Cancel Working Group Lead Opening' proposal
+pub(crate) fn cancel_working_group_lead_opening_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Membership Price' proposal
+pub(crate) fn set_membership_price_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Council Budget Increment' proposal
+pub(crate) fn set_council_budget_increment_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(200_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Councilor Reward' proposal
+pub(crate) fn set_councilor_reward_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100, // A council term
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(200_000),
+        constitutionality: 2,
+    }
+}
+
+// Proposal parameters for the 'Set Initial Invitation Balance' proposal
+pub(crate) fn set_initial_invitation_balance_proposal() -> ProposalParameters<BlockNumber, Balance>
+{
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Initial Invitation Quota' proposal
+// The parameter for this proposal still have to be more carefully reviewed
+pub(crate) fn set_membership_lead_invitation_quota_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Referral Cut' proposal
+pub(crate) fn set_referral_cut_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Initial Invitation Count' proposal
+pub(crate) fn set_invitation_count_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Create Blog Post' proposal
+pub(crate) fn create_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Edit Blog Post' proposal
+pub(crate) fn edit_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Lock Blog Post' proposal
+pub(crate) fn lock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Unlock Blog Post' proposal
+pub(crate) fn unlock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 200,
+        grace_period: 100,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Veto Proposal' proposal
+pub(crate) fn veto_proposal_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        // Doesn't make sense to be longer than longest grace period of all other proposals?
+        voting_period: 200,
+        grace_period: 0,
+        approval_quorum_percentage: 75,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 66,
+        required_stake: Some(1_000_000),
+        constitutionality: 1,
+    }
+}

+ 361 - 0
runtime/src/proposals_configuration/testing.rs

@@ -0,0 +1,361 @@
+//! This module contains testing parameters for the runtime codex proposals,
+//! suitable for automated integration testing.
+
+use crate::{Balance, BlockNumber, ProposalParameters};
+
+// Proposal parameters for the 'Set Max Validator Count' proposal
+pub(crate) fn set_max_validator_count_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(100_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Runtime Upgrade' proposal
+pub(crate) fn runtime_upgrade_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 100,
+        grace_period: 40,
+        approval_quorum_percentage: 80,
+        approval_threshold_percentage: 100,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(1_000_000),
+        constitutionality: 2,
+    }
+}
+
+// Proposal parameters for the 'Signal' proposal
+pub(crate) fn signal_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Funding Request' proposal
+pub(crate) fn funding_request_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+// Proposal parameters for the 'Create Working Group Lead Opening' proposal
+pub(crate) fn create_working_group_lead_opening_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(100_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Fill Working Group Lead Opening' proposal
+pub(crate) fn fill_working_group_lead_opening_proposal() -> ProposalParameters<BlockNumber, Balance>
+{
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Update Working Group Budget' proposal
+pub(crate) fn update_working_group_budget_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Decrease Working Group Lead Stake' proposal
+pub(crate) fn decrease_working_group_lead_stake_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Slash Working Group Lead' proposal
+pub fn slash_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Working Group Lead Reward' proposal
+pub(crate) fn set_working_group_lead_reward_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Terminate Working Group Lead' proposal
+pub(crate) fn terminate_working_group_lead_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(100_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Amend Constitution' proposal
+pub(crate) fn amend_constitution_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 40,
+        approval_quorum_percentage: 80,
+        approval_threshold_percentage: 100,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(1_000_000),
+        constitutionality: 2,
+    }
+}
+
+// Proposal parameters for the 'Cancel Working Group Lead Opening' proposal
+pub(crate) fn cancel_working_group_lead_opening_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Membership Price' proposal
+pub(crate) fn set_membership_price_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Council Budget Increment' proposal
+pub(crate) fn set_council_budget_increment_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(200_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Councilor Reward' proposal
+pub(crate) fn set_councilor_reward_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 40, // A council term
+        approval_quorum_percentage: 66,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(200_000),
+        constitutionality: 2,
+    }
+}
+
+// Proposal parameters for the 'Set Initial Invitation Balance' proposal
+pub(crate) fn set_initial_invitation_balance_proposal() -> ProposalParameters<BlockNumber, Balance>
+{
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Initial Invitation Quota' proposal
+// The parameter for this proposal still have to be more carefully reviewed
+pub(crate) fn set_membership_lead_invitation_quota_proposal(
+) -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Referral Cut' proposal
+pub(crate) fn set_referral_cut_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Set Initial Invitation Count' proposal
+pub(crate) fn set_invitation_count_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 75,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(50_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Create Blog Post' proposal
+pub(crate) fn create_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Edit Blog Post' proposal
+pub(crate) fn edit_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Lock Blog Post' proposal
+pub(crate) fn lock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Unlock Blog Post' proposal
+pub(crate) fn unlock_blog_post_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        voting_period: 30,
+        grace_period: 20,
+        approval_quorum_percentage: 60,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 80,
+        required_stake: Some(25_000),
+        constitutionality: 1,
+    }
+}
+
+// Proposal parameters for the 'Veto Proposal' proposal
+pub(crate) fn veto_proposal_proposal() -> ProposalParameters<BlockNumber, Balance> {
+    ProposalParameters {
+        // Doesn't make sense to be longer than longest grace period of all other proposals?
+        voting_period: 30,
+        grace_period: 0,
+        approval_quorum_percentage: 75,
+        approval_threshold_percentage: 80,
+        slashing_quorum_percentage: 60,
+        slashing_threshold_percentage: 66,
+        required_stake: Some(1_000_000),
+        constitutionality: 1,
+    }
+}

+ 0 - 5
runtime/src/proposals_configuration/tests.rs

@@ -1,5 +0,0 @@
-#[test]
-fn proposal_parameters() {
-    // Reading all proposal parameters and look for invalid JSON
-    super::get_all_proposals_parameters_objects();
-}

+ 6 - 2
scripts/cargo-build.sh

@@ -1,7 +1,11 @@
 #!/usr/bin/env bash
+set -e
 
-# TODO: Check for valid JSON in ALL_PROPOSALS_PARAMETERS_JSON ?
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source features.sh
 
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
-cargo +nightly-2021-02-20 build --release
+cargo +nightly-2021-02-20 build --release --features "${FEATURES}"

+ 7 - 2
scripts/cargo-tests-with-networking.sh

@@ -1,7 +1,12 @@
-#!/bin/sh
+#!/usr/bin/env bash
 set -e
 
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source features.sh
+
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
 echo 'running all cargo tests'
-cargo +nightly-2021-02-20 test --release --all -- --ignored
+cargo +nightly-2021-02-20 test --release --features "${FEATURES}" --all -- --ignored

+ 12 - 0
scripts/features.sh

@@ -0,0 +1,12 @@
+FEATURES=
+if [[ "$RUNTIME_PROFILE" == "TESTING" ]]; then
+  FEATURES="testing_runtime"
+fi
+
+if [[ "$RUNTIME_PROFILE" == "STAGING" ]]; then
+  FEATURES="staging_runtime"
+fi
+
+if [[ "$RUNTIME_PROFILE" == "PLAYGROUND" ]]; then
+  FEATURES="playground_runtime"
+fi

+ 9 - 3
scripts/run-dev-chain.sh

@@ -1,13 +1,19 @@
 #!/usr/bin/env bash
+set -e
+
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source features.sh
 
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
 # Build release binary
-cargo +nightly-2021-02-20 build --release
+cargo +nightly-2021-02-20 build --release --features "${FEATURES}"
 
 # Purge existing local chain
-yes | cargo +nightly-2021-02-20 run --release -- purge-chain --dev
+yes | cargo +nightly-2021-02-20 run --release --features "${FEATURES}" -- purge-chain --dev
 
 # Run local development chain -
 # No need to specify `-p joystream-node` it is the default bin crate in the cargo workspace
-cargo +nightly-2021-02-20 run --release -- --dev --log runtime
+cargo +nightly-2021-02-20 run --release --features "${FEATURES}" -- --dev --log runtime

+ 0 - 5
scripts/run-proposal-configuration-tests.sh

@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-
-ALL_PROPOSALS_PARAMETERS_JSON=`cat runtime/src/proposals_configuration/sample_proposal_parameters.json` cargo test proposals_configuration::tests -- --ignored
-

+ 1 - 17
scripts/runtime-code-shasum.sh

@@ -14,21 +14,6 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
   SED=gsed
 fi
 
-export TEST_NODE_BLOCKTIME=1000
-
-if [[ -n "$ALL_PROPOSALS_PARAMETERS_JSON" ]] && [[ -n "$TEST_NODE" ]]; then
-  echo "Do not set both TEST_NODE and ALL_PROPOSALS_PARAMETERS_JSON env variables"
-  exit 1
-elif [[ -z "$ALL_PROPOSALS_PARAMETERS_JSON" ]] && [[ -z "$TEST_NODE" ]]; then
-  PROPOSALS_PARAMETERS_FILE=""
-elif [[ -n "$TEST_NODE" ]]; then
-  PROPOSALS_PARAMETERS_FILE="./tests/network-tests/proposal-parameters.json"
-else
-  mkdir -p runtime-inputs
-  PROPOSALS_PARAMETERS_FILE="./runtime-inputs/proposal-parameters-input.json"
-  echo $ALL_PROPOSALS_PARAMETERS_JSON > $PROPOSALS_PARAMETERS_FILE
-fi
-
 # sort/owner/group/mtime arguments only work with gnu version of tar!
 ${TAR} -c --sort=name --owner=root:0 --group=root:0 --mode 644 --mtime='UTC 2020-01-01' \
     Cargo.lock \
@@ -39,7 +24,6 @@ ${TAR} -c --sort=name --owner=root:0 --group=root:0 --mode 644 --mtime='UTC 2020
     joystream-node.Dockerfile \
     joystream-node-armv7.Dockerfile \
     node \
-    $PROPOSALS_PARAMETERS_FILE \
-    | if [[ -n "$TEST_NODE" ]]; then ${SED} '$a'"$TEST_NODE_BLOCKTIME"; else tee; fi \
+    | if [[ -n "$RUNTIME_PROFILE" ]]; then ${SED} '$a'"$RUNTIME_PROFILE"; else tee; fi \
     | shasum \
     | cut -d " " -f 1

+ 2 - 1
setup.sh

@@ -36,7 +36,8 @@ source ~/.cargo/env
 rustup install nightly-2021-02-20
 rustup target add wasm32-unknown-unknown --toolchain nightly-2021-02-20
 
-rustup component add rustfmt clippy
+rustup component add --toolchain nightly-2021-02-20 clippy
+rustup component add rustfmt
 
 # Install substrate keychain tool - install doesn't seem to work lately.
 # cargo install --force subkey --git https://github.com/paritytech/substrate --version 2.0.1 --locked

+ 0 - 61
storage-playground-config.sh

@@ -1,61 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
-cd $SCRIPT_PATH
-
-# Basic script to be run to configure dev chain storage infrastructure.
-# Assumes one storage lead and distributor lead are already hired
-# and their identity information are stored in .env
-
-# Load the worker ids and SURIs as local variables only
-. .env
-
-HOST_IP=$(tests/network-tests/get-host-ip.sh)
-
-## Colossus 1
-CLI=storage-node/bin/run
-TRANSACTOR_KEY=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${COLOSSUS_1_TRANSACTOR_URI} --output-type json | jq .ss58Address -r)
-# Send some funds to TRANSACTOR to cover the acceptPendingDataObjects fees
-export AUTO_CONFIRM=true
-FUNDS_SOURCE_KEY=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
-TRANSACTOR_INITIAL_BALANCE=100000
-yarn joystream-cli account:transferTokens --amount ${TRANSACTOR_INITIAL_BALANCE} --from ${FUNDS_SOURCE_KEY}  --to ${TRANSACTOR_KEY}
-
-${CLI} leader:update-bag-limit -l 10 --accountUri ${COLOSSUS_1_WORKER_URI}
-${CLI} leader:update-voucher-limits -o 10000 -s 1000000000000 --accountUri ${COLOSSUS_1_WORKER_URI}
-BUCKET_ID=`${CLI} leader:create-bucket -i=${COLOSSUS_1_WORKER_ID} -a -n=10000 -s=1000000000000  --accountUri ${COLOSSUS_1_WORKER_URI}`
-${CLI} operator:accept-invitation -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -t=${TRANSACTOR_KEY} --accountUri ${COLOSSUS_1_WORKER_URI}
-${CLI} leader:update-dynamic-bag-policy -n 1 -t Channel --accountUri ${COLOSSUS_1_WORKER_URI}
-${CLI} leader:update-data-fee -f 0 --accountUri ${COLOSSUS_1_WORKER_URI} # Optionally - set some data fee per megabyte
-
-# The node uri should be an accessible endpoint from within a container as well as the host machine.
-# In production it would most likely be the reverse proxy endpoint. If not specified we
-# set it to the host machine address.
-COLOSSUS_1_NODE_URI=${COLOSSUS_1_NODE_URI:="http://${HOST_IP}:3333"}
-${CLI} operator:set-metadata -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -e="${COLOSSUS_1_NODE_URI}" --accountUri ${COLOSSUS_1_WORKER_URI}
-
-echo "Colossus 1 BUCKET_ID=${BUCKET_ID}"
-
-## Distributor 1
-export AUTO_CONFIRM=true
-export CONFIG_PATH=$(pwd)/distributor-node/config.yml
-export JOYSTREAM_DISTRIBUTOR__KEYS="[{\"suri\":\"${DISTRIBUTOR_1_ACCOUNT_URI}\"}]"
-CLI=distributor-node/bin/run
-
-${CLI} leader:set-buckets-per-bag-limit -l 10
-FAMILY_ID=`${CLI} leader:create-bucket-family`
-BUCKET_INDEX=`${CLI} leader:create-bucket -f ${FAMILY_ID} -a yes`
-BUCKET_ID="${FAMILY_ID}:${BUCKET_INDEX}"
-${CLI} leader:update-bucket-mode -B ${BUCKET_ID} --mode on
-${CLI} leader:update-dynamic-bag-policy -t Channel -p ${FAMILY_ID}:5
-${CLI} leader:invite-bucket-operator -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
-${CLI} operator:accept-invitation -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
-
-# The node uri should be an accessible endpoint from within a container as well as the host machine.
-# In production it would most likely be the reverse proxy endpoint. If not specified we
-# set it to the host machine address.
-DISTRIBUTOR_1_NODE_URI=${DISTRIBUTOR_1_NODE_URI:="http://${HOST_IP}:3334"}
-${CLI} operator:set-metadata -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID} -e="${DISTRIBUTOR_1_NODE_URI}"
-
-echo "Distributor 1 BUCKET_ID=${BUCKET_ID}"

+ 0 - 104
tests/network-tests/proposal-parameters.json

@@ -1,104 +0,0 @@
-{
-  "set_max_validator_count_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "runtime_upgrade_proposal": {
-    "voting_period": 100,
-    "grace_period": 40,
-    "constitutionality": 2
-  },
-  "signal_proposal": {
-    "voting_period": 30,
-    "grace_period": 0
-  },
-  "funding_request_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "create_working_group_lead_opening_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "fill_working_group_lead_opening_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "update_working_group_budget_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "decrease_working_group_lead_stake_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "slash_working_group_lead_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "set_working_group_lead_reward_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "terminate_working_group_lead_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "amend_constitution_proposal": {
-      "voting_period": 30,
-      "grace_period": 40,
-      "constitutionality": 2
-  },
-  "cancel_working_group_lead_opening_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  },
-  "set_membership_price_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "set_council_budget_increment_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "set_councilor_reward_proposal": {
-      "voting_period": 30,
-      "grace_period": 40
-  },
-  "set_initial_invitation_balance_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "set_membership_lead_invitation_quota_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "set_referral_cut_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "set_invitation_count_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "create_blog_post_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "edit_blog_post_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "lock_blog_post_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "unlock_blog_post_proposal": {
-      "voting_period": 30,
-      "grace_period": 20
-  },
-  "veto_proposal_proposal": {
-      "voting_period": 30,
-      "grace_period": 0
-  }
-}

+ 1 - 1
tests/network-tests/run-test-node-docker.sh

@@ -26,7 +26,7 @@ TREASURY_ACCOUNT=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 i
 >&2 echo "treasury account from suri: ${TREASURY_ACCOUNT}"
 
 # The docker image tag to use for joystream/node
-RUNTIME=${RUNTIME:=$(TEST_NODE=true ../../scripts/runtime-code-shasum.sh)}
+RUNTIME=${RUNTIME:=$(RUNTIME_PROFILE=TESTING ../../scripts/runtime-code-shasum.sh)}
 
 echo "{
   \"balances\":[

+ 1 - 1
utils/chain-spec-builder/Cargo.toml

@@ -3,7 +3,7 @@ authors = ['Joystream contributors']
 build = 'build.rs'
 edition = '2018'
 name = 'chain-spec-builder'
-version = '5.4.0'
+version = '6.5.0'
 
 [dependencies]
 enum-utils = "0.1.2"