I am using an Apple macOS with M1 processor when following the steps here https://docs.substrate.io/tutorials/v3/cumulus/start-relay/ I am using the versions specified here https://docs.substrate.io/tutorials/v3/cumulus/start-relay/#software-versioning (i.e. polkadot v0.9.16, substrate-parachain-template polkadot-v0.9.16 and Polkadot-JS Apps v0.103.2-8 from https://github.com/polkadot-js/apps/commit/0b6e52733181392e823f7c37e833f4f5fd6b16ef)
First I installed Substrate and Rust:
curl https://getsubstrate.io -sSf | bash -s -- --fast
wget -O - https://sh.rustup.rs | sh -s -- -y
PATH=$PATH:/root/.cargo/bin
rustup update stable
rustup update nightly
Then I cloned Polkadot-Launch:
mkdir -p ~/parachains
cd ~/parachains
git clone https://github.com/paritytech/polkadot-launch
cd ~/parachains/polkadot-launch
mkdir -p ~/parachains/polkadot-launch/bin
Then I built the Polkadot repository using v0.9.16 for the the relay chain node on the Rococo network, generated the relay chain specification, and convert it to a SCALE encoded raw chain spec for use when starting nodes. Then I copied across the Polkadot binary and the chain specifications to the Polkadot-Launch folder.
Note that stable-aarch64-apple-darwin
is required for an Apple M1 processor (otherwise you get illegal hardware instruction error) paritytech/subport#242 (comment)
git clone https://github.com/paritytech/polkadot
cd polkadot
git checkout v0.9.16
. ~/.cargo/env
PATH=$PATH:/root/.cargo/bin
rustup update stable
rustup toolchain install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup install stable-aarch64-apple-darwin
rustup default stable-aarch64-apple-darwin
rustup override set stable-aarch64-apple-darwin
cargo build --release
cp ./target/release/polkadot ~/parachains/polkadot-launch/bin/polkadot
./target/release/polkadot build-spec --chain=rococo-local --disable-default-bootnode > rococo-local.json
./target/release/polkadot build-spec --chain rococo-local.json --raw --disable-default-bootnode > rococo-local-raw.json
cp ./rococo-local.json ~/parachains/polkadot-launch
cp ./rococo-local-raw.json ~/parachains/polkadot-launch
[OPTION 1] Then I build the DataHighway-Parachain codebase
git clone https://github.com/DataHighway-DHX/DataHighway-Parachain
cd DataHighway-Parachain
./scripts/init.sh
cargo build --release
cp ./target/release/datahighway-collator ~/parachains/polkadot-launch/bin
[OPTION 2] Instead of building the DataHighway-Parachain codebase, you can alternatively build a fork of Substrate-Parachain-Template instead using v0.9.16 for the Cumulus-based parachain collators on the Rococo network.
I changed the parachain id values in the chain_spec.rs file from 1000 to 2000 (i.e. find/replace "1000.into()," with "2000.into(),", and find/replace "para_id: 1000," with "para_id: 2000,")
I also changed "" | "local"
to "" | "local" | "rococo-local"
in command.rs, so it would run in Polkadot-Launch.
After building it I copied across the Substrate-Parachain-Template binary to the Polkadot-Launch folder.
git clone https://github.com/ltfschoen/substrate-parachain-template
cd substrate-parachain-template
git remote add upstream https://github.com/substrate-developer-hub/substrate-parachain-template
git fetch upstream polkadot-v0.9.16:polkadot-v0.9.16
git checkout polkadot-v0.9.16
. ~/.cargo/env
PATH=$PATH:/root/.cargo/bin
rustup update stable
rustup toolchain install nightly-2021-11-07-x86_64-apple-darwin
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-11-07-x86_64-apple-darwin
rustup default nightly-2021-11-07-x86_64-apple-darwin
rustup override set nightly-2021-11-07-x86_64-apple-darwin
cargo build --release
cp ./target/release/parachain-collator ~/parachains/polkadot-launch/bin
Then I installed Dependencies including Node.js.
Then I modified the Polkadot-Launch config.json file to be as follows:
Note: If you used [OPTION 2] above then change ./bin/datahighway-collator
to ./bin/parachain-collator
in both places in the config.json file below.
{
"relaychain": {
"bin": "./bin/polkadot",
"chain": "rococo-local",
"nodes": [
{
"name": "alice",
"port": 30336,
"rpcPort": 9936,
"wsPort": 9947
},
{
"name": "bob",
"port": 30337,
"rpcPort": 9937,
"wsPort": 9948
},
{
"name": "charlie",
"port": 30338,
"rpcPort": 9938,
"wsPort": 9949
},
{
"name": "dave",
"port": 30339,
"rpcPort": 9939,
"wsPort": 9950
}
],
"genesis": {
"runtime": {
"runtime_genesis_config": {
"configuration": {
"config": {
"validation_upgrade_frequency": 10,
"validation_upgrade_delay": 10
}
}
}
}
}
},
"parachains": [
{
"bin": "./bin/datahighway-collator",
"chain": "rococo-local",
"id": "2000",
"nodes": [
{
"port": 31200,
"rpcPort": 9911,
"wsPort": 9988,
"name": "eve",
"flags": ["--", "--execution=wasm"]
}
]
},
{
"bin": "./bin/datahighway-collator",
"chain": "rococo-local",
"id": "3000",
"nodes": [
{
"port": 31300,
"rpcPort": 9922,
"wsPort": 9999,
"name": "ferdie",
"flags": ["--", "--execution=wasm"]
}
]
}
],
"hrmpChannels": [
{
"sender": 2000,
"recipient": 3000,
"maxCapacity": 8,
"maxMessageSize": 512
}
],
"types": {},
"finalization": false
}
Then I ran Polkadot-Launch
cd ~/parachains/polkadot-launch
git branch
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v16.3.0
nvm use v16.3.0
npm install -g yarn
yarn
cat ./config.json
RUST_BACKTRACE=1 yarn start config.json
If you used [OPTION 1] above, to add a further DataHighway collator node manually.
See https://docs.substrate.io/tutorials/v3/cumulus/connect-parachain/#connecting-additional-parachain-nodes
Note: If you used [OPTION 2] then the commands should start with ./target/release/parachain-collator
instead of ./target/release/datahighway-collator
- Build the raw chain specification for the "rococo-local" chain from our chain_spec.rs file. Note that we need to generate it from the binary that we copied across into Polkadot-Launch since that is the binary that we are using to run the other collator nodes. The files we need will be added into the cd DataHighway-Parachain folder. Then use that raw chain specification to export the genesis state and genesis WASM file for use in running further DataHighway collator nodes. See https://docs.substrate.io/tutorials/v3/cumulus/connect-parachain/
cd DataHighway-Parachain
~/parachains/polkadot-launch/bin/datahighway-collator build-spec --chain "rococo-local" --disable-default-bootnode > rococo-local-parachain-2000-plain.json
~/parachains/polkadot-launch/bin/datahighway-collator build-spec --chain rococo-local-parachain-2000-plain.json --raw --disable-default-bootnode > p;p
~/parachains/polkadot-launch/bin/datahighway-collator export-genesis-wasm --chain rococo-local-parachain-2000-raw.json > para-2000-wasm
~/parachains/polkadot-launch/bin/datahighway-collator export-genesis-state --chain rococo-local-parachain-2000-raw.json > para-2000-genesis
- Copy the "rococo" relay chain specification into the main directory. If you used [OPTION 1]
cd DataHighway-Parachain
cp ./res/rococo.json .
If you used [OPTION 2] then copy that file into the main directory of your clone of substrate-parachain-template
- Then if you used [OPTION 1] try to run another DataHighway collator node manually on your local machine with the following:
Note: If you used [OPTION 2] then the commands should start with
./target/release/parachain-collator
instead of./target/release/datahighway-collator
rm -rf /tmp/parachain/alice
./target/release/datahighway-collator \
--collator \
--alice \
--chain rococo-local-parachain-2000-raw.json \
--base-path /tmp/parachain/alice \
--bootnodes <INSERT_EXISTING_COLLATOR_BOOTNODE_FROM_POLKADOT_LAUNCH_LOGS> \
--name DataHighway-Collator-Alice \
--force-authoring \
--port 31400 \
--rpc-port 9933 \
--ws-port 9977 \
--unsafe-ws-external \
--unsafe-rpc-external \
--rpc-cors=all \
--rpc-methods=Unsafe \
-- \
--execution wasm \
--chain rococo-local-raw.json \
--port 30342 \
--rpc-port 9942 \
--ws-port 9953
Note: Obtain <INSERT_EXISTING_COLLATOR_BOOTNODE_FROM_POLKADOT_LAUNCH_LOGS> from the Polkadot-Launch logs. An example of what it outputs is the following, but the Local Node Identities may be different:
Added Boot Nodes: /ip4/127.0.0.1/tcp/30336/p2p/12D3KooWRxTiM5vAPZ9RNSgd7Uqwfa8bpx4MoNo2M1m4f34nrCot,/ip4/127.0.0.1/tcp/30337/p2p/12D3KooWAWqYpvBZvvmPJ8wQ5PeiCcv8XuFzjVQrT6JGyXyU72Fu
Now check that it works in the UI
git clone https://github.com/polkadot-js/apps
git checkout 0b6e52733181392e823f7c37e833f4f5fd6b16ef
nvm use v16.3.0
yarn
yarn start
Then go to http://localhost:3000/?rpc=ws%3A%2F%2F127.0.0.1%3A9988#/accounts and verify that you can transfer 1 UNIT from Alice to Bob