Skip to content

Instantly share code, notes, and snippets.

@sieemma
Last active November 23, 2023 10:10
Show Gist options
  • Save sieemma/27efce709c330a326f923df31e5d2d80 to your computer and use it in GitHub Desktop.
Save sieemma/27efce709c330a326f923df31e5d2d80 to your computer and use it in GitHub Desktop.
Setting up Joystream node and running a Validator

Running Joystream Node - Using Docker Approach

Hardware and other Requirements:

  1. Linux Kernel 5.16 or newer
  2. x86-64 compatible
  3. 4 physical cores @ 3.4GHz
  4. An NVMe SSD of 1 TB(Can be less than than this. Current chain size is around 75GB but it's still growing so choose size carefully)
  5. 16GB Memory
  6. The minimum symmetric networking speed is set to 500 Mbit/s
  7. Currently, at least 41.667k JOY in a single account, which is the minimum to sign up – actually getting a validator slot likely requires more
  8. Docker

Let's Start!

Install docker

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install docker package

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Test docker installation

docker run hello-world

Check your docker compose version

docker compose version Above V2.x is cool

Joystream Node Setup as Root

mkdir joystream-node
cd joystream-node
wget https://github.com/Joystream/joystream/releases/download/v12.1000.0/joy-mainnet.json
cd ~/
git clone https://github.com/Joystream/joystream.git
cd joystream

nano .env

make sure the variable below exist and uncommented by removing #

JOYSTREAM_NODE_TAG=latest

save and exit(ctrl + x, then y and enter key)

Edit service joystream-node of the docker compose file

nano docker-compose.yml

    image: joystream/node:$JOYSTREAM_NODE_TAG
    restart: unless-stopped
    container_name: joystream-node
    volumes:
      - /root/.local/share/joystream-node/chain-data:/data
      - /root/.local/share/joystream-node:/root/.local/share/joystream-node
      - /root/joystream-node:/root/joystream-node
    env_file:
      # relative to working directory where docker-compose was run from
      - .env
    command: --chain /root/joystream-node/joy-mainnet.json --pruning archive --validator --name <memberId-memberHandle> --unsafe-ws-external --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors all --prometheus-port 9615 --prometheus-external --base-path /data
    expose:
      - 9615
    ports:
      - "127.0.0.1:9944:9944"
      - "127.0.0.1:9933:9933"
      #- "127.0.0.1:9615:9615"
      - "30333:30333"

Note

Only the above should appear in the joystream service. You can delete the whole content of the joystream service and paste the above there. Change the name to how you would like your validator node to be called in line:

command: --chain /root/joystream-node/joy-mainnet.json --pruning archive --validator --name <memberId-memberHandle> --unsafe-ws-external --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors all --prometheus-port 9615 --prometheus-external --base-path /data

Look for the above line in the joystream service and change <memberId-memberHandle> to your preferred name.

Example, mine will look like:

command: --chain /root/joystream-node/joy-mainnet.json --pruning archive --validator --name sieemma --unsafe-ws-external --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors all --prometheus-port 9615 --prometheus-external --base-path /data

Save and exit.

Spin the container up

docker-compose up --detach --build joystream-node

Check docker logs to verify if it's synching

docker logs -f -n 10 joystream-node

You can also use telemetry: https://telemetry.polkadot.io/#/0x6b5e488e0fa8f9821110d5c13f4c468abcd43ce5e297e62b34c53c3346465956

If your node is still synching, you should see it below the list of nodes. You can click on it once to pin it to the top.

Wait for your node to catch up before continuing.

Assuming your node is fully synched, the next thing to do is to:

Setup Keys and Validate Generate Session Keys

On the machine(vps or whatever) where your joystream node is running, do:

  curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://localhost:9933

It should return

  {"jsonrpc":"2.0","result":"0xabc...123","id":1}

Where 0xabc...123 is a long string that was displayed on your screen. Copy and save it. This is your session key that you would be needing.

Caution

Please, do not repeat the above command twice on the same machine as it will create multiple session keys on the same machine. This is an offence in Joystream blockchain which is penalized

You can confirm that you do not have multiple session keys on the same machine by doing this:

ls -a ~/.local/share/joystream-node/chain-data/chains/joy_mainnet/keystore

Which should return 4 files, each a long string starting with a 6

Configure Validator on Chain

To continue, you must have polkadot extension installed. If noy installed yet, get it here: https://polkadot.js.org/extension/

Create two accounts on the polkadot wallet extension and name them as controller(This will be used for making transactions related to the validator) and stash(This will hold your amount of JOY to stake for validation) Note: This is not mandatory but it helps to recognize which of your accounts is use for what.) If you have two accounts already, you can skip this step) If you have the minimum JOY tokens, transfer them to your stash account. Transfer some JOY to your controller account as well for transaction fees.

Let's do this on the blockchain: Go to https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.joystream.org#/staking

Make sure the network is Joystream and not any other network. If it isn't joystream, switch to joystream this is done

Next Steps:

  1. Go to the "staking actions" tab - "Network" -> "Staking" -> "Accounts"(https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.joystream.org#/staking/actions), and click the "+ Validator" button in the top right corner.
  2. Select a stash and controller account from the dropdown, set the "value bonded" as the amount you want to stake, and choose a "payment destination", then hit "next".
  3. Paste in the public session keys (0xabc...123), choose a "reward commission percentage" and whether you want to allow nominations or not, then click "Bond & Validate".
  4. If you are preparing this for later, click the "+ Stash" button instead. This allows you to wait for your session keys and/or synching your node.

References

https://handbook.joystream.org/system/validation

https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

https://github.com/yasiryagi/community-repo/tree/master/working-groups/storage-group/NodeSteup/joystream-node

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