- Pull Requests
- Continuous Integration
- Linting
- Debugging
- Testing
- Code Editor Configuration
- Create new runtime modules
- FAQ
- Technical Support
Note: Generate a new chapter with openssl rand -hex 3
All Pull Requests should first be made into the 'develop' branch, since the Github Actions CI badge build status that is shown in the README depends on the outcome of building Pull Requests from the 'develop' branch.
To skip running the CI unnecessarily for simple changes such as updating the documentation, include [ci skip] or [skip ci] in your Git commit message.
Please apply Rust Format on your changes prior to creating a PR. See Linting.
cargo +nightly fmt --allOptionally run Clippy
cargo clippy --release -- -D warningsOptionally run check
cargo check
TODO - Replace with use of log::debug with native::debug. See #41
- Add to Cargo.toml of runtime module:
...
'log/std',
...
[dependencies.log]
version = "0.4.8"- Add to my-module/src/lib.rs
use log::{error, info, debug, trace};
...
log::debug!("hello {:?}", world); // Only shows in terminal in debug mode
log::info!("hello {:?}", world); // Shows in terminal in release mode
debug::native::info!("hello {:?}", world);RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/datahighway ... \
... \
-lruntime=debugcargo test -p datahighway-runtime &&
cargo test -p roaming-operators &&
cargo test -p roaming-networks &&
cargo test -p roaming-organizations &&
cargo test -p roaming-network-servers &&
cargo test -p roaming-devices &&
cargo test -p roaming-routing-profiles &&
cargo test -p roaming-service-profiles &&
cargo test -p roaming-accounting-policies &&
cargo test -p roaming-agreement-policies &&
cargo test -p roaming-network-profiles &&
cargo test -p roaming-device-profiles &&
cargo test -p roaming-sessions &&
cargo test -p roaming-billing-policies &&
cargo test -p roaming-charging-policies &&
cargo test -p roaming-packet-bundles &&
cargo test -p mining-config-token &&
cargo test -p mining-config-hardware &&
cargo test -p mining-rates-token &&
cargo test -p mining-rates-hardware &&
cargo test -p mining-sampling-token &&
cargo test -p mining-sampling-hardware &&
cargo test -p mining-eligibility-token &&
cargo test -p mining-eligibility-hardware &&
cargo test -p mining-claims-token &&
cargo test -p mining-claims-hardwarecargo test -p datahighway-runtime
Example
cargo test -p datahighway-runtime --test cli_integration_tests_mining_tokens
Github Actions are used for Continuous Integration. View the latest CI Build Status of the 'develop' branch, from which all Pull Requests are made into the 'master' branch.
Note: We do not watch Pull Requests from the 'master' branch, as they would come from Forked repos.
Reference: https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow
cargo clippy --release -- -D warningsThe following is a temporary fix. See rust-lang/rust-clippy#5094 (comment)
rustup component add clippy --toolchain nightly-2020-10-06-x86_64-unknown-linux-gnu
rustup component add clippy-preview --toolchain nightly-2020-10-06-x86_64-unknown-linux-gnu
cargo +nightly-2020-10-06 clippy-preview -Zunstable-options
Clippy is currently disabled in CI for the following reasons.
A configuration file clippy.toml to accept or ignore different types of Clippy errors is not available (see rust-lang/cargo#5034). So it currenty takes a long time to manually ignore each type of Clippy error in each file.
To manually ignore a clippy error it is necessary to do the following,
where redundant_pattern_matching is the clippy error type in this example:
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_pattern_matching))]RustFmt should be used for styling Rust code.
The styles are defined in the rustfmt.toml configuration file, which was generated by running rustfmt --print-config default rustfmt.toml and making some custom tweaks according to https://rust-lang.github.io/rustfmt/
rustup component add rustfmt --toolchain nightly-2020-10-06-x86_64-unknown-linux-gnuCheck that you agree with all the formating changes that RustFmt will apply to identify anything that you do not agree with.
cargo +nightly fmt --all -- --checkcargo +nightly fmt --allAdd the following to settings.json "editor.rulers": [80,120], as recommended here https://stackoverflow.com/a/45951311/3208553
Install an EditorConfig Plugin for your code editor to detect and apply the configuration in .editorconfig.
substrate-module-new <module-name> <author>-
Question: Why do we need to install Rust Stable and Rust Nightly?
- Answer: In .github/workflows/rust.yml, we need to run the following,
because Substrate builds two binaries: 1) Wasm binary of your Runtime;
and 2) Native executable containing all your other Substrate components
including your runtimes too. The Wasm build requires rust nightly and
wasm32-unknown-unknown to be installed. Note that we do not use
rustup update nightlysince the latest Rust Nightly may break our build, so we must manually change this to the latest Rust Nightly version only when it is known to work.rustup toolchain install nightly-2020-10-06 rustup update stable rustup target add wasm32-unknown-unknown --toolchain nightly
- Answer: In .github/workflows/rust.yml, we need to run the following,
because Substrate builds two binaries: 1) Wasm binary of your Runtime;
and 2) Native executable containing all your other Substrate components
including your runtimes too. The Wasm build requires rust nightly and
wasm32-unknown-unknown to be installed. Note that we do not use
-
Question: Why do we install a specific version of Rust Nightly in the CI?
- Answer: Since the latest version of Rust Nightly may break our build,
and because developers may forget to update to the latest version of Rust
Nightly locally. So the solution is to install a specific version of
Rust Nightly in .github/workflows/rust.yml (i.e.
rustup toolchain install nightly-2020-10-06), since for example the latest Rust Nightly version nightly-2020-02-20 may cause our CI tests to fail (i.e. #32)
- Answer: Since the latest version of Rust Nightly may break our build,
and because developers may forget to update to the latest version of Rust
Nightly locally. So the solution is to install a specific version of
Rust Nightly in .github/workflows/rust.yml (i.e.
-
Question: Why does the
SessionKeysstruct of our chain only have babe and grandpa, and not im_online and authority_discovery.- Answer: Since we'll be a parachain im_online and authority_discovery are not required here.
-
Question: How do I install specific dependencies
- Answer:
cargo install cargo-edit cargo add ...
- Answer:
-
Question: How do I upgrade the runtime without stopping the blockchain
-
Question: How may I debug and contribute to fixing UI errors or any errors in the browser console that I encounter when using Polkadot.js Apps https://polkadot.js.org/apps?
- Answer: If you run Polkadot.js Apps locally from your machine then the errors are easier to debug. Follow the instructions at https://github.com/polkadot-js/apps, including cloning it, and running it. Try to identify and fix the error, and raise an issue in that repository if necessary.
-
Question: How do I stop and remove all the Docker containers and images?
- Answer: Run
./scripts/docker-clean.sh - WARNING: This stops and removes all your Docker containers and images, not just DataHighway relates ones.
- Answer: Run
-
Question: How to access the Docker container of a running node and run shell commands?
- Answer:
docker exec -it node_alice_1 /bin/bash, wherenode_alice_1is the Container Name that is shown when you rundocker ps -a.
- Answer:
-
Question: How do I restart the testnet Docker containers (including each chain databases)?
- Answer: Run the following, where
node_alice_1is a Container Name that is shown when you rundocker ps -a.docker stop node_alice_1 node_bob_1 node_charlie_1 docker rm node_alice_1 node_bob_1 node_charlie_1 docker-compose --verbose up -d docker-compose logs -f
- Answer: Run the following, where
-
Question: Why can't I syncronize my node?
- Answer: Run
./scripts/docker-clean.shbefore starting them again with eitherdocker-compose upordocker-compose --verbose up -d; docker-compose logs -f, incase a cached image is still being used locally - WARNING: This stops and removes all your Docker containers and images, not just DataHighway relates ones.
- Answer: Run
-
Question: How do I run two nodes on the same host machine?
- Answer:
- Refer to "Testnet (Alpha) "testnet_latest" PoS testnet (with multiple nodes)" in EXAMPLES.
- Answer:
-
Question: Why I try to connect to my Substrate node usig Polkadot.js, by going to https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944, why do I get error
WebSocket connection to 'ws://127.0.0.1:9944/' failed: Unknown reason, API-WS: disconnected from ws://127.0.0.1:9944: 1006:: Abnormal Closure- Answer:
- Try using a different web browser. Brave may not work, however Chrome might. Try running Polkadot.js app locally instead. See https://stackoverflow.com/questions/45572440/how-to-access-an-insecure-websocket-from-a-secure-website
- Answer:
-
Question: Why is loose coupling important?
- Answer: Because sometimes things just won't work see example here
- Substrate Seminar example https://youtu.be/VVU3Io2dACY?t=4425
- Answer: Because sometimes things just won't work see example here