Running a Node on Gravity Protocol's Testnet Using a Cloud Server [Tutorial]

in #gravityprotocol6 years ago (edited)

Before proceeding

<blockquote> <p dir="auto">You should have some familiarity with command line. Not much is needed, but basics are a plus.<br /> Also note, using a cloud server does cost money. Be prepared to spend ~$20 USD a month. <hr /> <h2>Table of Contents <ol> <li>Setting up a cloud server <li>Using SSH to log into the server <li>Building Gravity <li>Connect to the Testnet <li>Installing and Using Docker <li>Common Troubleshooting <li>Helpful Links <hr /> <h1><strong>1. Setting up a cloud server <p dir="auto"><span>Starting out, you are going to need a way to run the <a href="/@gravity-protocol">@gravity-protocol node 24/7. I recommend using a cloud server for this purpose. There are a couple of different options to do this (an easy google search for cloud servers), but the one that I like using is Digital Ocean. Set up an account on Digital Ocean using either of the links below (one is a referral and one is not). <p dir="auto">(referral link) <a href="https://m.do.co/c/721f8e9043d1" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Digital Ocean $10 credit<br /> (non-referral link) <a href="https://www.digitalocean.com" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Digital Ocean <hr /> <p dir="auto">Once you've made an account, you need to create a <em>droplet. The button for creating a <em>droplet is in the upper right corner of the dashboard. <p dir="auto">Now, there are many different options here for your <em>droplet. These are the absolute basics to get it up and running. <p dir="auto">For the operating system, choose <em>Ubuntu 16.04. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmfZcV8fdmzMGDfX72saEYmQ4G1uMMDXB2wtYfoMaekCSr/Screen%20Shot%202018-06-10%20at%2010.43.54%20AM.png" alt="Creating a droplet @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmfZcV8fdmzMGDfX72saEYmQ4G1uMMDXB2wtYfoMaekCSr/Screen%20Shot%202018-06-10%20at%2010.43.54%20AM.png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmfZcV8fdmzMGDfX72saEYmQ4G1uMMDXB2wtYfoMaekCSr/Screen%20Shot%202018-06-10%20at%2010.43.54%20AM.png 2x" /> <p dir="auto">Next you have to choose how much memory you want. The developers' recommended minimum amount of memory for a node is 4GB. Do not choose any memory option lower than 4GB. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmdMbk21G51cKQhFkG7uVHkMr6Pns1Qtn24xXgHSiHV9GU/Screen%20Shot%202018-06-10%20at%2010.44.40%20AM%20(1).png" alt="Droplet size @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmdMbk21G51cKQhFkG7uVHkMr6Pns1Qtn24xXgHSiHV9GU/Screen%20Shot%202018-06-10%20at%2010.44.40%20AM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmdMbk21G51cKQhFkG7uVHkMr6Pns1Qtn24xXgHSiHV9GU/Screen%20Shot%202018-06-10%20at%2010.44.40%20AM%20(1).png 2x" /> <p dir="auto">Towards the bottom, there will be a section with the header <em>Finalize and Create. Here is where you'll name your cloud server something relevant and useful. In this example, the server name is <strong>GravityProtocolTestnetTutorial. Next, click create. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmb6gfY1B2m6QynKuwbLq37iicYb2kFw5CtTN6FFtdJobR/Screen%20Shot%202018-06-10%20at%2010.48.43%20AM%20(1).png" alt="Finalize and create droplet @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmb6gfY1B2m6QynKuwbLq37iicYb2kFw5CtTN6FFtdJobR/Screen%20Shot%202018-06-10%20at%2010.48.43%20AM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmb6gfY1B2m6QynKuwbLq37iicYb2kFw5CtTN6FFtdJobR/Screen%20Shot%202018-06-10%20at%2010.48.43%20AM%20(1).png 2x" /> <p dir="auto">The page should redirect you to the dashboard where you can see your cloud server being created. This is usually a pretty quick process since a server this size requires less to set up. Allow up to five minutes. <p dir="auto">Once the loading bar is done, you should see something like the image below (with your server name). The blacked out portion covers the IP address. That is where your IP address for your server will be. Take note of this IP address. <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmeQz7caWfaNEupSfwADqG7uG2CpufFoFQJLvddB3CKvA7/Screen%20Shot%202018-06-10%20at%2010.49.53%20AM%20(1).png" alt="Droplet created @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmeQz7caWfaNEupSfwADqG7uG2CpufFoFQJLvddB3CKvA7/Screen%20Shot%202018-06-10%20at%2010.49.53%20AM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmeQz7caWfaNEupSfwADqG7uG2CpufFoFQJLvddB3CKvA7/Screen%20Shot%202018-06-10%20at%2010.49.53%20AM%20(1).png 2x" /> <p dir="auto">Since the SSH keys were not used in setting up the cloud server, Digital Ocean will email you the <code>root user password. As mentioned before, this tutorial covers the absolute basics of getting a server running. Adding SSH keys will not be covered in this tutorial. However, adding SSH keys are vital to maintaining a secure server, so establishing some familiarity with them will be necessary in the future. <hr /> <h1>2. Using SSH to log into the server <p dir="auto">You should now check your email to see if Digital Ocean has contacted you. This is an important step because you need the <code>root user password to log into your cloud server. You CANNOT proceed past this point if you do not have the <code>root user password. This goes for any cloud server service. Take note of the password and the IP address if you haven't already. <p dir="auto">Up until this point it hasn't mattered what operating system you are using. But now, it kind of does. If you are on a Mac, you can use terminal with the <code>ssh command. If you are on Windows, you can download <a href="https://www.putty.org" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">PuTTY. <p dir="auto">In Terminal on Mac by typing:<br /> <code>ssh yourServerIPAddress -l root<br /> You are using SSH to log into your server, based on its IP address, and logging in as the <code>root user. It will now ask for the password. You will not be able to see what you are typing, so copy/paste are going to come in handy. <p dir="auto">The server will realize that you are logging in for the first time as <code>root and require you to change the password. Again, you will not be able to see what you are typing. Create a new, secure password and take note of it. <p dir="auto">Type <code>clear and enter to clear the screen of those extra distractions. <p dir="auto">Should look something like this: <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmfZ7FHmgw7RBVzY7qXNQt1DkmRQwHzH7xyP8md2D22voL/Screen%20Shot%202018-06-10%20at%2012.47.56%20PM%20(1).png" alt="Root user logged in @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmfZ7FHmgw7RBVzY7qXNQt1DkmRQwHzH7xyP8md2D22voL/Screen%20Shot%202018-06-10%20at%2012.47.56%20PM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmfZ7FHmgw7RBVzY7qXNQt1DkmRQwHzH7xyP8md2D22voL/Screen%20Shot%202018-06-10%20at%2012.47.56%20PM%20(1).png 2x" /> <p dir="auto">Congratulations, you are now logged into your cloud server that will soon be a node! <hr /> <h1>3. Building Gravity <p dir="auto">To start out on your server, let's get things up to date and install the required packages:<br /> <code>sudo apt-get update <p dir="auto"><code>sudo apt-get install git cmake openssl libssl-dev autoconf automake libtool libcurl4-openssl-dev libboost-all-dev build-essential <p dir="auto">Next, navigate to the home directory using:<br /> <code>cd ~ <blockquote> <p dir="auto">You can verify if you are in the home directory by using <code>pwd command (present working directory). Should print out as <code>/root <p dir="auto">Now copy, or <em>clone the Gravity-Core code from github and all of its subfolders:<br /> <code>git clone https://github.com/GravityProtocol/gravity-core <p dir="auto"><code>cd gravity-core <p dir="auto"><code>git submodule update --init --recursive <blockquote> <p dir="auto">These three lines above shouldn't take more than 2 minutes to finish downloading what they need <p dir="auto">Prepare package for libtool:<br /> <code>libtoolize <p dir="auto">Delete, or <strong>re<strong>move, the CMakeCache.txt file and the folder named build:<br /> <code>rm -f CMakeCache.txt <p dir="auto"><code>rm -f -r build <p dir="auto">Use cmake and give it the path to ssl libraries on your server:<br /> <code>cmake -DOPENSSL_ROOT_DIR=/usr/lib/ssl/openssl -DOPENSSL_LIBRARIES=/usr/lib/ssl <p dir="auto">If everything worked correctly, you should see:<br /> <code>-- Build files have been written to: /root/gravity-core <p dir="auto">Now, build Gravity:<br /> <code>make <blockquote> <p dir="auto">This can take upwards of 30 - 60 minutes, depending on your server configuration. While writing this tutorial with the configuration above, it timed at about 100 minutes. Keep in mind, these are the minimum requirements for a node. <blockquote> <p dir="auto">Another time I have built Gravity after writing this, it only took 40 minutes with the same configuration. <hr /> <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQh9aK3LGS1zzyHsXUGnCeMZxHAoEk7SBCfbvK5JfzY5B/Screen%20Shot%202018-06-10%20at%208.24.50%20PM%20(1).png" alt="Building Gravity @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmQh9aK3LGS1zzyHsXUGnCeMZxHAoEk7SBCfbvK5JfzY5B/Screen%20Shot%202018-06-10%20at%208.24.50%20PM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmQh9aK3LGS1zzyHsXUGnCeMZxHAoEk7SBCfbvK5JfzY5B/Screen%20Shot%202018-06-10%20at%208.24.50%20PM%20(1).png 2x" /> <p dir="auto">Once the process above finishes, you have built Gravity! <hr /> <h1>4. Connecting to the Testnet <p dir="auto">Create a folder, or make a directory, to run your testnet node and copy the witness_node:<br /> <code>mkdir ~/gravity_testnet <p dir="auto"><code>cd ~/gravity_testnet <p dir="auto"><code>cp -r ~/gravity-core/programs/witness_node . <p dir="auto"><code>cd witness_node <p dir="auto">Start the node so the correct files are generated:<br /> <code>./witness_node --data-dir=data --resync-blockchain <p dir="auto">Stop the node by pressing <code>ctrl + c <p dir="auto">Use a text editor of your choice (in this case <code>nano) and edit <code>config.ini:<br /> <code>nano data/config.ini <p dir="auto">Add the seed nodes to the P2P connections section of <code>config.ini:<br /> <code># P2P nodes to connect to on startup (may specify multiple times)<br /> <code>seed-node = testnet-seed-0.gravityprotocol.org:10111<br /> <code>seed-node = testnet-seed-1.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-2.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-3.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-4.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-5.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-6.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-7.gravityprotocol.org:4623<br /> <code>seed-node = testnet-seed-8.gravityprotocol.org:4623 <blockquote> <p dir="auto">Make sure there are no "#" in front of the seed node addresses. <p dir="auto">Save the file with <code>ctrl + O <p dir="auto">Exit nano <code>ctrl + X <p dir="auto">This is all that needs to be done here, the rest will be done using <code>Docker. <hr /> <h1>5. Installing and Using Docker <p dir="auto">The instructions to install <code>Docker are here: <a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">How to install Docker. MAKE SURE YOU FOLLOW STEP 2: DOCKER WITHOUT SUDO. If the second step is skipped, this will cause major problems. <p dir="auto">The instructions to install <code>Docker Compose are here: <a href="https://docs.docker.com/compose/install/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">How to install Docker Compose <p dir="auto"><strong>Make sure both are installed correctly before going beyond this point. <p dir="auto">To have the correct docker-compose.yml file, copy the code from github:<br /> <code>git clone https://github.com/GravityProtocol/gravity-testnet-docker <p dir="auto"><code>cd gravity-testnet-docker <p dir="auto">Get the latest <code>Docker image:<br /> <code>docker-compose pull <p dir="auto">Start your new Gravity Protocol Node:<br /> <code>docker-compose up -d <p dir="auto">This will start the node in detached mode. This allows us to do other things while it's running. <p dir="auto">One way to see what your server is doing is this command (while in the 'gravity-testnet-docker' folder):<br /> <code>docker logs --tail 3 --follow gravity-testnet-docker_gravity_node_1 <p dir="auto">This follows the logs of your node! If you want to get out of following the logs, simply press <code>ctrl + c. <p dir="auto">The picture below is what the console will look like while it is catching up: <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmfDxBNRQ35fPLQcsTeHcDKorvP1EEq94jt5MTV9Gj4hmj/Screen%20Shot%202018-06-10%20at%2010.13.55%20PM%20(1).png" alt="Node syncing @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmfDxBNRQ35fPLQcsTeHcDKorvP1EEq94jt5MTV9Gj4hmj/Screen%20Shot%202018-06-10%20at%2010.13.55%20PM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmfDxBNRQ35fPLQcsTeHcDKorvP1EEq94jt5MTV9Gj4hmj/Screen%20Shot%202018-06-10%20at%2010.13.55%20PM%20(1).png 2x" /> <p dir="auto">Picture below is what a node looks like when it is fully synced and receiving blocks in real-time: <p dir="auto"><img src="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmVeSVSsvsYaz2MTrF9F2FeJ3iwKukVgpzbjcuCfhaBQd2/Screen%20Shot%202018-06-10%20at%2010.21.34%20PM%20(1).png" alt="Synced node @iamredbar" srcset="https://images.hive.blog/768x0/https://cdn.steemitimages.com/DQmVeSVSsvsYaz2MTrF9F2FeJ3iwKukVgpzbjcuCfhaBQd2/Screen%20Shot%202018-06-10%20at%2010.21.34%20PM%20(1).png 1x, https://images.hive.blog/1536x0/https://cdn.steemitimages.com/DQmVeSVSsvsYaz2MTrF9F2FeJ3iwKukVgpzbjcuCfhaBQd2/Screen%20Shot%202018-06-10%20at%2010.21.34%20PM%20(1).png 2x" /> <h3>Congratulations! You now have a cloud server that is a node for Gravity Protocol's testnet! <hr /> <h1>6. Common Troubleshooting <ul> <li>SSH will not connect for an unknown reason. <blockquote> <p dir="auto">If you are outside the US and it will not connect to your cloud server, try using a proxy for your SSH. There have been reports of users outside of the US having trouble using SSH with DigitalOcean. <ul> <li>The user isn't correct when using ssh <code>wrongUserName@yourCloudServer password: <blockquote> <p dir="auto">When logging into your cloud server, you need to use the <code>-l option with <code>root. If <code>root is not specified, it will use your current username of the machine you are on. <ul> <li><code>There were unauthenticated packages and -y was used without --allow-unauthenticated <blockquote> <p dir="auto">Run the command again, except use the <code>--allow-unauthenticated option. This is caused if you did not import the GPG key for <code>Docker and tried to install it. <hr /> <h1>7. Helpful Links <ul> <li><a href="https://steemit.com/@gravity-protocol" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Protocol Steemit <li><a href="https://t.me/gravity_protocol" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Protocol Telegram <li><a href="https://www.gravityprotocol.org/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Protocol Website <li><a href="https://twitter.com/protocolgravity" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Protocol Twitter <li><a href="https://steemit.com/blockchain/@gravity-protocol/gravity-testnet-instructions-set" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Protocol Testnet Instructions <li><a href="https://wallet.gravityprotocol.org" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Wallet <li><a href="https://github.com/GravityProtocol" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity GitHub <li><a href="https://github.com/GravityProtocol/gravity-docs" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Gravity Testnet Docs <li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">How to install Docker <li><a href="https://docs.docker.com/compose/install/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">How to install Docker Compose <hr /> <p dir="auto">If you benefited from the tutorial, consider giving me a follow on Steemit. <p dir="auto">You can also vote for my witness in the Gravity Testnet wallet, witness address is <code>g2270k0890d2290e2410 <h3><span><a href="/@iamredbar">@iamredbar <hr /> <h6>this will be updated as needed over the next 6 or so days while it is editable
Sort:  

A good manual! We recommend it for use. Thank you very much, friend!

Okay, i will try to install the Ubuntu first