Browse Source

Merge branch 'development' into pioneer-migration

Mokhtar Naamani 4 years ago
parent
commit
ad222711f2

+ 35 - 57
.travis.yml

@@ -1,76 +1,54 @@
 language: rust
 
+# Caching of the runtime .wasm blob poses a problem.
+# See: https://github.com/Joystream/joystream/issues/466
+# Always starting with a clean slate is probably better, it allows us to ensure
+# the WASM runtime is always rebuilt. It also allows us to detect when certain upstream dependencies
+# sometimes break the build. When cache is enabled do not use the produced WASM build.
+# This also means the binary should not be used to produce the final chainspec file (because the same
+# one is embedded in the binary)
+cache: cargo
+
 rust:
-  - 1.43.0
+  - stable
 
 matrix:
   include:
     - os: linux
       env: TARGET=x86_64-unknown-linux-gnu
-    - os: linux
-      env: TARGET=arm-unknown-linux-gnueabihf
-      services: docker
-    - os: osx
-      env: TARGET=x86_64-apple-darwin
-    - os: linux
-      env: TARGET=wasm-blob
-      services: docker
+  # Removed all other plaftorm builds sice the repo is growing in terms of activitly
+  # and CI checks are taking long to start due to concurrent number of jobs
+  # one job should be sufficient for doing all manners of checks and unit nets. Will defer
+  # building all platform binanires and wasm blob to a different system.
 
-before_install:
+install:
+  - rustup install nightly-2020-05-23
+  - rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23
+  # travis installs rust using rustup with the "minimal" profile so these tools are not installed by default
   - rustup component add rustfmt
-  - cargo fmt --all -- --check
+  # choosing to add clippy for the nightly toolchain only
+  # becuase we want to run it with nighly to avoid having to set BUILD_DUMMY_WASM_BINARY=0
+  # setting that variable requires changing it in a later run of cargo bulid to ensure runtime/build.rs
+  # actually builds the runtime .. the behaviour is a bit odd so choosing to avoid messing with it.
   - rustup component add clippy
-  - BUILD_DUMMY_WASM_BINARY=1 cargo clippy -- -D warnings
-  - rustup default stable
-  - rustup update nightly
-  - rustup target add wasm32-unknown-unknown --toolchain nightly
-  - cargo test --verbose --all
 
-install:
-  - |
-    if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]
-    then
-      docker pull joystream/rust-raspberry
-    fi
+before_script:
+  - cargo fmt --all -- --check
 
 script:
-  - |
-    if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]
-    then
-      docker run -u root \
-        --volume ${TRAVIS_BUILD_DIR}:/home/cross/project \
-          joystream/rust-raspberry \
-        build --release
-      sudo chmod a+r ${TRAVIS_BUILD_DIR}/target/${TARGET}/release/joystream-node
-    elif [ "$TARGET" = "wasm-blob" ]
-    then
-      docker build --tag joystream/node \
-        --file ./devops/dockerfiles/node-and-runtime/Dockerfile \
-        .
-      docker create --name temp-container-joystream-node joystream/node
-      docker cp temp-container-joystream-node:/joystream/runtime.compact.wasm joystream_runtime.wasm
-      docker rm temp-container-joystream-node
-    else
-      cargo build --release --target=${TARGET}
-    fi
+  # we set release as build type for all steps to benefit from already compiled packages in prior steps
+  # skipping clippy ...
+  - BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --target=${TARGET} -- -D warnings
+  - BUILD_DUMMY_WASM_BINARY=1 cargo test --release --verbose --all --target=${TARGET}
+  - BUILD_DUMMY_WASM_BINARY=0 WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release --target=${TARGET} -p joystream-node
+  - ls -l ./target/${TARGET}/release/wbuild/joystream-node-runtime/
 
 before_deploy:
-  - |
-    if [ "$TARGET" = "wasm-blob" ]
-    then
-      export ASSET="joystream_runtime.wasm"
-    else
-      cp ./target/${TARGET}/release/joystream-node .
-      if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]
-      then
-        export FILENAME="joystream-node-armv7-linux-gnueabihf"
-      else
-        export FILENAME=`./joystream-node --version | sed -e "s/ /-/g"`
-      fi
-      tar -cf ${FILENAME}.tar ./joystream-node
-      gzip ${FILENAME}.tar
-      export ASSET=${FILENAME}.tar.gz
-    fi
+  - cp ./target/${TARGET}/release/joystream-node .
+  - FILENAME=`./joystream-node --version | sed -e "s/ /-/g"`
+  - tar -cf ${FILENAME}.tar ./joystream-node
+  - gzip ${FILENAME}.tar
+  - export ASSET=${FILENAME}.tar.gz
 
 deploy:
   - provider: releases

+ 2 - 1
devops/dockerfiles/node-and-runtime/Dockerfile

@@ -3,7 +3,8 @@ LABEL description="Compiles all workspace artifacts"
 WORKDIR /joystream
 COPY . /joystream
 
-RUN cargo build --release
+# Build joystream-node and its dependencies - runtime
+RUN cargo build --release -p joystream-node
 
 FROM debian:stretch
 LABEL description="Joystream node"

+ 5 - 5
devops/git-hooks/pre-push

@@ -1,10 +1,10 @@
 #!/bin/sh
 set -e
 
-export BUILD_DUMMY_WASM_BINARY=1
+echo '+cargo test --release --all'
+BUILD_DUMMY_WASM_BINARY=1 cargo test --all
+
+echo '+cargo clippy --release --all -- -D warnings'
+BUILD_DUMMY_WASM_BINARY=1 cargo clippy --all -- -D warnings
 
-echo '+cargo test --all'
-cargo test --all
 
-echo '+cargo clippy --all -- -D warnings'
-cargo clippy --all -- -D warnings

+ 3 - 1
package.json

@@ -5,7 +5,9 @@
 	"scripts": {
 		"test": "yarn && yarn workspaces run test",
 		"test-migration": "yarn && yarn workspaces run test-migration",
-		"postinstall": "yarn workspace @joystream/types build"
+		"postinstall": "yarn workspace @joystream/types build",
+    "cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
+		"cargo-build": "scripts/cargo-build.sh"
 	},
 	"workspaces": [
 		"tests/network-tests",

+ 1 - 1
runtime/Cargo.toml

@@ -272,7 +272,7 @@ rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
 
 [build-dependencies.wasm-builder-runner]
 package = 'substrate-wasm-builder-runner'
-version = '1.0.4'
+version = '1.0.5'
 
 [dependencies.forum]
 default_features = false

+ 1 - 1
runtime/build.rs

@@ -24,7 +24,7 @@ fn main() {
     }
 
     let file_name = "wasm_binary.rs";
-    let wasm_builder_source = WasmBuilderSource::Crates("1.0.8");
+    let wasm_builder_source = WasmBuilderSource::Crates("1.0.9");
     // This instructs LLD to export __heap_base as a global variable, which is used by the
     // external memory allocator.
     let default_rust_flags = "-Clink-arg=--export=__heap_base";

+ 3 - 24
runtime/src/migration.rs

@@ -3,7 +3,7 @@
 
 use crate::VERSION;
 use rstd::prelude::*;
-use sr_primitives::{print, traits::Zero};
+// use sr_primitives::{print, traits::Zero};
 use srml_support::{debug, decl_event, decl_module, decl_storage};
 
 impl<T: Trait> Module<T> {
@@ -12,37 +12,16 @@ impl<T: Trait> Module<T> {
     /// Important to note this method should be carefully maintained, because it runs on every runtime
     /// upgrade.
     fn runtime_upgraded() {
-        print("Running runtime upgraded handler");
+        debug::print!("Running runtime upgraded handler");
 
         // Add initialization of modules introduced in new runtime release. Typically this
         // would be any new storage values that need an initial value which would not
         // have been initialized with config() or build() chainspec construction mechanism.
         // Other tasks like resetting values, migrating values etc.
-
-        // Runtime Upgrade Code for going from Rome to Constantinople
-
-        // Create the Council mint. If it fails, we can't do anything about it here.
-        if let Err(err) = governance::council::Module::<T>::create_new_council_mint(
-            minting::BalanceOf::<T>::zero(),
-        ) {
-            debug::warn!(
-                "Failed to create a mint for council during migration: {:?}",
-                err
-            );
-        }
-
-        // Initialise the proposal system various periods
-        proposals_codex::Module::<T>::set_default_config_values();
     }
 }
 
-pub trait Trait:
-    system::Trait
-    + governance::election::Trait
-    + content_working_group::Trait
-    + roles::actors::Trait
-    + proposals_codex::Trait
-{
+pub trait Trait: system::Trait {
     type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
 }
 

+ 3 - 0
scripts/cargo-build.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+
+cargo build --release

+ 0 - 1
scripts/raspberry-cross-build.sh

@@ -7,7 +7,6 @@
 
 # joystream/rust-raspberry image was built from:
 # https://github.com/mnaamani/rust-on-raspberry-docker/commit/8536508b743d55c8573043c4082c62da3b4fd3e2
-docker pull joystream/rust-raspberry
 
 docker run \
     --volume ${PWD}/:/home/cross/project \

+ 7 - 0
setup.sh

@@ -9,7 +9,14 @@ set -e
 #  - skips installing substrate and subkey
 curl https://getsubstrate.io -sSf | bash -s -- --fast
 
+source ~/.cargo/env
+
 rustup component add rustfmt clippy
 
 # TODO: Install additional tools...
+
 # - b2sum
+# - nodejs
+# - npm
+# - yarn
+# .... ?