added bsc node

This commit is contained in:
_den 2022-03-03 19:14:26 +10:00
parent 7ac3ecc384
commit 7b61fcd9bc
7 changed files with 237 additions and 0 deletions

1
bsc/.dockerignore Normal file
View File

@ -0,0 +1 @@
./bsc-data/

18
bsc/Dockerfile Normal file
View File

@ -0,0 +1,18 @@
# Build Geth in a stock Go builder container
FROM golang:1.16-alpine as builder
ARG BSC_TAG
RUN apk add --no-cache make gcc musl-dev linux-headers git bash
RUN cd / && git clone --branch ${BSC_TAG} --single-branch https://github.com/binance-chain/bsc.git && cd ./bsc && make geth
# Pull Geth into a second stage deploy alpine container
FROM alpine:latest
RUN apk add --no-cache ca-certificates curl jq tini
COPY --from=builder /bsc/build/bin/geth /usr/local/bin/bsc
COPY ./docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["bsc"]

37
bsc/bsc.md Normal file
View File

@ -0,0 +1,37 @@
# BSC node
## Requirements for Ethereum network
* memory: 48Gb
* disk: 3Tb SSD (require periodically prune state)
## Installation
Set in the `.env` file:
* `DOMAIN=` - the domain name to be used in traefik;
* `BSC_TAG=` - Use latest stable version from https://github.com/bnb-chain/bsc/tags.
You can also set a list of allowed IP addresses there and addresses to treat as local. Rename `example.env` to `.env`:
```
mv example.env .env
```
Start node:
```bash
docker-compose build
docker-compose up -d bsc
```
## Upgrade
Periodically check for new versions. if there is a release, then you need to update the tag in the environment file.
```bash
docker-compose build
docker-compose up -d bsc
```
## Pruning
Use it if the size is approaching 800 GB. At least 150 GB must be free for successful pruning.
```bash
docker-compose down
docker-compose up bsc-pruning
docker-compose down
docker-compose up -d bsc
```

67
bsc/config.toml Normal file
View File

@ -0,0 +1,67 @@
[Eth]
NetworkId = 56
NoPruning = false
NoPrefetch = false
LightPeers = 100
UltraLightFraction = 75
TrieTimeout = 100000000000
EnablePreimageRecording = false
EWASMInterpreter = ""
EVMInterpreter = ""
DatabaseCache = 8192
DatabaseFreezer = ""
[Eth.Miner]
GasFloor = 30000000
GasCeil = 40000000
GasPrice = 1000000000
Recommit = 10000000000
Noverify = false
[Eth.TxPool]
Locals = []
NoLocals = true
Journal = "transactions.rlp"
Rejournal = 3600000000000
PriceLimit = 1000000000
PriceBump = 10
AccountSlots = 512
GlobalSlots = 10000
AccountQueue = 256
GlobalQueue = 5000
Lifetime = 10800000000000
[Eth.GPO]
Blocks = 20
Percentile = 60
OracleThreshold = 20
[Node]
IPCPath = "geth.ipc"
HTTPHost = "0.0.0.0"
NoUSB = true
InsecureUnlockAllowed = false
HTTPPort = 8525
HTTPVirtualHosts = ["*"]
HTTPModules = ["eth", "net", "web3", "txpool", "parlia"]
WSPort = 8526
WSModules = ["net", "web3", "eth"]
[Node.P2P]
MaxPeers = 100
NoDiscovery = false
BootstrapNodes = ["enode://1cc4534b14cfe351ab740a1418ab944a234ca2f702915eadb7e558a02010cb7c5a8c295a3b56bcefa7701c07752acd5539cb13df2aab8ae2d98934d712611443@52.71.43.172:30311","enode://28b1d16562dac280dacaaf45d54516b85bc6c994252a9825c5cc4e080d3e53446d05f63ba495ea7d44d6c316b54cd92b245c5c328c37da24605c4a93a0d099c4@34.246.65.14:30311","enode://5a7b996048d1b0a07683a949662c87c09b55247ce774aeee10bb886892e586e3c604564393292e38ef43c023ee9981e1f8b335766ec4f0f256e57f8640b079d5@35.73.137.11:30311"]
StaticNodes = ["enode://ace8e3b7e96290392a9c6238e005539dd1d1ca7c18aeedd979087789812e0656407e2c4baabcd83b50d583b583aa959ff42e5c95571d76b84995aad722a9a85c@44.198.55.182:30311","enode://1cda8150a6fe7597ce9f97b9886bc7bda2c3f0b246b509a5783c7dae7e57f831c7288a801ad129d2ffac330494ba75f0f0f62e1d1eba3499feca4ee29c6ae087@3.215.117.86:30311","enode://4b32e474c1aa896c856b916f2feb7af4e49feb6f2ff355896473b44d6723e71a5602a610cc0839654ad2f031e5da6e210d880a4cd977a2ec76e64a95c13f49a3@18.206.147.221:30311","enode://6265fbbf7fc2978900abee29ab1f019ccbccaa22e4e1e07149f3607c7d680a1ba006e7bb5cf8901e26d07cad8140799832caa389fc2fe0e1c6db4fec76946c2e@18.233.226.171:30311","enode://bdbcb42ff17a52af7ac120f23ee86f525ffbd854ce76e54bad858cf741fcd524d0f810be399d437bea939682a919c5af5df31811c43ccc270d04485caf4ddaeb@52.206.226.126:30311","enode://93a47b4de28dfd716a3de5481a72916f326b7c31c137d72ac12950c61ec3ee143312d903dbfab916ac0d7a92fedad6fc6f646c16ea009ca893089c9c2f64ec83@18.204.55.80:30311","enode://bb851ac2001f47e7c9a5d08a2fafcfe483c5bd02865b3a25901f853cfaec297e1eded6a27f0c0b8fcb59891b6a0846ca92f54e05c1db4b1c9f4dbef5b66062f3@3.88.19.251:30311","enode://d54499eb86df0f28d91906cef4f648360b636f923d58567865b83508fb97d2e95d2ce3e3a594facb73230b9e19172a534ce5af3f528599d0d1e52632438aa864@44.200.226.84:30311","enode://2d55e48679442a9e3ef2a3edf2854dcb289f8162d57dbda1e82e7576b0708e0670befaa7255f5c9fa8389443a7e7b4ff762c9e7fd33ddf9f21ec9562f03e8945@18.212.135.123:30311","enode://9df97e190f0b82ba7891e0ed556f11f4c1a172c26b2e823e52cfe5722b3df3f1819d2acb87ed0bfeb21fe3aee4ef1ffb8c9227fa7fdf744bfd4f47caad461edf@54.81.89.198:30311"]
ListenAddr = ":30302"
EnableMsgEvents = false
[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000
[Node.LogConfig]
FilePath = "bsc.log"
MaxBytesSize = 10485760
Level = "info"
FileRoot = ""

90
bsc/docker-compose.yml Normal file
View File

@ -0,0 +1,90 @@
version: "3.7"
services:
bsc-pruning:
image: bsc:local
container_name: bsc-pruning
entrypoint:
- bsc
- snapshot
- prune-state
restart: "no"
volumes:
- ./bsc-data:/root/.ethereum
- ./config.toml:/root/.ethereum/config.toml
bsc:
image: bsc:local
build:
context: .
args:
- BSC_TAG=${BSC_TAG}
container_name: bsc
env_file: .env
entrypoint:
- docker-entrypoint.sh
- bsc
- --config
- "/root/.ethereum/config.toml"
- --port
- "${P2P_PORT}"
- --rpc.allow-unprotected-txs
- --http
- --http.addr
- "0.0.0.0"
- --http.port
- "${HTTP_PORT}"
- --http.corsdomain=*
- --http.vhosts=*
- --http.api
- "eth,net,web3,parlia,txpool"
- --ws
- --ws.addr
- "0.0.0.0"
- --ws.port
- "${WS_PORT}"
- --ws.origins=*
- --ws.api
- "eth,net,web3,txpool"
- --txpool.pricelimit
- "1"
- --txpool.reannouncetime
- "1m"
- --txpool.locals
- "${TX_LOCAL_ADDR}"
- --cache
- "20480"
restart: always
stop_grace_period: 4m
stop_signal: SIGINT
ports:
# - ${HTTP_PORT}:${HTTP_PORT}
# - ${WS_PORT}:${WS_PORT}
- ${P2P_PORT}:${P2P_PORT}
volumes:
- ./bsc-data:/root/.ethereum
- ./config.toml:/root/.ethereum/config.toml
labels:
- "traefik.enable=true"
- "traefik.http.routers.bsc-http.middlewares=bsc-http-acl"
- "traefik.http.middlewares.bsc-http.headers.customrequestheaders.Access-Control-Allow-Origin=*"
- "traefik.http.middlewares.bsc-http-acl.ipwhitelist.sourcerange=127.0.0.1/32, ${ALLOW_FROM}"
- "traefik.http.routers.bsc-http.service=bsc-http"
- "traefik.http.routers.bsc-http.rule=Host(`${DOMAIN}`) && Path(`/bsc-http/`)"
- "traefik.http.routers.bsc-http.entrypoints=websecure"
- "traefik.http.routers.bsc-http.tls.certresolver=myresolver"
- "traefik.http.services.bsc-http.loadbalancer.server.port=${HTTP_PORT}"
- "traefik.http.routers.bsc-ws.middlewares=bsc-ws-acl"
- "traefik.http.middlewares.bsc-ws.headers.customrequestheaders.Access-Control-Allow-Origin=*"
- "traefik.http.middlewares.bsc-ws-acl.ipwhitelist.sourcerange=127.0.0.1/32, ${ALLOW_FROM}"
- "traefik.http.routers.bsc-ws.service=bsc-ws"
- "traefik.http.routers.bsc-ws.rule=Host(`${DOMAIN}`) && Path(`/bsc-ws/`)"
- "traefik.http.routers.bsc-ws.entrypoints=websecure"
- "traefik.http.routers.bsc-ws.tls.certresolver=myresolver"
- "traefik.http.services.bsc-ws.loadbalancer.server.port=${WS_PORT}"
networks:
- rpc
networks:
rpc:
name: rpc-shared-network

11
bsc/docker-entrypoint.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -x
if [ ! -f /root/.ethereum/setupdone ]; then
wget -O /root/mainnet.zip "https://github.com/bnb-chain/bsc/releases/download/${BSC_TAG}/mainnet.zip"
unzip -o -j /root/mainnet.zip "mainnet/genesis.json" -d /root/.ethereum/
bsc init /root/.ethereum/genesis.json
touch /root/.ethereum/setupdone
fi
exec "$@"

13
bsc/example.env Normal file
View File

@ -0,0 +1,13 @@
# Traefik
DOMAIN=domain.org
# Comma-separated list of IP/mask addresses to allow access. Replace 0.0.0.0/0 with your address
ALLOW_FROM=0.0.0.0/0
# Node
P2P_PORT=30302
HTTP_PORT=8525
WS_PORT=8526
# Comma-separated list of addresses to treat as "local"
TX_LOCAL_ADDR=0x0000000000000000000000000000000000000000
# Use latest stable version: https://github.com/bnb-chain/bsc/tags
BSC_TAG=v1.1.8