Pocket configuration
Configure your Pocket node. Part 3 of 5 in the Zero to Node tutorial.
This section will help you configure your instance of Pocket.
Create a Pocket wallet account
Pocket nodes are associated with a Pocket wallet account. This is the account that will be used to send and receive transactions from the node. You can either create a new account using the Pocket CLI we just installed, or you can use an existing account. For this guide, we'll be creating a new account.
Creating an account
To create an account, run the following command:
You'll be prompted to set a passphrase for the account. You can use any passphrase you like but for security reasons, it's best to use a passphrase that is at least 12 characters long, preferably longer.
Listing accounts
After you've created the account you can use the pocket accounts list
command to confirm that the account was added successfully.
Setting the validator address
Next, to set the account as the one the node will use, run the following command:
Confirm the validator address
Finally, you can confirm that the validator address was set correctly by running the following command:
Create config.json
config.json
The Pocket core software uses a config file to store configuration details. By default the config file is located at ~/.pocket/config/config.json
. In this step we'll look at how to create a new config file.
To create a new config file:
Run the following command, which will create the default
config.json
file, add the seeds, set port 8081 to 8082, and increase the RPC timeout value:This is a long command! Make sure you've copied it completely.
Verify the
config.json
file setting by viewing the contents of the file:
Create chains.json
chains.json
Pocket nodes relay transactions to other blockchains. So, you'll need to configure the chains your node can relay to. For this guide, we'll just be setting up our node to relay to the Pocket mainnet blockchain, essentially through itself.
To maximize your rewards, you'll want to relay to other chains. We'll cover that in more detail later but here is a list of other blockchains you could relay to.
Generating a chains.json
file with the CLI
chains.json
file with the CLIYou can use the Pocket CLI to generate a chains.json
file for your node by running the following command:
This will prompt you for the following information:
Enter the ID of the Pocket network identifier:
Enter the URL of the network identifier. Use
http://127.0.0.1:8081/
if you're not running a validator node:
When you're prompted to add another chain, enter n
for now.
By default the chains.json
file will be created in ~/.pocket/config
. You can use the --datadir
flag to create the chains.json file in an alternate location. For example: pocket util generate-chains --datadir "/mnt/data/.pocket"
.
Create genesis.json
genesis.json
Now that we have a chains.json
file set up, so we can move on to test our node.
When you start a Pocket node for the first time, it will need to find other nodes (peers) to connect with. To do that we use a file named genesis.json
with details about peers the node should connect to get on the network.
To create a JSON file with the genesis information:
Change to the
.pocket/config
directory:Use the following command to get the
genesis.json
file from GitHub:
Set open file limits
Ubuntu and other UNIX-like systems have a ulimit
shell command that's used to set resource limits for users. One of the limits that can be set is the number of open files a user is allowed to have. Pocket nodes will have a lot of files open at times, so we'll want to increase the default ulimit for the pocket
user account.
Increasing the ulimit
Before increasing the ulimit, you can check the current ulimit with the following command:
Increase the ulimit to 16384. The
-Sn
option is for setting the soft limit on the number of open files:Check the new ulimit to confirm that it was set correctly. The
-n
option is for getting the limit for just the number of open files:
Permanent settings
Using the above method for setting the ulimit
only keeps the change in effect for the current session. To permanently set the ulimit, you can do the following:
Open the
/etc/security/limits.conf
file.Add the following line to the bottom of the file:
Save the file with
Ctrl+O
and thenEnter
.Exit nano with
Ctrl+X
.
After permanently setting the ulimit, the next thing we'll do is download a snapshot of the Pocket blockchain.
Download snapshot
Rather than synchronizing your Pocket node from block zero (which could take weeks), you can use a snapshot. A snapshot of the Pocket blockchain is taken every 12 hours and can be downloaded using the instructions on the Pocket Snapshots Repository README page.
As of this writing, the snapshots are refreshed every 12 hours. In the GitHub repo you can look at when the README.md
file was last updated to determine when the last snapshot was taken. It's best to download the snapshot that is less than a few hours old.
Here are the steps for download the snapshot using the wget
command:
Change into the
.pocket
directory.Make a directory named
data
and change into it.Download the latest snapshot using the following command:
Make the
pocket
user the owner of thedata
directory.
This process can take a few hours depending on your internet connection.
Configure systemd
Next, we'll configure the Pocket service using systemd, a Linux service manager. This will enable the Pocket node to run and restart even when we're not logged in.
Creating a systemd service in Linux
To setup a systemd service for Pocket, do the following:
Open nano and create a new file called
pocket.service
:Add the following lines to the file:
Make sure the
User
is set to the user that will run the Pocket service.Make sure the
ExecStart
andExecStop
paths are set to the path for the Pocket binary.Save the file with
Ctrl+O
and thenreturn
.Exit nano with
Ctrl+X
.Reload the service files to include the pocket service:
Start the pocket service:
Verify the service is running:
Stop the pocket service:
Verify the service is stopped:
Set the service to start on boot:
Verify the service is set to start on boot:
Start the pocket service:
Other systemctl commands
To restart the service:
To prevent the service from starting on boot:
To see mounted volumes:
Viewing the logs
To view the logs for the pocket service:
To view just the last 100 lines of the logs (equivalent to the tail -f
command):
Finding Errors
You can use grep
to find errors in the logs.
Alright, we're just about done. We just need to setup an HTTP proxy and we'll be ready to go live. We'll setup the proxy next.
Last updated