[TOC]
Bitcoin (BTC) 节点¶
节点信息¶
环境配置¶
# 自定义环境变量
echo -e "export BITCOIN_HOME=/opt/chain/bitcoin" > /etc/profile.d/bitcoin.sh
source /etc/profile
# 创建数据存储目录以及配置文件目录
mkdir -p ${BITCOIN_HOME}/{config,data/blocks,src}
touch ${BITCOIN_HOME}/config/bitcoin.conf
chown -R deploy.deploy ${BITCOIN_HOME}
# 使用deploy用户启动服务
su deploy
下载程序¶
cd ${BITCOIN_HOME}/src
wget https://bitcoin.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
tar -zxf bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
mv ${BITCOIN_HOME}/src/bitcoin-0.21.0/* ${BITCOIN_HOME}
服务管理¶
首次启动需添加参数 -reindex
# testnet ${BITCOIN_HOME}/bin/bitcoind -testnet -reindex -conf=${BITCOIN_HOME}/config/bitcoin.conf -daemon # main ${BITCOIN_HOME}/bin/bitcoind -reindex -conf=${BITCOIN_HOME}/config/bitcoin.conf -daemon
启动服务
# testnet ${BITCOIN_HOME}/bin/bitcoind -testnet -conf=${BITCOIN_HOME}/config/bitcoin.conf -daemon # main ${BITCOIN_HOME}/bin/bitcoind -conf=${BITCOIN_HOME}/config/bitcoin.conf -daemon
停止服务
# testnet ${BITCOIN_HOME}/bin/bitcoin-cli -testnet -conf=${BITCOIN_HOME}/config/bitcoin.conf stop # main ${BITCOIN_HOME}/bin/bitcoin-cli -conf=${BITCOIN_HOME}/config/bitcoin.conf stop
区块同步信息
# testnet ${BITCOIN_HOME}/bin/bitcoin-cli -testnet -conf=${BITCOIN_HOME}/config/bitcoin.conf getblockchaininfo ${BITCOIN_HOME}/bin/bitcoin-cli -testnet -conf=${BITCOIN_HOME}/config/bitcoin.conf getmininginfo # main ${BITCOIN_HOME}/bin/bitcoin-cli -conf=${BITCOIN_HOME}/config/bitcoin.conf getblockchaininfo ${BITCOIN_HOME}/bin/bitcoin-cli -conf=${BITCOIN_HOME}/config/bitcoin.conf getmininginfo
查看日志
# testnet tail -f ${BITCOIN_HOME}/data/testnet3/debug.log # main tail -f ${BITCOIN_HOME}/data/debug.log
附录1:Testnet 配置文件¶
vim config/bitcoin.conf
# [core]
# 存储区块链数据目录。
blocksdir=/opt/chain/bitcoin-0.21.0/data/blocks
# 在后台作为守护进程运行并接受命令。
daemon=1
# 存储区块链和其他数据目录。
datadir=/opt/chain/bitcoin-0.21.0/data/
# 设置数据库缓存大小为兆字节;机器与更大的缓存同步更快。建议根据机器的可用RAM设置尽可能高的值。
dbcache=2048
# [debug]
# 在比特币测试网络上运行这个节点。相当于 -chain=test
testnet=1
txindex=1
# [rpc]
# 接受命令行和JSON-RPC命令。
server=1
# Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times.
rpcallowip=0.0.0.0/0
# [Sections]
# Most options automatically apply to mainnet, testnet, and regtest networks.
# If you want to confine an option to just one network, you should add it in the relevant section.
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.
#rpcuser=rpc
#rpcpassword=rpcp@ssw0rd
# Options only for mainnet
#[main]
# Options only for testnet
[test]
# Listen for JSON-RPC connections on this port
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcport=18332
rpcuser=rpc
rpcpassword=rpcp@ssw0rd
# Options only for regtest
#[regtest]
附录2:Main 配置文件¶
vim /opt/chain/bitcoin-0.21.0/config/bitcoin.conf
# [core]
# Specify a non-default location to store blockchain data.
blocksdir=/opt/chain/bitcoin-0.21.0/data/blocks
# Run in the background as a daemon and accept commands.
# 后台执行(是否后台执行)
daemon=0
# Specify a non-default location to store blockchain and other data.
# 数据存储目录
datadir=/opt/chain/bitcoin-0.21.0/data/
# Set database cache size in megabytes; machines sync faster with a larger cache. Recommend setting as high as possible based upon machine's available RAM.
dbcache=2048
# [debug]
# Run this node on the Bitcoin Test Network. Equivalent to -chain=test
# 使用测试网络(0:正式网,1:测试网)
testnet=0
txindex=1
# [rpc]
# Accept command line and JSON-RPC commands.
# 告知 Bitcoin-Qt 和 bitcoind 接受JSON-RPC命令(是否启用命令和接受RPC服务)
server=1
# 设置 gen=1 以尝试比特币挖矿
gen=0
# Options only for mainnet
[main]
# Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times.
# 允许那些IP访问RPC接口,以下写法为默认所有ip都可访问
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
ppcbind=127.0.0.1
rpcconnect=127.0.0.1
# [Sections]
# Most options automatically apply to mainnet, testnet, and regtest networks.
# If you want to confine an option to just one network, you should add it in the relevant section.
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.
# 监听 RPC 链接,正式默认端口8333 测试默认18333
rpcport=8332
rpcuser=rpc
rpcpassword=rpcp@ssw0rd
# Options only for testnet
[test]
# Listen for JSON-RPC connections on this port
# rpcport=18332
# Options only for regtest
[regtest]
Ethereum (ETH) 节点¶
节点信息¶
下载程序¶
# 自定义环境变量
echo -e "export ETH_HOME=/opt/chain/ethereum" > /etc/profile.d/ethereum.sh
source /etc/profile
mkdir -p ${ETH_HOME}/{data,log,bin,src}
cd ${ETH_HOME}/src
# wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.15-0f77f34b.tar.gz
# tar -zxf geth-linux-amd64-1.9.15-0f77f34b.tar.gz
# mv geth-linux-amd64-1.9.15-0f77f34b ethereum
# 下载源码
# wget https://github.com/ethereum/go-ethereum/archive/refs/tags/v1.10.1.tar.gz
# tar -zxf go-ethereum-1.10.1.tar.gz
# cd go-ethereum-1.10.1
wget https://github.com/ethereum/go-ethereum/archive/refs/tags/v1.10.6.tar.gz
# 设置golang代理
export GOPROXY=https://goproxy.cn
# 编译
make geth
cp -a build/bin/geth ${ETH_HOME}/bin
环境配置¶
chown -R deploy.deploy ${ETH_HOME}
# 使用deploy用户启动服务
su deploy
使用创始文件初始化(rinkeby网络需要执行,main无需执行,只需执行一次)
wget https://www.rinkeby.io/rinkeby.json
# 使用创始文件初始化节点
${ETH_HOME}/geth --datadir=${ETH_HOME}/data init rinkeby.json
# 创建账号
${ETH_HOME}/geth --datadir=${ETH_HOME}/data account new
服务管理¶
启动
# rinkeby nohup ${ETH_HOME}/geth --networkid=4 --http --http.addr 0.0.0.0 --http.port 16666 --http.api eth,net,web3 --syncmode full --cache 2048 --datadir ${ETH_HOME}/data/ --ethash.dagdir ${ETH_HOME}/data/ethdag/ --ws --ws.addr 0.0.0.0 --ws.port 16667 --ws.origins "*" --rpcvhosts "*" --bootnodes=enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303 --verbosity 3 >> ${ETH_HOME}/log/geth.log & # main nohup ${ETH_HOME}/bin/geth --http --http.addr 0.0.0.0 --http.port 6666 --http.api eth,net,web3 --syncmode full --cache 2048 --datadir ${ETH_HOME}/node-master/data/ --ethash.dagdir ${ETH_HOME}/node-master/data/ethdag/ --ws --ws.addr 0.0.0.0 --ws.port 6667 --ws.origins "*" --rpcvhosts "*" --verbosity 3 >> ${ETH_HOME}/node-master/log/geth.log & nohup /opt/chain/ethereum/bin/geth --http --http.addr 0.0.0.0 --http.port 6666 --http.api eth,net,web3 --syncmode full --cache 2048 --datadir /opt/chain/ethereum/node-master/data/ --ethash.dagdir /opt/chain/ethereum/node-master/data/ethdag/ --ws --ws.addr 0.0.0.0 --ws.port 6667 --ws.origins "*" --rpcvhosts "*" --verbosity 3 >> /opt/chain/ethereum/node-master/log/geth.log & nohup /opt/chain/ethereum/bin/geth --http --http.addr 0.0.0.0 --http.port 6666 --http.api eth,net,web3 --syncmode full --cache 2048 --datadir /opt/chain/ethereum/node-master/data/ --ethash.dagdir /opt/chain/ethereum/node-master/data/ethdag/ --ws --ws.addr 0.0.0.0 --ws.port 6667 --ws.origins "*" --http.vhosts "*" --verbosity 3 >> /opt/chain/ethereum/node-master/log/geth.log &
查看日志
tail -f ${ETH_HOME}/log/geth.log
进入控制台
${ETH_HOME}/geth attach ipc:${ETH_HOME}/data/geth.ipc
控制台常用命令
# 查看区块同步情况 eth.syncing # 列出所有账号 eth.accounts # 在同步的过程中我们通过 eth.blockNumber 去查看当前区块号的话会显示为0 eth.blockNumber # 节点连了多少个其它节点进行数据同步。如果返回结果为0,就要自查一下了 net.peerCount #查看网络上的小伙伴 admin.peers # 查看第一个账号余额 eth.getBalance(eth.accounts[0]) # 新建一个密码123456的账号 personal.newAccount('123456') # 币值转换为big ether web3.toWei(0.0001, "ether") # big ether转换为ether web3.fromWei(100000000000000, "ether") # 查看网络当前网络信息 admin.nodeInfo # 查看连接的节点信息 admin.peers # 删除同步节点 admin.removePeer("enode://cb27417409f49cad6046fabac3de7da21fe04044021fcea49a764befac786fa7b9617fc90141464899d4305854df341ea0d0f1708cc3f15b0c0b4bc1acff2139@51.81.154.30:30303") # 添加节点 admin.addPeer("enode://3af83ae28fc90838c334369ed2bf8071065062b851e5845e5eb07bd2efc5ba68f9d77865bea3ea09d3cc866bded716c258b0bca002696a69463fba7fdefb51df@128.230.208.74:30303") # 添加信任节点 admin.addTrustedPeer("enode://3af83ae28fc90838c334369ed2bf8071065062b851e5845e5eb07bd2efc5ba68f9d77865bea3ea09d3cc866bded716c258b0bca002696a69463fba7fdefb51df@128.230.208.74:30303") # 查看网络是否监听 net.listening # 开始挖矿 miner.start() # 停止挖矿 miner.stop() # 获取用户金额 eth.getBalance(my)
附录1:ETH JSON RPC 手册¶
附录2:相关技术问题手册¶
EOS 节点¶
节点信息¶
下载程序¶
# 自定义环境变量
echo -e "export EOS_HOME=/opt/chain/eosio" > /etc/profile.d/eosio.sh
source /etc/profile
mkdir -p ${EOS_HOME}/{data,config,log,src}
cd ${EOS_HOME}/src
wget https://github.com/EOSIO/eos/releases/download/v2.0.4/eosio-2.0.4-1.el7.x86_64.rpm
rpm -ivh eosio-2.0.4-1.el7.x86_64.rpm
环境配置¶
cd ${EOS_HOME}/config/
# Testnet下载创世文件
wget https://genesis.testnet.eos.io/genesis.json
touch ${EOS_HOME}/config/config.ini
# Main下载创世文件
wget https://eosnodes.privex.io/static/genesis.json
touch ${EOS_HOME}/config/config.ini
chown -R deploy.deploy ${EOS_HOME}
# 使用deploy用户启动服务
su deploy
服务管理¶
首次启动
nohup nodeos --config-dir ${EOS_HOME}/config --data-dir ${EOS_HOME}/data --genesis-json ${EOS_HOME}/config/genesis.json >> ${EOS_HOME}/log/nodeos.log &
启动
nohup nodeos --config-dir ${EOS_HOME}/config --data-dir ${EOS_HOME}/data >> ${EOS_HOME}/log/nodeos.log &
删除区块重新启动
nohup nodeos --delete-all-blocks --config-dir ${EOS_HOME}/config --data-dir ${EOS_HOME}/data --genesis-json ${EOS_HOME}/config/genesis.json >> ${EOS_HOME}/log/nodeos.log &
重放区块重新启动
nohup nodeos --hard-replay-blockchain --config-dir ${EOS_HOME}/config --data-dir ${EOS_HOME}/data --genesis-json ${EOS_HOME}/config/genesis.json >> ${EOS_HOME}/log/nodeos.log &
安全停止
ps -aux |grep nodeos kill -15 [pid]
安全备份并重启
ps -aux |grep nodeos kill -15 [pid] cp -rf data/ data-[date] tar -czvf data-[date].tar.gz data-[date] nohup nodeos --config-dir ${EOS_HOME}/config --data-dir ${EOS_HOME}/data >> ${EOS_HOME}/log/nodeos.log &
附录1:Testnet 配置文件¶
vim ${EOS_HOME}/config/config.ini
# the location of the blocks directory (absolute path or relative to application data dir) (eosio::chain_plugin)
blocks-dir = "blocks"
# the location of the protocol_features directory (absolute path or relative to application config dir) (eosio::chain_plugin)
protocol-features-dir = "protocol_features"
# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin)
# checkpoint =
# Override default WASM runtime (eosio::chain_plugin)
# wasm-runtime =
# Override default maximum ABI serialization time allowed in ms (eosio::chain_plugin)
abi-serializer-max-time-ms = 15000
# Maximum size (in MiB) of the chain state database (eosio::chain_plugin)
chain-state-db-size-mb = 32768
# Safely shut down node when free space remaining in the chain state database drops below this size (in MiB). (eosio::chain_plugin)
chain-state-db-guard-size-mb = 128
# Maximum size (in MiB) of the reversible blocks database (eosio::chain_plugin)
reversible-blocks-db-size-mb = 340
# Safely shut down node when free space remaining in the reverseible blocks database drops below this size (in MiB). (eosio::chain_plugin)
reversible-blocks-db-guard-size-mb = 2
# Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50% (eosio::chain_plugin)
signature-cpu-billable-pct = 50
# Number of worker threads in controller thread pool (eosio::chain_plugin)
chain-threads = 2
# print contract's output to console (eosio::chain_plugin)
contracts-console = true
# Account added to actor whitelist (may specify multiple times) (eosio::chain_plugin)
# actor-whitelist =
# Account added to actor blacklist (may specify multiple times) (eosio::chain_plugin)
# actor-blacklist =
# Contract account added to contract whitelist (may specify multiple times) (eosio::chain_plugin)
# contract-whitelist =
# Contract account added to contract blacklist (may specify multiple times) (eosio::chain_plugin)
# contract-blacklist =
# Action (in the form code::action) added to action blacklist (may specify multiple times) (eosio::chain_plugin)
# action-blacklist =
# Public key added to blacklist of keys that should not be included in authorities (may specify multiple times) (eosio::chain_plugin)
# key-blacklist =
# Deferred transactions sent by accounts in this list do not have any of the subjective whitelist/blacklist checks applied to them (may specify multiple times) (eosio::chain_plugin)
# sender-bypass-whiteblacklist =
# Database read mode ("speculative", "head", "read-only", "irreversible").
# In "speculative" mode: database contains state changes by transactions in the blockchain up to the head block as well as some transactions not yet included in the blockchain.
# In "head" mode: database contains state changes by only transactions in the blockchain up to the head block; transactions received by the node are relayed if valid.
# In "read-only" mode: (DEPRECATED: see p2p-accept-transactions & api-accept-transactions) database contains state changes by only transactions in the blockchain up to the head block; transactions received via the P2P network are not relayed and transactions cannot be pushed via the chain API.
# In "irreversible" mode: database contains state changes by only transactions in the blockchain up to the last irreversible block; transactions received via the P2P network are not relayed and transactions cannot be pushed via the chain API.
# (eosio::chain_plugin)
read-mode = speculative
# Allow API transactions to be evaluated and relayed if valid. (eosio::chain_plugin)
# api-accept-transactions = true
# Chain validation mode ("full" or "light").
# In "full" mode all incoming blocks will be fully validated.
# In "light" mode all incoming blocks headers will be fully validated; transactions in those validated blocks will be trusted
# (eosio::chain_plugin)
validation-mode = full
# Disable the check which subjectively fails a transaction if a contract bills more RAM to another account within the context of a notification handler (i.e. when the receiver is not the code of the action). (eosio::chain_plugin)
# disable-ram-billing-notify-checks = false
# Subjectively limit the maximum length of variable components in a variable legnth signature to this size in bytes (eosio::chain_plugin)
# maximum-variable-signature-length = 16384
# Indicate a producer whose blocks headers signed by it will be fully validated, but transactions in those validated blocks will be trusted. (eosio::chain_plugin)
# trusted-producer =
# Database map mode ("mapped", "heap", or "locked").
# In "mapped" mode database is memory mapped as a file.
# In "heap" mode database is preloaded in to swappable memory.
# In "locked" mode database is preloaded, locked in to memory, and optionally can use huge pages.
# (eosio::chain_plugin)
# database-map-mode = mapped
# Optional path for database hugepages when in "locked" mode (may specify multiple times) (eosio::chain_plugin)
# database-hugepage-path =
# Maximum size (in MiB) of the EOS VM OC code cache (eosio::chain_plugin)
# eos-vm-oc-cache-size-mb = 1024
# Number of threads to use for EOS VM OC tier-up (eosio::chain_plugin)
# eos-vm-oc-compile-threads = 1
# Enable EOS VM OC tier-up runtime (eosio::chain_plugin)
# eos-vm-oc-enable = false
# Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Recieiver. Receiver may not be blank. (eosio::history_plugin)
filter-on = *
# Do not track actions which match receiver:action:actor. Action and Actor both blank excludes all from Reciever. Actor blank excludes all from reciever:action. Receiver may not be blank. (eosio::history_plugin)
filter-out = eosio:onblock:
# PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made. (may specify multiple times)
# (eosio::http_client_plugin)
# https-client-root-cert =
# true: validate that the peer certificates are valid and trusted, false: ignore cert errors (eosio::http_client_plugin)
https-client-validate-peers = true
# The filename (relative to data-dir) to create a unix socket for HTTP RPC; set blank to disable. (eosio::http_plugin)
# unix-socket-path =
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
http-server-address = 127.0.0.1:8888
# The local IP and port to listen for incoming https connections; leave blank to disable. (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
# Configure https ECDH curve to use: secp384r1 or prime256v1 (eosio::http_plugin)
# https-ecdh-curve = secp384r1
# Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin)
access-control-allow-origin = *
# Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin)
access-control-allow-headers = *
# Specify the Access-Control-Max-Age to be returned on each request. (eosio::http_plugin)
# access-control-max-age =
# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin)
access-control-allow-credentials = false
# The maximum body size in bytes allowed for incoming RPC requests (eosio::http_plugin)
max-body-size = 1048576
# Maximum size in megabytes http_plugin should use for processing http requests. 503 error response when exceeded. (eosio::http_plugin)
# http-max-bytes-in-flight-mb = 500
# Maximum time for processing a request. (eosio::http_plugin)
# http-max-response-time-ms = 30
# Append the error log to HTTP responses (eosio::http_plugin)
verbose-http-errors = true
# If set to false, then any incoming "Host" header is considered valid (eosio::http_plugin)
http-validate-host = false
# Additionaly acceptable values for the "Host" header of incoming HTTP requests, can be specified multiple times. Includes http/s_server_address by default. (eosio::http_plugin)
# http-alias =
# Number of worker threads in http thread pool (eosio::http_plugin)
http-threads = 2
# The maximum number of pending login requests (eosio::login_plugin)
max-login-requests = 1000000
# The maximum timeout for pending login requests (in seconds) (eosio::login_plugin)
max-login-timeout = 60
# The target queue size between nodeos and MongoDB plugin thread. (eosio::mongo_db_plugin)
mongodb-queue-size = 1024
# The maximum size of the abi cache for serializing data. (eosio::mongo_db_plugin)
mongodb-abi-cache-size = 2048
# Required with --replay-blockchain, --hard-replay-blockchain, or --delete-all-blocks to wipe mongo db.This option required to prevent accidental wipe of mongo db. (eosio::mongo_db_plugin)
mongodb-wipe = false
# If specified then only abi data pushed to mongodb until specified block is reached. (eosio::mongo_db_plugin)
mongodb-block-start = 0
# MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/. If not specified then plugin is disabled. Default database 'EOS' is used if not specified in URI. Example: mongodb://127.0.0.1:27017/EOS (eosio::mongo_db_plugin)
# mongodb-uri =
# Update blocks/block_state with latest via block number so that duplicates are overwritten. (eosio::mongo_db_plugin)
mongodb-update-via-block-num = false
# Enables storing blocks in mongodb. (eosio::mongo_db_plugin)
mongodb-store-blocks = true
# Enables storing block state in mongodb. (eosio::mongo_db_plugin)
mongodb-store-block-states = true
# Enables storing transactions in mongodb. (eosio::mongo_db_plugin)
mongodb-store-transactions = true
# Enables storing transaction traces in mongodb. (eosio::mongo_db_plugin)
mongodb-store-transaction-traces = true
# Enables storing action traces in mongodb. (eosio::mongo_db_plugin)
mongodb-store-action-traces = true
# Enables expiring data in mongodb after a specified number of seconds. (eosio::mongo_db_plugin)
mongodb-expire-after-seconds = 0
# Track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to include all. i.e. eosio:: or :transfer: Use * or leave unspecified to include all. (eosio::mongo_db_plugin)
# mongodb-filter-on =
# Do not track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to exclude all. (eosio::mongo_db_plugin)
# mongodb-filter-out =
# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9876
# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin)
# p2p-server-address =
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network.
# Syntax: host:port[:<trx>|<blk>]
# The optional 'trx' and 'blk' indicates to node that only transactions 'trx' or blocks 'blk' should be sent. Examples:
# p2p.eos.io:9876
# p2p.trx.eos.io:9876:trx
# p2p.blk.eos.io:9876:blk
# (eosio::net_plugin)
p2p-peer-address = seed.testnet.eos.io:9876
# Maximum number of client nodes from any single IP address (eosio::net_plugin)
p2p-max-nodes-per-host = 1
# Allow transactions received over p2p network to be evaluated and relayed if valid. (eosio::net_plugin)
p2p-accept-transactions = true
# The name supplied to identify this node amongst the peers. (eosio::net_plugin)
agent-name = "Ystar EOS Test Agent"
# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin)
allowed-connection = any
# Optional public key of peer allowed to connect. May be used multiple times. (eosio::net_plugin)
# peer-key =
# Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin)
# peer-private-key =
# Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin)
max-clients = 25
# number of seconds to wait before cleaning up dead connections (eosio::net_plugin)
connection-cleanup-period = 30
# max connection cleanup time per cleanup call in millisec (eosio::net_plugin)
max-cleanup-time-msec = 10
# Number of worker threads in net_plugin thread pool (eosio::net_plugin)
net-threads = 2
# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin)
sync-fetch-span = 100
# Enable experimental socket read watermark optimization (eosio::net_plugin)
se-socket-read-watermark = false
# The string used to format peers when logging messages about them. Variables are escaped with ${<variable name>}.
# Available Variables:
# _name self-reported name
#
# _id self-reported ID (64 hex characters)
#
# _sid first 8 characters of _peer.id
#
# _ip remote IP address of peer
#
# _port remote port number of peer
#
# _lip local IP address connected to peer
#
# _lport local port number connected to peer
#
# (eosio::net_plugin)
peer-log-format = ["${_name}" ${_ip}:${_port}]
# Enable block production, even if the chain is stale. (eosio::producer_plugin)
enable-stale-production = false
# Start this node in a state where production is paused (eosio::producer_plugin)
pause-on-startup = false
# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::producer_plugin)
max-transaction-time = 300
# Limits the maximum age (in seconds) of the DPOS Irreversible Block for a chain this node will produce blocks on (use negative value to indicate unlimited) (eosio::producer_plugin)
max-irreversible-block-age = -1
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
# producer-name =
# (DEPRECATED - Use signature-provider instead) Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin)
# private-key =
# Key=Value pairs in the form <public-key>=<provider-spec>
# Where:
# <public-key> is a string form of a vaild EOSIO public key
#
# <provider-spec> is a string in the form <provider-type>:<data>
#
# <provider-type> is KEY, or KEOSD
#
# KEY:<data> is a string form of a valid EOSIO private key which maps to the provided public key
#
# KEOSD:<data> is the URL where keosd is available and the approptiate wallet(s) are unlocked (eosio::producer_plugin)
# signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
# Limits the maximum time (in milliseconds) that is allowed for sending blocks to a keosd provider for signing (eosio::producer_plugin)
# keosd-provider-timeout = 5
# account that can not access to extended CPU/NET virtual resources (eosio::producer_plugin)
# greylist-account =
# Limit (between 1 and 1000) on the multiple that CPU/NET virtual resources can extend during low usage (only enforced subjectively; use 1000 to not enforce any limit) (eosio::producer_plugin)
greylist-limit = 1000
# Offset of non last block producing time in microseconds. Valid range 0 .. -block_time_interval. (eosio::producer_plugin)
produce-time-offset-us = 0
# Offset of last block producing time in microseconds. Valid range 0 .. -block_time_interval. (eosio::producer_plugin)
last-block-time-offset-us = -200000
# Percentage of cpu block production time used to produce block. Whole number percentages, e.g. 80 for 80% (eosio::producer_plugin)
cpu-effort-percent = 80
# Percentage of cpu block production time used to produce last block. Whole number percentages, e.g. 80 for 80% (eosio::producer_plugin)
last-block-cpu-effort-percent = 80
# Threshold of CPU block production to consider block full; when within threshold of max-block-cpu-usage block can be produced immediately (eosio::producer_plugin)
max-block-cpu-usage-threshold-us = 5000
# Threshold of NET block production to consider block full; when within threshold of max-block-net-usage block can be produced immediately (eosio::producer_plugin)
max-block-net-usage-threshold-bytes = 1024
# Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing. (eosio::producer_plugin)
max-scheduled-transaction-time-per-block-ms = 100
# Time in microseconds allowed for a transaction that starts with insufficient CPU quota to complete and cover its CPU usage. (eosio::producer_plugin)
# subjective-cpu-leeway-us = 31000
# ratio between incoming transactions and deferred transactions when both are queued for execution (eosio::producer_plugin)
# incoming-defer-ratio = 1
# Maximum size (in MiB) of the incoming transaction queue. Exceeding this value will subjectively drop transaction with resource exhaustion. (eosio::producer_plugin)
incoming-transaction-queue-size-mb = 1024
# Number of worker threads in producer thread pool (eosio::producer_plugin)
producer-threads = 2
# the location of the snapshots directory (absolute path or relative to application data dir) (eosio::producer_plugin)
snapshots-dir = "snapshots"
# the location of the state-history directory (absolute path or relative to application data dir) (eosio::state_history_plugin)
state-history-dir = "state-history"
# enable trace history (eosio::state_history_plugin)
trace-history = false
# enable chain state history (eosio::state_history_plugin)
chain-state-history = false
# the endpoint upon which to listen for incoming connections. Caution: only expose this port to your internal network. (eosio::state_history_plugin)
state-history-endpoint = 127.0.0.1:8080
# enable debug mode for trace history (eosio::state_history_plugin)
trace-history-debug-mode = false
# the location of the trace directory (absolute path or relative to application data dir) (eosio::trace_api_plugin)
trace-dir = "traces"
# the number of blocks each "slice" of trace data will contain on the filesystem (eosio::trace_api_plugin)
trace-slice-stride = 10000
# Number of blocks to ensure are kept past LIB for retrieval before "slice" files can be automatically removed.
# A value of -1 indicates that automatic removal of "slice" files will be turned off. (eosio::trace_api_plugin)
trace-minimum-irreversible-history-blocks = -1
# ABIs used when decoding trace RPC responses.
# There must be at least one ABI specified OR the flag trace-no-abis must be used.
# ABIs are specified as "Key=Value" pairs in the form <account-name>=<abi-def>
# Where <abi-def> can be:
# an absolute path to a file containing a valid JSON-encoded ABI
# a relative path from `data-dir` to a file containing a valid JSON-encoded ABI
# (eosio::trace_api_plugin)
trace-rpc-abi =
# Use to indicate that the RPC responses will not use ABIs.
# Failure to specify this option when there are no trace-rpc-abi configuations will result in an Error.
# This option is mutually exclusive with trace-rpc-api (eosio::trace_api_plugin)
trace-no-abis =
# Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block) (eosio::txn_test_gen_plugin)
txn-reference-block-lag = 0
# Number of worker threads in txn_test_gen thread pool (eosio::txn_test_gen_plugin)
txn-test-gen-threads = 2
# Prefix to use for accounts generated and used by this plugin (eosio::txn_test_gen_plugin)
txn-test-gen-account-prefix = txn.test.
# Plugin(s) to enable, may be specified multiple times
plugin = eosio::chain_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::db_size_api_plugin
plugin = eosio::history_api_plugin
plugin = eosio::history_plugin
附录2:Main 配置文件¶
vim ${EOS_HOME}/config/config.ini
# the location of the blocks directory (absolute path or relative to application data dir) (eosio::chain_plugin)
blocks-dir = "blocks"
# the location of the protocol_features directory (absolute path or relative to application config dir) (eosio::chain_plugin)
protocol-features-dir = "protocol_features"
# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin)
# checkpoint =
# Override default WASM runtime (eosio::chain_plugin)
# wasm-runtime =
# Override default maximum ABI serialization time allowed in ms (eosio::chain_plugin)
abi-serializer-max-time-ms = 15000
# Maximum size (in MiB) of the chain state database (eosio::chain_plugin)
chain-state-db-size-mb = 32768
# Safely shut down node when free space remaining in the chain state database drops below this size (in MiB). (eosio::chain_plugin)
chain-state-db-guard-size-mb = 128
# Maximum size (in MiB) of the reversible blocks database (eosio::chain_plugin)
reversible-blocks-db-size-mb = 340
# Safely shut down node when free space remaining in the reverseible blocks database drops below this size (in MiB). (eosio::chain_plugin)
reversible-blocks-db-guard-size-mb = 2
# Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50% (eosio::chain_plugin)
signature-cpu-billable-pct = 50
# Number of worker threads in controller thread pool (eosio::chain_plugin)
chain-threads = 2
# print contract's output to console (eosio::chain_plugin)
contracts-console = true
# Account added to actor whitelist (may specify multiple times) (eosio::chain_plugin)
# actor-whitelist =
# Account added to actor blacklist (may specify multiple times) (eosio::chain_plugin)
# actor-blacklist =
# Contract account added to contract whitelist (may specify multiple times) (eosio::chain_plugin)
# contract-whitelist =
# Contract account added to contract blacklist (may specify multiple times) (eosio::chain_plugin)
# contract-blacklist =
# Action (in the form code::action) added to action blacklist (may specify multiple times) (eosio::chain_plugin)
# action-blacklist =
# Public key added to blacklist of keys that should not be included in authorities (may specify multiple times) (eosio::chain_plugin)
# key-blacklist =
# Deferred transactions sent by accounts in this list do not have any of the subjective whitelist/blacklist checks applied to them (may specify multiple times) (eosio::chain_plugin)
# sender-bypass-whiteblacklist =
# Database read mode ("speculative", "head", "read-only", "irreversible").
# In "speculative" mode: database contains state changes by transactions in the blockchain up to the head block as well as some transactions not yet included in the blockchain.
# In "head" mode: database contains state changes by only transactions in the blockchain up to the head block; transactions received by the node are relayed if valid.
# In "read-only" mode: (DEPRECATED: see p2p-accept-transactions & api-accept-transactions) database contains state changes by only transactions in the blockchain up to the head block; transactions received via the P2P network are not relayed and transactions cannot be pushed via the chain API.
# In "irreversible" mode: database contains state changes by only transactions in the blockchain up to the last irreversible block; transactions received via the P2P network are not relayed and transactions cannot be pushed via the chain API.
# (eosio::chain_plugin)
read-mode = speculative
# Allow API transactions to be evaluated and relayed if valid. (eosio::chain_plugin)
# api-accept-transactions = true
# Chain validation mode ("full" or "light").
# In "full" mode all incoming blocks will be fully validated.
# In "light" mode all incoming blocks headers will be fully validated; transactions in those validated blocks will be trusted
# (eosio::chain_plugin)
validation-mode = full
# Disable the check which subjectively fails a transaction if a contract bills more RAM to another account within the context of a notification handler (i.e. when the receiver is not the code of the action). (eosio::chain_plugin)
# disable-ram-billing-notify-checks = false
# Subjectively limit the maximum length of variable components in a variable legnth signature to this size in bytes (eosio::chain_plugin)
# maximum-variable-signature-length = 16384
# Indicate a producer whose blocks headers signed by it will be fully validated, but transactions in those validated blocks will be trusted. (eosio::chain_plugin)
# trusted-producer =
# Database map mode ("mapped", "heap", or "locked").
# In "mapped" mode database is memory mapped as a file.
# In "heap" mode database is preloaded in to swappable memory.
# In "locked" mode database is preloaded, locked in to memory, and optionally can use huge pages.
# (eosio::chain_plugin)
# database-map-mode = mapped
# Optional path for database hugepages when in "locked" mode (may specify multiple times) (eosio::chain_plugin)
# database-hugepage-path =
# Maximum size (in MiB) of the EOS VM OC code cache (eosio::chain_plugin)
# eos-vm-oc-cache-size-mb = 1024
# Number of threads to use for EOS VM OC tier-up (eosio::chain_plugin)
# eos-vm-oc-compile-threads = 1
# Enable EOS VM OC tier-up runtime (eosio::chain_plugin)
# eos-vm-oc-enable = false
# Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Recieiver. Receiver may not be blank. (eosio::history_plugin)
filter-on = *
# Do not track actions which match receiver:action:actor. Action and Actor both blank excludes all from Reciever. Actor blank excludes all from reciever:action. Receiver may not be blank. (eosio::history_plugin)
filter-out = eosio:onblock:
# PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made. (may specify multiple times)
# (eosio::http_client_plugin)
# https-client-root-cert =
# true: validate that the peer certificates are valid and trusted, false: ignore cert errors (eosio::http_client_plugin)
https-client-validate-peers = true
# The filename (relative to data-dir) to create a unix socket for HTTP RPC; set blank to disable. (eosio::http_plugin)
# unix-socket-path =
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
http-server-address = 127.0.0.1:8888
# The local IP and port to listen for incoming https connections; leave blank to disable. (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
# Configure https ECDH curve to use: secp384r1 or prime256v1 (eosio::http_plugin)
# https-ecdh-curve = secp384r1
# Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin)
access-control-allow-origin = *
# Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin)
access-control-allow-headers = *
# Specify the Access-Control-Max-Age to be returned on each request. (eosio::http_plugin)
# access-control-max-age =
# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin)
access-control-allow-credentials = false
# The maximum body size in bytes allowed for incoming RPC requests (eosio::http_plugin)
max-body-size = 1048576
# Maximum size in megabytes http_plugin should use for processing http requests. 503 error response when exceeded. (eosio::http_plugin)
# http-max-bytes-in-flight-mb = 500
# Maximum time for processing a request. (eosio::http_plugin)
# http-max-response-time-ms = 30
# Append the error log to HTTP responses (eosio::http_plugin)
verbose-http-errors = true
# If set to false, then any incoming "Host" header is considered valid (eosio::http_plugin)
http-validate-host = false
# Additionaly acceptable values for the "Host" header of incoming HTTP requests, can be specified multiple times. Includes http/s_server_address by default. (eosio::http_plugin)
# http-alias =
# Number of worker threads in http thread pool (eosio::http_plugin)
http-threads = 2
# The maximum number of pending login requests (eosio::login_plugin)
max-login-requests = 1000000
# The maximum timeout for pending login requests (in seconds) (eosio::login_plugin)
max-login-timeout = 60
# The target queue size between nodeos and MongoDB plugin thread. (eosio::mongo_db_plugin)
mongodb-queue-size = 1024
# The maximum size of the abi cache for serializing data. (eosio::mongo_db_plugin)
mongodb-abi-cache-size = 2048
# Required with --replay-blockchain, --hard-replay-blockchain, or --delete-all-blocks to wipe mongo db.This option required to prevent accidental wipe of mongo db. (eosio::mongo_db_plugin)
mongodb-wipe = false
# If specified then only abi data pushed to mongodb until specified block is reached. (eosio::mongo_db_plugin)
mongodb-block-start = 0
# MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/. If not specified then plugin is disabled. Default database 'EOS' is used if not specified in URI. Example: mongodb://127.0.0.1:27017/EOS (eosio::mongo_db_plugin)
# mongodb-uri =
# Update blocks/block_state with latest via block number so that duplicates are overwritten. (eosio::mongo_db_plugin)
mongodb-update-via-block-num = false
# Enables storing blocks in mongodb. (eosio::mongo_db_plugin)
mongodb-store-blocks = true
# Enables storing block state in mongodb. (eosio::mongo_db_plugin)
mongodb-store-block-states = true
# Enables storing transactions in mongodb. (eosio::mongo_db_plugin)
mongodb-store-transactions = true
# Enables storing transaction traces in mongodb. (eosio::mongo_db_plugin)
mongodb-store-transaction-traces = true
# Enables storing action traces in mongodb. (eosio::mongo_db_plugin)
mongodb-store-action-traces = true
# Enables expiring data in mongodb after a specified number of seconds. (eosio::mongo_db_plugin)
mongodb-expire-after-seconds = 0
# Track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to include all. i.e. eosio:: or :transfer: Use * or leave unspecified to include all. (eosio::mongo_db_plugin)
# mongodb-filter-on =
# Do not track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to exclude all. (eosio::mongo_db_plugin)
# mongodb-filter-out =
# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9876
# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin)
# p2p-server-address =
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network.
# Syntax: host:port[:<trx>|<blk>]
# The optional 'trx' and 'blk' indicates to node that only transactions 'trx' or blocks 'blk' should be sent. Examples:
# p2p.eos.io:9876
# p2p.trx.eos.io:9876:trx
# p2p.blk.eos.io:9876:blk
# (eosio::net_plugin)
p2p-peer-address = fullnode.eoslaomao.com:443
p2p-peer-address = p2p.genereos.io:9876
p2p-peer-address = peer.eosn.io:9876
p2p-peer-address = 18.234.6.119:80
p2p-peer-address = peer.main.alohaeos.com:9876
p2p-peer-address = eosbp-1.atticlab.net:9876
p2p-peer-address = mainnet.eosamsterdam.net:9876
p2p-peer-address = p2p.eosflare.io:9876
p2p-peer-address = peer1.eosphere.io:9876
p2p-peer-address = peer1.swisseos.com:9876
p2p-peer-address = api3.tokenika.io:9876
p2p-peer-address = eth2.tokenika.io:9876
# Maximum number of client nodes from any single IP address (eosio::net_plugin)
p2p-max-nodes-per-host = 1
# Allow transactions received over p2p network to be evaluated and relayed if valid. (eosio::net_plugin)
p2p-accept-transactions = true
# The name supplied to identify this node amongst the peers. (eosio::net_plugin)
agent-name = "Ystar EOS Test Agent"
# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin)
allowed-connection = any
# Optional public key of peer allowed to connect. May be used multiple times. (eosio::net_plugin)
# peer-key =
# Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin)
# peer-private-key =
# Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin)
max-clients = 25
# number of seconds to wait before cleaning up dead connections (eosio::net_plugin)
connection-cleanup-period = 30
# max connection cleanup time per cleanup call in millisec (eosio::net_plugin)
max-cleanup-time-msec = 10
# Number of worker threads in net_plugin thread pool (eosio::net_plugin)
net-threads = 2
# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin)
sync-fetch-span = 100
# Enable experimental socket read watermark optimization (eosio::net_plugin)
# se-socket-read-watermark = false
# The string used to format peers when logging messages about them. Variables are escaped with ${<variable name>}.
# Available Variables:
# _name self-reported name
#
# _id self-reported ID (64 hex characters)
#
# _sid first 8 characters of _peer.id
#
# _ip remote IP address of peer
#
# _port remote port number of peer
#
# _lip local IP address connected to peer
#
# _lport local port number connected to peer
#
# (eosio::net_plugin)
peer-log-format = ["${_name}" ${_ip}:${_port}]
# Enable block production, even if the chain is stale. (eosio::producer_plugin)
enable-stale-production = false
# Start this node in a state where production is paused (eosio::producer_plugin)
pause-on-startup = false
# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::producer_plugin)
max-transaction-time = 300
# Limits the maximum age (in seconds) of the DPOS Irreversible Block for a chain this node will produce blocks on (use negative value to indicate unlimited) (eosio::producer_plugin)
max-irreversible-block-age = -1
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
# producer-name =
# (DEPRECATED - Use signature-provider instead) Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin)
# private-key =
# Key=Value pairs in the form <public-key>=<provider-spec>
# Where:
# <public-key> is a string form of a vaild EOSIO public key
#
# <provider-spec> is a string in the form <provider-type>:<data>
#
# <provider-type> is KEY, or KEOSD
#
# KEY:<data> is a string form of a valid EOSIO private key which maps to the provided public key
#
# KEOSD:<data> is the URL where keosd is available and the approptiate wallet(s) are unlocked (eosio::producer_plugin)
# signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
# Limits the maximum time (in milliseconds) that is allowed for sending blocks to a keosd provider for signing (eosio::producer_plugin)
# keosd-provider-timeout = 5
# account that can not access to extended CPU/NET virtual resources (eosio::producer_plugin)
# greylist-account =
# Limit (between 1 and 1000) on the multiple that CPU/NET virtual resources can extend during low usage (only enforced subjectively; use 1000 to not enforce any limit) (eosio::producer_plugin)
greylist-limit = 1000
# Offset of non last block producing time in microseconds. Valid range 0 .. -block_time_interval. (eosio::producer_plugin)
produce-time-offset-us = 0
# Offset of last block producing time in microseconds. Valid range 0 .. -block_time_interval. (eosio::producer_plugin)
last-block-time-offset-us = -200000
# Percentage of cpu block production time used to produce block. Whole number percentages, e.g. 80 for 80% (eosio::producer_plugin)
cpu-effort-percent = 80
# Percentage of cpu block production time used to produce last block. Whole number percentages, e.g. 80 for 80% (eosio::producer_plugin)
last-block-cpu-effort-percent = 80
# Threshold of CPU block production to consider block full; when within threshold of max-block-cpu-usage block can be produced immediately (eosio::producer_plugin)
max-block-cpu-usage-threshold-us = 5000
# Threshold of NET block production to consider block full; when within threshold of max-block-net-usage block can be produced immediately (eosio::producer_plugin)
max-block-net-usage-threshold-bytes = 1024
# Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing. (eosio::producer_plugin)
max-scheduled-transaction-time-per-block-ms = 100
# Time in microseconds allowed for a transaction that starts with insufficient CPU quota to complete and cover its CPU usage. (eosio::producer_plugin)
# subjective-cpu-leeway-us = 31000
# ratio between incoming transactions and deferred transactions when both are queued for execution (eosio::producer_plugin)
# incoming-defer-ratio = 1
# Maximum size (in MiB) of the incoming transaction queue. Exceeding this value will subjectively drop transaction with resource exhaustion. (eosio::producer_plugin)
incoming-transaction-queue-size-mb = 1024
# Number of worker threads in producer thread pool (eosio::producer_plugin)
producer-threads = 2
# the location of the snapshots directory (absolute path or relative to application data dir) (eosio::producer_plugin)
snapshots-dir = "snapshots"
# the location of the state-history directory (absolute path or relative to application data dir) (eosio::state_history_plugin)
state-history-dir = "state-history"
# enable trace history (eosio::state_history_plugin)
trace-history = false
# enable chain state history (eosio::state_history_plugin)
chain-state-history = false
# the endpoint upon which to listen for incoming connections. Caution: only expose this port to your internal network. (eosio::state_history_plugin)
state-history-endpoint = 127.0.0.1:8080
# enable debug mode for trace history (eosio::state_history_plugin)
trace-history-debug-mode = false
# the location of the trace directory (absolute path or relative to application data dir) (eosio::trace_api_plugin)
trace-dir = "traces"
# the number of blocks each "slice" of trace data will contain on the filesystem (eosio::trace_api_plugin)
trace-slice-stride = 10000
# Number of blocks to ensure are kept past LIB for retrieval before "slice" files can be automatically removed.
# A value of -1 indicates that automatic removal of "slice" files will be turned off. (eosio::trace_api_plugin)
trace-minimum-irreversible-history-blocks = -1
# ABIs used when decoding trace RPC responses.
# There must be at least one ABI specified OR the flag trace-no-abis must be used.
# ABIs are specified as "Key=Value" pairs in the form <account-name>=<abi-def>
# Where <abi-def> can be:
# an absolute path to a file containing a valid JSON-encoded ABI
# a relative path from `data-dir` to a file containing a valid JSON-encoded ABI
# (eosio::trace_api_plugin)
trace-rpc-abi =
# Use to indicate that the RPC responses will not use ABIs.
# Failure to specify this option when there are no trace-rpc-abi configuations will result in an Error.
# This option is mutually exclusive with trace-rpc-api (eosio::trace_api_plugin)
trace-no-abis =
# Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block) (eosio::txn_test_gen_plugin)
txn-reference-block-lag = 0
# Number of worker threads in txn_test_gen thread pool (eosio::txn_test_gen_plugin)
txn-test-gen-threads = 2
# Prefix to use for accounts generated and used by this plugin (eosio::txn_test_gen_plugin)
txn-test-gen-account-prefix = txn.test.
# Plugin(s) to enable, may be specified multiple times
plugin = eosio::chain_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::db_size_api_plugin
plugin = eosio::history_api_plugin
plugin = eosio::history_plugin
OmniCore Bitcoin 节点¶
节点信息¶
环境配置¶
# 自定义环境变量
echo -e "export OMNI_HOME=/opt/chain/omnicore" > /etc/profile.d/omnicore.sh
source /etc/profile
mkdir -p ${OMNI_HOME}/{conf,data,src}
cd ${OMNI_HOME}/src
wget https://bintray.com/artifact/download/omni/OmniBinaries/omnicore-0.9.0-x86_64-linux-gnu.tar.gz
tar -zxf omnicore-0.9.0-x86_64-linux-gnu.tar.gz
cp -a ${OMNI_HOME}/src/omnicore-0.9.0/* ${OMNI_HOME}
管理服务¶
首次启动
# Testnet ${OMNI_HOME}/bin/omnicored -conf=${OMNI_HOME}/conf/omnicore.conf -testnet -reindex-chainstate # Main ${OMNI_HOME}/bin/omnicored -conf=${OMNI_HOME}/conf/omnicore.conf -reindex-chainstate
启动
# Testnet ${OMNI_HOME}/bin/omnicored -conf=${OMNI_HOME}/conf/omnicore.conf -testnet # Main ${OMNI_HOME}/bin/omnicored -conf=${OMNI_HOME}/conf/omnicore.conf
查看日志
# Testnet tail -f ${OMNI_HOME}/data/testnet3/debug.log tail -f ${OMNI_HOME}/data/testnet3/omnicore.log # Main tail -f ${OMNI_HOME}/data/debug.log tail -f ${OMNI_HOME}/data/omnicore.log
创建钱包地址
${OMNI_HOME}/bin/omnicore-cli -conf=${OMNI_HOME}/conf/omnicore.conf getnewaddress # mmRTfHS4M6jX3dq6Jrjxhca1yu1fhwDLwP
查看同步状态
${OMNI_HOME}/bin/omnicore-cli -conf=${OMNI_HOME}/conf/omnicore.conf "omni_getinfo"
获取块交易信息
${OMNI_HOME}/bin/omnicore-cli -conf=${OMNI_HOME}/conf/omnicore.conf "omni_listblocktransactions" 283729
获取交易详情
${OMNI_HOME}/bin/omnicore-cli -conf=${OMNI_HOME}/conf/omnicore.conf "omni_gettransaction" "1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d"
附录1:Testnet 配置文件¶
vim conf/omnicore.conf
# 数据存储目录
datadir=/opt/chain/omnicore/data
# 告知 Bitcoin-Qt 和 bitcoind 接受JSON-RPC命令
server=1
# 设置 gen=1 以尝试比特币挖矿
gen=0
# 启用交易索引
txindex=1
experimental-btc-balances=1
[main]
[test]
# 数据存储目录
# datadir=/opt/chain/omnicore-0.9.0/data
# # 使用测试网络
testnet=1
# # 告知 Bitcoin-Qt 和 bitcoind 接受JSON-RPC命令
server=1
# # 后台执行
daemon=1
port=28333
# 监听 RPC,正式默认端口8333 测试默认18333
rpcport=28333
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcbind=127.0.0.1
#rpcuser=123456
#rpcpassword=abcdef
rpcconnect=127.0.0.1
#listen=0
附录2:Main 配置文件¶
vim conf/omnicore.conf
# 数据存储目录
datadir=/opt/chain/omnicore/data
# 告知 Bitcoin-Qt 和 bitcoind 接受JSON-RPC命令
server=1
# 设置 gen=1 以尝试比特币挖矿
gen=0
# 启用交易索引
txindex=1
experimental-btc-balances=1
# 后台执行
daemon=1
# 使用测试网络
testnet=0
port=38333
# 监听 RPC,正式默认端口8333 测试默认18333
rpcport=38333
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcbind=127.0.0.1
#rpcuser=123456
#rpcpassword=abcdef
rpcconnect=127.0.0.1
#listen=0
附录3:常用参数¶
reindex 与 reindex-chainstate
reindex
删除chainstate (UTXO设置)、擦除块索引(包含关于磁盘上哪个块的信息的数据库)、重建块索引(通过遍历所有block *.dat文件,并在其中找到看起来像块的东西)、基于索引中的块重建chainstate(重做所有的块验证)
reindex-chainstate
删除chainstate,使用之前索引中的块重新构建chainstate
严格来说,后者应该更快,因为它不需要首先重建块索引。重新索引期间的进度条可能会使您感到困惑:该进度只用于重新建立索引。在重新构建完成后,将重新创建chainstate。只有当您运行在pruning模式下,或者如果您怀疑磁盘上的块实际上已损坏,您才应该使用-reindex。否则,当你只是怀疑chainstate的损坏(这是更有可能的),使用-reindex-chainstate
币安链节点¶
BSC¶
节点信息¶
全节点功能
将完整的区块链历史记录存储在磁盘上,并可以回答来自网络的数据请求。
接收并验证新的区块和交易。
验证每个帐户的状态。
支持的平台
我们支持在Mac OS X和Linux上运行一个完整的节点。
配置最低要求
硬件必须满足一定的要求才能运行一个完整的节点。
VPS运行最新版本的Mac OS X或Linux。
500 GB的可用磁盘空间。
4个CPU核心和8 GB内存(RAM)。
每秒上传/下载速度至少为1兆字节的宽带Internet连接
同步模式
快速同步
在默认的同步模式。通过下载整个状态数据库,首先请求标头并随后填写块主体和收据,来同步进行快速同步的完整节点。一旦快速同步到达Binance Smart Chain网络的最佳区域,它将切换到完全同步模式。
完全同步
从创世开始同步整个节点,验证所有块并执行所有事务。此模式比快速同步模式要慢一些,但具有更高的安全性。
下载源码并编译¶
确保您已安装Go 1.13+并已添加GOPATH到PATH环境变量中
git clone https://github.com/binance-chain/bsc
cd bsc
make geth
环境配置¶
# 自定义环境变量
echo -e "export BSC_HOME=/opt/chain/bsc" > /etc/profile.d/bsc.sh
source /etc/profile
mkdir ${BSC_HOME}/{conf,bin,data,src}
chown -R deploy.deploy ${BSC_HOME}
su deploy
或者您可以从发行版页面下载预构建二进制文件,或按照以下说明进行操作:
cd ${BSC_HOME}/bin
# Linux
wget https://github.com/binance-chain/bsc/releases/download/v1.0.7-ht.3/geth_linux
cp -a geth_linux geth_bsc
# MacOS
wget https://github.com/binance-chain/bsc/releases/download/v1.0.6/geth_mac
# ln -sf ${bsc_home}/bsc/bin/geth_linux /usr/bin/geth_bsc
配置文件¶
下载 genesis.json 及 config.toml 文件:
cd ${BSC_HOME}/conf
# mainet
wget $(curl -s https://api.github.com/repos/binance-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4)
unzip mainnet.zip
# testnet
wget $(curl -s https://api.github.com/repos/binance-chain/bsc/releases/latest |grep browser_ |grep testnet |cut -d\" -f4)
unzip testnet.zip
配置
${BSC_HOME}/bin/geth --datadir ${BSC_HOME}/data init ${BSC_HOME}/conf/genesis.json
您可能会看到以下输出:
INFO [03-16|16:23:50.501] Maximum peer count ETH=50 LES=0 total=50
INFO [03-16|16:23:50.501] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [03-16|16:23:50.514] Allocated cache and file handles database=/opt/chain/bsc/data/geth/chaindata cache=16.00MiB handles=16
INFO [03-16|16:23:50.525] Writing custom genesis block
INFO [03-16|16:23:50.528] Persisted trie from memory database nodes=25 size=98.51KiB time=433.953µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-820.00B
INFO [03-16|16:23:50.528] Successfully wrote genesis state database=chaindata hash=0d2184…d57b5b
INFO [03-16|16:23:50.528] Allocated cache and file handles database=/opt/chain/bsc/data/geth/lightchaindata cache=16.00MiB handles=16
INFO [03-16|16:23:50.541] Writing custom genesis block
INFO [03-16|16:23:50.550] Persisted trie from memory database nodes=25 size=98.51KiB time=8.394923ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-820.00B
INFO [03-16|16:23:50.551] Successfully wrote genesis state database=lightchaindata hash=0d2184…d57b5b
服务管理¶
启动全节点
# start a full node # ${BSC_HOME}/bin/geth_bsc --config ${BSC_HOME}/conf/config.toml --datadir ${BSC_HOME}/data --pprofaddr 0.0.0.0 --metrics --pprof ${BSC_HOME}/bin/geth_linux --config ${BSC_HOME}/conf/config.toml --datadir ${BSC_HOME}/data --cache 18000 --rpc.allow-unprotected-txs --txlookuplimit 0
启动验证器节点
## generate the consensus key and input the password geth account new --datadir ${BSC_HOME}/data echo {your-password} > password.txt geth --config ${BSC_HOME}/conf/config.toml --datadir ${BSC_HOME}/data -unlock {your-validator-address} --password password.txt --mine --gcmode archive --allow-insecure-unlock --pprofaddr 0.0.0.0 --metrics --pprof
注意
由于config.toml中的默认值TrieTimeout很大,这意味着geth在达到这个时间阈值之前不会将状态持久化到数据库中,如果节点已经强制关闭,它将从最后一个状态开始同步,这可能需要很长时间。对于验证器,建议设置为“TrieTimeout = 100000000000”
日志查看
tail -f ${BSC_HOME}/data/bsc.log
控制台
/opt/chain/bsc/bin/geth attach ipc:/opt/chain/bsc/data/geth.ipc # 代理 admin.addPeer( "enode://1cc4534b14cfe351ab740a1418ab944a234ca2f702915eadb7e558a02010cb7c5a8c295a3b56bcefa7701c07752acd5539cb13df2aab8ae2d98934d712611443@129.226.167.57:30312" ) admin.addPeer( "enode://28b1d16562dac280dacaaf45d54516b85bc6c994252a9825c5cc4e080d3e53446d05f63ba495ea7d44d6c316b54cd92b245c5c328c37da24605c4a93a0d099c4@129.226.167.57:30313" ) admin.addPeer( "enode://5a7b996048d1b0a07683a949662c87c09b55247ce774aeee10bb886892e586e3c604564393292e38ef43c023ee9981e1f8b335766ec4f0f256e57f8640b079d5@129.226.167.57:30314" ) admin.addPeer( "enode://8fb5dd1259e0672efb8c141434bf0c24c73b338f7c2da15efc2def7403b952d453814230eeb97f555aaed46ee0b0b6e2a8568b518f88bd328729031746114dd2@129.226.167.57:30315" ) admin.addPeer( "enode://c4aca7cd579f528bfad09fbc8c3880fc4966fb070cd8a56f643f7dd237faafede07315791da805c8b59a0010793449d02fd0880554da617fbcaf1dc57cf0295a@43.129.250.112:30311" ) admin.addPeer( "enode://6f0af3e0bb23e473c8dc271fb138145b73ae4a5c8da744271c810f23d24afc74480955a881e8d3119d071059d95de1852f91b7a6dfa53001e040a4a181e02e5f@120.27.131.105:30311" ) admin.addPeer( "enode://d6e5ffafa987155bc5de9c3091487eda55090e3ab4a3d43887e821e54fd00320bfa7b3f29ceefcfa0cf2ca0d2e5096f6bd653989e1ee8200b0013f642f0224a8@117.78.23.238:30311" ) admin.addPeer( "enode://2d308e97cd1e24fb7456bbd67647ea3477801394e2558d2fd0f61097a7a64143172f7078cd3ded4b80e77b0f2503b59790c79acd3d29fd3d119b5853e2c133f5@47.241.193.147:50505" ) admin.addPeer( "enode://f062846ac9833207fbad909b04daa1a71fac60af991d1f89cb0d9a77eaea13bbb8a7f79d3d0a91f99967a618620d2682245a75cd70f2426b58b67b19225038fa@51.91.152.154:30311" ) admin.addPeer( "enode://0daef7aa168454c9404f7d4f819f340ebc28d1593a7f29953c93968f87ca35d8e88d5cf37258fe9326f95e63b959eb8f8c62ac1020b7fca1f2a37eec483c41e1@49.233.60.245:30311" )
附录1:配置文件信息¶
vim ${BSC_HOME}/conf/config.toml
[Eth]
NetworkId = 56
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
[Node]
IPCPath = "geth.ipc"
HTTPHost = "0.0.0.0"
NoUSB = true
InsecureUnlockAllowed = false
HTTPPort = 8645
HTTPVirtualHosts = ["*"]
HTTPModules = ["eth", "net", "web3", "txpool", "parlia"]
WSHost = "0.0.0.0"
WSPort = 8646
WSModules = ["net", "web3", "eth"]
GraphQLPort = 8557
GraphQLVirtualHosts = ["*"]
[Node.P2P]
MaxPeers = 200
NoDiscovery = false
StaticNodes = ["enode://f3cfd69f2808ef64838abd8786342c0b22fdd28268703c8d6812e26e109f9a7cb2b37bd49724ebb46c233289f22da82991c87345eb9a2dadeddb8f37eeb259ac@18.180.28.21:30311","enode://ae74385270d4afeb953561603fcedc4a0e755a241ffdea31c3f751dc8be5bf29c03bf46e3051d1c8d997c45479a92632020c9a84b96dcb63b2259ec09b4fde38@54.178.30.104:30311","enode://d1cabe083d5fc1da9b510889188f06dab891935294e4569df759fc2c4d684b3b4982051b84a9a078512202ad947f9240adc5b6abea5320fb9a736d2f6751c52e@54.238.28.14:30311","enode://f420209bac5324326c116d38d83edfa2256c4101a27cd3e7f9b8287dc8526900f4137e915df6806986b28bc79b1e66679b544a1c515a95ede86f4d809bd65dab@54.178.62.117:30311","enode://c0e8d1abd27c3c13ca879e16f34c12ffee936a7e5d7b7fb6f1af5cc75c6fad704e5667c7bbf7826fcb200d22b9bf86395271b0f76c21e63ad9a388ed548d4c90@54.65.247.12:30311","enode://f1b49b1cf536e36f9a56730f7a0ece899e5efb344eec2fdca3a335465bc4f619b98121f4a5032a1218fa8b69a5488d1ec48afe2abda073280beec296b104db31@13.114.199.41:30311","enode://4924583cfb262b6e333969c86eab8da009b3f7d165cc9ad326914f576c575741e71dc6e64a830e833c25e8c45b906364e58e70cdf043651fd583082ea7db5e3b@18.180.17.171:30311","enode://4d041250eb4f05ab55af184a01aed1a71d241a94a03a5b86f4e32659e1ab1e144be919890682d4afb5e7afd837146ce584d61a38837553d95a7de1f28ea4513a@54.178.99.222:30311","enode://b5772a14fdaeebf4c1924e73c923bdf11c35240a6da7b9e5ec0e6cbb95e78327690b90e8ab0ea5270debc8834454b98eca34cc2a19817f5972498648a6959a3a@54.170.158.102:30311","enode://f329176b187cec87b327f82e78b6ece3102a0f7c89b92a5312e1674062c6e89f785f55fb1b167e369d71c66b0548994c6035c6d85849eccb434d4d9e0c489cdd@34.253.94.130:30311","enode://cbfd1219940d4e312ad94108e7fa3bc34c4c22081d6f334a2e7b36bb28928b56879924cf0353ad85fa5b2f3d5033bbe8ad5371feae9c2088214184be301ed658@54.75.11.3:30311","enode://c64b0a0c619c03c220ea0d7cac754931f967665f9e148b92d2e46761ad9180f5eb5aaef48dfc230d8db8f8c16d2265a3d5407b06bedcd5f0f5a22c2f51c2e69f@54.216.208.163:30311","enode://352a361a9240d4d23bb6fab19cc6dc5a5fc6921abf19de65afe13f1802780aecd67c8c09d8c89043ff86947f171d98ab06906ef616d58e718067e02abea0dda9@79.125.105.65:30311","enode://bb683ef5d03db7d945d6f84b88e5b98920b70aecc22abed8c00d6db621f784e4280e5813d12694c7a091543064456ad9789980766f3f1feb38906cf7255c33d6@54.195.127.237:30311","enode://11dc6fea50630b68a9289055d6b0fb0e22fb5048a3f4e4efd741a7ab09dd79e78d383efc052089e516f0a0f3eacdd5d3ffbe5279b36ecc42ad7cd1f2767fdbdb@46.137.182.25:30311","enode://21530e423b42aed17d7eef67882ebb23357db4f8b10c94d4c71191f52955d97dc13eec03cfeff0fe3a1c89c955e81a6970c09689d21ecbec2142b26b7e759c45@54.216.119.18:30311","enode://d61a31410c365e7fcd50e24d56a77d2d9741d4a57b295cc5070189ad90d0ec749d113b4b0432c6d795eb36597efce88d12ca45e645ec51b3a2144e1c1c41b66a@34.204.129.242:30311","enode://bb91215b1d77c892897048dd58f709f02aacb5355aa8f50f00b67c879c3dffd7eef5b5a152ac46cdfb255295bec4d06701a8032456703c6b604a4686d388ea8f@75.101.197.198:30311","enode://786acbdf5a3cf91b99047a0fd8305e11e54d96ea3a72b1527050d3d6f8c9fc0278ff9ef56f3e56b3b70a283d97c309065506ea2fc3eb9b62477fd014a3ec1a96@107.23.90.162:30311","enode://4653bc7c235c3480968e5e81d91123bc67626f35c207ae4acab89347db675a627784c5982431300c02f547a7d33558718f7795e848d547a327abb111eac73636@54.144.170.236:30311","enode://c6ffd994c4ef130f90f8ee2fc08c1b0f02a6e9b12152092bf5a03dd7af9fd33597d4b2e2000a271cc0648d5e55242aeadd6d5061bb2e596372655ba0722cc704@54.147.151.108:30311","enode://99b07e9dc5f204263b87243146743399b2bd60c98f68d1239a3461d09087e6c417e40f1106fa606ccf54159feabdddb4e7f367559b349a6511e66e525de4906e@54.81.225.170:30311","enode://1479af5ea7bda822e8747d0b967309bced22cad5083b93bc6f4e1d7da7be067cd8495dc4c5a71579f2da8d9068f0c43ad6933d2b335a545b4ae49a846122b261@52.7.247.132:30311"]
TrustedNodes = []
ListenAddr = ":30311"
EnableMsgEvents = false
[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000
[Node.LogConfig]
FilePath = "bsc.log"
MaxBytesSize = 10485760
Level = "info"
FileRoot = ""
附录2:其他部署方法(仅供参考)¶
mkdir /data/blockdata/bnb
cd /data/blockdata/bnb
# Linux
wget --no-check-certificate https://github.com/binance-chain/bsc/releases/download/v1.0.6/geth_linux
## mainet genesis.json and config.toml
wget --no-check-certificate $(curl -s https://api.github.com/repos/binance-chain/bsc/releases/latest |grep browser_ |grep mainnet |cut -d\" -f4)
unzip mainnet.zip
mv geth_linx geth
./data/blockdata/bnb/geth --datadir node init genesis.json
vim startbnb.sh
#!/bin/sh
geth_bsc --config /opt/chain/bsc/conf/config.toml --datadir /opt/chain/bsc/data --pprofaddr 0.0.0.0 --metrics --pprof &
chmod +x startbnb.sh
# 守护进程
crontab -l
* * * * * killall -0 geth_bsc &>> /opt/chain/bsc/bsc_listen.log || sh /opt/chain/bsc/start.sh &>> /opt/chain/bsc/bsc_listen.log
BC¶
官方文档链接¶
浏览器¶
One-line install¶
sh <(wget -qO- https://raw.githubusercontent.com/binance-chain/node-binary/master/install.sh)
注意
这个安装脚本里用到了wget的一个显示进度条的功能,由于centos自带的wget的版本太低,在下载安装的过程中会报错,导致脚本退出执行,最终程序下载失败
wget: unrecognized option '--show-progress'
解决方案:
方案一、直接打开脚本,复制到本地,把脚本中的 "--show-progress" 选项去掉,执行脚本,不看进度条了,可以下载安装成功。 方案二、升级wget到最新版本
wget http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
tar -zxvf wget-latest.tar.gz
cd wget-1.20.3
./configure --prefix=/usr --sysconfdir=/etc --with-ssl=openssl
configure: error: no acceptable C compiler found in $PATH
yum install openssl
yum list | grep openssl
yum install openssl-devel
make && make install
wget -V
# 升级成功后再执行
sh <(wget -qO- https://raw.githubusercontent.com/binance-chain/node-binary/master/install.sh)
修改配置文件¶
vim /data/blockdata/bnb-bep2/config.toml
# A custom human readable name for this node
moniker = "mybnbchian" //起个代号
# TCP or UNIX socket address for the RPC server to listen on
laddr = "tcp://0.0.0.0:9897" //端口号改成 9897
vim startbnbbep2.sh
#!/bin/sh
/usr/local/bin/bnbchaind start --home /data/blockdata/bnb-bep2 &
chmod +x startbnbbep2.sh
sh /data/blockdata/bnb-bep2/startbnbbep2.sh &>> /data/blockdata/bnb-bep2/bnbbep2_listen.log
# 守护进程
crontab -e
* * * * * killall -0 /usr/local/bin/bnbchaind start --home /data/blockdata/bnb-bep2 &>> /data/blockdata/bnb-bep2/bnbbep2_listen.log || sh /data/blockdata/bnb-bep2/startbnbbep2.sh &>> /data/blockdata/bnb-bep2/bnbbep2_listen.log
# 查看状态
curl localhost:9897/status
HecoChain 节点¶
节点信息¶
Testnet 网络¶
Main 网络¶
Chain ID: 128
P2P节点
已预置在代码中,作为 bootstrap node
enode://7bed18c87054f807bc9096501bc78f737363f357af831791bab07c4fa6c5a1a67cdcf0a097dc2cc918262ef04fb1c05c26026df5c11a6a56666f9b1fb4072210@18.178.30.66:32668 enode://d67251dd3b050e555679a8abdc427a4c78a9bae174f2fd3b9163c364d27b6a69688ee067cd3214e8ceb71e6e602fd812797b085ae37ed3bf93b78e2b77ae3306@18.181.40.7:32668 enode://f88bb1f5d0e42cf75ec879212b7c8477d605315d5296fba02bc4600eccf73c64427de46567a320d00985d5bc612168817ba6dff169bd6a4774e112e6db0ff6a2@18.176.66.118:32668
环境配置¶
# 自定义环境变量
echo -e "export HECO_HOME=/opt/chain/hecochain" > /etc/profile.d/hecochain.sh
source /etc/profile
# 设置golang代理
export GOPROXY=https://goproxy.cn
# 创建数据存储目录
mkdir -p ${HECO_HOME}/{bin,data,log,src}
cd ${HECO_HOME}/src
# 下载源码
git clone https://github.com/HuobiGroup/huobi-eco-chain.git
cd huobi-eco-chain/
# 开始编译
# 编译完成后,生成的二进制文件在build/bin目录下
make geth
cp build/bin/geth ${HECO_HOME}/bin
# ln -fs ${HECO_HOME}/bin/geth /usr/bin/geth-hecochain
chown -R deploy.deploy ${HECO_HOME}
su deploy
管理服务¶
启动
程序启动默认接入
mainnet,如需接入公共测试网,可添加option--testnet。# Testnet nohup ${HECO_HOME}/bin/geth --port 33333 --networkid=256 --http --http.addr 0.0.0.0 --http.port 8545 --http.api eth,net,web3 --syncmode full --cache 2048 --datadir ${HECO_HOME}/data/ --ethash.dagdir ${HECO_HOME}/data/ethdag/ --ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.origins "*" --rpcvhosts "*" --verbosity 3 --testnet >> ${HECO_HOME}/log/hecochain.log & # Main nohup ${HECO_HOME}/bin/geth --port 33333 --networkid=128 --http --http.addr 0.0.0.0 --http.port 8545 --http.api eth,net,web3 --syncmode full --cache 2048 --datadir ${HECO_HOME}/data/ --ethash.dagdir ${HECO_HOME}/data/ethdag/ --ws --ws.addr 0.0.0.0 --ws.port 18546 --ws.origins "*" --rpcvhosts "*" --verbosity 3 >> ${HECO_HOME}/log/hecochain.log &
查看日志
tail -f ${HECO_HOME}/log/hecochain.log
通过ipc进入控制台
${HECO_HOME}/bin/geth attach ipc:${HECO_HOME}/data/geth.ipc
附录1:常用命令¶
# 查看区块同步情况
eth.syncing
# 列出所有账号
eth.accounts
# 在同步的过程中我们通过 eth.blockNumber 去查看当前区块号的话会显示为0
eth.blockNumber
# 节点连了多少个其它节点进行数据同步。如果返回结果为0,就要自查一下了
net.peerCount
#查看网络上的小伙伴
admin.peers
# 查看第一个账号余额
eth.getBalance(eth.accounts[0])
# 新建一个密码123456的账号
personal.newAccount('123456')
# 币值转换为big ether
web3.toWei(0.0001, "ether")
# big ether转换为ether
web3.fromWei(100000000000000, "ether")
# 查看当前网络信息
admin.nodeInfo
# 查看网络是否监听
net.listening
# 开始挖矿
miner.start()
# 停止挖矿
miner.stop()
# 获取用户金额
eth.getBalance(my)
admin.addPeer( "enode://9e779099395c022e4a4f14305f3b513c09c8a933f058dd50cf93ad4418dc62d990ce54e07267b8a5a87ee3da5c8b4ec760998ef869abd276487066f0da0f4dba@43.129.250.112:30311" )
admin.addPeer( "enode://0daef7aa168454c9404f7d4f819f340ebc28d1593a7f29953c93968f87ca35d8e88d5cf37258fe9326f95e63b959eb8f8c62ac1020b7fca1f2a37eec483c41e1@49.233.60.245:30311" )
BlockBook¶
安装环境¶
GoLang环境配置¶
# 下载地址:https://golang.google.cn/dl/
# wget https://golang.org/dl/go1.14.4.linux-amd64.tar.gz
wget https://golang.google.cn/dl/go1.15.11.linux-amd64.tar.gz
tar -zxf go1.15.11.linux-amd64.tar.gz -C /usr/local/
vim /etc/profile.d/go.sh
################# file content #################
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
export GOPATH=/opt/go
################################################
source /etc/profile
go version
# 设置golang代理
export GOPROXY=https://goproxy.cn
安装RocksDB¶
# 将gcc升级到至少4.8版本以获得c++ 11支持:
yum install -y gcc-c++ git
# Install gflags:
git clone https://github.com/gflags/gflags.git
cd gflags
git checkout v2.0
./configure && make && sudo make install
export CPATH=$CPATH:/usr/local/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
yum install -y snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4-devel libzstd-devel libasan
# Install zstandard:
wget https://github.com/facebook/zstd/archive/v1.1.3.tar.gz
mv v1.1.3.tar.gz zstd-1.1.3.tar.gz
tar zxvf zstd-1.1.3.tar.gz
cd zstd-1.1.3
make && sudo make install
# Install RocksDB
cd ~
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
CFLAGS=-fPIC CXXFLAGS=-fPIC make release
make install
# gorocksdb的设置变量:https : //github.com/tecbot/gorocksdb
export CGO_CFLAGS="-I/usr/local/include/rocksdb/include"
export CGO_LDFLAGS="-L/usr/local/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
go get github.com/tecbot/gorocksdb
安装ZeroMQ¶
cd /etc/yum.repos.d/
wget https://download.opensuse.org/repositories/network:messaging:zeromq:release-stable/CentOS_7/network:messaging:zeromq:release-stable.repo
# 安装企业版源
yum install epel-release
yum install zeromq-devel
编译BlockBook¶
cd $GOPATH/src
# 官方,不支持 Huobi ECO Chain,BSC,OK链配置
# git clone https://github.com/trezor/blockbook
# cd blockbook
# git checkout v0.3.4
# 支持 Huobi ECO Chain
git clone https://gitlab.ystarglobal.com/bingoo/backend/blockbook.git
cd blockbook
CGO_CFLAGS="-I/usr/local/include/rocksdb/include"
CGO_LDFLAGS="-L/usr/local/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd -ldl"
修改源码中 Ethereum Testnet 网络配置信息
使用官方的 blockbook 需要以下操作,修改 Ethereum 测试链环境,编译 Main 网无需修改
cd /opt/go/src/blockbook
vim bchain/coins/blockchain.go
############################################
# 修改约68行内容
BlockChainFactories["Ethereum Testnet Ropsten"] = eth.NewEthereumRPC
# 改成
BlockChainFactories["Ethereum Testnet Rinkeby"] = eth.NewEthereumRPC
############################################
vim bchain/coins/eth/ethrpc.go
############################################
# 修改约30,31行内容
// TestNet is Ropsten test network
TestNet EthereumNet = 3
# 改成
// TestNet is Rinkeby test network
TestNet EthereumNet = 4
############################################
添加 ethereum_testnet_rinkeby.json 和 hecochain_testnet.json 等文件到 configs/coins 目录中,文件信息请参考附录。
编译
chmod 644 ethereum_testnet_rinkeby.json hecochain_testnet.json
cd /opt/go/src/blockbook
go build
安装BlockBook¶
配置 BlockBook 环境
# 自定义环境变量 echo -e "export BLOCKBOOK_HOME=/opt/chain/blockbook" > /etc/profile.d/blockbook.sh source /etc/profile mkdir -p ${BLOCKBOOK_HOME}/bin cp blockbook ${BLOCKBOOK_HOME}/bin ln -sf ${BLOCKBOOK_HOME}/bin/blockbook /usr/bin/blockbook
Ethereum 配置文件
# Testnet mkdir -p ${BLOCKBOOK_HOME}/ethereum/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh ethereum_testnet_rinkeby mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/ethereum/config/ethereum_testnet.json cp -r static/ ${BLOCKBOOK_HOME}/ethereum/ # Main mkdir -p ${BLOCKBOOK_HOME}/ethereum/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh ethereum mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/ethereum/config/ethereum.json cp -r static/ ${BLOCKBOOK_HOME}/ethereum/
Bitcoin 配置文件
# Testnet mkdir -p ${BLOCKBOOK_HOME}/bitcoin/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh bitcoin_testnet mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/bitcoin/config/bitcoin_testnet.json cp -r static/ ${BLOCKBOOK_HOME}/bitcoin/ # Main mkdir -p ${BLOCKBOOK_HOME}/bitcoin/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh bitcoin mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/bitcoin/config/bitcoin.json cp -r static/ ${BLOCKBOOK_HOME}/bitcoin/
Hecochain 配置文件
# Testnet mkdir -p ${BLOCKBOOK_HOME}/hecochain/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh hecochain_testnet mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/hecochain/config/hecochain_testnet.json cp -r static/ ${BLOCKBOOK_HOME}/hecochain/ # Main mkdir -p ${BLOCKBOOK_HOME}/hecochain/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh hecochain mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/hecochain/config/hecochain.json cp -r static/ ${BLOCKBOOK_HOME}/hecochain/
BSC 配置文件
# Main mkdir -p ${BLOCKBOOK_HOME}/bsc/{config,data,log} ./contrib/scripts/build-blockchaincfg.sh binance_smart_chain mv build/blockchaincfg.json ${BLOCKBOOK_HOME}/bsc/config/bsc.json cp -r static/ ${BLOCKBOOK_HOME}/bsc/
管理服务¶
添加deploy用户权限
chown -R deploy.deploy ${BLOCKBOOK_HOME} su deploy
启动 Ethereum
cd ${BLOCKBOOK_HOME}/ethereum # Testnet nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/ethereum/config/ethereum_testnet.json -datadir=${BLOCKBOOK_HOME}/ethereum/data/ -debug=true -internal=:9036 -public=:9136 -logtostderr >> ${BLOCKBOOK_HOME}/ethereum/log/ethereum.log & # 非debug模式运行 nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/ethereum/config/ethereum_testnet.json -datadir=${BLOCKBOOK_HOME}/ethereum/data/ -debug=false -internal=:9036 -public=:9136 -logtostderr >> ${BLOCKBOOK_HOME}/ethereum/log/ethereum_20201224.log & # Main nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/ethereum/config/ethereum.json -datadir=${BLOCKBOOK_HOME}/ethereum/data/ -debug=true -internal=:9036 -public=:9136 -logtostderr >> ${BLOCKBOOK_HOME}/ethereum/log/ethereum.log & # 非debug模式运行 nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/ethereum/config/ethereum.json -datadir=${BLOCKBOOK_HOME}/ethereum/data/ -debug=false -internal=:9036 -public=:9136 -logtostderr >> ${BLOCKBOOK_HOME}/ethereum/log/ethereum.log &
启动 Bitcoin
TODO: 启动前确定 Bitcoin 节点服务配置文件是否有 txindex=1 配置项,启动参数是否含有 -reindex 参数,-reindex 只需 第一次启动时添加。
cd ${BLOCKBOOK_HOME}/bitcoin # Testnet nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/bitcoin/config/bitcoin_testnet.json -datadir=${BLOCKBOOK_HOME}/bitcoin/data/ -workers=1 -debug=true -internal=:9030 -public=:9130 -logtostderr >> ${BLOCKBOOK_HOME}/bitcoin/log/bitcoin.log & # Main nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/bitcoin/config/bitcoin.json -datadir=${BLOCKBOOK_HOME}/bitcoin/data/ -workers=1 -debug=true -internal=:9030 -public=:9130 -logtostderr >> ${BLOCKBOOK_HOME}/bitcoin/log/bitcoin.log &
启动 Hecochain
cd ${BLOCKBOOK_HOME}/hecochain # Testnet nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/hecochain/config/hecochain_testnet.json -datadir=${BLOCKBOOK_HOME}/hecochain/data/ -debug=true -internal=:9039 -public=:9139 -logtostderr >> ${BLOCKBOOK_HOME}/hecochain/log/hecochain.log & # Main nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/hecochain/config/hecochain.json -datadir=${BLOCKBOOK_HOME}/hecochain/data/ -debug=true -internal=:9039 -public=:9139 -logtostderr >> ${BLOCKBOOK_HOME}/hecochain/log/hecochain.log &
启动 BSC
cd ${BLOCKBOOK_HOME}/bsc # Main nohup blockbook -sync -blockchaincfg=${BLOCKBOOK_HOME}/bsc/config/bsc.json -datadir=${BLOCKBOOK_HOME}/bsc/data/ -workers=1 -debug=true -internal=:9033 -public=:9133 -logtostderr >> ${BLOCKBOOK_HOME}/bsc/log/bsc.log &
问题记录¶
正常通过systemctl关闭blockbook服务后, 隔段时间后重新启动服务,rocksdb报错: blockbook.go:210] internalState: database is in inconsistent state and cannot be used 解决过程记录: 参考blockbook官方两个issue建议: https://github.com/trezor/blockbook/issues/89 https://github.com/trezor/blockbook/issues/147 启用单线程工作模式, 否则需要每个blockbook服务实例占用30G内存的方式才能解决: systemctl stop blockbook-bitcoin-testnet rm -rf /opt/coins/data/bitcoin_testnet/blockbook/db vim /lib/systemd/system/blockbook-bitcoin-testnet.service 在启动参数中增加
-workers=1参数, 并启动blockbook服务 systemctl start blockbook-bitcoin-testnet自测时不启用自签名证书,去掉启动参数中的
-certfile=/opt/coins/blockbook/ethereum/cert/blockbook项,即可使用http访问restapi接口
修改源码¶
支持其他链修改源码
// 修改文件 blockbook/bchain/coins/blockchain.go
func init() {
// 增加以下代码
BlockChainFactories["Huobi ECO Chain"] = eth.NewEthereumRPC
BlockChainFactories["Huobi ECO Chain Testnet"] = eth.NewEthereumRPC
BlockChainFactories["Binance Smart Chain"] = eth.NewEthereumRPC
}
// 修改文件 blockbook/bchain/coins/eth/ethrpc.go
const (
// MainNet is production network
MainNet EthereumNet = 1
// TestNet is Rinkeby test network
TestNet EthereumNet = 4
// HecoMainNet is production network for Huobi ECO Chain
HecoMainNet EthereumNet = 128
// HecoTestNet is test network for Huobi ECO Chain
HecoTestNet EthereumNet = 256
// BscMainNet is production network for Binance Smart Chain
BscMainNet EthereumNet = 56
)
// Initialize initializes ethereum rpc interface
func (b *EthereumRPC) Initialize() error {
ctx, cancel := context.WithTimeout(context.Background(), b.timeout)
defer cancel()
id, err := b.client.NetworkID(ctx)
if err != nil {
return err
}
// parameters for getInfo request
switch EthereumNet(id.Uint64()) {
case MainNet:
b.Testnet = false
b.Network = "livenet"
break
case TestNet:
b.Testnet = true
b.Network = "testnet"
break
case HecoMainNet:
b.Testnet = false
b.Network = "mainnet"
break
case HecoTestNet:
b.Testnet = true
b.Network = "testnet"
break
case BscMainNet:
b.Testnet = false
b.Network = "mainnet"
break
default:
return errors.Errorf("Unknown network id %v", id)
}
glog.Info("rpc: block chain ", b.Network)
return nil
}
附录1:BlockBook 各服务端口信息¶
| coin | blockbook internal port | blockbook public port | backend rpc port | backend service ports (zmq) |
|---|---|---|---|---|
| Bitcoin | 9030 | 9130 | 8030 | 38330 |
| Ethereum | 9036 | 9136 | 8036 | 38336 p2p, 8136 http |
| Hecochain | 9039 | 9139 | ||
| BSC | 9033 | 9133 |
附录2:ethereum_testnet_rinkeby.json¶
{
"coin": {
"name": "Ethereum Testnet Rinkeby",
"shortcut": "tROP",
"label": "Ethereum Rinkeby",
"alias": "ethereum_testnet_rinkeby"
},
"ports": {
"backend_rpc": 18036,
"backend_message_queue": 0,
"backend_p2p": 48336,
"blockbook_internal": 19036,
"blockbook_public": 19136
},
"ipc": {
"rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_timeout": 25
},
"backend": {
"package_name": "backend-ethereum-testnet-rinkeby",
"package_revision": "satoshilabs-1",
"system_user": "ethereum",
"version": "1.9.13-cbc4ac26",
"binary_url": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz",
"verification_type": "gpg",
"verification_source": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz.asc",
"extract_command": "tar -C backend --strip 1 -xf",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/geth --testnet --syncmode full --ipcdisable --cache 1024 --nat none --datadir {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend --port 48336 --ws --wsaddr 127.0.0.1 --wsport {{.Ports.BackendRPC}} --wsorigins \"*\" 2>>{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "",
"service_type": "simple",
"service_additional_params_template": "",
"protect_memory": true,
"mainnet": false,
"server_config_file": "",
"client_config_file": ""
},
"blockbook": {
"package_name": "blockbook-ethereum-testnet-rinkeby",
"system_user": "blockbook-ethereum",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "",
"block_chain": {
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 300,
"additional_params": {
"mempoolTxTimeoutHours": 12,
"queryBackendOnMempoolResync": false
}
}
},
"meta": {
"package_maintainer": "IT",
"package_maintainer_email": "it@satoshilabs.com"
}
}
附录3:hecochain_testnet.json¶
{
"coin": {
"name": "Huobi ECO Chain Testnet",
"shortcut": "tHECO",
"label": "HecoChain Testnet",
"alias": "hecochain_testnet"
},
"ports": {
"backend_rpc": 18356,
"backend_message_queue": 0,
"backend_p2p": 48556,
"blockbook_internal": 19356,
"blockbook_public": 19456
},
"ipc": {
"rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_timeout": 25
},
"backend": {
"package_name": "backend-hecochain-testnet",
"package_revision": "satoshilabs-1",
"system_user": "hecochain",
"version": "1.9.13-cbc4ac26",
"binary_url": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz",
"verification_type": "gpg",
"verification_source": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz.asc",
"extract_command": "tar -C backend --strip 1 -xf",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/geth --testnet --syncmode full --ipcdisable --cache 1024 --nat none --datadir {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend --port 48556 --ws --wsaddr 127.0.0.1 --wsport {{.Ports.BackendRPC}} --wsorigins \"*\" 2>>{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "",
"service_type": "simple",
"service_additional_params_template": "",
"protect_memory": true,
"mainnet": false,
"server_config_file": "",
"client_config_file": ""
},
"blockbook": {
"package_name": "blockbook-hecochain-testnet",
"system_user": "blockbook-hecochain",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "",
"block_chain": {
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 300,
"additional_params": {
"mempoolTxTimeoutHours": 12,
"queryBackendOnMempoolResync": false
}
}
},
"meta": {
"package_maintainer": "IT",
"package_maintainer_email": "it@satoshilabs.com"
}
}
附录4:hecochain.json¶
{
"coin": {
"name": "Huobi ECO Chain",
"shortcut": "HECO",
"label": "HecoChain",
"alias": "hecochain"
},
"ports": {
"backend_rpc": 8356,
"backend_message_queue": 0,
"backend_p2p": 38556,
"backend_http": 8456,
"blockbook_internal": 9356,
"blockbook_public": 9456
},
"ipc": {
"rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_timeout": 25
},
"backend": {
"package_name": "backend-hecochain",
"package_revision": "satoshilabs-1",
"system_user": "hecochain",
"version": "1.9.13-cbc4ac26",
"binary_url": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz",
"verification_type": "gpg",
"verification_source": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz.asc",
"extract_command": "tar -C backend --strip 1 -xf",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/geth --ipcdisable --syncmode full --cache 1024 --nat none --datadir {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend --port 38556 --ws --wsaddr 127.0.0.1 --wsport {{.Ports.BackendRPC}} --wsorigins \"*\" --rpc --rpcport 8356 -rpcaddr 127.0.0.1 --rpccorsdomain \"*\" --rpcvhosts \"*\" 2>>{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "",
"service_type": "simple",
"service_additional_params_template": "",
"protect_memory": true,
"mainnet": true,
"server_config_file": "",
"client_config_file": ""
},
"blockbook": {
"package_name": "blockbook-hecochain",
"system_user": "blockbook-hecochain",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "",
"block_chain": {
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 300,
"additional_params": {
"mempoolTxTimeoutHours": 48,
"queryBackendOnMempoolResync": false,
"fiat_rates": "coingecko",
"fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"huobi-token\", \"periodSeconds\": 60}"
}
}
},
"meta": {
"package_maintainer": "IT",
"package_maintainer_email": "it@satoshilabs.com"
}
}
附录5:binance_smart_chain.json¶
{
"coin": {
"name": "Binance Smart Chain",
"shortcut": "BSC",
"label": "BSChain",
"alias": "bschain"
},
"ports": {
"backend_rpc": 8366,
"backend_message_queue": 0,
"backend_p2p": 38666,
"backend_http": 8466,
"blockbook_internal": 9366,
"blockbook_public": 9466
},
"ipc": {
"rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_timeout": 25
},
"backend": {
"package_name": "backend-bschain",
"package_revision": "satoshilabs-1",
"system_user": "bschain",
"version": "1.9.13-cbc4ac26",
"binary_url": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz",
"verification_type": "gpg",
"verification_source": "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.9.13-cbc4ac26.tar.gz.asc",
"extract_command": "tar -C backend --strip 1 -xf",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/geth --ipcdisable --syncmode full --cache 1024 --nat none --datadir {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend --port 38666 --ws --wsaddr 127.0.0.1 --wsport {{.Ports.BackendRPC}} --wsorigins \"*\" --rpc --rpcport 8366 -rpcaddr 127.0.0.1 --rpccorsdomain \"*\" --rpcvhosts \"*\" 2>>{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "",
"service_type": "simple",
"service_additional_params_template": "",
"protect_memory": true,
"mainnet": true,
"server_config_file": "",
"client_config_file": ""
},
"blockbook": {
"package_name": "blockbook-bschain",
"system_user": "blockbook-bschain",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "",
"block_chain": {
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 300,
"additional_params": {
"mempoolTxTimeoutHours": 48,
"queryBackendOnMempoolResync": false,
"fiat_rates": "coingecko",
"fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"binance-coin\", \"periodSeconds\": 60}"
}
}
},
"meta": {
"package_maintainer": "IT",
"package_maintainer_email": "it@satoshilabs.com"
}
}
OKExChain¶
节点信息¶
默认端口:解析到start命令指定的 --rest.laddr 参数上面,默认是26659端口
环境配置¶
# 自定义环境变量
echo -e "export OKEX_HOME=/opt/chain/okexchain" > /etc/profile.d/okexchain.sh
source /etc/profile
mkdir -p ${OKEX_HOME}/{bin,log,src}
# 设置golang代理
export GOPROXY=https://goproxy.cn
# 下载代码并编译可执行程序
cd ${OKEX_HOME}/src
# wget https://github.com/okex/exchain/archive/refs/tags/v0.18.6.tar.gz
# tar -zxf v0.18.6.tar.gz
# cd exchain-0.18.6/
wget https://github.com/okex/exchain/archive/refs/tags/v0.18.18.tar.gz
tar -zxf v0.18.18.tar.gz
cd exchain-0.18.18/
编译运行¶
Testnet 编译安装
make GenesisHeight=1121818 install cp ${GOPATH}/bin/{exchaind,exchaincli} ${OKEX_HOME}/bin # 查看版本 ${OKEX_HOME}/bin/exchaind version # 下载 Testnet 数据快照 cd ${OKEX_HOME} wget -c https://ok-public-hk.oss-cn-hongkong.aliyuncs.com/cdn/okexchain/snapshot/data_180.tar.gz tar -zxf data_180.tar.gz # 配置文件生成, `okexNodeBingoo`为节点别称,只允许ASCII码 ${OKEX_HOME}/bin/exchaind init okexNodeBingoo --chain-id exchain-65 --home ${OKEX_HOME} chown -R deploy.deploy ${OKEX_HOME} su deploy # 配置节点环境信息 # export EXCHAIN_SEEDS="b7c6bdfe0c3a6c1c68d6d6849f1b60f566e189dd@3.13.150.20:36656,d7eec05e6449945c8e0fd080d58977d671eae588@35.176.111.229:36656,223b5b41d1dba9057401def49b456630e1ab2599@18.162.106.25:36656" # 启动服务 # nohup ${OKEX_HOME}/bin/exchaind start --chain-id exchain-65 --home ${OKEX_HOME} --p2p.seeds $EXCHAIN_SEEDS >> ${OKEX_HOME}/log/okchain.log & export EXCHAIN_SEEDS="b7c6bdfe0c3a6c1c68d6d6849f1b60f566e189dd@3.13.150.20:36656,d7eec05e6449945c8e0fd080d58977d671eae588@35.176.111.229:36656,223b5b41d1dba9057401def49b456630e1ab2599@18.162.106.25:36656" nohup /data/okexchain/bin/exchaind start --chain-id exchain-65 --db_backend rocksdb --mempool.sort_tx_by_gp --home /data/okexchain/ --p2p.seeds $EXCHAIN_SEEDS >> /data/okexchain/log/okchain.log & # exchaind start --chain-id exchain-65 --mempool.sort_tx_by_gp --home /data/okexchain --p2p.seeds $EXCHAIN_SEEDS # 查看链的状态 ${OKEX_HOME}/bin/exchaincli status
Mainnet 编译安装
make GenesisHeight=2322600 install cp -r ${GOPATH}/bin/{exchaincli,exchaind} ${OKEX_HOME}/bin # 查看版本 ${OKEX_HOME}/bin/exchaind version # 配置文件生成, `okexNodeBingoo`为节点别称,只允许ASCII码 ${OKEX_HOME}/bin/exchaind init okexNodeBingoo --chain-id exchain-66 --home ${OKEX_HOME} chown -R deploy.deploy ${OKEX_HOME} su deploy mv ${OKEX_HOME}/config/genesis.json ${OKEX_HOME}/config/genesis.json.bak wget https://raw.githubusercontent.com/okex/mainnet/main/genesis.json -O ${OKEX_HOME}/config/genesis.json # 注意:检查genesis.json文件的shasum值 sha256sum ${OKEX_HOME}/config/genesis.json # 输出信息 >> 0958b6c9f5f125d1d6b8f56e042fa8a71b1880310227b8b2f27ba93ff7cd673b /opt/chain/okexchain/config/genesis.json echo -e 'export EXCHAIN_SEEDS="e926c8154a2af4390de02303f0977802f15eafe2@3.16.103.80:26656,7fa5b1d1f1e48659fa750b6aec702418a0e75f13@35.177.8.240:26656,c8f32b793871b56a11d94336d9ce6472f893524b@18.167.16.85:26656"' >> /etc/profile.d/okexchain.sh source /etc/profile # export EXCHAIN_SEEDS="e926c8154a2af4390de02303f0977802f15eafe2@3.16.103.80:26656,7fa5b1d1f1e48659fa750b6aec702418a0e75f13@35.177.8.240:26656,c8f32b793871b56a11d94336d9ce6472f893524b@18.167.16.85:26656" # 启动服务 # nohup ${OKEX_HOME}/bin/exchaind start --chain-id exchain-66 --home ${OKEX_HOME} --p2p.seeds $EXCHAIN_SEEDS >> ${OKEX_HOME}/log/exchain.log & # 启动服务 #nohup ${OKEX_HOME}/bin/exchaind start --chain-id exchain-66 --home ${OKEX_HOME} --p2p.seeds $EXCHAIN_SEEDS --mempool.sort_tx_by_gp true >> ${OKEX_HOME}/log/exchain.log & # 设置参数--p2p.persistent_peers加速区块同步效率 --p2p.persistent_peers bbd4aa19249ad42de4fe2ca99209894412fd4707@3.135.138.205:26656,add30aff52c2e43f071c7c2a8be797bef0ed8261@18.135.79.233:26656,e5c4c525df58bb072f2aacebea1cd92d36e83fd3@18.162.117.130:26656,7ce43d169e955309e1cca22468ee3ed9e6fd6f45@8.166.245.222:26656,f7c67632e51fde3c30bc8e41852c1e81aa1d9c2a@18.167.7.207:26656,833777703584393d763b60169e5ca204da91dd83@18.166.194.215:26656,54c195e08ff53e9fd31973dd73d530dcd1506807@52.78.236.126:26656,0eb87d4eb92f8f04d9c2d444dd403671a634af56@13.125.38.24:26656,01b21d39f250a3a5411113aae4a7032eaf9b344e@3.64.37.17:26656,69ea6fb105a3f85d3dd44267d28fae4f0dedf5ab@18.192.220.49:26656,b2a2f799a726b74f83f73b62e1bfef017575b21a@54.151.166.67:26656,3449bb4d2180dfaa9ddb13776177b0e67f95ebb4@54.255.93.228:26656,da32322e27dc9ef5002fed0416f05326fd27723f@54.151.129.9:26656,c88044fb164896bd9ed29bbee7c290c6ac362133@3.112.119.135:26656,39700092b3c7893fdd8ab3af9d66f18113ca47cd@54.150.183.225:26656,9e2aa6bd61c40f08782f7c2ff47d9ea197994b74@54.249.109.150:26656,44cd4db42723a65d61e8803498703b9e4b353036@44.233.186.156:26656,8c7affcb25e8e059f992d4c6494586587782d809@52.40.214.137:26656 # 启动服务 nohup ${OKEX_HOME}/bin/exchaind start --chain-id exchain-66 --home ${OKEX_HOME} --p2p.seeds $EXCHAIN_SEEDS --p2p.persistent_peers bbd4aa19249ad42de4fe2ca99209894412fd4707@3.135.138.205:26656,add30aff52c2e43f071c7c2a8be797bef0ed8261@18.135.79.233:26656,e5c4c525df58bb072f2aacebea1cd92d36e83fd3@18.162.117.130:26656,7ce43d169e955309e1cca22468ee3ed9e6fd6f45@8.166.245.222:26656,f7c67632e51fde3c30bc8e41852c1e81aa1d9c2a@18.167.7.207:26656,833777703584393d763b60169e5ca204da91dd83@18.166.194.215:26656,54c195e08ff53e9fd31973dd73d530dcd1506807@52.78.236.126:26656,0eb87d4eb92f8f04d9c2d444dd403671a634af56@13.125.38.24:26656,01b21d39f250a3a5411113aae4a7032eaf9b344e@3.64.37.17:26656,69ea6fb105a3f85d3dd44267d28fae4f0dedf5ab@18.192.220.49:26656,b2a2f799a726b74f83f73b62e1bfef017575b21a@54.151.166.67:26656,3449bb4d2180dfaa9ddb13776177b0e67f95ebb4@54.255.93.228:26656,da32322e27dc9ef5002fed0416f05326fd27723f@54.151.129.9:26656,c88044fb164896bd9ed29bbee7c290c6ac362133@3.112.119.135:26656,39700092b3c7893fdd8ab3af9d66f18113ca47cd@54.150.183.225:26656,9e2aa6bd61c40f08782f7c2ff47d9ea197994b74@54.249.109.150:26656,44cd4db42723a65d61e8803498703b9e4b353036@44.233.186.156:26656,8c7affcb25e8e059f992d4c6494586587782d809@52.40.214.137:26656 --mempool.sort_tx_by_gp true --max-open=10000 --close-mutex=1 --fast-query=1 --enable-bloom-filter=1 --mempool.size=10000 --mempool.recheck=0 --mempool.force_recheck_gap=2000 --iavl-cache-size=1000000 >> ${OKEX_HOME}/log/exchain.log & nohup /data/okexchain/bin/exchaind start --chain-id exchain-66 --mempool.sort_tx_by_gp --home /data/okexchain --p2p.seeds $EXCHAIN_SEEDS >> /data/okexchain/log/exchain.log &
一、在启动rpc节点时建议带上一些性能优化的参数,可以避免节点同步区块慢等问题。具体参数如下:¶
1、以二进制形式启动的节点,在exchaind start命令中增加以下参数:
--max-open=10000
--close-mutex=1
--fast-query=1
--enable-bloom-filter=1
--mempool.size=10000
--mempool.recheck=0
--mempool.force_recheck_gap=2000
--iavl-cache-size=1000000
以docker方式启动的节点,在docker run命令中增加以下参数:
--env OKEXCHAIN_MAX_OPEN=10000
--env OKEXCHAIN_CLOSE_MUTEX=1
--env OKEXCHAIN_FAST_QUERY=1
--env OKEXCHAIN_ENABLE_BLOOM_FILTER=1
--env OKEXCHAIN_MEMPOOL_SIZE=10000
--env OKEXCHAIN_MEMPOOL_RECHECK=0
--env OKEXCHAIN_MEMPOOL_FORCE_RECHECK_GAP=2000
--env OKEXCHAIN_IAVL_CACHE_SIZE=1000000
性能参数含义解释¶
--max-open=10000 最大连接数,默认值1000,增加该值可以提供rpc服务能够接收的连接数。
--close-mutex=1 abci query中的锁开关,默认值为关闭,打开后可以提升查询性能
--fast-query=1 快速查询模式开关,默认值为关闭,打开后查询数据会额外记录到watch.db,提升查询性能
--enable-bloom-filter=1 bloom filter开关,默认值为关闭,打开可以提升eth_getLogs查询性能_
--mempool.size=10000 设置mempool大小,默认值2000,增加该值可以提高mempool中存储
tx数量。
--mempool.recheck=0 设置mempool recheck开关,默认值为打开,关闭可以减少recheck消耗的性能
--mempool.force_recheck_gap=2000 设置mempool强制进行recheck的区块间隔数,默认值200,增大该值可以减少recheck
次数,提升性能,但是设置过大可能会导致mempool中积压过多无效的交易。
--iavl-cache-size=1000000 设置iavl树缓存大小,默认值1000000,增加该值可以减少磁盘读取,提升执行速度,但是会占用更多内存,可根据机器实际内存占用情况调整。
查看主网区块哈希:https://exchaintmrpc.okex.org/block?height=2439212