docker 部署BSC v1.0.7-ht.3版本开发网
其实上次已经和大家分享过一篇关于BSC(币安智能链)开发网的部署《BSC(币安智能链)开发网部署》,今天这篇同样也是关于BSC开发网部署的文档,但是也稍微的有一些不一样,共有以下几点:
Fatal: Failed to register the Ethereum service: unsupported fork ordering: mirrorSyncBlock not enabled, but berlinBlock enabled at 0
然后就发现v1.1.0及以上版本都有这个问题,官方的issues中暂时也没有回应这个问题,如果哪位大佬解决了这个问题,也可以一起沟通一下。
通过本文档对BSC币安智能链使用docker进行单节点部署过程进行描述
<table> <tr> <th>服务器</th> <th>程序</th> <th>默认端口</th> </tr> <tr> <td rowspan="9">127.0.0.1</td> <td>BSC开发网节点(BSC)</td> <td>rpc接口:8545<br>p2p接口:30303</td> </tr> </table>
服务器系统:Centos7+
CPU:8核
内存:16GB
硬盘:1024 GB
网络:千兆网卡
Docker:19.03.11
注意:软件使用版本不强制使用与上面一样的版本
docker pull buildpack-deps:jessie-curl
FROM buildpack-deps:jessie-curl
RUN wget -P /usr/local/bin/ https://github.com/binance-chain/bsc/releases/download/v1.0.7-ht.3/geth_linux && mv /usr/local/bin/geth_linux /usr/local/bin/geth && chmod +x /usr/local/bin/geth
EXPOSE 8545 8546 30303 30303/udp
WORKDIR /data
ENTRYPOINT ["geth"]
docker build . -t private_bsc:v1.0.7-ht.3
注:需要在与Dockerfile同一级目录下执行此命令
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
private_bsc v1.0.7-ht.3 1e35739486c3 8 minutes ago 214MB
参考: https://github.com/binance-chain/bsc/releases/download/v1.0.7-ht.3/mainnet.zip
[Eth]
NetworkId = 1024
NoPruning = false
NoPrefetch = false
LightPeers = 100
UltraLightFraction = 75
TrieTimeout = 100000000000
EnablePreimageRecording = false
EWASMInterpreter = ""
EVMInterpreter = ""
[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 = 8545
HTTPVirtualHosts = ["*"]
HTTPModules = ["eth", "net", "web3", "txpool", "parlia"]
WSPort = 8546
WSModules = ["net", "web3", "eth"]
[Node.P2P]
MaxPeers = 30
NoDiscovery = false
ListenAddr = ":30311"
EnableMsgEvents = false
[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000
[Node.LogConfig]
FilePath = "bsc.log"
MaxBytesSize = 10485760
Level = "info"
FileRoot = ""
geth.tpml 文件可创建在/opt/docker/bsc-private
使用MetaMask或者其他工具预先创建一个账户地址,并保存好私钥,后面这个地址会配置在genesis文件中,并用做挖矿coinbase地址及初始化地址
参考: https://github.com/binance-chain/bsc/releases/download/v1.0.7-ht.3/mainnet.zip
根据需要修改特定的字段,常规的比如
对于共识参数,可以根据需要再做修改
"congress": {
"period": 3, // 出块间隔(秒)
"epoch": 200 // 出块顺序刷新间隔(块数),epoch为一个周期设定,单位是block,每个epoch结束的时候,会对验证人进行相应调整;
}
genesis.json 文件创建
{
"config": {
"chainId": 1024,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"congress": {
"period": 20,
"epoch": 20000
}
},
"nonce": "0x0000000000000061",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x2625a00",
"difficulty": "0x100",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x6e60F5243e1a3F0Be3F407b5AFE9e5395ee82aa2",
"alloc": {
"0x6e60F5243e1a3F0Be3F407b5AFE9e5395ee82aa2":{
"balance": "6660010000000000000000000000"
}
}
}
注:genesis.json 应创建在/opt/docker/bsc-private
将上面修改好的geth.toml和genesis.json以及预生成的账户地址keystore文件放到规划好的位置,我们此时放在 /opt/docker/heco-private
cd /opt/docker/bsc-private
docker run --rm -v $(pwd):/data private_bsc:v1.0.7-ht.3 init /data/genesis.json --datadir /data/bsc
cp UTC--2017-11-21T05-46-23.555205600Z--6e60f5243e1a3f0be3f407b5afe9e5395ee82aa2 bsc/keystore/
或者可以将以上步骤编写为一个脚本,例如:
# vim /opt/docker/bsc-private/genesis.sh
#!/bin/bash
docker run --rm -v $(pwd):/data private_bsc:v1.0.7-ht.3 init /data/genesis.json --datadir /data/bsc
cp UTC--* ./bsc/keystore/
docker run -itd --restart=unless-stopped -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --name private-bsc -v /opt/docker/bsc-private:/data -p 30303:30303 -p 8545:8545 private_bsc:v1.0.7-ht.3 --config config.toml --datadir /data/bsc --nodiscover
# tail -100 /opt/docker/bsc-private/bsc/bsc.log.2021-08-04_16
t=2021-08-04T16:20:45+0800 lvl=info msg="Starting peer-to-peer node" instance=Geth/v1.0.7-hf.3-5bc1d30b/linux-amd64/go1.16.3
t=2021-08-04T16:20:45+0800 lvl=info msg="Allocated trie memory caches" clean="614.00 MiB" dirty="1024.00 MiB"
注意:此时heco私链并没有开启挖矿
启动后,进入ipc,解锁我们预先生成的地址,作为此节点的coinbase
# docker exec -it private-bsc bash
root@3366708929de:/data# geth attach /data/bsc/geth.ipc
> eth
{
accounts: ["0x6e60f5243e1a3f0be3f407b5afe9e5395ee82aa2"],
blockNumber: 0,
coinbase: "0x6e60f5243e1a3f0be3f407b5afe9e5395ee82aa2",
accounts和coinbase都为以上步骤预先生成的地址
> personal.unlockAccount("0x6e60f5243e1a3f0be3f407b5afe9e5395ee82aa2","123456",0)
true
> miner.start(1)
null
注:开启一个线程进行挖矿
# docker logs -f private_heco --tail 10
// 生成DAG数据
t=2021-08-04T16:26:50+0800 lvl=info msg="Generating DAG in progress" epoch=0 percentage=0 elapsed=356.389ms
t=2021-08-04T16:26:50+0800 lvl=info msg="Generating DAG in progress" epoch=0 percentage=1 elapsed=708.495ms
t=2021-08-04T16:26:50+0800 lvl=info msg="Generating DAG in progress" epoch=0 percentage=2 elapsed=1.058s
t=2021-08-04T16:26:51+0800 lvl=info msg="Generating DAG in progress" epoch=0 percentage=3 elapsed=1.404s
t=2021-08-04T16:26:51+0800 lvl=info msg="Generating DAG in progress" epoch=0 percentage=4 elapsed=1.762s
// 开始出块
t=2021-08-04T16:27:29+0800 lvl=info msg="Successfully sealed new block" number=1 sealhash=0x57d0cdcc353de2b1b2d99b455efc0dce14f6e204434d362bed005ea5f003dcaf hash=0x89cdece36c95746fd82fbb65b994f8ea3db5f4953570737459c6f2673cebdf50 elapsed=40.576s
t=2021-08-04T16:27:29+0800 lvl=info msg=" mined potential block" number=1 hash=0x89cdece36c95746fd82fbb65b994f8ea3db5f4953570737459c6f2673cebdf50
t=2021-08-04T16:27:29+0800 lvl=info msg="Commit new mining work" number=2 sealhash=0xdf92768fb682d0c811c0637d2431478731b06c49070f54824c164ef1988175fd uncles=0 txs=0 gas=0 fees=0 elapsed=172.97µs
节点出块主要是以下日志
// 成功封存新的区块
t=2021-08-04T16:33:22+0800 lvl=info msg="Successfully sealed new block" number=119 sealhash=0x944e47c25deb67219e80af398b21a0c9b55a5eef4a61e22c78376a5118c46189 hash=0xd8cdbdcc9e8cc513866125dbd372deb65cecf0fa618fbd09dc0d01cd14b952e2 elapsed=1.737s
// 区块进行上链
t=2021-08-04T16:33:22+0800 lvl=info msg=" block reached canonical chain" number=108 hash=0xf8a65a6468625c14b4d195963460ffd413f9f9f9d3cf7e0a6b1cf77d6b16f40c
// 挖掘可能的区块
t=2021-08-04T16:33:22+0800 lvl=info msg=" mined potential block" number=119 hash=0xd8cdbdcc9e8cc513866125dbd372deb65cecf0fa618fbd09dc0d01cd14b952e2
// 进行新的挖矿工作
t=2021-08-04T16:33:22+0800 lvl=info msg="Commit new mining work" number=120 sealhash=0xaf151731361f37ff932f905e9af6b05b25557ace82c670fd6abe42abd455fb8c uncles=0 txs=0 gas=0 fees=0 elapsed=166.462µs
查看前面预先设置的初始资金接收地址余额
> web3.fromWei(eth.getBalance(eth.accounts[0]))
6660010300
> eth.blockNumber
153
> miner.stop()
null
以上,就是今天分享的全部内容了。
希望大家通过以上方式可以解决自己的实际需求,解决自己目前所遇到的问题。
如果在部署过程中有任何疑问,可以扫描下面的二维码,添加我的个人微信,备注:地区-职业方向-昵称,欢迎来撩,加入区块链技术交流群,与更多的区块链技术大佬学习交流。
原创不易,码字不易。 觉得这篇文章对你有点用的话,麻烦你为本文点个赞,留言或转发一下,因为这将是我输出更多优质文章的动力,感谢!
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!