天天看點

heco(火币生态鍊)主網鍊部署一.前期準備二.heco主鍊鏡像生成三.heco主鍊容器生成四.檢視heco主網鍊是否部署成功五.檢視heco主網節點是否同步完成

文章目錄

  • 一.前期準備
    • 1.1 部署文檔資訊:
    • 1.2 硬體配置資訊
    • 1.3 網絡配置資訊
  • 二.heco主鍊鏡像生成
  • 三.heco主鍊容器生成
    • 3.1 編輯heco主網配置檔案
    • 3.2 啟動heco主網鍊
  • 四.檢視heco主網鍊是否部署成功
    • 4.1 檢視heco容器是否成功啟動
    • 4.2 檢視heco主網節點啟動日志是否正常
    • 4.3 檢視heco主網節點區塊同步日志是否正常
  • 五.檢視heco主網節點是否同步完成

一.前期準備

1.1 部署文檔資訊:

  • heco官網:https://www.hecochain.com/zh-cn/
  • heco鍊github位址:https://github.com/HuobiGroup/huobi-eco-chain/releases
  • 主網區塊鍊浏覽器:https://hecoinfo.com/
  • 主網鍊官方部署文檔:https://docs.hecochain.com/#/dev/install
  • heco主網相關資訊:https://docs.hecochain.com/#/mainnet
  • 手續費(gasprice):https://tc.hecochain.com/price/prediction
  • 創世檔案介紹:https://docs.hecochain.com/#/genesis
  • 開發者文檔:https://docs.hecochain.com/#/

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"}}
           

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

希望大家通過以上方式可以解決自己的實際需求,解決自己目前所遇到的問題。

如果在部署過程中有任何疑問,可以掃描下面的二維碼,添加我的個人微信,備注:地區-職業方向-昵稱,歡迎來撩,加入區塊鍊技術交流群,與更多的區塊鍊技術大佬學習交流。

heco(火币生态鍊)主網鍊部署一.前期準備二.heco主鍊鏡像生成三.heco主鍊容器生成四.檢視heco主網鍊是否部署成功五.檢視heco主網節點是否同步完成

原創不易,碼字不易。 覺得這篇文章對你有點用的話,麻煩你為本文點個贊,留言或轉發一下,因為這将是我輸出更多優質文章的動力,感謝!