配置参考
所有配置文件位于 config/ 目录下,采用 TOML 格式。
网络
[network]
name = "devnet" # "devnet"、"testnet"、"mainnet"
port = 8333 # P2P 监听端口
rpc_port = 8545 # JSON-RPC 端口
ws_port = 8546 # WebSocket 端口
bootstrap_nodes = [] # 用于发现的初始节点
max_peers = 50 # 最大节点连接数
connection_timeout = 30 # 超时时间(秒)
| 参数 | 开发环境 | 生产环境 | 描述 |
|---|---|---|---|
max_peers | 10 | 50 | 最大 P2P 连接数 |
connection_timeout | 10s | 30s | 节点连接超时时间 |
存储
[storage]
data_dir = "./data" # 数据库目录
cache_size_mb = 1024 # RocksDB 块缓存
write_buffer_size_mb = 64 # 每列族写缓冲区
max_open_files = 1000 # 最大文件描述符数
sync_interval = 30 # WAL 同步间隔(秒)
compression = true # 启用 LZ4 压缩
| 参数 | 开发环境 | 生产环境 | 描述 |
|---|---|---|---|
cache_size_mb | 256 | 1024 | 块缓存大小 |
write_buffer_size_mb | 16 | 64 | 写缓冲区 |
compression | false | true | 存储压缩 |
统一性证明(PoU)
[pou]
scoring_update_interval = 300 # 分数更新间隔(秒)
group_formation_interval = 600 # 分组重平衡间隔(秒)
consensus_sync_interval = 30 # 同步间隔(秒)
min_eligibility_score = 1000 # 最低资格分数(基点,0-10000)
min_stake_amount = 150 # 参与所需最低质押量
min_uptime_requirement = 0.8 # 最低在线时间要求(0.0-1.0)
[pou.weights]
availability = 0.25 # 在线时间权重
latency = 0.20 # 响应时间权重
integrity = 0.20 # 正确性权重
reputation = 0.20 # 历史记录权重
participation = 0.15 # 活跃度权重
[pou.groups]
group_size = 7 # 每组轻节点数量
num_groups = 10 # 分组数量
algorithm = "TopScore" # 分组算法
| 参数 | 开发环境 | 生产环境 | 描述 |
|---|---|---|---|
scoring_update_interval | 30s | 300s | PoU 分数更新频率 |
group_formation_interval | 60s | 600s | 分组重平衡频率 |
min_eligibility_score | 100 | 1000 | 参与所需最低分数 |
group_size | 3 | 7 | 每组轻节点数量 |
性能
[performance]
max_scoring_time_ms = 1000 # 最大评分计算时间
max_group_formation_time_ms = 3000
max_consensus_sync_time_ms = 500
target_tps = 1000 # 目标每秒交易数
max_block_size = 2097152 # 最大区块大小(字节)
block_time_ms = 5000 # 目标出块时间
| 参数 | 开发环境 | 生产环境 | 描述 |
|---|---|---|---|
target_tps | 100 | 1000 | 目标吞吐量 |
block_time_ms | 2000 | 5000 | 出块间隔 |
自适应延迟
[adaptive_latency]
enabled = true
base_latency_ms = 100 # 基准延迟
max_latency_ms = 2000 # 最大可接受延迟
adjustment_factor = 0.05 # 平滑因子
epoch_window = 100 # 用于平均计算的轮次数
network_averaging = true # 跨网络平均
共识
[consensus]
timeout = 10 # 轮次超时时间(秒)
max_rounds = 10 # 最大投票轮次
quorum_threshold = 0.67 # BFT 法定人数(2f+1)
enable_bft_optimizations = true # 一致投票快速路径
惩罚机制(Slashing)
[slashing]
enabled = true # 启用惩罚(仅生产环境)
double_vote_slash = 0.50 # 双重投票惩罚 50%
downtime_slash = 0.10 # 离线惩罚 10%
invalid_proposal_slash = 0.25 # 无效区块提案惩罚 25%
downtime_threshold = 0.2 # 错过 20% 区块触发惩罚
grace_period = 3600 # 离线惩罚宽限期 1 小时
监控
[monitoring]
enabled = true
host = "127.0.0.1"
port = 9090
update_interval_secs = 5
log_level = "info" # "debug"、"info"、"warn"、"error"
[monitoring.thresholds]
block_stall_timeout_secs = 300
high_block_time_secs = 15
low_peer_count = 3
high_memory_usage = 0.9
分数缓存
[cache]
max_entries = 10000 # LRU 缓存大小
ttl_seconds = 300 # 缓存条目生存时间
cleanup_interval = 60 # 清理频率(秒)
主节点配置
各主节点配置文件位于 exucutables/configs/masternode/mn-*.toml:
[node]
listen_port = 5021
group_node_timeout_secs = 600 # 节点不活跃超时时间
[storage]
db_path = "data/mn1"
环境变量
| 变量 | 描述 |
|---|---|
RUST_LOG | 日志过滤器(例如:info,libp2p_gossipsub::behaviour=error) |
CARGO_TARGET_DIR | 构建输出目录 |
RUSTFLAGS | 编译器标志(例如:-C link-arg=/STACK:8388608) |