Giter VIP home page Giter VIP logo

status.im-mining's Introduction

Description

Solution to a recruitment task for Statis.im.

Task

Create N geth nodes in AWS that will mine ether in Ropsten and it will be easy to scale the number of nodes and monitor them. Monitoring can be ad hoc, no need to get deep into visualization/graphs. Document your solution so anyone can scale this up given access to the machine.

NOTE: Only CPU mining is required.

Usage

In order to create the mining infractructure you will need to provide the required variables. You can do that by creating a terraform/terraform.tfvars file.

Example:

pub_key_path = "~/.ssh/id_rsa.pub"
private_key_path = "~/.ssh/id_rsa"
# name of key pair to create in AWS for SSH access
key_name = "miner-admin"
# domain to which entries for created hosts should be added
domain = "mydomain.com"
# prefix for domain before hostnames, ex: miner-01.geth.mydomain.com
env = "geth"
# ethereum address for receiving mining rewards
etherbase = "CHANGE ME PLZ"

# type of instance used for collecting metrics
sentry_params {
  type = "t2.medium"
}

# number and type of miner instances to start
miner_params {
  type = "t2.small"
  count = "2"
}

Once that exists you can simply go into the terraform directory and run terraform plan and then terraform apply if you like what you see.

To configure miner hosts separately you can run ansible:

cd ansible && ansible-playbook miner.yml -e "etherbase=$CHANGE_ME" -e "monitor_host=$HOSTNAME"

Same can be done for the sentry host:

cd ansible && ansible-playbook sentry.yml -e "monitor_host=$HOSTNAME"

Details

The repo is divided into two sections:

  • terraform - Contains configuration that creates the AWS infrastructure
  • ansible - Contains provisioning for mining instances in AWS.

Infrastructure

There are two types of hosts this creates:

  • miners - Hosts that run geth for mining.
  • sentry - Hosting Graphite and Grafana for metrics.

The miners are mining in Ropsten Proof-of-Work chain using CPU. This is inefficient but good enough for a test.

The sentry is there to collect metrics and provide a UI for exploring them.

Provisioning

Using terraform 4 types of resources are created:

  • aws_security_group - One for SSH access and one for exposing 30303 port for Ethereum nodes.
  • aws_key_pair - RSA key pair used to give remote SSH access to the created instances.
  • aws_instance - Instances that will run the Geth processes for mining.
  • aws_route53_record - Route53 DNS entries for easier access to the instances.

In the modules directory reside files defining these resources.

The main configuration files are:

  • terraform/main.tf - Defines which modules to run and provisioning afterwards.
  • terraform/variables.tf - Requried and optional variables for infrastructure. Some provided by terraform.tfvars.
  • terraform/data.tf - Pulls information from AWS, in this case about AMI and Route53 zone ID.
  • terraform/output.tf - Defines what information terraform will return after successful run.

NOTE: If you wish to run ansible separately comment out the null_resource section in terraform/main.tf.

Configuration

Using ansible provisioned hosts are configured for their respective roles using playbooks:

  • ansible/miner.yml - Configures miners to run geth and send metrics.
  • ansible/sentry.yml - Configures sentry to run Graphite and Grafana

A set of roles configures the necessary services:

  • ansible/roles/common - Installs common utilities like htop or netstat.
  • ansible/roles/docker - Installs Docker to enable use of containers
  • ansible/roles/miner - Configures go-ethereum client
  • ansible/roles/monitoring-client - Configures netdata for monitoring miners
  • ansible/roles/monitoring-server - Configures Graphite and Grafana

TODO

  • SSL certificates for web services like Grafana
  • Auth for netdata running on miners
  • Backups of Grafana dashboards
  • Backups of geth blockchain to reduce sync time
  • Find why metrics not starting with eth don't get saved in graphite

Resources

status.im-mining's People

Contributors

jakubgs avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.