配置文件概览
Stable 节点使用两个主要配置文件:config.toml:核心 Tendermint/CometBFT 配置app.toml:应用程序特定配置
~/.stabled/config/ 中
核心配置 (config.toml)
基础设置
Copy
Ask AI
# 要加入的链 ID(当前链 ID 请参阅私有测试网信息)
chain_id = "stabletestnet_2201-1"
# 此节点的自定义可读名称
moniker = "your-node-name"
# 数据库后端:goleveldb | cleveldb | boltdb | rocksdb | badgerdb
db_backend = "goleveldb"
P2P 配置
Copy
Ask AI
[p2p]
# 监听传入连接的地址
laddr = "tcp://0.0.0.0:26656"
# 向对等节点公布的拨号地址
external_address = "YOUR_PUBLIC_IP:26656"
# 逗号分隔的种子节点列表
seeds = ""
# 逗号分隔的持久对等节点列表
persistent_peers = "5ed0f977a26ccf290e184e364fb04e268ef16430@37.187.147.27:26656,128accd3e8ee379bfdf54560c21345451c7048c7@37.187.147.22:26656"
# 最大入站对等节点数
max_num_inbound_peers = 50
# 最大出站对等节点数
max_num_outbound_peers = 30
# 切换以禁止防止来自相同 ip 的对等节点连接
allow_duplicate_ip = false
# 对等节点连接配置
handshake_timeout = "20s"
dial_timeout = "3s"
# 在连接上刷新消息前等待的时间
flush_throttle_timeout = "100ms"
# 消息包载荷的最大大小
max_packet_msg_payload_size = 1024
# 速率限制
send_rate = 5120000 # 5 MB/s
recv_rate = 5120000 # 5 MB/s
# 种子模式(仅适用于种子节点)
seed_mode = false
# 启用对等节点交换反应器
pex = true
RPC 服务器配置
Copy
Ask AI
[rpc]
# RPC 服务器的 TCP 或 UNIX 套接字地址
laddr = "tcp://127.0.0.1:26657"
# 可以执行跨域请求的来源列表
cors_allowed_origins = ["*"]
# 客户端在跨域请求中允许使用的方法列表
cors_allowed_methods = ["HEAD", "GET", "POST"]
# 客户端在跨域请求中允许使用的非简单头部列表
cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]
# gRPC 服务器的 TCP 或 UNIX 套接字地址
grpc_laddr = "tcp://127.0.0.1:9090"
# 最大同时连接数
grpc_max_open_connections = 900
# 激活不安全的 RPC 命令,如 /dial_seeds 和 /unsafe_flush_mempool
unsafe = false
# 最大同时连接数(包括 WebSocket)
max_open_connections = 900
# 可连接的唯一客户端 ID 的最大数量
max_subscription_clients = 100
# 给定客户端可订阅的唯一查询的最大数量
max_subscriptions_per_client = 5
# 等待 tx 提交的时间
timeout_broadcast_tx_commit = "10s"
# 请求体的最大大小
max_body_bytes = 1000000
# 请求头的最大大小
max_header_bytes = 1048576
内存池配置
Copy
Ask AI
[mempool]
# 要使用的内存池版本
version = "v1"
# 重新检查启用
recheck = true
# 广播启用
broadcast = true
# 内存池中交易的最大数量
size = 3000
# 限制内存池中所有 tx 的总大小
max_txs_bytes = 1073741824 # 1GB
# 缓存大小
cache_size = 10000
# 不要从缓存中删除无效交易
keep-invalid-txs-in-cache = false
# 单个交易的最大大小
max_tx_bytes = 1048576 # 1MB
# 发送给对等节点的交易批次的最大大小
max_batch_bytes = 0
共识配置
Copy
Ask AI
[consensus]
# 在预投票为 nil 之前等待提案区块的时间
timeout_propose = "5s"
# timeout_propose 在每轮增加多少
timeout_propose_delta = "10ms"
# 收到 +2/3 预投票后等待多长时间
timeout_prevote = "150ms"
# timeout_prevote 在每轮增加多少
timeout_prevote_delta = "10ms"
# 收到 +2/3 预提交后等待多长时间
timeout_precommit = "150s"
# timeout_precommit 在每轮增加多少
timeout_precommit_delta = "10ms"
# 一旦我们有了所有预提交就立即取得进展
skip_timeout_commit = false
# 启用/禁用双重签名检查
double_sign_check_height = 2
# 空块模式
create_empty_blocks = true
create_empty_blocks_interval = "0s"
# 反应器睡眠持续时间
peer_gossip_sleep_duration = "100ms"
peer_query_maj23_sleep_duration = "2s"
应用程序配置 (app.toml)
基础应用程序设置
Copy
Ask AI
# 修剪策略
pruning = "default"
# HaltHeight 包含一个非零区块高度,节点将在此高度停止
halt-height = 0
# HaltTime 包含一个非零时间,节点将在此时间停止
halt-time = 0
# MinRetainBlocks 定义节点将保留的区块数量
min-retain-blocks = 0
# InterBlockCache 启用块间缓存
inter-block-cache = true
# IndexEvents 以 {eventType}.{attributeKey} 形式定义事件集
index-events = []
# IavlCacheSize 设置 iavl 树缓存的大小
iavl-cache-size = 781250
API 配置
Copy
Ask AI
[api]
# Enable 定义是否应启用 API 服务器
enable = true
# Swagger 定义是否应自动注册 swagger 文档
swagger = true
# Address 定义 API 服务器监听的地址
address = "tcp://0.0.0.0:1317"
# MaxOpenConnections 定义最大开放连接数
max-open-connections = 1000
# EnabledUnsafeCORS 定义是否应启用 CORS
enabled-unsafe-cors = true
gRPC 配置
Copy
Ask AI
[grpc]
# Enable 定义是否应启用 gRPC 服务器
enable = true
# Address 定义要绑定的 gRPC 服务器地址
address = "0.0.0.0:9090"
EVM JSON-RPC 配置
Copy
Ask AI
[json-rpc]
# 启用 JSON-RPC 服务器
enable = true
# 绑定 JSON-RPC 服务器的地址
address = "0.0.0.0:8545"
# 绑定 WebSocket 服务器的地址
ws-address = "0.0.0.0:8546"
# 要启用的 API
api = "eth,net,web3,txpool,personal,debug"
# eth_call/estimateGas 的 Gas 上限
gas-cap = 25000000
# eth_call/estimateGas 的 EVM 超时
evm-timeout = "5s"
# 交易的 Tx 费用上限
txfee-cap = 1
# eth_getLogs 的过滤器上限
filter-cap = 200
# FeeHistory 上限
feehistory-cap = 100
# eth_getLogs 的区块范围上限
logs-cap = 10000
# 区块范围上限
block-range-cap = 10000
# HTTP 超时
http-timeout = "30s"
# HTTP 空闲超时
http-idle-timeout = "120s"
# 允许未保护的交易
allow-unprotected-txs = true
# 池中交易的最大数量
max-tx-in-pool = 3000
# 启用索引器
enable-indexer = false
# 启用指标
metrics = true
配置配置文件
全节点(默认)
全节点的平衡配置:Copy
Ask AI
# config.toml 调整
sed -i 's/^indexer = ".*"/indexer = "kv"/' ~/.stabled/config/config.toml
sed -i 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 50/' ~/.stabled/config/config.toml
sed -i 's/^max_num_outbound_peers = .*/max_num_outbound_peers = 30/' ~/.stabled/config/config.toml
# app.toml 调整
sed -i 's/^pruning = ".*"/pruning = "default"/' ~/.stabled/config/app.toml
sed -i 's/^snapshot-interval = .*/snapshot-interval = 1000/' ~/.stabled/config/app.toml
存档节点
无修剪,完整历史:Copy
Ask AI
# config.toml 调整
sed -i 's/^indexer = ".*"/indexer = "kv"/' ~/.stabled/config/config.toml
# app.toml 调整
sed -i 's/^pruning = ".*"/pruning = "nothing"/' ~/.stabled/config/app.toml
RPC 节点
公共 RPC 端点配置:Copy
Ask AI
# config.toml 调整
sed -i 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 30/' ~/.stabled/config/config.toml
sed -i 's/^max_open_connections = .*/max_open_connections = 30/' ~/.stabled/config/config.toml
sed -i 's/^cors_allowed_origins = .*/cors_allowed_origins = ["*"]/' ~/.stabled/config/config.toml
# app.toml 调整
sed -i 's/^enable = .*/enable = true/' ~/.stabled/config/app.toml
sed -i 's/^swagger = .*/swagger = true/' ~/.stabled/config/app.toml
sed -i 's/^enabled-unsafe-cors = .*/enabled-unsafe-cors = true/' ~/.stabled/config/app.toml
监控配置
Prometheus 指标
Copy
Ask AI
# config.toml
[instrumentation]
# 启用 Prometheus 指标
prometheus = true
# 指标监听地址
prometheus_listen_addr = ":26660"
# 指标的命名空间
namespace = "stablebft"
日志记录
Copy
Ask AI
# config.toml
[log]
# 日志级别 (trace|debug|info|warn|error|fatal|panic)
level = "info"
# 日志格式 (plain|json)
format = "plain"
应用配置更改
进行配置更改后:Copy
Ask AI
# 重启节点
sudo systemctl restart ${SERVICE_NAME}
# 检查日志中的错误
sudo journalctl -u ${SERVICE_NAME} -f
# 验证配置已加载
curl localhost:26657/status | jq '.result.node_info'

