Docker Install
Set up a Sidechain Operator Node (SON) using a pre-configured Docker container
This document assumes that you are running Ubuntu 18.04. Other Debian based releases may also work with the provided script.
This tutorial will take you through the steps required to have an operating SON. Since SONs serve the purpose of facilitating transfers of assets between the Peerplays blockchain and other blockchains, we'll need to connect to another chain to be of any use...
Let's use Bitcoin! 😎
The following steps outline the Docker installation of a (Bitcoin enabled) SON:
Preparing the Environment
Installing Docker
The Bitcoin node
Installing the
peerplays:son
imageStarting the environment
Using the CLI wallet
Update
config.ini
with SON Account Info
Before we begin, to set up a SON node requires about 110 PPY. This is to pay for an upgraded account (5 PPY) and to fund two vesting balances (50 PPY each). The remaining funds are to pay for various transaction fees while setting up the node. Please see Obtaining Your First Tokens for more info.
Note that these fees will likely change over time as recommended by the Committee of Advisors.
1. Preparing the Environment
1.1. Hardware requirements
Please see the SON hardware requirements.
For the docker install, we'll be using a self-hosted Bitcoin node. The requirements that we'll need for this guide are as follows (as per the hardware requirements docs):
Bitcoin node type
CPU
Memory
Storage
Bandwidth
OS
Self-Hosted, Reduced Storage
2 Cores
16GB
150GB SSD
1Gbps
Ubuntu 18.04
1.2. Installing the required dependencies
Then we'll clone the Peerplays Docker repository.
2. Installing Docker
It is required to have Docker installed on the system that will be performing the steps in this document.
Docker can be installed using the run.sh
script inside the Peerplays Docker repository:
Since the script has added the currently logged in user to the Docker group, you'll need to re-login (or close and reconnect SSH) for Docker to function correctly. You can check to see if the current user belongs to the Docker group with the groups
command. If the Docker group is still not listed after a re-login, you'll have to reboot the machine with sudo reboot
(This will be the case if your using Ubuntu 20.04).
You can look at https://docs.docker.com/engine/install/ to learn more on how to install Docker. Or if you are having permission issues trying to run Docker, use sudo
or look at https://docs.docker.com/engine/install/linux-postinstall/.
2.1. Setting up the .env file
Copy the example.env
to .env
located in the root of the repository:
We're going to have to make some changes to the .env
file so we'll open that now using the Vim editor.
Here are the important parts of the .env
file. These will be the parts that need to be edited or optionally edited. The rest of the file should be unchanged.
3. Connect to Bitcoin Network and Generate an Address
There are two options available to connect to the Bitcoin network.
Run a Bitcoin node yourself
Find an open Bitcoin node to connect to
For the purposes of this guide, I'll discuss how to run a node yourself as that will be a more reliable connection for now. Either way you go, you'll need to collect the following information to use in the config.ini
file:
The IP address of a Bitcoin node you can connect to (127.0.0.1 if self-hosting)
ZMQ port of the Bitcoin node (default is 1111)
RPC port of the Bitcoin node (default is 8332)
Bitcoin RPC connection username (default is 1)
Bitcoin RPC connection password (default is 1)
Bitcoin wallet label (default is son-wallet)
Bitcoin wallet password
A new Bitcoin address
The Public key of the Bitcoin address
The Private key of the Bitcoin address
3.1. Install Bitcoin-core
First we'll download and install one of the official Bitcoin Core binaries:
The official Bitcoin Core binaries can be found here: https://bitcoincore.org/en/download/
The latest version is 0.21.1 as of July 2021. You may want to find and download the latest version of the binaries just like you would for the 0.21.1 version above.
Then we make a config file to manage the settings of our new Bitcoin node.
in the Vim text editor we'll set the following (You can copy and paste the content of this complete config file):
Save and quit the Vim editor.
The settings in the config file above are set to reduce the requirements of the server. Block pruning and setting the node to Blocks Only save network and storage resources. For more information, see https://bitcoin.org/en/full-node#reduce-storage.
Lastly we'll set a Cron job to ensure the Bitcoin node starts up every time the server starts.
At the bottom of the crontab file, add the following:
Save and quit the crontab file. Now we're ready to fire up the Bitcoin node!
If successful, you'll see Bitcoin Core starting
. As an extra check to see if everything is working, try the bitcoin-cli -version
or bitcoin-cli getblockchaininfo
commands.
You can also use this website to check the status of your node: https://bitnodes.io/
If you use the Bitnodes website, your node will appear as "down" until it's almost done downloading and verifying the Bitcoin chain. This can take a while.
Your Bitcoin node should now be downloading the Bitcoin blockchain data from other nodes. This might take a few hours to complete even though we cut down the requirements with block pruning. It's a lot of data after all.
3.2. Use the bitcoin-cli program to make a new wallet
We'll need a wallet to store your Bitcoin address.
At this point we hit a fork in the road! You'll need to do one of the following:
Option 1: Generate a new Bitcoin address to use for your SON node. (see 3.2.a. below)
Option 2: Import an existing Bitcoin address to use for your SON node. (see 3.2.b. below)
Either way, you'll need the Bitcoin address, its public key, and its private key.
3.3.a. Make a new Bitcoin address
Now we will create a Bitcoin address.
Then we'll use this address to get its keys.
Now we get the private key.
3.3.b. Import an existing Bitcoin address
You don't need to do this if you made a new address in step 3.3.a. above!
Now we will import an existing Bitcoin address. You'll need the private key of the existing address which should be obtainable from your current wallet. You may not be able to get the private key from online or cloud wallet providers (contact their support teams for assistance with this.)
Then you can get the public key with the getaddressinfo
command.
3.4. A quick recap
That was a lot to go over. Let's collect our data. Here's an example:
Keep your tuple handy. We'll need it in the Peerplays config file.
4. Installing the peerplays:son image
Use run.sh
to pull the SON image:
4.1. Setting up config.ini file
There are many example configuration files, make sure to copy the right one. In this case it is: config.ini.son-exists.example
Copy the correct example configuration:
We'll need to make an edit to the config.ini
file as well.
The important parts of the config.ini
file (for now!) should look like the following. But don't forget to add your own Bitcoin public and private keys!
Save the file and quit.
5. Starting the environment
Once the configuration is set up, use run.sh
to start the peerplaysd and bitcoind containers:
The SON network will be created and the seed (peerplaysd) and bitcoind-node (bitcoind) containers will be launched. To check the status, inspect the logs:
If the logs are throwing errors, perform a replay.
6. Using the CLI wallet
After starting the environment, the CLI wallet for the seed (peerplaysd) will be available.
6.1. Connecting to the blockchain with the CLI Wallet
Open another terminal and use docker exec
to connect to the wallet.
If an exception is thrown and contains Remote server gave us an unexpected chain_id
, then copy the remote_chain_id
that is provided by it. Pass the chain ID to the CLI wallet:
Set a password for the wallet and then unlock it:
The CLI wallet will show unlocked >>>
when successfully unlocked
A list of CLI wallet commands is available here: https://devs.peerplays.tech/api-reference/wallet-api/wallet-calls
Assuming we're starting without any account, it's easiest to create an account with the Peerplays GUI Wallet. The latest release is located here: https://github.com/peerplays-network/peerplays-core-gui/releases/latest. When you create an account with the GUI wallet, you should have a username and password. We'll need those for the next steps. First we'll get the private key for the new account.
The key beginning with "PPY" is the public key. The other key is the private key. We'll need to import this private key into the cli_wallet.
Next we'll upgrade the account to a lifetime membership.
At the time of writing this guide, it costs 5 PPY to perform this operation. You'll need that in your account first! To this end, check out Obtaining Your First Tokens.
Next we'll create the vesting balances.
Now we have all the info we need to create a SON account.
To get the SON ID:
We'll set the signing key using the active key from the owning account:
Now we have our SON account ID and the public and private keys for the SON account. We'll need this for the config.ini
file.
7. Update config.ini with SON Account Info
Lets stop the node for now so we can finish up the config.ini
.
Ensure the following config settings are in the config.ini
file under the peerplays_sidechain plugin options.
Then it's just a matter of starting the node back up!
Your SON is now good to go!
8. What's Next?
8.1. Auto-starting your node
Up until this point we have been running the node in the foreground which is fragile and inconvenient. So let's start the node as a service when the system boots up instead.
Auto-Starting a Node8.2. Creating a backup node
After that, it would be smart to create a backup server to enable you to make software updates, troubleshoot issues with the node, and otherwise take your node offline without causing service outages.
Backup Servers8.3. Configure more sidechains
Why stop at Bitcoin?
8.4. Fire up another node 🔥
Now you have a SON, but have you thought about becoming a Witness? It will be a piece of cake for you since you've already set up a SON.
Witnesses8.5. Enable SSL to encrypt your node traffic
If you have a node that is accessible from the internet (for example, an API or Seed node) it would be wise to enable SSL connections to your node.
Reverse Proxy for Enabling SSL9. Glossary
SON: Sidechain Operator Node - An independent server operator which facilitates the transfer of off-chain assets (like Bitcoin or Ethereum tokens) between the Peerplays chain and the asset's native chain.
Witness: An independent server operator which validates network transactions.
Witness Node: Nodes with a closed RPC port. They don't allow external connections. Instead these nodes focus on processing transactions into blocks.
10. Related Documents
Vim is a text editing program available for Ubuntu 18.04. See vim.org
Last updated