heco(火幣生態鏈)主網鏈部署

toString 2021-08-15 17:27:50 阅读数:428

本文一共[544]字,预计阅读时长:1分钟~
heco 部署

一.前期准備

1.1 部署文檔信息:

1.2 硬件配置信息

  • 最低
8core16g硬盤空間 > 500 GB帶寬2M
  • 推薦
16core32g硬盤空間 > 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-curlRUN 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/gethEXPOSE 8545 8546 30303 30303/udp WORKDIR /dataENTRYPOINT ["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 = 8000000GasCeil = 8000000GasPrice = 0Recommit = 3000000000Noverify = false[Eth.Ethash]CacheDir = "ethash"CachesInMem = 2CachesOnDisk = 3CachesLockMmap = falseDatasetDir = "/data/heco/data/.ethash"DatasetsInMem = 1DatasetsOnDisk = 2DatasetsLockMmap = falsePowMode = 0[Eth.TxPool]Locals = []NoLocals = falseJournal = "transactions.rlp"Rejournal = 3600000000000PriceLimit = 1PriceBump = 10AccountSlots = 16GlobalSlots = 4096AccountQueue = 64GlobalQueue = 1024Lifetime = 10800000000000[Node]DataDir = "/data/heco/data"InsecureUnlockAllowed = trueNoUSB = trueIPCPath = "geth.ipc"HTTPHost = "0.0.0.0"HTTPPort = 8545HTTPCors = ["*"]HTTPVirtualHosts = ["*"]HTTPModules = ['eth', 'net', 'web3']WSHost = "0.0.0.0"WSPort = 8546WSModules = ['eth', 'net', 'web3']GraphQLVirtualHosts = ["localhost"][Node.P2P]MaxPeers = 50NoDiscovery = falseListenAddr = ":32668"EnableMsgEvents = false[Node.HTTPTimeouts]ReadTimeout = 30000000000WriteTimeout = 30000000000IdleTimeout = 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 psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES26477f6ae83d 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.logINFO [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=4096INFO [06-02|18:47:09.036] Maximum peer count ETH=50 LES=0 total=50INFO [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=25000000WARN [06-02|18:47:09.036] Sanitizing invalid miner gas price provided=0 updated=1000000000INFO [06-02|18:47:09.036] Allocated trie memory caches clean=1023.00MiB dirty=1024.00MiBINFO [06-02|18:47:09.036] Allocated cache and file handles database=/data/heco/data/geth/chaindata cache=2.00GiB handles=524288INFO [06-02|18:47:09.077] Opened ancient database database=/data/heco/data/geth/chaindata/ancientINFO [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=6mo3d10hINFO [06-02|18:47:09.079] Loaded most recent local full block number=0 hash="5751d1…4cb144" td=1 age=6mo3d10hINFO [06-02|18:47:09.079] Loaded most recent local fast block number=0 hash="5751d1…4cb144" td=1 age=6mo3d10hINFO [06-02|18:47:09.080] Regenerated local transaction journal transactions=0 accounts=0INFO [06-02|18:47:09.080] Starting peer-to-peer node instance=Geth/v1.0.0-stable/linux-amd64/go1.13.4INFO [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=32668INFO [06-02|18:47:09.096] Started P2P networking self=enode://7142acfd66cedfceff9736f46bb9cb71a5628c34fe654c03052f00957f48c4ed8[email protected]127.0.0.1:32668INFO [06-02|18:47:09.097] IPC endpoint opened url=/data/heco/data/geth.ipcINFO [06-02|18:47:09.097] HTTP server started endpoint=[::]:8545 cors=* vhosts=*INFO [06-02|18:47:09.098] WebSocket enabled url=ws://[::]:8546INFO [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=0INFO [06-02|18:47:24.605] Block synchronisation started INFO [06-02|18:47:33.777] Looking for peers peercount=1 tried=133 static=0INFO [06-02|18:49:28.421] Looking for peers peercount=2 tried=95 static=0WARN [06-02|18:49:34.934] Synchronisation failed, dropping peer peer=0abf7fd9b6d1a16e err=timeoutINFO [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.logINFO [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.15KiBINFO [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.51KiBINFO [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.14KiBINFO [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.40KiBINFO [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.51KiBINFO [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.40KiBINFO [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.21KiBINFO [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.19KiBINFO [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.54KiBINFO [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.84KiBINFO [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.16KiBINFO [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.21KiBINFO [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.52KiBINFO [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.75KiBINFO [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.25KiBINFO [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.72KiBINFO [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

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

版权声明:本文为[toString]所创,转载请带上原文链接,感谢。 https://gsmany.com/2021/08/20210815172737039D.html