Skip to content

Latest commit

 

History

History
330 lines (220 loc) · 7.93 KB

README.md

File metadata and controls

330 lines (220 loc) · 7.93 KB

Tezos Link

Go Report Card Build

Tezos link is a gateway to access to the Tezos network aiming to improve developer experience when developing Tezos dApps.

Table of Contents

Project Organization

The repository is currently following this organization:

.
├── api          # api documentation
├── build        # packaging
├── cmd          # mains
├── config       # config parsers
├── data         # config and migrations
├── infra        # infrastructure
├── internal     # services
├── test         # test-specific files
└── web          # frontend
    └── public
        └── docs # usage documentation

Run services locally on the machine with mockup blockchain node

Blockchain nodes are mocked up for development environment the be as lightweight as possible.

Requirements

  • Docker
  • docker-compose
  • Yarn (setup with 1.22.0)
  • Golang (setup with 1.13)
  • GNU Make (setup with 3.81)
  • Node.js (setup with 11.14.0)

How to

To run services locally on the machine, you will need to run those commands :

$> make deps
$> make build-docker
$> make run-dev

It will run:

  • tezos-link_proxy
  • tezos-link_proxy-carthagenet
  • tezos-link_api
  • mockserver/mockserver:mockserver-5.9.0 (mocking a blockchain node)
  • postgres:9.6

The only endpoint served by the blockchain mock is:

curl -X PUT localhost:8001/v1/<YOUR_PROJECT_ID>/mockserver/status

Test all services

Requirements

  • Golang (setup with 1.13)
  • GNU Make (setup with 3.81)

For integrations tests only:

  • Docker
  • docker-compose
  • yarn

How to

To run the unit tests, you can use the command

$> make unit-test

To run integration tests locally, you will need to run following commands :

# We build docker images and run them
$> make build-docker & make run

# We run integration tests...
$> make integration-test

# And we clean the environment when we are done
$> docker-compose down

Build all services and frontend

Requirements

  • GNU Make (setup with 3.81)
  • Golang (setup with 1.13)
  • Yarn (setup with 1.22.0)
  • Node.js (setup with 11.14.0)

How to

To build your project, you need first to install dependencies:

$> make deps

After, you can run the build with

$> make build

Frontend

Requirements

  • Yarn (setup with 1.22.0)
  • Node.js (setup with 11.14.0)

To build the frontend, you need first to install dependencies:

$> make deps

Run

To run the frontend, execute:

$> cd web && yarn start-local

Build

To run the frontend, execute:

$> make build-frontend

Deploy

You will need AWS credentials setup on your machine, see AWS Credentials

To run the frontend, execute:

$> make deploy-frontend

Services

API

REST API to manage projects and get project's metrics.

Dependencies

  • PostgreSQL (setup with 9.6)

Environment variables

  • DATABASE_URL (default: postgres:5432)
  • DATABASE_USERNAME (default: user)
  • DATABASE_PASSWORD (default: pass)
  • DATABASE_TABLE (default: tezoslink)
  • DATABASE_ADDITIONAL_PARAMETER (default: sslmode=disable)
  • SERVER_HOST (default: localhost)
  • SERVER_PORT (default: 8000)

Proxy

  • HTTP proxy in front of the nodes
  • In-memory (LRU) cache

Dependencies

  • PostgreSQL (setup with 9.6)

Environment variables

  • DATABASE_URL (default: postgres:5432)
  • DATABASE_USERNAME (default: user)
  • DATABASE_PASSWORD (default: pass)
  • DATABASE_TABLE (default: tezoslink)
  • DATABASE_ADDITIONAL_PARAMETER (default: sslmode=disable)
  • ARCHIVE_NODES_URL (default: node)
  • TEZOS_ARCHIVE_PORT (default: 1090)
  • ROLLING_NODES_URL (default: node)
  • TEZOS_ROLLING_PORT (default: 1090)
  • SERVER_PORT (default: 8001)

Snapshot exporter lambda

Lambda function scheduled with a Cloudwatch Rule cronjob, connect to a node with SSH and trigger a snapshot export.

Deploy for testing and for development purpose

Individual deployment of the lambda is possible for testing and development purpose.

You will need AWS credentials setup on your machine, see AWS Credentials

It will build, send to the S3 bucket and update snapshot lambda code:

$> make build-unix
$> make deploy-snapshot-lambda

To execute the lambda, run:

aws lambda invoke --region=eu-west-1 --function-name=snapshot --log Tail output.txt | grep "LogResult"| awk -F'"' '{print $4}' | base64 --decode

Metrics cleaner lambda

Lambda function scheduled with a Cloudwatch Rule cronjob, connect to a node with SSH and trigger a metrics clean.

Deploy for testing and development purpose

Individual deployment of the lambda is possible for testing and development purpose.

You will need AWS credentials setup on your machine, see AWS Credentials

It will build, send to the S3 bucket and update metrics-cleaner lambda code:

$> make build-unix
$> make deploy-metrics-cleaner-lambda

To execute the lambda, run:

aws lambda invoke --region=eu-west-1 --function-name=metrics --log Tail output.txt | grep "LogResult"| awk -F'"' '{print $4}' | base64 --decode

Environment variables

These environment variables are set in infra/dev.tfvars.

  • NODE_USER (default: ec2-user)
  • S3_REGION (default: eu-west-1)
  • S3_BUCKET (default: tzlink-snapshot-lambda-dev)
  • S3_LAMBDA_KEY (default: snapshot_lambda_key)

Infrastructure

Architecture

Architecture

Requirements

  • Terraform (version == 0.12.20)
  • Terragrunt (version == 0.21.4)

We recommend to install tf-env to manage easily your terraform environments.

How to deploy

All the files related to the infrastructure are based on the infra folder.

First, you will need to update the configuration (if needed). To do this, you will find common.tfvars and <env>.tfvars in the folder infra/terragrunt.

Currently, database password is encrypted inside the file vaulted.tfvars. To see it content, you will need ansible-vault and a passphrase to decrypt it with the command ansible-vault decrypt vaulted.tfvars.

This will be changed soon with AWS Secret Manager.

When they are updated, we will use Terragrunt to deploy our infrastructure by running:

# To check if all is OK
$> terragrunt plan-all

# To apply the change
$> terragrunt apply-all

If you want to apply a specific part of the infrastructure (ex: 00_network), you can run

$> cd infra/terragrunt/00_network

# To check if all is OK
$> terragrunt plan

# To apply the change
$> terragrunt apply

Documentation

The documentation usage is located at web/public/docs.

It contains the various Markdown files served by the application at /documentation.

References

This repo took some ideas & code from: