配置

Tendermint Core 可以通过 $TMHOME/config/config.toml TOML 文件进行配置。其中一些参数可以由命令行标志覆盖。对于大多数用户来说,对于大多数用户来说,##### main base configuration options ##### 中的选项将被修改,而下面的配置选项将用于高级用户。

选项

tendermint init 创建的默认配置文件使用默认值设置了所有参数。不过,它看起来就像下面的文件一样,通过您已安装的 tendermint 版本创建的 config.toml 进行双重检查:

  1. # This is a TOML config file.
  2. # For more information, see https://github.com/toml-lang/toml
  3. ##### main base config options #####
  4. # TCP or UNIX socket address of the ABCI application,
  5. # or the name of an ABCI application compiled in with the Tendermint binary
  6. proxy_app = "tcp://127.0.0.1:26658"
  7. # A custom human readable name for this node
  8. moniker = "anonymous"
  9. # If this node is many blocks behind the tip of the chain, FastSync
  10. # allows them to catchup quickly by downloading blocks in parallel
  11. # and verifying their commits
  12. fast_sync = true
  13. # Database backend: leveldb | memdb | cleveldb
  14. db_backend = "leveldb"
  15. # Database directory
  16. db_dir = "data"
  17. # Output level for logging, including package level options
  18. log_level = "main:info,state:info,*:error"
  19. # Output format: 'plain' (colored text) or 'json'
  20. log_format = "plain"
  21. ##### additional base config options #####
  22. # Path to the JSON file containing the initial validator set and other meta data
  23. genesis_file = "config/genesis.json"
  24. # Path to the JSON file containing the private key to use as a validator in the consensus protocol
  25. priv_validator_file = "config/priv_validator.json"
  26. # TCP or UNIX socket address for Tendermint to listen on for
  27. # connections from an external PrivValidator process
  28. priv_validator_laddr = ""
  29. # Path to the JSON file containing the private key to use for node authentication in the p2p protocol
  30. node_key_file = "config/node_key.json"
  31. # Mechanism to connect to the ABCI application: socket | grpc
  32. abci = "socket"
  33. # TCP or UNIX socket address for the profiling server to listen on
  34. prof_laddr = ""
  35. # If true, query the ABCI app on connecting to a new peer
  36. # so the app can decide if we should keep the connection or not
  37. filter_peers = false
  38. ##### advanced configuration options #####
  39. ##### rpc server configuration options #####
  40. [rpc]
  41. # TCP or UNIX socket address for the RPC server to listen on
  42. laddr = "tcp://0.0.0.0:26657"
  43. # A list of origins a cross-domain request can be executed from
  44. # Default value '[]' disables cors support
  45. # Use '["*"]' to allow any origin
  46. cors_allowed_origins = []
  47. # A list of methods the client is allowed to use with cross-domain requests
  48. cors_allowed_methods = ["HEAD", "GET", "POST"]
  49. # A list of non simple headers the client is allowed to use with cross-domain requests
  50. cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]
  51. # TCP or UNIX socket address for the gRPC server to listen on
  52. # NOTE: This server only supports /broadcast_tx_commit
  53. grpc_laddr = ""
  54. # Maximum number of simultaneous connections.
  55. # Does not include RPC (HTTP&WebSocket) connections. See max_open_connections
  56. # If you want to accept a larger number than the default, make sure
  57. # you increase your OS limits.
  58. # 0 - unlimited.
  59. # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
  60. # 1024 - 40 - 10 - 50 = 924 = ~900
  61. grpc_max_open_connections = 900
  62. # Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool
  63. unsafe = false
  64. # Maximum number of simultaneous connections (including WebSocket).
  65. # Does not include gRPC connections. See grpc_max_open_connections
  66. # If you want to accept a larger number than the default, make sure
  67. # you increase your OS limits.
  68. # 0 - unlimited.
  69. # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
  70. # 1024 - 40 - 10 - 50 = 924 = ~900
  71. max_open_connections = 900
  72. # Maximum number of unique clientIDs that can /subscribe
  73. # If you're using /broadcast_tx_commit, set to the estimated maximum number
  74. # of broadcast_tx_commit calls per block.
  75. max_subscription_clients = 100
  76. # Maximum number of unique queries a given client can /subscribe to
  77. # If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to
  78. # the estimated # maximum number of broadcast_tx_commit calls per block.
  79. max_subscriptions_per_client = 5
  80. # How long to wait for a tx to be committed during /broadcast_tx_commit.
  81. # WARNING: Using a value larger than 10s will result in increasing the
  82. # global HTTP write timeout, which applies to all connections and endpoints.
  83. # See https://github.com/tendermint/tendermint/issues/3435
  84. timeout_broadcast_tx_commit = "10s"
  85. # The name of a file containing certificate that is used to create the HTTPS server.
  86. # If the certificate is signed by a certificate authority,
  87. # the certFile should be the concatenation of the server's certificate, any intermediates,
  88. # and the CA's certificate.
  89. # NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
  90. tls_cert_file = ""
  91. # The name of a file containing matching private key that is used to create the HTTPS server.
  92. # NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
  93. tls_key_file = ""
  94. ##### peer to peer configuration options #####
  95. [p2p]
  96. # Address to listen for incoming connections
  97. laddr = "tcp://0.0.0.0:26656"
  98. # Address to advertise to peers for them to dial
  99. # If empty, will use the same port as the laddr,
  100. # and will introspect on the listener or use UPnP
  101. # to figure out the address.
  102. external_address = ""
  103. # Comma separated list of seed nodes to connect to
  104. seeds = ""
  105. # Comma separated list of nodes to keep persistent connections to
  106. persistent_peers = ""
  107. # UPNP port forwarding
  108. upnp = false
  109. # Path to address book
  110. addr_book_file = "config/addrbook.json"
  111. # Set true for strict address routability rules
  112. # Set false for private or local networks
  113. addr_book_strict = true
  114. # Maximum number of inbound peers
  115. max_num_inbound_peers = 40
  116. # Maximum number of outbound peers to connect to, excluding persistent peers
  117. max_num_outbound_peers = 10
  118. # Time to wait before flushing messages out on the connection
  119. flush_throttle_timeout = "100ms"
  120. # Maximum size of a message packet payload, in bytes
  121. max_packet_msg_payload_size = 1024
  122. # Rate at which packets can be sent, in bytes/second
  123. send_rate = 5120000
  124. # Rate at which packets can be received, in bytes/second
  125. recv_rate = 5120000
  126. # Set true to enable the peer-exchange reactor
  127. pex = true
  128. # Seed mode, in which node constantly crawls the network and looks for
  129. # peers. If another node asks it for addresses, it responds and disconnects.
  130. #
  131. # Does not work if the peer-exchange reactor is disabled.
  132. seed_mode = false
  133. # Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
  134. private_peer_ids = ""
  135. # Toggle to disable guard against peers connecting from the same ip.
  136. allow_duplicate_ip = false
  137. # Peer connection configuration.
  138. handshake_timeout = "20s"
  139. dial_timeout = "3s"
  140. ##### mempool configuration options #####
  141. [mempool]
  142. recheck = true
  143. broadcast = true
  144. wal_dir = ""
  145. # Maximum number of transactions in the mempool
  146. size = 5000
  147. # Limit the total size of all txs in the mempool.
  148. # This only accounts for raw transactions (e.g. given 1MB transactions and
  149. # max_txs_bytes=5MB, mempool will only accept 5 transactions).
  150. max_txs_bytes = 1073741824
  151. # Size of the cache (used to filter transactions we saw earlier) in transactions
  152. cache_size = 10000
  153. ##### consensus configuration options #####
  154. [consensus]
  155. wal_file = "data/cs.wal/wal"
  156. timeout_propose = "3s"
  157. timeout_propose_delta = "500ms"
  158. timeout_prevote = "1s"
  159. timeout_prevote_delta = "500ms"
  160. timeout_precommit = "1s"
  161. timeout_precommit_delta = "500ms"
  162. timeout_commit = "1s"
  163. # Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
  164. skip_timeout_commit = false
  165. # EmptyBlocks mode and possible interval between empty blocks
  166. create_empty_blocks = true
  167. create_empty_blocks_interval = "0s"
  168. # Reactor sleep duration parameters
  169. peer_gossip_sleep_duration = "100ms"
  170. peer_query_maj23_sleep_duration = "2s"
  171. # Block time parameters. Corresponds to the minimum time increment between consecutive blocks.
  172. blocktime_iota = "1s"
  173. ##### transactions indexer configuration options #####
  174. [tx_index]
  175. # What indexer to use for transactions
  176. #
  177. # Options:
  178. # 1) "null"
  179. # 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
  180. indexer = "kv"
  181. # Comma-separated list of tags to index (by default the only tag is "tx.hash")
  182. #
  183. # You can also index transactions by height by adding "tx.height" tag here.
  184. #
  185. # It's recommended to index only a subset of tags due to possible memory
  186. # bloat. This is, of course, depends on the indexer's DB and the volume of
  187. # transactions.
  188. index_tags = ""
  189. # When set to true, tells indexer to index all tags (predefined tags:
  190. # "tx.hash", "tx.height" and all tags from DeliverTx responses).
  191. #
  192. # Note this may be not desirable (see the comment above). IndexTags has a
  193. # precedence over IndexAllTags (i.e. when given both, IndexTags will be
  194. # indexed).
  195. index_all_tags = false
  196. ##### instrumentation configuration options #####
  197. [instrumentation]
  198. # When true, Prometheus metrics are served under /metrics on
  199. # PrometheusListenAddr.
  200. # Check out the documentation for the list of available metrics.
  201. prometheus = false
  202. # Address to listen for Prometheus collector(s) connections
  203. prometheus_listen_addr = ":26660"
  204. # Maximum number of simultaneous connections.
  205. # If you want to accept a larger number than the default, make sure
  206. # you increase your OS limits.
  207. # 0 - unlimited.
  208. max_open_connections = 3
  209. # Instrumentation namespace
  210. namespace = "tendermint"

空块 VS 没有空块

create_empty_blocks = true

如果在你的配置中 create_empty_blocks 被设置为 true

If create_empty_blocks is set to true in your config, 每隔大约一秒就会创建一个块(默认的共识参数)。您可以通过更改 timeout_commit 来调节块之间的延迟。如 timeout_commit = "10s" 应该导致大约每 10 秒一个块。

create_empty_blocks = false

在此设置中,在接收交易时创建块。

注意,在 H 块之后,Tendermint 创建了一个我们称为 H+1 “proof block”的东西(只有当应用程序哈希发生变化时) 。这样做的原因是为了支持证明。如果在块 H 中有一个交易将状态更改为 X,则新的应用程序哈希将只包含在块 H+1 中。如果提交交易后,你想要一个轻节点证明新状态(X),为此,需要提交新块,因为新块具有状态 X 的新应用程序哈希。这就是为什么如果应用程序块哈希变化我们出一个新块(空的)。否则,就无法证明新状态。

另外,如果您将 create_empty_blocks_interval 设置为默认值(0)以外的值,Tendermint 将创建空块,即使在每个 create_empty_blocks_interval 都没有交易的情况下也是如此。例如,使用 create_empty_blocks = falsecreate_empty_blocks_interval = "30s",Tendermint 只在有交易时创建块,或者在等待 30 秒后没有收到任何交易时创建块。

共识超时解释

关于生产运行中的超时有很多信息。

您还可以在规范中找到更详细的技术解释:拜占庭共识最新 gossip

  1. [consensus]
  2. ...
  3. timeout_propose = "3s"
  4. timeout_propose_delta = "500ms"
  5. timeout_prevote = "1s"
  6. timeout_prevote_delta = "500ms"
  7. timeout_precommit = "1s"
  8. timeout_precommit_delta = "500ms"
  9. timeout_commit = "1s"

注意,在成功的一个轮中,我们绝对等待的惟一超时是 timeout_commit

以下是超时时间的简要总结:

  • timeout_propose = 我们要等多久才会有提案被否决
  • timeout_propose_delta = 每轮增加的 timeout_propose
  • timeout_prevote = 在收到 +2/3 的预选后我们要等多久 (也就是说,没有一个快或者空)
  • timeout_prevote_delta = 每轮增加的 timeout_prevote
  • timeout_precommit = 在收到 +2/3 的预提交后我们要等多久 (也就是说,没有一个快或者空)
  • timeout_precommit_delta = 每轮增加的 timeout_precommit
  • timeout_commit = 提交一个块之后,在开始新的高度之前等待的时间(这给了我们一个机会来接收更多的预提交,即使我们已经有 +2/3)