Skip to content

1. BSC配置文件

1.1 端口

30303(tcp,udp)used by the P2P protocol running the network
8545used by the HTTP based JSON RPC API
8546used by the WebSocket based JSON RPC API
8547used by the GraphQL API

2. BSC优化

2.1 启动优化

BSC 节点提供可配置的缓存设置以提高性能。建议将大约三分之一的物理内存分配给高速缓存。例如,如果物理内存为 64GB,则缓存设置可以配置为:

bash
--cache 20000
--cache 20000

2.2 跟踪同步速度

bash
t=2021-05-13T17:17:17+0800 lvl=info msg="Imported new chain segment"             blocks=11  txs=3701  mgas=482.461  elapsed=8.075s    mgasps=59.744  number=7,355,800 hash=0x84e085b1cd5b1ad4f9a954e2f660704c8375a80f04326395536eedf83363942f age=12h38m32s dirty="583.73 MiB"
t=2021-05-13T17:17:20+0800 lvl=info msg="Deep froze chain segment"               blocks=117 elapsed=263.497ms number=7,265,806 hash=0x7602f6b960b4092d39ff49781c64404a047e2c78bc166f071ee8714020c39b2e
t=2021-05-13T17:17:25+0800 lvl=info msg="Imported new chain segment"             blocks=17  txs=5025  mgas=740.885  elapsed=8.125s    mgasps=91.177  number=7,355,817 hash=0xde7a2a76ff7b38414acf3b360bb427d2d0b7dd1f8fe2afe2ffd59d64b237a81b age=12h37m49s dirty="594.65 MiB"
t=2021-05-13T17:17:33+0800 lvl=info msg="Imported new chain segment"             blocks=18  txs=5108  mgas=748.016  elapsed=8.354s    mgasps=89.535  number=7,355,835 hash=0x757c476f9fe30fc6ef001fb4a03fa991843cf3ed271f21cfc01a9bba5e5eff98 age=12h37m3s  dirty="604.39 MiB"
t=2021-05-13T17:17:42+0800 lvl=info msg="Imported new chain segment"             blocks=18  txs=5612  mgas=799.778  elapsed=8.260s    mgasps=96.815  number=7,355,853 hash=0x73e87742ef4405ffefec987fc4b8b19e69c54b8f914c27ea69a502fae4d735e0 age=12h36m18s dirty="613.03 MiB"
t=2021-05-13T17:17:17+0800 lvl=info msg="Imported new chain segment"             blocks=11  txs=3701  mgas=482.461  elapsed=8.075s    mgasps=59.744  number=7,355,800 hash=0x84e085b1cd5b1ad4f9a954e2f660704c8375a80f04326395536eedf83363942f age=12h38m32s dirty="583.73 MiB"
t=2021-05-13T17:17:20+0800 lvl=info msg="Deep froze chain segment"               blocks=117 elapsed=263.497ms number=7,265,806 hash=0x7602f6b960b4092d39ff49781c64404a047e2c78bc166f071ee8714020c39b2e
t=2021-05-13T17:17:25+0800 lvl=info msg="Imported new chain segment"             blocks=17  txs=5025  mgas=740.885  elapsed=8.125s    mgasps=91.177  number=7,355,817 hash=0xde7a2a76ff7b38414acf3b360bb427d2d0b7dd1f8fe2afe2ffd59d64b237a81b age=12h37m49s dirty="594.65 MiB"
t=2021-05-13T17:17:33+0800 lvl=info msg="Imported new chain segment"             blocks=18  txs=5108  mgas=748.016  elapsed=8.354s    mgasps=89.535  number=7,355,835 hash=0x757c476f9fe30fc6ef001fb4a03fa991843cf3ed271f21cfc01a9bba5e5eff98 age=12h37m3s  dirty="604.39 MiB"
t=2021-05-13T17:17:42+0800 lvl=info msg="Imported new chain segment"             blocks=18  txs=5612  mgas=799.778  elapsed=8.260s    mgasps=96.815  number=7,355,853 hash=0x73e87742ef4405ffefec987fc4b8b19e69c54b8f914c27ea69a502fae4d735e0 age=12h36m18s dirty="613.03 MiB"

您的同步速度为 mgasps。该值应约为 100。如果同步速度缓慢,请检查磁盘的速度

3.常用命令

3.1 查看当前最新区块

bash
curl -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":"0xa352a4"}
curl -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":"0xa352a4"}

3.2 查看当前同步状态

bash
# curl -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":false}
# curl -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":false}

结果为false为同步完成

3.3 attach

1.节点状态监听

bash
geth attach http://localhost:8545     #端口如果修改配置文件了,就填写配置文件的端口即可
> eth.syncing	                      #查看当前区块情况,结果为false表示已同步最新区块
geth attach http://localhost:8545     #端口如果修改配置文件了,就填写配置文件的端口即可
> eth.syncing	                      #查看当前区块情况,结果为false表示已同步最新区块

💡 说明

currentBlock: 14290861,

#当前同步到区块高度

highestBlock: 14297354,

#主网当前高度

knownStates:297473485,

pulledStates: 297473485,

startingBlock: 14270385

2.查看当前连接节点数量

> net.peerCount	  #查看当前连接节点数量
> net.peerCount	  #查看当前连接节点数量

3.当前同步到区块高度

bash
> eth.blockNumber #当前同步到区块高度
> eth.blockNumber #当前同步到区块高度