Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Last active February 20, 2022 12:34
Show Gist options
  • Save ltfschoen/44db460c02b23aa6562e3567cfac4659 to your computer and use it in GitHub Desktop.
Save ltfschoen/44db460c02b23aa6562e3567cfac4659 to your computer and use it in GitHub Desktop.
Errors in polkadot-launch after combining a JSON file with other accounts to be endowed at genesis

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)

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

Then I built a fork of Substrate-Parachain-Template using v0.9.16 for the Cumulus-based parachain collators on the Rococo network. The branch "luke/polkadot-v0.9.16/endow" contains the changes proposed by Bruno in this Substrate StackExchange response https://substrate.stackexchange.com/a/303/83 that I have applied. 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 build 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 fetch origin luke/polkadot-v0.9.16/endow:luke/polkadot-v0.9.16/endow
git checkout luke/polkadot-v0.9.16/endow
. ~/.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:

{
  "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/parachain-collator",
          "chain": "rococo-local",
          "id": "2000",
          "nodes": [
              {
                  "port": 31200,
                  "rpcPort": 9911,
                  "wsPort": 9988,
                  "name": "eve",
                  "flags": ["--", "--execution=wasm"]
              }
          ]
      },
      {
          "bin": "./bin/parachain-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

However I get errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment