Skip to content

Commit 36e4233

Browse files
authored
Merge pull request #17 from DataHighway-DHX/luke/migrate-standalone-pr-215-step-by-step
feat: Migrate pallets from standalone chain that was updated to common branch 'polkadot-v0.9.17' progressively
2 parents 4b660c1 + 28f6fc6 commit 36e4233

File tree

159 files changed

+2039
-25436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2039
-25436
lines changed

.env.sample

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ jobs:
1818
- name: Add wasm toolchain
1919
uses: actions-rs/toolchain@v1
2020
with:
21-
toolchain: nightly-2021-09-29
21+
toolchain: nightly-2021-12-15
2222
target: wasm32-unknown-unknown
2323
override: true
2424

2525
- name: Initialize environment and build
2626
run: |
2727
rustup update stable
28-
rustup toolchain install nightly-2021-09-29
29-
rustup default nightly-2021-09-29
30-
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-09-29
28+
rustup toolchain install nightly-2021-12-15
29+
rustup default nightly-2021-12-15
30+
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-12-15
3131
cargo build --release
3232
3333
- name: Upload artifact

.github/workflows/test.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jobs:
2626
- name: Initialize WASM build environment
2727
run: |
2828
rustup update stable
29-
rustup toolchain install nightly-2021-11-07
30-
rustup default nightly-2021-11-07
31-
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-11-07
29+
rustup toolchain install nightly-2021-12-15
30+
rustup default nightly-2021-12-15
31+
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-12-15
3232
3333
- name: Run cargo check
34-
run: cargo +nightly-2021-11-07 check
34+
run: cargo +nightly-2021-12-15 check
3535

3636
test:
3737
name: Test Suite
@@ -56,14 +56,16 @@ jobs:
5656
- name: Initialize WASM build environment
5757
run: |
5858
rustup update stable
59-
rustup toolchain install nightly-2021-11-07
60-
rustup default nightly-2021-11-07
61-
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-11-07
59+
rustup toolchain install nightly-2021-12-15
60+
rustup default nightly-2021-12-15
61+
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-12-15
6262
6363
# Runs integration tests in the runtime/tests folder
64+
# To run tests in a specific package run
65+
# `cargo +nightly-2021-12-15 test -p <package name> (i.e. datahighway-runtime)
6466
- name: Run All Tests
6567
run: |
66-
cargo +nightly-2021-11-07 test
68+
cargo +nightly-2021-12-15 test
6769
6870
lints:
6971
name: Lints
@@ -88,19 +90,19 @@ jobs:
8890
override: true
8991
components: rustfmt, clippy
9092

91-
# nightly-2021-11-07-x86_64-unknown-linux-gnu
93+
# nightly-2021-12-15-x86_64-unknown-linux-gnu
9294
- name: Initialize WASM build environment
9395
run: |
9496
rustup update stable
95-
rustup toolchain install nightly-2021-11-07
96-
rustup default nightly-2021-11-07
97-
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-11-07
97+
rustup toolchain install nightly-2021-12-15
98+
rustup default nightly-2021-12-15
99+
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-12-15
98100
99101
# Ignore use of Rust Linting since rearranging makes it challenging to update to latest Substrate
100102
# - name: Run cargo fmt
101103
# run: |
102-
# rustup component add rustfmt --toolchain nightly-2021-11-07-x86_64-unknown-linux-gnu
103-
# cargo +nightly-2021-11-07 fmt --all -- --check
104+
# rustup component add rustfmt --toolchain nightly-2021-12-15-x86_64-unknown-linux-gnu
105+
# cargo +nightly-2021-12-15 fmt --all -- --check
104106

105107
# Ignore use of Clippy until a clippy.toml file may be used. See README.md
106108
# - name: Run cargo clippy
@@ -110,6 +112,6 @@ jobs:
110112
# # args: --release -- -D warnings
111113
# # FIXME - temporary fix below. See https://github.com/rust-lang/rust-clippy/issues/5094#issuecomment-579116431
112114
# run: |
113-
# rustup component add clippy --toolchain nightly-2021-11-07-x86_64-unknown-linux-gnu
114-
# rustup component add clippy-preview --toolchain nightly-2021-11-07-x86_64-unknown-linux-gnu
115-
# cargo +nightly-2021-11-07 clippy-preview -Zunstable-options
115+
# rustup component add clippy --toolchain nightly-2021-12-15-x86_64-unknown-linux-gnu
116+
# rustup component add clippy-preview --toolchain nightly-2021-12-15-x86_64-unknown-linux-gnu
117+
# cargo +nightly-2021-12-15 clippy-preview -Zunstable-options

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ pallets/.DS_Store
1515

1616
*-babe.json
1717
*-gran.json
18+
19+
# autogenerated chain_specs
20+
chain_dumps/
21+
rococo-local*
22+
westend-local*
23+
kusama-local*
24+
polkadot-local*

CONTRIBUTING.md

Lines changed: 97 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* [Linting](#chapter-c345d7)
66
* [Debugging](#chapter-93c645)
77
* [Testing](#chapter-e146ec)
8+
* [Benchmarking](#chapter-6c1b24)
9+
* [Try-Runtime](#chapter-397b84)
10+
* [Memory Profiling](#chapter-585a25)
811
* [Code Editor Configuration](#chapter-d5a9de)
912
* [Create new runtime modules](#chapter-18873f)
1013
* [FAQ](#chapter-f078a2)
@@ -23,7 +26,12 @@ To skip running the CI unnecessarily for simple changes such as updating the doc
2326

2427
### Linting
2528

26-
Please apply Rust Format on your changes prior to creating a PR. See [Linting](#chapter-c345d7).
29+
Check with Rust Format. Note: If you need a specific version of it replace `+nightly` with say `+nightly-2022-03-16`
30+
```
31+
cargo +nightly fmt --all -- --check
32+
```
33+
34+
If you wish to apply Rust Format on your changes prior to creating a PR. See [Linting](#chapter-c345d7).
2735

2836
```bash
2937
cargo +nightly fmt --all
@@ -61,9 +69,10 @@ use log::{error, info, debug, trace};
6169
...
6270
log::debug!("hello {:?}", world); // Only shows in terminal in debug mode
6371
log::info!("hello {:?}", world); // Shows in terminal in release mode
64-
debug::native::info!("hello {:?}", world);
6572
```
6673

74+
Note: The use of `debug::native::info!("hello {:?}", world);` does not appear to work anymore since Substrate updates in Feb 2021.
75+
6776
### Detailed Debugging
6877

6978
```bash
@@ -72,6 +81,8 @@ RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/datahighway ... \
7281
-lruntime=debug
7382
```
7483

84+
Refer to Susbtrate Debugging documentation [here](https://docs.substrate.io/v3/runtime/debugging/)
85+
7586
## Testing <a id="chapter-e146ec"></a>
7687

7788
### Run All Tests
@@ -93,16 +104,16 @@ cargo test -p roaming-sessions &&
93104
cargo test -p roaming-billing-policies &&
94105
cargo test -p roaming-charging-policies &&
95106
cargo test -p roaming-packet-bundles &&
96-
cargo test -p mining-speed-boosts-configuration-token-mining &&
97-
cargo test -p mining-speed-boosts-configuration-hardware-mining &&
98-
cargo test -p mining-speed-boosts-rates-token-mining &&
99-
cargo test -p mining-speed-boosts-rates-hardware-mining &&
100-
cargo test -p mining-speed-boosts-sampling-token-mining &&
101-
cargo test -p mining-speed-boosts-sampling-hardware-mining &&
102-
cargo test -p mining-speed-boosts-eligibility-token-mining &&
103-
cargo test -p mining-speed-boosts-eligibility-hardware-mining &&
104-
cargo test -p mining-speed-boosts-lodgements-token-mining &&
105-
cargo test -p mining-speed-boosts-lodgements-hardware-mining
107+
cargo test -p mining-setting-token &&
108+
cargo test -p mining-setting-hardware &&
109+
cargo test -p mining-rates-token &&
110+
cargo test -p mining-rates-hardware &&
111+
cargo test -p mining-sampling-token &&
112+
cargo test -p mining-sampling-hardware &&
113+
cargo test -p mining-eligibility-token &&
114+
cargo test -p mining-eligibility-hardware &&
115+
cargo test -p mining-claims-token &&
116+
cargo test -p mining-claims-hardware
106117
```
107118

108119
### Run Integration Tests Only
@@ -118,6 +129,78 @@ Example
118129
cargo test -p datahighway-parachain-runtime --test cli_integration_tests_mining_tokens
119130
```
120131

132+
## Benchmarking <a id="chapter-6c1b24"></a>
133+
134+
Run the following:
135+
```
136+
./scripts/benchmark_all_pallets.sh
137+
```
138+
139+
## Try-Runtime <a id="chapter-397b84"></a>
140+
141+
* Run Collator nodes
142+
143+
* Build whilst specifying the `try-runtime` feature
144+
```
145+
cargo build --release features=try-runtime
146+
```
147+
148+
* Run Try-Runtime so `on-runtime-upgrade` will invoke all `OnRuntimeUpgrade` hooks in pallets and the runtime
149+
```
150+
RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \
151+
./target/release/datahighway-collator \
152+
try-runtime \
153+
--chain <chain-spec> \
154+
--execution Wasm \
155+
--wasm-execution Compiled \
156+
--uri <ws/s port>
157+
--block-at <block-hash> \
158+
on-runtime-upgrade \
159+
live
160+
```
161+
162+
Notes:
163+
* Ensure that the Collator node was run with:
164+
```
165+
--rpc-max-payload 1000 \
166+
--rpc-cors=all \
167+
```
168+
* The `--chain` argument must be provided
169+
* Provide a `--uri` and `--block-at` hash from the testnet where the Collator node was launched. The defaults are the wss://127.0.0.1:9944 port and the latest finalized block respectively.
170+
* `live` means we are going to scrape a live testnet, as opposed to loading a saved file.
171+
172+
References:
173+
* https://docs.substrate.io/how-to-guides/v3/tools/try-runtime/
174+
* https://docs.substrate.io/v3/tools/try-runtime/
175+
176+
## Memory Profiling <a id="chapter-585a25"></a>
177+
178+
```
179+
curl -L https://github.com/koute/memory-profiler/releases/download/0.6.1/memory-profiler-x86_64-unknown-linux-gnu.tgz -o memory-profiler-x86_64-unknown-linux-gnu.tgz
180+
tar -xf memory-profiler-x86_64-unknown-linux-gnu.tgz
181+
182+
export MEMORY_PROFILER_LOG=info
183+
export MEMORY_PROFILER_LOGFILE=profiling_%e_%t.log
184+
export MEMORY_PROFILER_OUTPUT=profiling_%e_%t.dat
185+
export MEMORY_PROFILER_CULL_TEMPORARY_ALLOCATIONS=1
186+
```
187+
188+
It should only be run on a testnet. See https://github.com/paritytech/subport/issues/257.
189+
Purge local chain from previous tests, then:
190+
```
191+
LD_PRELOAD=<INSERT_PATH_TO_MEMORY_PROFILER>/libmemory_profiler.so \
192+
./target/release/datahighway-collator <INSERT_TESTNET_ARGS>
193+
```
194+
195+
```
196+
./memory-profiler-cli server *.dat
197+
```
198+
199+
View output at http://localhost:8080/
200+
201+
Reference:
202+
* https://docs.substrate.io/v3/tools/memory-profiling/
203+
121204
## Continuous Integration <a id="chapter-7a8301"></a>
122205

123206
Github Actions are used for Continuous Integration.
@@ -206,68 +289,8 @@ substrate-module-new <module-name> <author>
206289

207290
## FAQ <a id="chapter-f078a2"></a>
208291

209-
* Question: Why do we need to install Rust Stable and Rust Nightly?
210-
* Answer: In .github/workflows/rust.yml, we need to run the following,
211-
because Substrate builds two binaries: 1) Wasm binary of your Runtime;
212-
and 2) Native executable containing all your other Substrate components
213-
including your runtimes too. The Wasm build requires rust nightly and
214-
wasm32-unknown-unknown to be installed. Note that we do not use
215-
`rustup update nightly` since the latest Rust Nightly may break our build,
216-
so we must manually change this to the latest Rust Nightly version only
217-
when it is known to work.
218-
```bash
219-
rustup toolchain install nightly-2020-12-12
220-
rustup update stable
221-
rustup target add wasm32-unknown-unknown --toolchain nightly
222-
```
223-
224-
* Question: Why do we install a specific version of Rust Nightly in the CI?
225-
* Answer: Since the latest version of Rust Nightly may break our build,
226-
and because developers may forget to update to the latest version of Rust
227-
Nightly locally. So the solution is to install a specific version of
228-
Rust Nightly in .github/workflows/rust.yml (i.e.
229-
`rustup toolchain install nightly-2020-12-12`), since for example
230-
the latest Rust Nightly version nightly-2020-02-20 may cause our CI tests
231-
to fail (i.e. https://github.com/DataHighway-DHX/node/issues/32)
232-
233-
* Question: Why does the `SessionKeys` struct of our chain only have [babe and grandpa](https://github.com/DataHighway-DHX/node/blob/master/runtime/src/lib.rs#L94), and not [im_online and authority_discovery](https://github.com/paritytech/substrate/blob/master/bin/node/runtime/src/lib.rs#L242).
234-
* Answer: Since we'll be a parachain im_online and authority_discovery are not required here.
235-
236-
* Question: How do I install specific dependencies
237-
* Answer:
238-
```bash
239-
cargo install cargo-edit
240-
cargo add ...
241-
```
242-
* Question: How do I upgrade the runtime without stopping the blockchain
243-
* Answer: https://www.youtube.com/watch?v=0aTnxHrV_j4&list=PLOyWqupZ-WGt3mA_d9wu74vVe0bM37-39&index=9&t=0s
244-
245-
* 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?
246-
* 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.
247-
248-
* Question: How do I stop and remove all the Docker containers and images?
249-
* Answer: Run `./scripts/docker-clean.sh`
250-
* **WARNING**: This stops and removes **all** your Docker containers and images, not just DataHighway relates ones.
251-
252-
* Question: How to access the Docker container of a running node and run shell commands?
253-
* Answer: `docker exec -it node_alice_1 /bin/bash`, where `node_alice_1` is the Container Name that is shown when you run `docker ps -a`.
254-
255-
* Question: How do I restart the testnet Docker containers (including each chain databases)?
256-
* Answer: Run the following, where `node_alice_1` is a Container Name that is shown when you run `docker ps -a`.
257-
```bash
258-
docker stop node_alice_1 node_bob_1 node_charlie_1
259-
docker rm node_alice_1 node_bob_1 node_charlie_1
260-
docker-compose --verbose up -d
261-
docker-compose logs -f
262-
```
263-
264-
* Question: Why can't I syncronize my node?
265-
* Answer: Run `./scripts/docker-clean.sh` before starting them again with either `docker-compose up` or `docker-compose --verbose up -d; docker-compose logs -f`, incase a cached image is still being used locally
266-
* **WARNING**: This stops and removes **all** your Docker containers and images, not just DataHighway relates ones.
267-
268-
* Question: How do I run two nodes on the same host machine?
269-
* Answer:
270-
* Refer to "Testnet (Alpha) "testnet_latest" PoS testnet (with multiple nodes)" in [EXAMPLES](./EXAMPLES.md).
292+
The latest FAQ is still recorded on the DataHighway standalone codebase [here](https://github.com/DataHighway-DHX/node/blob/master/CONTRIBUTING.md#faq-), or modified in subsequent PRs.
293+
It will be migrated into the DataHighway/documentation codebase.
271294

272295
## Technical Support <a id="chapter-c00ab7"></a>
273296

0 commit comments

Comments
 (0)