Giter VIP home page Giter VIP logo

nodesguru / casper-world-backend Goto Github PK

View Code? Open in Web Editor NEW
4.0 0.0 2.0 189 KB

This web app monitors Casper network health, including nodes version distribution, VPS centralization, stake distribution (to prevent possible sybil attacks) and stake distribution by country, active/non-active nodes and validators statistics by date, etc.

License: MIT License

Shell 0.40% JavaScript 0.47% TypeScript 99.13%

casper-world-backend's Introduction

Casper Network Stats & Decentralization Map

This web app monitors Casper network health, including nodes version distribution, VPS centralization, stake distribution (to prevent possible sybil attacks) and stake distribution by country, active/non-active nodes and validators statistics by date, etc.


Prerequisites

It's required to install Git, Node.js, npm, Yarn and MongoDB.

Update your system

$ sudo apt update
$ sudo apt upgrade

Install git

$ sudo apt install git -y

Open required ports

$ sudo ufw allow 27017 
$ sudo ufw allow 80
$ sudo ufw allow 443
$ sudo ufw allow 3000

Install nodejs and npm

  • Node installation on Ubuntu

    You can install nodejs and npm easily with apt install, just run the following commands.

    $ curl https://deb.nodesource.com/setup_14.x | sudo bash
    $ sudo apt install -y nodejs
    
  • Other Operating Systems

    You can find more information about the installation on the official Node.js website and the official NPM website.

If the installation was successful, you should be able to run the following command.

$ node --version
v14.15.5

$ npm --version
v6.14.11

Install Yarn

After installing node, this project will need yarn too, so just run the following command.

$ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
$ echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt update && sudo apt install yarn -y

MongoDb installation

Install the latest stable version.

If Ubuntu 20:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

If Ubuntu 18:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

Then continue with the following:

mkdir -p /data/db
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y mongodb-org < "/dev/null"
echo "storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
net:
  port: 27017
  bindIp: 127.0.0.1, $(curl ifconfig.me)
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

security:
  authorization: enabled" > /etc/mongod.conf
systemctl enable mongod
systemctl restart mongod
systemctl status mongod

Now we need to create сasper user, do the following:

Open mongosh:

mongosh

Create Admin:

use admin
db.createUser(
{
user: "Admin",
pwd: "YOUR_$ECURE_P@ASSW0RD",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
exit

Re-enter with Admin:

mongosh -u Admin

Enter your password, in our case it will be YOUR_$ECURE_P@ASSW0RD.

Create сasper user:

use casper
db.createUser(
{
user: "Casper",
pwd: "YOUR_$ECURE_P@ASSW0RD",
roles: [ { role: "readWrite", db: "casper" } ]
}
)
exit

Install Casper World Backend

$ git clone https://github.com/nodesguru/casper-world-backend
$ cd casper-world-backend
$ yarn install

Configure the application

Create .env file and fill parameters:

You can find an example shown below

# Casper RPC
RPC=https://node-clarity-mainnet.make.services/rpc

# MONGODB
DB_USER=Casper
DB_PASSWORD=YOUR_%24ECURE_P%40ASSW0RD
DB_HOST=127.0.0.1
DB_AUTH_SOURCE=casper

Test the project

If you made changes in the project code, then start code testing.

yarn run test

Expected result: all tests are passed

Running the project

Create service file and start the application using commands below:

echo "[Unit]
Description=Casper Job
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/casper-world-backend
ExecStart=$(which yarn) --cwd $HOME/casper-world-backend/ start
Restart=always
RestartSec=1
LimitNOFILE=10000
[Install]
WantedBy=multi-user.target" > $HOME/casper-job.service
sudo mv $HOME/casper-job.service /etc/systemd/system/casper-job.service
sudo systemctl daemon-reload
sudo systemctl enable casper-job
sudo systemctl restart casper-job

Documentation

Documentation is available here

License

Released under the MIT license.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) Nodes.Guru

casper-world-backend's People

Stargazers

 avatar  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.