8

heco(火币生态链)主网链部署

 2 years ago
source link: https://learnblockchain.cn/article/2859
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

一.前期准备

1.1 部署文档信息:

1.2 硬件配置信息

8core
16g
硬盘空间 > 500 GB
带宽2M
16core
32g
硬盘空间 > 500 GB
带宽30M

1.3 网络配置信息

  • 一个公网ip
  • 开启 TCP/UDP 32668 端口;便于 p2p 发现和互联
  • rpc端口:8545

二.heco主链镜像生成

  • 下载heco主链基础镜像
docker pull buildpack-deps:jessie-curl
  • 编写Dockerfile
# vim Dockerfile 

FROM buildpack-deps:jessie-curl
RUN wget -P /usr/local/bin/ https://github.com/HuobiGroup/huobi-eco-chain/releases/download/v1.0.0/geth-linux-amd64 && mv /usr/local/bin/geth-linux-amd64 /usr/local/bin/geth && chmod +x /usr/local/bin/geth
EXPOSE 8545 8546 30303 30303/udp 
WORKDIR /data
ENTRYPOINT ["geth"]
  • 生成heco主链镜像
docker build . -t huobi-eco:v1.0.0

注:需要在与Dockerfile同一级目录下执行此命令

三.heco主链容器生成

3.1 编辑heco主网配置文件

下载heco主网的config.toml(配置文件)

# cd /opt/docker/heco/

[Eth]
SyncMode = "full"
DiscoveryURLs = []
TrieCleanCacheRejournal= 300000000000

[Eth.Miner]
GasFloor = 8000000
GasCeil = 8000000
GasPrice = 0
Recommit = 3000000000
Noverify = false

[Eth.Ethash]
CacheDir = "ethash"
CachesInMem = 2
CachesOnDisk = 3
CachesLockMmap = false
DatasetDir = "/data/heco/data/.ethash"
DatasetsInMem = 1
DatasetsOnDisk = 2
DatasetsLockMmap = false
PowMode = 0

[Eth.TxPool]
Locals = []
NoLocals = false
Journal = "transactions.rlp"
Rejournal = 3600000000000
PriceLimit = 1
PriceBump = 10
AccountSlots = 16
GlobalSlots = 4096
AccountQueue = 64
GlobalQueue = 1024
Lifetime = 10800000000000

[Node]
DataDir = "/data/heco/data"
InsecureUnlockAllowed = true
NoUSB = true
IPCPath = "geth.ipc"
HTTPHost = "0.0.0.0"
HTTPPort = 8545
HTTPCors = ["*"]
HTTPVirtualHosts = ["*"]
HTTPModules = ['eth', 'net', 'web3']

WSHost = "0.0.0.0"
WSPort = 8546
WSModules = ['eth', 'net', 'web3']

GraphQLVirtualHosts = ["localhost"]


[Node.P2P]
MaxPeers = 50
NoDiscovery = false

ListenAddr = ":32668"
EnableMsgEvents = false

[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000

注:关键配置详解

HTTPHost:HTTP-RPC服务连接白名单,此参数的值默认为 “localhost”,仅允许本地可访问,可设置为:“0.0.0.0”

HTTPVirtualHosts:HTTP-RPC服务监听接口,此参数的值默认为 [“localhost”],可设置为:HTTPVirtualHosts = ["*"]

以上文件默认使用了全节点同步,如果需要使用fast模式,将下列配置:

SyncMode = "full"
修改为
SyncMode = "fast"

3.2 启动heco主网链

启动参数完整帮助信息,可通过命令 geth help 或 geth -h 进行查阅。

docker run -itd --restart=unless-stopped -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --name public_heco -v $(pwd):/data -p 32668:32668 -p 8545:8545 huobi-eco:v1.0.0 --config /data/config.toml --logpath /data/logs

注:配置参数详解:

--config:指定配置文件路径

--logpath:指定日志文件路径,若不指定,日志将输出到heco控制台

--verbosity:日志级别(0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail)

如果需要启用archive 类型,需要加入以下两个启动参数:

使用 --syncmode=full --gcmode=archive 模式,即归档节点,这种模式保存了最最最全的节点数据,占用硬盘空间也会更大。(后面会专门针对节点数据配置写一篇文档)

--syncmode full 
--gcmode archive

--testnet:节点未指定网络标识时,默认连接heco主网;若需要连接heco测试网,启动时需加入此参数:

四.查看heco主网链是否部署成功

4.1 查看heco容器是否成功启动

# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                  NAMES
26477f6ae83d        huobi-eco:v1.0.0    "geth --config /data…"   About an hour ago   Up About an hour    8546/tcp, 30303/udp, 0.0.0.0:5545->8545/tcp, 0.0.0.0:5030->30303/tcp   public_heco

4.2 查看heco主网节点启动日志是否正常

# tail -f ./logs/chain.log
INFO [06-02|18:47:09.034] Starting Geth on Ethereum mainnet... 
INFO [06-02|18:47:09.034] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [06-02|18:47:09.036] Maximum peer count                       ETH=50 LES=0 total=50
INFO [06-02|18:47:09.036] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [06-02|18:47:09.036] Set global gas cap                       cap=25000000
WARN [06-02|18:47:09.036] Sanitizing invalid miner gas price       provided=0    updated=1000000000
INFO [06-02|18:47:09.036] Allocated trie memory caches             clean=1023.00MiB dirty=1024.00MiB
INFO [06-02|18:47:09.036] Allocated cache and file handles         database=/data/heco/data/geth/chaindata cache=2.00GiB handles=524288
INFO [06-02|18:47:09.077] Opened ancient database                  database=/data/heco/data/geth/chaindata/ancient
INFO [06-02|18:47:09.077] Writing default main-net genesis block 
INFO [06-02|18:47:09.078] Persisted trie from memory database      nodes=5 size=742.00B time="46.396µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
# 初始化heco链配置
INFO [06-02|18:47:09.078] Initialised chain configuration          config="{ChainID: 128 Homestead: 0 DAO: <nil> DAOSupport: true EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: 0, Muir Glacier: <nil>, YOLO v1: <nil>, Engine: congress}"
INFO [06-02|18:47:09.078] Initialising Ethereum protocol           versions="[65 64 63]" network=128 dbversion=<nil>
WARN [06-02|18:47:09.078] Upgrade blockchain database version      from=<nil> to=8
# 加载块
INFO [06-02|18:47:09.079] Loaded most recent local header          number=0 hash="5751d1…4cb144" td=1 age=6mo3d10h
INFO [06-02|18:47:09.079] Loaded most recent local full block      number=0 hash="5751d1…4cb144" td=1 age=6mo3d10h
INFO [06-02|18:47:09.079] Loaded most recent local fast block      number=0 hash="5751d1…4cb144" td=1 age=6mo3d10h
INFO [06-02|18:47:09.080] Regenerated local transaction journal    transactions=0 accounts=0
INFO [06-02|18:47:09.080] Starting peer-to-peer node               instance=Geth/v1.0.0-stable/linux-amd64/go1.13.4
INFO [06-02|18:47:09.082] Stored checkpoint snapshot to disk       number=0 hash="5751d1…4cb144"
INFO [06-02|18:47:09.096] New local node record                    seq=1 id=be0253324fd50a3c ip=127.0.0.1 udp=32668 tcp=32668
INFO [06-02|18:47:09.096] Started P2P networking                   self=enode://7142acfd66cedfceff9736f46bb9cb71a5628c34fe654c03052f00957f48c4ed8fcf4d2d76a4faadf1506efd625fac6ddf738c9d5e4f63aa248320758fda0a53@127.0.0.1:32668
INFO [06-02|18:47:09.097] IPC endpoint opened                      url=/data/heco/data/geth.ipc
INFO [06-02|18:47:09.097] HTTP server started                      endpoint=[::]:8545 cors=* vhosts=*
INFO [06-02|18:47:09.098] WebSocket enabled                        url=ws://[::]:8546
INFO [06-02|18:47:10.365] New local node record                    seq=2 id=be0253324fd50a3c ip=47.56.107.152 udp=32668 tcp=32668
# 寻找可连接的p2p节点
INFO [06-02|18:47:23.772] Looking for peers                        peercount=0 tried=112 static=0
INFO [06-02|18:47:24.605] Block synchronisation started 
INFO [06-02|18:47:33.777] Looking for peers                        peercount=1 tried=133 static=0
INFO [06-02|18:49:28.421] Looking for peers                        peercount=2 tried=95  static=0
WARN [06-02|18:49:34.934] Synchronisation failed, dropping peer    peer=0abf7fd9b6d1a16e err=timeout
INFO [06-02|18:49:45.998] Downloader queue stats                   receiptTasks=0 blockTasks=345 itemSize=607.45B throttle=8192

4.3 查看heco主网节点区块同步日志是否正常

# tail -f ./logs/chain.log
INFO [06-02|18:49:46.003] Imported new chain segment               blocks=28 txs=0 mgas=0.000 elapsed=4.913ms mgasps=0.000 number=28 hash="640547…320bed" age=6mo2d3h  dirty=5.15KiB
INFO [06-02|18:50:17.441] Imported new chain segment               blocks=356 txs=61 mgas=8.877 elapsed=85.000ms mgasps=104.438 number=384 hash="11f03e…6f57ba" age=6mo2d3h  dirty=66.51KiB
INFO [06-02|18:50:17.685] Imported new chain segment               blocks=1648 txs=0  mgas=0.000 elapsed=234.768ms mgasps=0.000   number=2032 hash="b4a99a…82969a" age=6mo2d1h  dirty=74.14KiB
INFO [06-02|18:50:17.972] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=274.895ms mgasps=0.000   number=4080 hash="abf316…4b6831" age=6mo2d15m dirty=79.40KiB
INFO [06-02|18:50:18.282] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=297.958ms mgasps=0.000   number=6128 hash="d8b2fa…bb053e" age=6mo1d22h dirty=81.51KiB
INFO [06-02|18:50:18.622] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=327.925ms mgasps=0.000   number=8176 hash="f9720a…7d3def" age=6mo1d20h dirty=86.40KiB
INFO [06-02|18:50:18.929] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=296.145ms mgasps=0.000   number=10224 hash="508cee…b21323" age=6mo1d19h dirty=95.21KiB
INFO [06-02|18:50:19.258] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=316.399ms mgasps=0.000   number=12272 hash="785690…692d82" age=6mo1d17h dirty=100.19KiB
INFO [06-02|18:50:19.606] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=336.842ms mgasps=0.000   number=14320 hash="1a9f94…044d20" age=6mo1d15h dirty=104.54KiB
INFO [06-02|18:50:19.943] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=324.403ms mgasps=0.000   number=16368 hash="820d72…def29d" age=6mo1d14h dirty=106.84KiB
INFO [06-02|18:50:20.250] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=295.783ms mgasps=0.000   number=18416 hash="a171a5…cdce4d" age=6mo1d12h dirty=116.16KiB
INFO [06-02|18:50:20.587] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=324.990ms mgasps=0.000   number=20464 hash="5262a5…a9948b" age=6mo1d10h dirty=120.21KiB
INFO [06-02|18:50:20.902] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=301.400ms mgasps=0.000   number=22512 hash="02d6cc…35bd1b" age=6mo1d8h  dirty=125.52KiB
INFO [06-02|18:50:21.241] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=327.600ms mgasps=0.000   number=24560 hash="5cfbae…564cd3" age=6mo1d7h  dirty=126.75KiB
INFO [06-02|18:50:21.540] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=283.429ms mgasps=0.000   number=26608 hash="2fb139…430c65" age=6mo1d5h  dirty=135.25KiB
INFO [06-02|18:50:21.877] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=325.097ms mgasps=0.000   number=28656 hash="058ff3…04ba5c" age=6mo1d3h  dirty=140.72KiB
INFO [06-02|18:50:22.167] Imported new chain segment               blocks=2048 txs=0  mgas=0.000 elapsed=277.699ms mgasps=0.000   number=30704 hash="80c8e2…da76e1" age=6mo1d2h  dirty=146.78KiB

五.查看heco主网节点是否同步完成

  • 查看节点区块数据同步进度
    查看节点当前同步的同步进度,返回为false,则heco主网节点区块数据同步完成
# curl -s -H Content-Type:application/json -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:8545
{"jsonrpc":"2.0","id":1,"result":{"currentBlock":"0x11a6db","highestBlock":"0x500bfe","knownStates":"0x0","pulledStates":"0x0","startingBlock":"0x0"}}
  • 查看节点最新区块号

查看节点当前同步的最新区块号,与heco官方区块链浏览器进行对比,查看是否一致,是否已与公网节点的区块一致

heco官方主网浏览器:https://hecoinfo.com/

# curl -s -H Content-Type:application/json -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://127.0.0.1:8545
{"jsonrpc":"2.0","id":1,"result":"0x11d8a0"}

查询heco链上最新的交易哈希,确认是否可获取交易信息,如果可获取,说明已同步区块信息

# curl -H Content-Type:application/json -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xab943f0a9c41f1b931bd1f95dd6776559ef689144aa792478d5952c62611513d"],"id":1}' http://127.0.0.1:5545
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0xa511f1cb62d9ab1c6c28584a4e476a463b0b7183136519b226d5ed873bf55fa7","blockNumber":"0x11fd4c","from":"0x6f7059179b93c88b961cc279deee898ff7e93faa","gas":"0xf4240","gasPrice":"0x3b9aca00","hash":"0xab943f0a9c41f1b931bd1f95dd6776559ef689144aa792478d5952c62611513d","input":"0x22c90166","nonce":"0x6864","to":"0x81fbaaacd63b423d71de99b95a654c0526bfdc69","transactionIndex":"0x10","value":"0x0","v":"0x123","r":"0x79bc2ab27f5588f7b7129cffe9786a92a974d41775ddbf8ffe8ca316894628c3","s":"0x37df2240af75fbe48917ae583d39437619e8ec3ec5d444fb30ee486207193f02"}}

以上,就是今天分享的全部内容了。

希望大家通过以上方式可以解决自己的实际需求,解决自己目前所遇到的问题。

如果在部署过程中有任何疑问,可以扫描下面的二维码,添加我的个人微信,备注:地区-职业方向-昵称,欢迎来撩,加入区块链技术交流群,与更多的区块链技术大佬学习交流。
.jpg

原创不易,码字不易。 觉得这篇文章对你有点用的话,麻烦你为本文点个赞,留言或转发一下,因为这将是我输出更多优质文章的动力,感谢!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK