# Genex Chain — CometBFT 节点配置
# 生产验证节点配置
#
# 文档: https://docs.cometbft.com/main/core/configuration

# 基本配置
proxy_app = "tcp://127.0.0.1:26658"
moniker = "genex-node"
fast_sync = true
db_backend = "goleveldb"
db_dir = "data"
log_level = "info"
log_format = "json"

# ========================
# 共识配置
# ========================
[consensus]
  # 出块时间目标: ≤1 秒（CometBFT 即时终结性）
  timeout_propose = "1s"
  timeout_propose_delta = "500ms"
  timeout_prevote = "500ms"
  timeout_prevote_delta = "500ms"
  timeout_precommit = "500ms"
  timeout_precommit_delta = "500ms"
  timeout_commit = "800ms"

  # 是否在收到 2/3 以上预投票后跳过 timeout
  skip_timeout_commit = false

  # 创建空区块
  create_empty_blocks = true
  create_empty_blocks_interval = "0s"

  # 双签证据
  double_sign_check_height = 0

# ========================
# 交易内存池
# ========================
[mempool]
  # 是否复播交易
  recheck = true
  broadcast = true

  # 内存池大小
  size = 10000
  max_txs_bytes = 1073741824    # 1GB
  max_tx_bytes = 1048576         # 1MB

  # 缓存大小
  cache_size = 10000

  # 是否保持检查交易的顺序
  keep-invalid-txs-in-cache = false

# ========================
# P2P 网络
# ========================
[p2p]
  laddr = "tcp://0.0.0.0:26656"

  # 外部地址（NAT 后面的节点需要设置）
  external_address = ""

  # 种子节点
  seeds = ""

  # 持久连接的对等节点
  # 生产环境: "node1@us-east:26656,node2@sg:26656,node3@eu:26656"
  persistent_peers = ""

  # UPNP 端口映射
  upnp = false

  # 地址簿
  addr_book_file = "config/addrbook.json"
  addr_book_strict = true

  # 最大对等节点数
  max_num_inbound_peers = 100
  max_num_outbound_peers = 50

  # 发送/接收速率限制 (字节/秒)
  send_rate = 5120000    # 5 MB/s
  recv_rate = 5120000    # 5 MB/s

  # 握手超时
  handshake_timeout = "20s"
  dial_timeout = "3s"

# ========================
# RPC 服务
# ========================
[rpc]
  laddr = "tcp://127.0.0.1:26657"

  # CORS 允许的域名
  cors_allowed_origins = []
  cors_allowed_methods = ["HEAD", "GET", "POST"]
  cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]

  # gRPC
  grpc_laddr = ""
  grpc_max_open_connections = 900

  # 是否启用不安全的 RPC（仅开发环境）
  unsafe = false

  # WebSocket
  max_open_connections = 900
  max_subscription_clients = 100
  max_subscriptions_per_client = 5

  # 超时
  timeout_broadcast_tx_commit = "10s"

# ========================
# 状态同步
# ========================
[statesync]
  enable = false
  rpc_servers = ""
  trust_height = 0
  trust_hash = ""
  trust_period = "168h0m0s"

# ========================
# 区块同步
# ========================
[blocksync]
  version = "v0"

# ========================
# 遥测
# ========================
[instrumentation]
  prometheus = true
  prometheus_listen_addr = ":26660"
  max_open_connections = 3
  namespace = "cometbft"
