How to deploy a Neo node in 5 Steps on ThreeFold Grid?

image

Dear Friends,

This post is intended for friends at Neo :slightly_smiling_face:. Both ThreeFold and Neo share common values and there is an enormous potential that can be exploited together, especially when it comes to leveraging ThreeFold’s peer to peer cloud network .

We will quickly demonstrate how to setup a Neo node on the ThreeFold Grid . The purpose here is to get people started. The configuration can be tweaked to perfection with other experts in the community.

Most of the deployments have a common pattern and just require a change in the underlying flist and inputs. The rest of the process for all deployments is more or less the same.

What we will do ?

  1. Setup your 3bot and install the 3sdk
  2. Log in and create your Network
  3. Get your wallet loaded :slightly_smiling_face: , don’t worry, we have FreeTFTs
  4. Deploy your Neo container
  5. Access your Neo container
  6. Verify your Neo deployment

Before you start, we have 2 networks publicly available

  1. Mainnet @ https://explorer.grid.tf
  2. Testnet @ https://explorer.testnet.grid.tf

Our Recommendation : *Start deploying on testnet as ThreeFold gives free nodes to deploy and play around with. Mainnet is production and paid for. Therefore, from settings in the 3sdk menu, switch to TESTNET *

Step 1 - Setup the 3sdk

The 3sdk is a tool that allows you to setup your 3bot and give you access to the ThreeFold Grid for your deployments (containers, virtual machines, S3 storage and so on). The wiki provides detailed instructions on how to set up the 3sdk .

If this part is done, rest should be extremely easy as management is done via web interface.

To access the 3sdk admin interface, in your browser use the following link,

http://YOUR_IP_HERE:7000 or https://YOUR_IP_HERE:4000

7000 is the http port and 4000 is the https port

If you installed locally on your machine, you can use http://localhost:7000

Step 2 - Log in and Create your Network for Deployment

From the previous step, http://YOUR_IP_HERE:7000

Log in here with your 3bot. Make sure you open the 3bot connect app first!

Once you log in, Go to Solutions and then go to Network . The interface is user-friendly and it should be easy. Few things to note,

  • Use IPv4 network unless you are sure you have IPv6. You can test IPv6 connectivity here
  • It is better to have the chat bot configure the network for you unless you have specific requirements
  • Ideally start with FreeTFT as your network currency

Now setup the Expiration time

Note : Resources on the ThreeFold Grid are provisioned under a Smart IT Contract . So they will decommission after the expiration. Set the Network to 1 or 3 months or more as you may using it every time you do a deployment.

You can have IPv6 too, but make sure you have IPv6 first. You can test here

Better to have an auto-configured IP range unless you have specific network requirements,

Note : The wizard will ask you to download your Wireguard configuration. This is important as you won’t be able to access your network without it. This serves as an entry point to your private network.

Step 3 : Get your wallet loaded - Get some FreeTFTs :slightly_smiling_face:

First things first, create a wallet from the Wallet Manager. It is pretty easy actually,

The next step is to get your wallet funded, there are 2 ways,

To get FreeTFTs for testnet, use this link => https://getfreetft.testnet.threefold.io

Login with your 3botID which you created in the 1st step and provide the wallet address. You get 1000 FreeTFTs per wallet. This should be adequate ! The stellar address is the simply the wallet address. Our transaction layer is on stellar.

To get FreeTFTs for Mainnet, use this request form => https://www.getfreetft.threefold.io

Step 4 - Create your Neo Container - It is show time :muscle:

Under Solutions , go to Generic flists , the wizard will guide you accordingly.

  • Select the network name which you created . Your container is going to be deployed in this network.
  • Enter the container name, size in terms of CPU and memory . Ideally start with 2 CPUs and 2048 MB memory. You can specify the size of the boot disk / rootfs to whatever appropriate. We recommend 250 GB for Neo.
  • The flist link you have to use is => https://hub.grid.tf/arehman/v2-neo-0-2.flist
  • Would you like access to your container through the web browser (coreX)? Select NO . You may want to use this for troubleshooting.
  • Set the IP address from the drop down list you want to assign to your container.
  • The container entry_point should be set to /start_neo.sh .
  • Under environment variables , use pub_key=your_public_key_here . Specify an ed25519 SSH public key . This would allow to SSH into the container once it is deployed.

Choosing from the list of your available networks ( Select the one you created above )

After the Name, setup the flist as below. By the way, you can create flists out of your own docker images.

The container resources are a matter of choice, but it would good to start with below. The boottdisk / rootfs is user defined.

Note : Moving forward, we will have the ability to attach persistent data volumes from the chat flows. We can still add them but via code.

You can set this to NO .

Setup your entry point to the container as below => /start_neo.sh

What is the entry point ? In simple words, it is the first user defined script that the container will call once it starts ~

You can pass your ssh public key to gain access. You can also add more variables to control your application logic once you create your own images / flists.

This is the location and the farm where your container would be deployed. It is better to select freefarm or leave it empty.

Select the expiration time and then choose the IP address of your container. This is what you will use to access the container,

Before the actual deployment happens, you get a screen to review. If all looks good, just go ahead and click Next to pay,

Now you have the payment screen. You can pay using your wallet you created in Step 3 or even through the 3bot App moving forward. Just make sure you have tokens there. To buy tokens, look here

If all went well, this what you shoud see in the end :point_down:

That should be it ! You will be given a reservation ID of your deployment that you can use for future references.

Step 5 - Access your Neo Container

To access the container,

For Linux , wg-quick up path_to_wireguard_conf_file. For example, wg-quick up /my-wg/net-1.conf

For windows , Import the downloaded wireguard configuration from Step 2,

Once the wireguard tunnel is up, you can test connectivity by doing a ping test for your container IP address. Access the container with ssh using your private key.

ssh -i path_to_your_privatekey root@container_ip_address, For example ssh -i /opt/mysshkey root@172.20.10.5

The SSH public key should be provisioned during the container deployment.

Step 6 - Verify your Neo Node Deployment

Click Generic flist again from the menu and you should see the name of your solution deployed.

You can click it to see details of your deployment,

Now is the time to get under the hood :muscle:

SSH in to your Neo container. The configuration directory is at /opt/neo. To list the configuration files, you can do ls -ali1t *.json

root@r9_cpu_01:/opt/neo# ls -ali1t *.json
 319 -rwxrwxrwx 1 root root    560 Jun 28 10:10 config.json
 339 -rw-r--r-- 1 root root    436 Apr 17 10:12 tf-neo.json
  70 -rwxrwxrwx 1 root root 111957 Sep 16  2019 neo-cli.deps.json
  71 -rwxrwxrwx 1 root root     28 Sep 16  2019 neo-cli.runtimeconfig.json
 320 -rwxrwxrwx 1 root root    879 Sep  3  2019 protocol.json
1707 -rwxrwxrwx 1 root root    879 Sep  3  2019 protocol.mainnet.json
1708 -rwxrwxrwx 1 root root    887 Sep  3  2019 protocol.testnet.json
1704 -rwxrwxrwx 1 root root    544 Aug 30  2019 config.mainnet.json
1705 -rwxrwxrwx 1 root root    547 Aug 30  2019 config.testnet.json

Important files that you can change or modify,

  • config.json
  • tf-neo.json (wallet file)
  • protocol.json

You can access the Neo cli with neo-cli and perform various operations,

root@r9_cpu_01:/opt/neo# ./neo-cli

To start syncing with the network, you can do start consensus. You will see blocks appearing. Here is a sample,

If you do a ps aux, you could see the neo process running,

root@r9_cpu_01:/opt/neo# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  72296   748 ?        Ss   Jun28   0:00 /usr/sbin/sshd -D
root       110  0.0  0.0  27096  1020 ?        Ss   Jun28   0:03 tmux new -s ops
root       111  0.0  0.0  20364   484 pts/1    Ss   Jun28   0:00 -bash
root       125  0.0  0.0   4624   100 pts/1    S+   Jun28   0:00 /bin/sh ./start_neo.sh
root       130  0.7  0.0 4315020 37336 pts/1   SLl+ Jun28  86:38 ./neo-cli

All block data is stored under /opt/neo and you could see the size of the directory increasing as the sync is in progress.

Once the node is synced, you will see the block height becomes equal in all columns. Here is a sample,

That should be pretty much ! :slightly_smiling_face:. We have a Neo Node running. By the way, this is a consensus node.

Sources:

NEO documentation is neat and pretty updated.

image

4 Likes

Awesome stuff @abdultf!

1 Like