14.08.2018

The Power Guide How to setup local Power_testnet

Original link: https://medium.com/@thepower/open-code-at-github-how-to-setup-your-local-power-testnet-e89333a3dc39

 

Dear community!

We are pleased to announce:

github.com/thepower/snapshot

 

What does it give to you

  1. You’ll setup a virtual machine. VirtualBox (Windows, macOS) and Parallels (macOS) were tested by the team.
  2. There is Linux within the virtual machine with automatically installed all necessary tools for local testnet launch. For the test build, we used Ubuntu 16.04 LTS.
  3. You’ll run 3 shards with 3 nodes in each (9 nodes at all) with interchain interaction implemented.

Thanks to that, you will explore our BFT-like own algorithm of consensus Resonance and cross-chain transactions between shards.

Disclaimer

Please be aware all the code published on The Power GitHub is the intellectual property of The Power. You can use this code to explore and test the code in your local Power_testnet only.

This code is published for non-commercial purposes!
 

Guidelines

Prerequisites

1. In case you are using macOS, you may need a ‘Homebrew’ package manager to install ‘vagrant’. You can install ‘brew’ using the following command in terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Of course, you could use any other known method of prerequisites installation. To get more information about the ‘Homebrew’ package manager search on its official website: https://brew.sh/

2. Install vagrant. Also, you need have installed a virtual machine at this step. We tested ‘vagrant’ with ‘Virtual Box’ and ‘Parallels’ on macOS. You can install ‘vagrant’ on macOS using the following command in terminal:

brew install caskroom/cask/vagrant

3. In case you’re using parallels virtual machine, you should install vagrant plugin:


vagrant plugin install vagrant-parallels

4. In case you’re using virtualbox, you should modify your PATH environment:

export PATH=/Applications/VirtualBox.app/Contents/MacOS:$PATH

5. We use the hostmanager vagrant plugin to change /etc/hosts file on a host system. Please, install this plugin:

vagrant plugin install vagrant-hostmanager

Testnet Setup

1. Creating a directory:


mkdir thepower

2. Get into that directory:


cd thepower

3. Download prepared bundle which contains: Vagrantfile, scripts for managing testnet and testnet configuration files

wget http://dist.thepower.io/blockchain.tar.bz2

At this step, you will use an only Vagrant file from this bundle. If you haven’t the ‘wget’ command you can download the file using any other method. For example, you can download it using a web browser and put it to created on the previous step the directory ‘thepower’.

4. Unpack which was downloaded:


tar xf blockchain.tar.bz2
At this step, you have the Vagrantfile and testnet management script and configs in the current directory. Now, you should set up a virtual machine with the appropriate environment from the Vagrantfile.

5. It configures a virtual machine:


vagrant up

6. The first virtual machine run requires a reboot:


vagrant halt

7. Start it again:


vagrant up

8. Getting inside the VM:


vagrant ssh

If you were asked a password you should type ‘vagrant’ as the password.

9. Do the same as 1–4 but with other files inside a virtual machine:

mkdir thepower; cd thepower; wget http://dist.thepower.io/blockchain.tar.bz2 ; tar xf blockchain.tar.bz2
At this point, you have script testnet2.sh and testnet configs in a current directory inside the virtual machine. Also, you have configured /etc/hosts file on your host machine (vagrant added pwr.local domain) and installed correct versions of dependencies.

10. Download latest version of thepower node software:


./testnet2.sh update

11. Start the testnet:


./testnet2.sh start

12. Wait for some time (5 seconds would be enough).


13. Check everything is launched in a proper way with the command ‘netstat’, which one shows all needed ports are open. You should see 9 different ports. These ports are API ports of the power nodes:

netstat -an |grep 498

14. This is example of a call to one of the nodes API:


curl http://127.0.0.1:49842/api/node/status | jq .
Every node in testnet listens to it’s own port and provide API. You should have all nodes API port numbers on your screen after step 13. You can use curl to access the API from command line (inside or outside the VM):

curl http://pwr.local:49841/api/node/status | jq .

Or you can use your browser on host system to call this APIs (domain pwr.local is already added to your /etc/hosts by vagrant-hostmanager plugin).

Congrats! Your Power_testnet is launched successfully!

 

Now you could use all API functions following this wiki:


http://thepower.io/doc/api
 

If you need to update your software to the latest version, you have to run the command below thus you’ll get the latest version of software:

./testnet2.sh update

You have to run it within VM (you’ll get into VM via command ‘vagrant ssh’)

Dear developers!

You a more than welcome to share your experience while you test Power_testnet. Your feedback, questions and proposals are very important to us.

Let’s turn on The Power!

Don’t hesitate to ask us your questions and give your feedback via email and Telegram.


Useful resources:

We provide close access to our testnet to early adopters and partners by request (pm us in Telegram or send e-mail on info@thepower.io)

Follow us: