Skip to content

TiesDB Local Setup

Anton Filatov edited this page Jul 24, 2019 · 3 revisions

Table of contents

Prerequisites

  • Latest version of GIT
  • Version 10.x LTS of NodeJS with npm
  • Version 2.7 or higher of Python
  • Version 1.8 of Java Runtime or JDK

Schema setup

All definitions of the data structures which are storing in TiesDB are in the Schemа Smart Contract, in the blockchain. For local deployment, you need to install a blockchain and deploy the contracts.

Ethereum local setup

First, you need to obtain a stable version of ethereum blockchain for your system. For this installation, we will use go-ethereum of version 1.8.27-4bcc0a37. Extract the downloaded archive to any directory and open the console in this directory. Then run the following commands in the console window:

geth --miner.gastarget 1000000000 --dev.period 1 --dev --exec "while(eth.getBlock('latest').gasLimit<7000000){}" console

It will prepare the necessary gas limit for the deployment of TiesDB contracts. After successful completion run geth in console mode:

geth --miner.gastarget 1000000000 --rpc --dev console

You should see that geth started successfully and prompting for command input. Enter the following commands in geth window:

for(var i=3;i>0;i--){personal.unlockAccount(personal.newAccount(''), '', 1000000);}

Three new accounts, for your data nodes, will be created. Now you are ready for contract deployment.

Contracts deployment

To store data structure definitions, you should deploy the TiesDB contracts to the prepared blockchain. You will need tools described in prerequisites for this.

Use git to obtain the contracts source code with this commands:

git clone --no-checkout "https://github.com/TiesNetwork/ties.db-contracts.git" contracts
cd contracts
git checkout --detach 1115debfe0b60d291221f1ad4c3e2ac77445967e

Then build the contracts and deploy them, to the running local ethereum blockchain:

npm ci
npm run migrate

If the deployment is successful, you will see the addresses of newly deployed contracts and nodes, like:

        TiesDB: <contractaddress>
NoRestrictions: <restrictaddress>
   Node[1]: 0x<node1stripaddress>
   Node[2]: 0x<node2stripaddress>
   Node[3]: 0x<node3stripaddress>

You will need them later for configuration, so write them down.

Database setup

Database installation, described here, consists of three data nodes and one coordinator, connected to them. Data nodes are dedicated machines (maybe virtual), with different IP-addresses. The coordinator node could be installed locally.

Data Node rollout

You should run this step on each of data node machines

Download the binary distribution of TiesDB node from GitHub. Extract the archive to the destination folder and edit the conf/tiesdb.yaml setting the contractAddress parameter to address, obtained from the contracts deployment. Then start the node:

bin/tiesdb

Coordinator rollout

Download the binary distribution of TiesDB coordinator from GitHub. Extract the archive to destination folder and edit the conf/tiesdb.yaml setting the contractAddress parameter to address, obtained from the contracts deployment and nodesUrl parameter to file:nodes.json. Then create file nodes.json in the coordinator directory with the following contents:

Replace the <nodestripaddress> by the actual addresses, without the 0x prefix, obtained from the contracts deployment and <nodeipaddress> by the actual IP-addresses of the data nodes

{
  "60x<node1stripaddress>": "ws://<node1ipaddress>:8080/websocket",
  "60x<node2stripaddress>": "ws://<node2ipaddress>:8080/websocket",
  "60x<node3stripaddress>": "ws://<node3ipaddress>:8080/websocket"
}

And start the coordinator:

bin/tiesdb-coordinator

Designer setup

TiesDB Schema Designer will be useful for data structure manipulation. To build the designer you also need prerequisites and latest version of yarn. Install it by using the instructions from the official site or by running the following command:

npm install yarn -g

You can obtain the TiesDB Schema Designer source code using this command:

git clone --no-checkout "https://github.com/TiesNetwork/ties.db-ui.git" designer
cd designer
git checkout --detach 1fbcca955de62bce689428190fbf7cdc89cbe05f

Run the following commands for build and start:

Replace the <contractaddress> and <restrictaddress> by the actual addresses, obtained from the contracts deployment

yarn install
yarn start <contractaddress> <restrictaddress> 1337

You should see the browser opened on http://localhost:3000

TiesDB UI Schema Designer

Clone this wiki locally