From 20d9e10d26ae05913ad1a358c186d5286c39eebb Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 20 Feb 2026 08:37:31 -0800 Subject: [PATCH] =?UTF-8?q?fix(chain):=20=E6=81=A2=E5=A4=8D=20create=5Femp?= =?UTF-8?q?ty=5Fblocks=3Dtrue,=20=E7=A8=B3=E5=AE=9A=201s/=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cosmos/evm 链上 create_empty_blocks=false 无效: EVM EndBlock 每次都改变 app hash → needProofBlock() 始终 true, 链照样出块,设 false 反而引入不稳定延迟 (官方已知问题 ethermint#308) 正确配置: timeout_commit=1s + create_empty_blocks=true → 稳定 ~1s/块 (有无交易均一致) Co-Authored-By: Claude Opus 4.6 --- blockchain/genex-chain/cmd/genexd/cmd/root.go | 10 ++++----- blockchain/init-genesis.sh | 21 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/blockchain/genex-chain/cmd/genexd/cmd/root.go b/blockchain/genex-chain/cmd/genexd/cmd/root.go index ff9e0ca..78f7466 100644 --- a/blockchain/genex-chain/cmd/genexd/cmd/root.go +++ b/blockchain/genex-chain/cmd/genexd/cmd/root.go @@ -162,13 +162,13 @@ Bond Denom: agnx (GNX)`, // initCometConfig returns CometBFT config optimized for Genex Chain func initCometConfig() *cmtcfg.Config { cfg := cmtcfg.DefaultConfig() - // Genex Chain: 1s timeout_commit → 实际出块 ~0.75s (单验证者) - // 多节点部署时 (20-50 验证者): ~1.5-2s + // Genex Chain: 稳定 1s 出块 + // 单验证者: ~1.0-1.05s/块, 多验证者(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 + // cosmos/evm 链必须 create_empty_blocks = true: + // EVM EndBlock 每次都改变 app hash → needProofBlock() 始终 true + // 设 false 无实际效果,反而引入不稳定延迟 (官方已知问题 ethermint#308) return cfg } diff --git a/blockchain/init-genesis.sh b/blockchain/init-genesis.sh index 0b389a8..4886a59 100644 --- a/blockchain/init-genesis.sh +++ b/blockchain/init-genesis.sh @@ -145,19 +145,14 @@ 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: 1s (代码级 initCometConfig 已设为 1s) -# 实际出块: 单验证者 ~0.75s, 多验证者(20-50) ~1.5-2s +# timeout_commit: 1s → 稳定 ~1s/块 (代码级 initCometConfig 已设为 1s) +# 单验证者: ~1.0s, 多验证者(20-50): ~1.5-2s # 对标: dYdX 1-2s, Injective 1.2s, Cosmos Hub 6-7s -# 注意: skip_timeout_commit 保持 false,避免空块风暴 - -# ============================================================ -# 空块控制 — 防止磁盘快速耗尽 -# ============================================================ -# 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" +# +# create_empty_blocks 保持默认 true: +# cosmos/evm 链的 EVM EndBlock 每次都改变 app hash, +# needProofBlock() 始终返回 true, 设 false 无实际效果 (ethermint#308) +# 磁盘: ~86,400 块/天 × ~1.5KB ≈ 130 MB/天, 配合 pruning 可控 # ============================================================ # Mempool 优化 — 提升交易吞吐 @@ -191,7 +186,7 @@ echo " - Optimistic Execution: enabled (code-level, SDK v0.53)" 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 " - Empty blocks: enabled (cosmos/evm requires, ~130 MB/day + pruning)" 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)"