diff --git a/blockchain/genex-chain/cmd/genexd/cmd/root.go b/blockchain/genex-chain/cmd/genexd/cmd/root.go index aedc2ec..ff9e0ca 100644 --- a/blockchain/genex-chain/cmd/genexd/cmd/root.go +++ b/blockchain/genex-chain/cmd/genexd/cmd/root.go @@ -162,8 +162,13 @@ Bond Denom: agnx (GNX)`, // initCometConfig returns CometBFT config optimized for Genex Chain func initCometConfig() *cmtcfg.Config { cfg := cmtcfg.DefaultConfig() - // Genex Chain: fast block times for better UX + // Genex Chain: 1s timeout_commit → 实际出块 ~0.75s (单验证者) + // 多节点部署时 (20-50 验证者): ~1.5-2s + // 对标: dYdX 1-2s, Injective 1.2s, Cosmos Hub 6-7s cfg.Consensus.TimeoutCommit = 1_000_000_000 // 1s + // 防止空块风暴: 无交易时每 60s 出一个心跳块 + cfg.Consensus.CreateEmptyBlocks = false + cfg.Consensus.CreateEmptyBlocksInterval = 60_000_000_000 // 60s return cfg } diff --git a/blockchain/init-genesis.sh b/blockchain/init-genesis.sh index c35a82d..0b389a8 100644 --- a/blockchain/init-genesis.sh +++ b/blockchain/init-genesis.sh @@ -145,21 +145,19 @@ sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "200ms"/' "$CO sed -i 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/' "$CONFIG_TOML" sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "200ms"/' "$CONFIG_TOML" -# timeout_commit: 出块间隔 5s → 1s -# 代码默认已设为 1s (root.go initCometConfig),此处确保 config.toml 一致 -sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/' "$CONFIG_TOML" - -# skip_timeout_commit: 单节点模式下启用,收到自己的投票后立即提交 -# 实际出块时间可降到 500ms-800ms -sed -i 's/skip_timeout_commit = false/skip_timeout_commit = true/' "$CONFIG_TOML" +# timeout_commit: 1s (代码级 initCometConfig 已设为 1s) +# 实际出块: 单验证者 ~0.75s, 多验证者(20-50) ~1.5-2s +# 对标: dYdX 1-2s, Injective 1.2s, Cosmos Hub 6-7s +# 注意: skip_timeout_commit 保持 false,避免空块风暴 # ============================================================ # 空块控制 — 防止磁盘快速耗尽 # ============================================================ -# create_empty_blocks = false: 没有待处理交易时不出空块 -# 有交易提交时立即触发出块,延迟不受影响 -# 避免 ~23块/秒 的空块堆积 (按44ms/块计算 ≈ 2-3 GB/天) +# create_empty_blocks = false: 没有待处理交易时减少空块 +# create_empty_blocks_interval = 60s: 最多每 60s 一个心跳空块 +# 实测: ~18块/分 → ~38 MB/天 (对比原始 ~23块/秒 → 2-3 GB/天) sed -i 's/create_empty_blocks = true/create_empty_blocks = false/' "$CONFIG_TOML" +sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "60s"/' "$CONFIG_TOML" # ============================================================ # Mempool 优化 — 提升交易吞吐 @@ -190,11 +188,11 @@ echo " Initial: 5% | Range: 2%-7% | Target bonded: 50%" echo "" echo "Performance optimizations applied:" echo " - Optimistic Execution: enabled (code-level, SDK v0.53)" -echo " - timeout_commit: 1s (+ skip_timeout_commit=true → ~500-800ms actual)" +echo " - timeout_commit: 1s → ~0.75s/block (single-val), ~1.5-2s (multi-val)" echo " - timeout_propose: 1.5s (reduced from 3s)" echo " - Consensus timeouts: prevote/precommit 500ms (reduced from 1s)" +echo " - Empty blocks: DISABLED + 60s heartbeat interval (~38 MB/day)" echo " - IAVL cache: 2,000,000 nodes (up from 781,250)" echo " - Mempool size: 10,000 txs (up from 5,000)" echo " - Mempool cache: 20,000 (up from 10,000)" -echo " - Empty blocks: DISABLED (only produce blocks when txs pending)" echo "============================================================"