Configure node
Below you can find guide how to configure and start your node.
Obtain master key
Before starting your node, you should obtain epoch keys, which will be used to encrypt and decrypt transactions and smart contract state.
To do it, use one of the following commands:
EPID Remote Attestation:
DCAP Remote Attestation:
The command above will pass Remote Attestation, during which, another node checks whether the correct software and hardware are used. If the command returns you same output as shown below, it means your node is ready to work:
Initialize Node
Monikers can only contain ASCII characters. The use of Unicode characters is not supported and will render the node unreachable.
Please replace YOUR_MONIKER
with your own moniker.
The moniker
can be edited in the ~/.swisstronikd/config/config.toml
file:
Download the Genesis File
After initializing the node, download the genesis file and move it to the /config directory within the Swisstronik home directory.
Set Gas Prices
A full node keeps unconfirmed transactions in its mempool. To protect it from spam, it is advisable to set a minimum-gas-prices
that the transaction must meet to be accepted in the node's mempool. This parameter can be configured in ~/.swisstronikd/config/app.toml
.
Configure Seed
It is our best practice to use a seed node for bootstrapping. Alternatively, you can use persistent_peers.
Specify pruning option
This is an optional configuration
There are four strategies for pruning the state. These strategies apply only to the state and do not apply to block storage. A node operator may consider custom pruning if node storage is a concern or if there is an interest in running an archive node.
To set pruning, adjust the pruning
parameter in the ~/.swisstronikd/config/app.toml
file. The following pruning state settings are available:
everything
: Prune all saved states other than the current state.nothing
: Save all states and delete nothing.default
: Save the last 100 states and the state of every 10,000th block.custom
: Specify pruning settings with thepruning-keep-recent
,pruning-keep-every
, andpruning-interval
parameters.
By default, every node is in default
mode, which is the recommended setting for most environments. If a node operator wants to change their node's pruning strategy, this must be done before the node is initialized.
In ~/.swisstronikd/config/app.toml
Passing a flag when starting swisstronikd
will always override settings in the app.toml
file. To change the node's pruning setting to everything
mode pass the ---pruning everything
flag when running swisstronikd start
.
If the node is running with a pruned state, querying heights that are not in the node's store will not be possible.
REST API
This is an optional configuration
By default, the REST API is disabled. To enable the REST API, edit the ~/.swisstronikd/config/app.toml
file, and set enable
to true
in the [api]
section.
EVM JSON-RPC and Websockets
This is an optional configuration
By default, EVM JSON-RPC and Websockets are set to use ports 127.0.0.1:8545
and 127.0.0.1:8546
. You can expose them by changing those values in ~/.swisstronikd/config/app.toml
Launch Node
Cosmovisor
Setting up Cosmovisor is relatively straightforward. However, it expects certain environment variables and folder structure to be set.
Install
First, go and get cosmovisor (recommended approach):
You can set it to false by running the command
You can confirm your installation with:
Add environment variables to your shell.
In the .profile
file, usually located at ~/.profile
, add:
Next, source your profile to gain access to these variables:
You can confirm success by executing:
It should return swisstronikd
.
Set up folder structure
Cosmovisor expects a certain folder structure:
Don't worry about current
- that is simply a symlink used by Cosmovisor. The other folders will need setting up, but this is easy:
Set up genesis binary
Cosmovisor needs to know which binary to use at genesis. We put this in $DAEMON_HOME/cosmovisor/genesis/bin
.
First, find the location of the binary you want to use:
Then use the path returned to copy it to the directory Cosmovisor expects. Let's assume the previous command returned /home/your-user/go/bin/swisstronikd
:
Cosmovisor init
Post v1 versions of Cosmovisor include a command that creates the directories and copy the swisstronikd
binary into the proper directory. To execute this process, use the following command:
Once you're done, check that the folder structure looks correct using a tool like tree
.
Setting up the service
Commands sent to Cosmovisor are sent to the underlying binary. For example, cosmovisor version
is the same as typing swisstronikd version
.
Nevertheless, similar to managing swisstronikd
using a process manager, we want to ensure that Cosmovisor is automatically restarted in case of events like errors or reboots.
First, create the service file:
Modify the content below to match your setup.cosmovisor
is likely located at ~/go/bin/cosmovisor
irrespective of the installation path you chose above, but it's worth verifying.
Note cosmovisor run start
is only for the latest versions of cosmovisor. For earlier versions that line should be:
Download Snapshot
Refer to our snapshot docs to download and extract Swisstronik testnet snapshot.
Start Cosmovisor
If syncing from a snapshot, do not start Cosmovisor yet.
Finally, enable the service and start it.
Verify that it is running by using:
If you need to monitor the service after launch, you can view the logs by using:
Other considerations
This installation guide is the bare minimum to get a node started. As you progress and gain experience as a node operator, consider the following:
Configure firewall to close most ports leaving only the p2p port (typically 26656);
Use custom ports for each node so you can run multiple nodes on the same server.
If you encounter any issues or discover a bug in this installation guide, please reach out to us and inform us.
Last updated