Coder Social home page Coder Social logo

azarshab-saeed / ethereum-blockchain-docker-compose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tradingstrategy-ai/ethereum-blockchain-docker-compose

0.0 0.0 0.0 570 KB

Docker composes for various Ethereum blockchains: Mainnet, Polygon, Binance Smart Chain

Shell 74.69% Dockerfile 25.31%

ethereum-blockchain-docker-compose's Introduction

This repository contains Docker Compose file to run various EVM based blockchains with examples of Caddy reverse proxy.

The compose provides high speed inter-process communication sockets (IPC), on beside the normal HTTP JSON-RPC, for communicating with the nodes.

Generic diagnostics commands

JSON RPC

Check that your JSON-RPC endpot responds:

curl \
  -H "Content-Type: application/json" \
  --data "{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":67}" \
  https://yournode.example.com

Products

{"jsonrpc":"2.0","id":67,"result":"1"}

GraphQL

To diagnose, visit GraphQL UI provided by your node by default

https://vitalik2.example.com/graphql/ui

Caddy

Assume system wide Ubuntu install.

Example Caddyfile

How to proxy Ethereum JSON-RPC node with Let's Encrypt TLS certificate and HTTP Basic Auth password. This example provides two Ethereum nodes on the same server.

Goes to /etc/caddy/Caddyfile:

{
    # Disable the Caddy admin API
    # This is personal preference, you can remove this if desired
    admin off
    email [email protected]

}


vitalik2.tradingstrategy.ai {

    basicauth {
		    myuser mytoken
    }

    reverse_proxy 127.0.0.1:10000
    reverse_proxy /graphql 127.0.0.1:10000

    # Set the default 404 page
    # https://caddyserver.com/docs/caddyfile/directives/handle_errors
    handle_errors {
        respond "{http.error.status_code} {http.error.status_text}"
    }

    log {
        output file /var/log/caddy/vitalik2.log
        format json
    }

}


vitalik.tradingstrategy.ai {

        basicauth {
          		youruser yourtoken
        }

        reverse_proxy 127.0.0.1:8545
        reverse_proxy /graphql 127.0.0.1:8545

       # Set the default 404 page
       # https://caddyserver.com/docs/caddyfile/directives/handle_errors
       handle_errors {
          respond "{http.error.status_code} {http.error.status_text}"
      }

      # Log startup messages
      log {
        output file /var/log/caddy/vitalik.log
        format json
      }

}

Validating Caddy config file

Try:

caddy validate --config /etc/caddy/Caddyfile

Display Caddy logs

System logs

journalctl -fu caddy

Access logs

less /var/log/caddy/vitalik.log
less /var/log/caddy/access.log

Ethereum mainnet

  • Based on the official GoEthereum Docker image

  • Network id: 1

  • IPC socket: ./ipc/ethereum.ipc

  • HTTP RPC Port: 8545

  • Data volume: ./data/ethereum

Commands

Access ethereum directory: cd ethereum

Help: docker-compose run ethereum --help

Shell: (not available)

Build and run as daemon: docker-compose up --build -d ethereum

Restart: docker-compose restart ethereum

Logs: docker-compose logs ethereum

(todo) Show sync status: docker-compose run ethereum attach http://127.0.0.1:8545 --exec "eth.syncing"

Binance Smart Chain (BSC)

Notes

Commands

BSC geth might take a minute or two before it starts to respond to port 9545. BSC logs seem to be very terse and you cannot get useful log output even with -verbosity 5 - you cannot see from the logs if it is syncing or not.

Help: docker-compose run bsc /usr/bin/geth --help

Shell: docker-compose run bsc bash

Build and run as daemon: docker-compose up --build -d bsc

Restart: docker-compose restart bsc

Logs: docker-compose logs bsc

Geth console: docker-compose run bsc /usr/bin/geth attach http://127.0.0.1:9545

Show sync status: docker-compose exec bsc /usr/bin/geth attach http://127.0.0.1:9545 --exec "eth.syncing"

Polygon

Please see Polygon DAppNode compose here.

Cronos

Cronosd is the oficial client that we use to create a fullnode on cronos node. Currently we are using version

official docs: https://cronos.org/docs/getting-started/cronos-mainnet.html#step-3-run-everything

Requeriments

CPU: Equivalent of 8 AWS vCPU RAM: 16 GiB Storage: 1 TB OS: Ubuntu 18.04/20.04 or MacOS >= Catalina

Cronos Public Network Mainnet

Install avanlanchego

curl -LOJ https://github.com/crypto-org-chain/cronos/releases/download/v0.6.5/cronos_0.6.5_Linux_x86_64.tar.gz

tar -zxvf cronos_0.6.5_Linux_x86_64.tar.gz

./cronosd version

0.6.5

Create as a Service

  curl -s https://raw.githubusercontent.com/crypto-org-chain/cronos-docs/master/systemd/create-service.sh -o create-service.sh && curl -s https://raw.githubusercontent.com/crypto-org-chain/cronos-docs/master/systemd/cronosd.service.template -o cronosd.service.template

  chmod +x ./create-service.sh && ./create-service.sh

We can create a specific config file look at /avalance/node.json in this repository to get a sample file.

Commands

get version: cronosd --version

Start Daemon: sudo systemctl start cronosd

Restart: sudo systemctl restart cronosd

Logs: sudo journalctl -u cronosd -f

Get last block: ./cronosd status 2>&1 | jq '.SyncInfo.latest_block_height' you can check if its correct with `curl -s https://rpc.cronos.org/commit | jq "{height: .result.signed_header.header.height}"

(todo) Show sync status:

geth attach http://localhost:8545

> eth.syncing

Avalanche

Avalanchego is the oficial client that we use to create a fullnode on avalanche node. Currently we are using version

official docs: https://docs.avax.network/nodes/build/run-avalanche-node-manually/

Requeriments

Avalanche is an incredibly lightweight protocol, so nodes can run on commodity hardware. Note that as network usage increases, hardware requirements may change.

CPU: Equivalent of 8 AWS vCPU RAM: 16 GiB Storage: 1 TB OS: Ubuntu 18.04/20.04 or MacOS >= Catalina

Avalanche C-chain Public Network Mainnet

Install avanlanchego

add deb source

echo "deb https://downloads.avax.network/apt focal main" > /etc/apt/sources.list.d/avalanche.list

install as deb package

apt install avalanchego

We can create a specific config file look at /avalance/node.json in this repository to get a sample file.

Commands

get version: avalanchego --version

Build and run as daemon: look at /avalanche/avalanche.service

Start Daemon: sudo systemctl start avalanchego

Restart: sudo systemctl restart avalanchego

Logs: sudo journalctl -u avalanchego -f

(todo) Show sync status:

curl -X POST --data '{
    "jsonrpc":"2.0",
    "id"     :1,
    "method" :"info.isBootstrapped",
    "params": {
        "chain":"X"
    }
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/info

# response -> {"jsonrpc":"2.0","result":{"isBootstrapped":true},"id":1}

NVMe drivers and RAID0 on Hetzner

Here is how to tpo configure your drives to RAID0 (max speed, no redundancy) on Hetzner.

Boot a Hetzner server to a rescue mode.

SSH in.

Start installation

installimage

Choose Ubuntu 20.04.

The editor will pop up and allow you to configure partitions.

Set software raid settings

# RAID enabled
SWRAID 1

# Use  stripe mode
SWRAIDLEVEL 0

Set the partition scheme as follow:

PART swap swap 32G
PART /boot ext3 512M
PART / xfs all

ext4 does not support large multi terabyte file systems, so we go with XFS. XFS might be even better for GoEthereum node like write loads.

Different disk sizes

If you have different sizes disk, then disable installation raid by setting SWRAID 0. This is because RAID 0 goes by the smallest disk and you want to utilise all the capacity.

Use mdadm tool from the command line to create a RAID particion and mount it in a special mount point.

  • Create stripe partition with mdadm
  • mkfs -f -t xfs /dev/md2
  • mkdir /bsc
  • blkid to find out the UUID of /dev/md2
  • nano /etc/fstab and add the partition there
  • mount -a to verify /etc/fstab is good

BSC further info

Latest releases on Github

BSC command:

./geth_linux \
  --config ./config.toml \
  --datadir ./data/bsc \
  --cache 32000 \
  --txlookuplimit 0 \
  --http.port 9545 \
  --http.addr 127.0.0.1 \
  --http.vhosts=* \
  --http.api=eth,net,web3,debug \
  --graphql \
  --graphql.vhosts=* \
  --snapshot=false \
  --diffsync \
  --verbosity 3

Cache should be half of the RAM.

diffsync was added in BSC geth 1.1.5

txlookuplimit 0 is needed to be able to fetch historical transactions. txlookuplimit 0 also here in geth release notes.

You can speed up a bit by adding the following config.toml bit:

[Eth]
DisablePeerTxBroadcast = true

Make sure StaticNodes in the config.toml contains the latest list

BSC pruning instructions

See here. See also pruning instructions for Polygon.

To prune:

geth snapshot prune-state --datadir ./data/bsc

Monitoring node

Use atop (apt install atop).

You can see disk business in the stats. This is often the bottleneck for the node syncing.

DSK |      nvme2n1  | busy     89%  |               | read   13669  | write   4630  |               | KiB/r     13  | KiB/w     62 |  MBr/s   18.3 |               |  MBw/s   28.3 |  avq     0.44 |               |  avio 0.49 ms |
DSK |      nvme3n1  | busy     89%  |               | read   13532  | write   4166  |               | KiB/r     13  | KiB/w     66 |  MBr/s   17.7 |               |  MBw/s   27.0 |  avq     1.10 |               |  avio 0.50 ms |

ethereum-blockchain-docker-compose's People

Contributors

miohtama avatar servatj avatar sontn1988 avatar hieuh25 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.