Run Your Own Node
Requirements
System Requirements We recommend consulting the standard hardware section of the Polkadot Wiki for specs.
Below we describe two ways of running our chain node:
Docker Container This is the recommended way to experiment with your own node. It will get you started within 5 minutes. Since docker is running pre-build containers, this setup minimizes the steps required to get started and isolates any potential issues.
Bare Metal Running a bare metal setup requires you to compile centrifuge chain from source, which can take between a 10 minutes up to 4 hours, depending on your specs. For a production grade setup, we do recommend to run a bare metal validators for 2 reasons: a) It minimizes the tools involved, which increases security, b) The performance is slightly supperior.
Run your node in a Docker Container
- Ensure you have docker as well as subkey installed. Use
subkey
versionv2.0.0
. - Generate a new key pair with subkey that will be used as your node-key:
subkey generate
. Make sure you save the output in a safe place. For mainnet keys use network flag:subkey generate -n centrifuge
- Start your node by running the following, where {name} is the name that will show up in Polkadot Telemetry and {node-key} is the private key you just generated (without the
0x
prefix). Note that we do expose RPC and WS ports here for simplicity – these ports should not be exposed in a production grade setup.
a) Flint:
1docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 --rm -it centrifugeio/centrifuge-chain:20201022093419-da56ac5 centrifuge-chain --validator --name="{name}" --node-key={node-key} --chain=flint --bootnodes=/ip4/35.246.197.135/tcp/30333/p2p/12D3KooWBF1RdctVztxLLzEwUiuMtqEDVicCjVCS8eyxh71nonxz --bootnodes=/ip4/34.89.219.76/tcp/30333/p2p/12D3KooWNHRdve4U1rsZsDnTKbY8C94Y7VJTrifBy9P2LXLDhCnG --unsafe-rpc-external --unsafe-ws-external --rpc-cors="*"
b) Amber:
1docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 --rm -it centrifugeio/centrifuge-chain:20201022093419-da56ac5 centrifuge-chain --validator --name="{name}" --node-key={node-key} --chain=amber --bootnodes=/ip4/34.107.94.59/tcp/30333/p2p/12D3KooWQ3YL8sP2M1S9PVNj8JjmACUjawwRPckzL8fJmXZ7YRPY --bootnodes=/ip4/35.242.247.213/tcp/30333/p2p/12D3KooWECFKJirQiVHeidSkwrEocPr7wkUw3ijbJKNyvCVd3xcu --unsafe-rpc-external --unsafe-ws-external --rpc-cors="*"
c) Mainnet:
1docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 --rm -it centrifugeio/centrifuge-chain:20201022093419-da56ac5 centrifuge-chain --validator --name="{name}" --node-key={node-key} --chain=mainnet --bootnodes=/ip4/34.89.245.58/tcp/30333/p2p/12D3KooWAVAMPNJywZS3J4be8gFGZACfgt1rXS3MyJ2MxEGtLXjr --bootnodes=/ip4/35.246.188.4/tcp/30333/p2p/12D3KooWCUjDbbhJf1o6skuE1EJ5PnKpJMaK6scmvWsHnjAULzDU
** Mainnet deployments should follow a more secure setup. Learn more here: https://github.com/w3f/polkadot-secure-validator
- Generate new session keys in your node's keystore by running:
curl -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"author_rotateKeys", "id": 1 }' http://127.0.0.1:9933
This command will return the public keys under the "result" field starting with0x...
, which you should copy in order to use them in the next chapter.
Bare metal instructions
Install dependencies:
a) On Unix systems (Debian, Ubuntu, ...):
sudo apt install -y cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev
b) On MacOS:
brew install openssl cmake llvm
Install Rust:
curl https://sh.rustup.rs -sSf | sh
Make sure that you are using the latest Rust stable by default:
rustup default stable
Install nightly for WASM support:
1RUST_TOOLCHAIN=nightly2rustup update $RUST_TOOLCHAINIf above does not work, use:
1RUST_TOOLCHAIN=nightly-2020-08-162rustup update $RUST_TOOLCHAIN34rustup toolchain install $RUST_TOOLCHAIN5rustup default $RUST_TOOLCHAIN67rustup target add wasm32-unknown-unknown --toolchain $RUST_TOOLCHAINAdd the WASM target:
rustup target add wasm32-unknown-unknown --toolchain $RUST_TOOLCHAIN
Clone centrifuge-chain:
git clone -b v2.0.0-rc6.0 git@github.com:centrifuge/centrifuge-chain.git
Change directory:
cd centrifuge-chain
Optional - run the tests:
cargo test --all
Build Centrifuge Chain:
cargo build --release
Ensure you have subkey installed (can be on another machine).
Generate a new key pair with subkey that will be used as your node-key:
subkey generate
. Make sure you save the output in a safe place.
The node is now built and available in target/release/centrifuge-chain
.
Executing the binary
Below are the commands to start a node as a validator. {name}
is the name that will show up in Polkadot Telemetry and {node-key}
is the private key (Secret seed
in the output of subkey) you just generated (without the 0x prefix).
To run the node for Flint you can use:
1./target/release/centrifuge-chain --validator --name="{name}" --node-key={node_key} --chain=flint --bootnodes=/ip4/35.246.197.135/tcp/30333/p2p/12D3KooWBF1RdctVztxLLzEwUiuMtqEDVicCjVCS8eyxh71nonxz --bootnodes=/ip4/34.89.219.76/tcp/30333/p2p/12D3KooWNHRdve4U1rsZsDnTKbY8C94Y7VJTrifBy9P2LXLDhCnG
or Amber:
1./target/release/centrifuge-chain --validator --name="{name}" --node-key={node_key} --chain=amber --bootnodes=/ip4/34.107.94.59/tcp/30333/p2p/12D3KooWQ3YL8sP2M1S9PVNj8JjmACUjawwRPckzL8fJmXZ7YRPY --bootnodes=/ip4/35.242.247.213/tcp/30333/p2p/12D3KooWECFKJirQiVHeidSkwrEocPr7wkUw3ijbJKNyvCVd3xcu
Mainnet:
1./target/release/centrifuge-chain --validator --name="{name}" --node-key={node_key} --chain=mainnet --bootnodes=/ip4/34.89.245.58/tcp/30333/p2p/12D3KooWAVAMPNJywZS3J4be8gFGZACfgt1rXS3MyJ2MxEGtLXjr --bootnodes=/ip4/35.246.188.4/tcp/30333/p2p/12D3KooWCUjDbbhJf1o6skuE1EJ5PnKpJMaK6scmvWsHnjAULzDU
Creating a service
For your convenience, below are templates for running it as a systemd service:
Create a service, where {pwd} is your current working directory, {name}
is the name that will show up in Polkadot Telemetry and {node-key}
is the private key (Secret seed
in the output of subkey) you just generated (without the 0x prefix).
Copy below template to /etc/systemd/system/centrifuge-chain.service
and replace the {}
placeholders with your local settings.
a) Flint:
1[Unit]2Description=Centrifuge Chain Validator3After=network.target4StartLimitIntervalSec=056[Service]7Type=simple8Restart=always9RestartSec=110ExecStart={pwd}/target/release/centrifuge-chain --validator --name="{name}" --node-key={node_key} --chain=flint --bootnodes=/ip4/35.246.197.135/tcp/30333/p2p/12D3KooWBF1RdctVztxLLzEwUiuMtqEDVicCjVCS8eyxh71nonxz --bootnodes=/ip4/34.89.219.76/tcp/30333/p2p/12D3KooWNHRdve4U1rsZsDnTKbY8C94Y7VJTrifBy9P2LXLDhCnG1112[Install]13WantedBy=multi-user.target
b) Amber:
1[Unit]2Description=Centrifuge Chain Validator3After=network.target4StartLimitIntervalSec=056[Service]7Type=simple8Restart=always9RestartSec=110ExecStart={pwd}/target/release/centrifuge-chain --validator --name="{name}" --node-key={node_key} --chain=amber --bootnodes=/ip4/34.107.94.59/tcp/30333/p2p/12D3KooWQ3YL8sP2M1S9PVNj8JjmACUjawwRPckzL8fJmXZ7YRPY --bootnodes=/ip4/35.242.247.213/tcp/30333/p2p/12D3KooWECFKJirQiVHeidSkwrEocPr7wkUw3ijbJKNyvCVd3xcu1112[Install]13WantedBy=multi-user.target
c) Mainnet:
1[Unit]2Description=Centrifuge Chain Validator3After=network.target4StartLimitIntervalSec=056[Service]7Type=simple8Restart=always9RestartSec=110ExecStart={pwd}/target/release/centrifuge-chain --validator --name="{name}" --node-key={node_key} --chain=mainnet --bootnodes=/ip4/34.89.245.58/tcp/30333/p2p/12D3KooWAVAMPNJywZS3J4be8gFGZACfgt1rXS3MyJ2MxEGtLXjr --bootnodes=/ip4/35.246.188.4/tcp/30333/p2p/12D3KooWCUjDbbhJf1o6skuE1EJ5PnKpJMaK6scmvWsHnjAULzDU1112[Install]13WantedBy=multi-user.target
To run the service:
- Start your service:
systemctl start centrifuge-chain
- Enable automatic restarts of your service after every boot:
systemctl enable centrifuge-chain
- To view and follow your logs, run
tail -f /var/log/syslog