github.com/KYVENetwork/cometbft/v38@v38.0.3/docs/core/configuration.md (about) 1 --- 2 order: 3 3 --- 4 5 # Configuration 6 7 CometBFT can be configured via a TOML file in 8 `$CMTHOME/config/config.toml`. Some of these parameters can be overridden by 9 command-line flags. For most users, the options in the `##### main base configuration options #####` are intended to be modified while config options 10 further below are intended for advance power users. 11 12 ## Options 13 14 The default configuration file create by `cometbft init` has all 15 the parameters set with their default values. It will look something 16 like the file below, however, double check by inspecting the 17 `config.toml` created with your version of `cometbft` installed: 18 19 ```toml 20 # This is a TOML config file. 21 # For more information, see https://github.com/toml-lang/toml 22 23 # NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or 24 # relative to the home directory (e.g. "data"). The home directory is 25 # "$HOME/.cometbft" by default, but could be changed via $CMTHOME env variable 26 # or --home cmd flag. 27 28 # The version of the CometBFT binary that created or 29 # last modified the config file. Do not modify this. 30 version = "0.38.0" 31 32 ####################################################################### 33 ### Main Base Config Options ### 34 ####################################################################### 35 36 # TCP or UNIX socket address of the ABCI application, 37 # or the name of an ABCI application compiled in with the CometBFT binary 38 proxy_app = "tcp://127.0.0.1:26658" 39 40 # A custom human readable name for this node 41 moniker = "anonymous" 42 43 # Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb 44 # * goleveldb (github.com/syndtr/goleveldb) 45 # - UNMAINTAINED 46 # - stable 47 # - pure go 48 # - stable 49 # * cleveldb (uses levigo wrapper) 50 # - fast 51 # - requires gcc 52 # - use cleveldb build tag (go build -tags cleveldb) 53 # * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) 54 # - EXPERIMENTAL 55 # - may be faster is some use-cases (random reads - indexer) 56 # - use boltdb build tag (go build -tags boltdb) 57 # * rocksdb (uses github.com/tecbot/gorocksdb) 58 # - EXPERIMENTAL 59 # - requires gcc 60 # - use rocksdb build tag (go build -tags rocksdb) 61 # * badgerdb (uses github.com/dgraph-io/badger) 62 # - EXPERIMENTAL 63 # - use badgerdb build tag (go build -tags badgerdb) 64 db_backend = "goleveldb" 65 66 # Database directory 67 db_dir = "data" 68 69 # Output level for logging, including package level options 70 log_level = "info" 71 72 # Output format: 'plain' (colored text) or 'json' 73 log_format = "plain" 74 75 ##### additional base config options ##### 76 77 # Path to the JSON file containing the initial validator set and other meta data 78 genesis_file = "config/genesis.json" 79 80 # Path to the JSON file containing the private key to use as a validator in the consensus protocol 81 priv_validator_key_file = "config/priv_validator_key.json" 82 83 # Path to the JSON file containing the last sign state of a validator 84 priv_validator_state_file = "data/priv_validator_state.json" 85 86 # TCP or UNIX socket address for CometBFT to listen on for 87 # connections from an external PrivValidator process 88 priv_validator_laddr = "" 89 90 # Path to the JSON file containing the private key to use for node authentication in the p2p protocol 91 node_key_file = "config/node_key.json" 92 93 # Mechanism to connect to the ABCI application: socket | grpc 94 abci = "socket" 95 96 # If true, query the ABCI app on connecting to a new peer 97 # so the app can decide if we should keep the connection or not 98 filter_peers = false 99 100 101 ####################################################################### 102 ### Advanced Configuration Options ### 103 ####################################################################### 104 105 ####################################################### 106 ### RPC Server Configuration Options ### 107 ####################################################### 108 [rpc] 109 110 # TCP or UNIX socket address for the RPC server to listen on 111 laddr = "tcp://127.0.0.1:26657" 112 113 # A list of origins a cross-domain request can be executed from 114 # Default value '[]' disables cors support 115 # Use '["*"]' to allow any origin 116 cors_allowed_origins = [] 117 118 # A list of methods the client is allowed to use with cross-domain requests 119 cors_allowed_methods = ["HEAD", "GET", "POST", ] 120 121 # A list of non simple headers the client is allowed to use with cross-domain requests 122 cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] 123 124 # TCP or UNIX socket address for the gRPC server to listen on 125 # NOTE: This server only supports /broadcast_tx_commit 126 grpc_laddr = "" 127 128 # Maximum number of simultaneous connections. 129 # Does not include RPC (HTTP&WebSocket) connections. See max_open_connections 130 # If you want to accept a larger number than the default, make sure 131 # you increase your OS limits. 132 # 0 - unlimited. 133 # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} 134 # 1024 - 40 - 10 - 50 = 924 = ~900 135 grpc_max_open_connections = 900 136 137 # Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool 138 unsafe = false 139 140 # Maximum number of simultaneous connections (including WebSocket). 141 # Does not include gRPC connections. See grpc_max_open_connections 142 # If you want to accept a larger number than the default, make sure 143 # you increase your OS limits. 144 # 0 - unlimited. 145 # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} 146 # 1024 - 40 - 10 - 50 = 924 = ~900 147 max_open_connections = 900 148 149 # Maximum number of unique clientIDs that can /subscribe 150 # If you're using /broadcast_tx_commit, set to the estimated maximum number 151 # of broadcast_tx_commit calls per block. 152 max_subscription_clients = 100 153 154 # Maximum number of unique queries a given client can /subscribe to 155 # If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to 156 # the estimated # maximum number of broadcast_tx_commit calls per block. 157 max_subscriptions_per_client = 5 158 159 # Experimental parameter to specify the maximum number of events a node will 160 # buffer, per subscription, before returning an error and closing the 161 # subscription. Must be set to at least 100, but higher values will accommodate 162 # higher event throughput rates (and will use more memory). 163 experimental_subscription_buffer_size = 200 164 165 # Experimental parameter to specify the maximum number of RPC responses that 166 # can be buffered per WebSocket client. If clients cannot read from the 167 # WebSocket endpoint fast enough, they will be disconnected, so increasing this 168 # parameter may reduce the chances of them being disconnected (but will cause 169 # the node to use more memory). 170 # 171 # Must be at least the same as "experimental_subscription_buffer_size", 172 # otherwise connections could be dropped unnecessarily. This value should 173 # ideally be somewhat higher than "experimental_subscription_buffer_size" to 174 # accommodate non-subscription-related RPC responses. 175 experimental_websocket_write_buffer_size = 200 176 177 # If a WebSocket client cannot read fast enough, at present we may 178 # silently drop events instead of generating an error or disconnecting the 179 # client. 180 # 181 # Enabling this experimental parameter will cause the WebSocket connection to 182 # be closed instead if it cannot read fast enough, allowing for greater 183 # predictability in subscription behavior. 184 experimental_close_on_slow_client = false 185 186 # How long to wait for a tx to be committed during /broadcast_tx_commit. 187 # WARNING: Using a value larger than 10s will result in increasing the 188 # global HTTP write timeout, which applies to all connections and endpoints. 189 # See https://github.com/tendermint/tendermint/issues/3435 190 timeout_broadcast_tx_commit = "10s" 191 192 # Maximum size of request body, in bytes 193 max_body_bytes = 1000000 194 195 # Maximum size of request header, in bytes 196 max_header_bytes = 1048576 197 198 # The path to a file containing certificate that is used to create the HTTPS server. 199 # Might be either absolute path or path related to CometBFT's config directory. 200 # If the certificate is signed by a certificate authority, 201 # the certFile should be the concatenation of the server's certificate, any intermediates, 202 # and the CA's certificate. 203 # NOTE: both tls_cert_file and tls_key_file must be present for CometBFT to create HTTPS server. 204 # Otherwise, HTTP server is run. 205 tls_cert_file = "" 206 207 # The path to a file containing matching private key that is used to create the HTTPS server. 208 # Might be either absolute path or path related to CometBFT's config directory. 209 # NOTE: both tls-cert-file and tls-key-file must be present for CometBFT to create HTTPS server. 210 # Otherwise, HTTP server is run. 211 tls_key_file = "" 212 213 # pprof listen address (https://golang.org/pkg/net/http/pprof) 214 pprof_laddr = "" 215 216 ####################################################### 217 ### P2P Configuration Options ### 218 ####################################################### 219 [p2p] 220 221 # Address to listen for incoming connections 222 laddr = "tcp://0.0.0.0:26656" 223 224 # Address to advertise to peers for them to dial. If empty, will use the same 225 # port as the laddr, and will introspect on the listener to figure out the 226 # address. IP and port are required. Example: 159.89.10.97:26656 227 external_address = "" 228 229 # Comma separated list of seed nodes to connect to 230 seeds = "" 231 232 # Comma separated list of nodes to keep persistent connections to 233 persistent_peers = "" 234 235 # Path to address book 236 addr_book_file = "config/addrbook.json" 237 238 # Set true for strict address routability rules 239 # Set false for private or local networks 240 addr_book_strict = true 241 242 # Maximum number of inbound peers 243 max_num_inbound_peers = 40 244 245 # Maximum number of outbound peers to connect to, excluding persistent peers 246 max_num_outbound_peers = 10 247 248 # List of node IDs, to which a connection will be (re)established ignoring any existing limits 249 unconditional_peer_ids = "" 250 251 # Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) 252 persistent_peers_max_dial_period = "0s" 253 254 # Time to wait before flushing messages out on the connection 255 flush_throttle_timeout = "100ms" 256 257 # Maximum size of a message packet payload, in bytes 258 max_packet_msg_payload_size = 1024 259 260 # Rate at which packets can be sent, in bytes/second 261 send_rate = 5120000 262 263 # Rate at which packets can be received, in bytes/second 264 recv_rate = 5120000 265 266 # Set true to enable the peer-exchange reactor 267 pex = true 268 269 # Seed mode, in which node constantly crawls the network and looks for 270 # peers. If another node asks it for addresses, it responds and disconnects. 271 # 272 # Does not work if the peer-exchange reactor is disabled. 273 seed_mode = false 274 275 # Comma separated list of peer IDs to keep private (will not be gossiped to other peers) 276 private_peer_ids = "" 277 278 # Toggle to disable guard against peers connecting from the same ip. 279 allow_duplicate_ip = false 280 281 # Peer connection configuration. 282 handshake_timeout = "20s" 283 dial_timeout = "3s" 284 285 ####################################################### 286 ### Mempool Configuration Option ### 287 ####################################################### 288 [mempool] 289 290 # The type of mempool for this node to use. 291 # 292 # Possible types: 293 # - "flood" : concurrent linked list mempool with flooding gossip protocol 294 # (default) 295 # - "nop" : nop-mempool (short for no operation; the ABCI app is responsible 296 # for storing, disseminating and proposing txs). "create_empty_blocks=false" is 297 # not supported. 298 type = "flood" 299 300 # Recheck (default: true) defines whether CometBFT should recheck the 301 # validity for all remaining transaction in the mempool after a block. 302 # Since a block affects the application state, some transactions in the 303 # mempool may become invalid. If this does not apply to your application, 304 # you can disable rechecking. 305 recheck = true 306 307 # Broadcast (default: true) defines whether the mempool should relay 308 # transactions to other peers. Setting this to false will stop the mempool 309 # from relaying transactions to other peers until they are included in a 310 # block. In other words, if Broadcast is disabled, only the peer you send 311 # the tx to will see it until it is included in a block. 312 broadcast = true 313 314 # WalPath (default: "") configures the location of the Write Ahead Log 315 # (WAL) for the mempool. The WAL is disabled by default. To enable, set 316 # wal_dir to where you want the WAL to be written (e.g. 317 # "data/mempool.wal"). 318 wal_dir = "" 319 320 # Maximum number of transactions in the mempool 321 size = 5000 322 323 # Limit the total size of all txs in the mempool. 324 # This only accounts for raw transactions (e.g. given 1MB transactions and 325 # max_txs_bytes=5MB, mempool will only accept 5 transactions). 326 max_txs_bytes = 1073741824 327 328 # Size of the cache (used to filter transactions we saw earlier) in transactions 329 cache_size = 10000 330 331 # Do not remove invalid transactions from the cache (default: false) 332 # Set to true if it's not possible for any invalid transaction to become valid 333 # again in the future. 334 keep-invalid-txs-in-cache = false 335 336 # Maximum size of a single transaction. 337 # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. 338 max_tx_bytes = 1048576 339 340 # Maximum size of a batch of transactions to send to a peer 341 # Including space needed by encoding (one varint per transaction). 342 # XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 343 max_batch_bytes = 0 344 345 ####################################################### 346 ### State Sync Configuration Options ### 347 ####################################################### 348 [statesync] 349 # State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine 350 # snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in 351 # the network to take and serve state machine snapshots. State sync is not attempted if the node 352 # has any local state (LastBlockHeight > 0). The node will have a truncated block history, 353 # starting from the height of the snapshot. 354 enable = false 355 356 # RPC servers (comma-separated) for light client verification of the synced state machine and 357 # retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding 358 # header hash obtained from a trusted source, and a period during which validators can be trusted. 359 # 360 # For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 361 # weeks) during which they can be financially punished (slashed) for misbehavior. 362 rpc_servers = "" 363 trust_height = 0 364 trust_hash = "" 365 trust_period = "168h0m0s" 366 367 # Time to spend discovering snapshots before initiating a restore. 368 discovery_time = "15s" 369 370 # Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). 371 # Will create a new, randomly named directory within, and remove it when done. 372 temp_dir = "" 373 374 # The timeout duration before re-requesting a chunk, possibly from a different 375 # peer (default: 1 minute). 376 chunk_request_timeout = "10s" 377 378 # The number of concurrent chunk fetchers to run (default: 1). 379 chunk_fetchers = "4" 380 381 ####################################################### 382 ### Block Sync Configuration Options ### 383 ####################################################### 384 [blocksync] 385 386 # Block Sync version to use: 387 # 388 # In v0.37, v1 and v2 of the block sync protocols were deprecated. 389 # Please use v0 instead. 390 # 391 # 1) "v0" - the default block sync implementation 392 version = "v0" 393 394 ####################################################### 395 ### Consensus Configuration Options ### 396 ####################################################### 397 [consensus] 398 399 wal_file = "data/cs.wal/wal" 400 401 # How long we wait for a proposal block before prevoting nil 402 timeout_propose = "3s" 403 # How much timeout_propose increases with each round 404 timeout_propose_delta = "500ms" 405 # How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) 406 timeout_prevote = "1s" 407 # How much the timeout_prevote increases with each round 408 timeout_prevote_delta = "500ms" 409 # How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) 410 timeout_precommit = "1s" 411 # How much the timeout_precommit increases with each round 412 timeout_precommit_delta = "500ms" 413 # How long we wait after committing a block, before starting on the new 414 # height (this gives us a chance to receive some more precommits, even 415 # though we already have +2/3). 416 timeout_commit = "1s" 417 418 # How many blocks to look back to check existence of the node's consensus votes before joining consensus 419 # When non-zero, the node will panic upon restart 420 # if the same consensus key was used to sign {double_sign_check_height} last blocks. 421 # So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. 422 double_sign_check_height = 0 423 424 # Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) 425 skip_timeout_commit = false 426 427 # EmptyBlocks mode and possible interval between empty blocks 428 create_empty_blocks = true 429 create_empty_blocks_interval = "0s" 430 431 # Reactor sleep duration parameters 432 peer_gossip_sleep_duration = "100ms" 433 peer_query_maj23_sleep_duration = "2s" 434 435 ####################################################### 436 ### Storage Configuration Options ### 437 ####################################################### 438 [storage] 439 440 # Set to true to discard ABCI responses from the state store, which can save a 441 # considerable amount of disk space. Set to false to ensure ABCI responses are 442 # persisted. ABCI responses are required for /block_results RPC queries, and to 443 # reindex events in the command-line tool. 444 discard_abci_responses = false 445 446 ####################################################### 447 ### Transaction Indexer Configuration Options ### 448 ####################################################### 449 [tx_index] 450 451 # What indexer to use for transactions 452 # 453 # The application will set which txs to index. In some cases a node operator will be able 454 # to decide which txs to index based on configuration set in the application. 455 # 456 # Options: 457 # 1) "null" 458 # 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). 459 # - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. 460 # 3) "psql" - the indexer services backed by PostgreSQL. 461 # When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. 462 indexer = "kv" 463 464 # The PostgreSQL connection configuration, the connection format: 465 # postgresql://<user>:<password>@<host>:<port>/<db>?<opts> 466 psql-conn = "" 467 468 ####################################################### 469 ### Instrumentation Configuration Options ### 470 ####################################################### 471 [instrumentation] 472 473 # When true, Prometheus metrics are served under /metrics on 474 # PrometheusListenAddr. 475 # Check out the documentation for the list of available metrics. 476 prometheus = false 477 478 # Address to listen for Prometheus collector(s) connections 479 prometheus_listen_addr = ":26660" 480 481 # Maximum number of simultaneous connections. 482 # If you want to accept a larger number than the default, make sure 483 # you increase your OS limits. 484 # 0 - unlimited. 485 max_open_connections = 3 486 487 # Instrumentation namespace 488 namespace = "cometbft" 489 490 ``` 491 492 ## Empty blocks VS no empty blocks 493 494 ### create_empty_blocks = true 495 496 If `create_empty_blocks` is set to `true` in your config, blocks will be created ~ every second (with default consensus parameters). You can regulate the delay between blocks by changing the `timeout_commit`. E.g. `timeout_commit = "10s"` should result in ~ 10 second blocks. 497 498 ### create_empty_blocks = false 499 500 In this setting, blocks are created when transactions received. 501 502 Note after the block H, CometBFT creates something we call a "proof block" (only if the application hash changed) H+1. The reason for this is to support proofs. If you have a transaction in block H that changes the state to X, the new application hash will only be included in block H+1. If after your transaction is committed, you want to get a light-client proof for the new state (X), you need the new block to be committed in order to do that because the new block has the new application hash for the state X. That's why we make a new (empty) block if the application hash changes. Otherwise, you won't be able to make a proof for the new state. 503 504 Plus, if you set `create_empty_blocks_interval` to something other than the default (`0`), CometBFT will be creating empty blocks even in the absence of transactions every `create_empty_blocks_interval.` For instance, with `create_empty_blocks = false` and `create_empty_blocks_interval = "30s"`, CometBFT will only create blocks if there are transactions, or after waiting 30 seconds without receiving any transactions. 505 506 ## Consensus timeouts explained 507 508 There's a variety of information about timeouts in [Running in 509 production](./running-in-production.md#configuration-parameters). 510 You can also find more detailed explanation in the paper describing 511 the Tendermint consensus algorithm, adopted by CometBFT: [The latest 512 gossip on BFT consensus](https://arxiv.org/abs/1807.04938). 513 514 ```toml 515 [consensus] 516 ... 517 518 timeout_propose = "3s" 519 timeout_propose_delta = "500ms" 520 timeout_prevote = "1s" 521 timeout_prevote_delta = "500ms" 522 timeout_precommit = "1s" 523 timeout_precommit_delta = "500ms" 524 timeout_commit = "1s" 525 ``` 526 527 Note that in a successful round, the only timeout that we absolutely wait no 528 matter what is `timeout_commit`. 529 Here's a brief summary of the timeouts: 530 531 - `timeout_propose` = how long a validator should wait for a proposal block before prevoting nil 532 - `timeout_propose_delta` = how much `timeout_propose` increases with each round 533 - `timeout_prevote` = how long a validator should wait after receiving +2/3 prevotes for 534 anything (ie. not a single block or nil) 535 - `timeout_prevote_delta` = how much the `timeout_prevote` increases with each round 536 - `timeout_precommit` = how long a validator should wait after receiving +2/3 precommits for 537 anything (ie. not a single block or nil) 538 - `timeout_precommit_delta` = how much the `timeout_precommit` increases with each round 539 - `timeout_commit` = how long a validator should wait after committing a block, before starting 540 on the new height (this gives us a chance to receive some more precommits, 541 even though we already have +2/3) 542 543 ### The adverse effect of using inconsistent `timeout_propose` in a network 544 545 Here's an interesting question. What happens if a particular validator sets a 546 very small `timeout_propose`, as compared to the rest of the network? 547 548 Imagine there are only two validators in your network: Alice and Bob. Bob sets 549 `timeout_propose` to 0s. Alice uses the default value of 3s. Let's say they 550 both have an equal voting power. Given the proposer selection algorithm is a 551 weighted round-robin, you may expect Alice and Bob to take turns proposing 552 blocks, and the result like: 553 554 ``` 555 #1 block - Alice 556 #2 block - Bob 557 #3 block - Alice 558 #4 block - Bob 559 ... 560 ``` 561 562 What happens in reality is, however, a little bit different: 563 564 ``` 565 #1 block - Bob 566 #2 block - Bob 567 #3 block - Bob 568 #4 block - Bob 569 ``` 570 571 That's because Bob doesn't wait for a proposal from Alice (prevotes `nil`). 572 This leaves Alice no chances to commit a block. Note that every block Bob 573 creates needs a vote from Alice to constitute 2/3+. Bob always gets one because 574 Alice has `timeout_propose` set to 3s. Alice never gets one because Bob has it 575 set to 0s. 576 577 Imagine now there are ten geographically distributed validators. One of them 578 (Bob) sets `timeout_propose` to 0s. Others have it set to 3s. Now, Bob won't be 579 able to move with his own speed because it still needs 2/3 votes of the other 580 validators and it takes time to propagate those. I.e., the network moves with 581 the speed of time to accumulate 2/3+ of votes (prevotes & precommits), not with 582 the speed of the fastest proposer. 583 584 > Isn't block production determined by voting power? 585 586 If it were determined solely by voting power, it wouldn't be possible to ensure 587 liveness. Timeouts exist because the network can't rely on a single proposer 588 being available and must move on if such is not responding. 589 590 > How can we address situations where someone arbitrarily adjusts their block 591 > production time to gain an advantage? 592 593 The impact shown above is negligible in a decentralized network with enough 594 decentralization. 595 596 ### The adverse effect of using inconsistent `timeout_commit` in a network 597 598 Let's look at the same scenario as before. There are ten geographically 599 distributed validators. One of them (Bob) sets `timeout_commit` to 0s. Others 600 have it set to 1s (the default value). Now, Bob will be the fastest producer 601 because he doesn't wait for additional precommits after creating a block. If 602 waiting for precommits (`timeout_commit`) is not incentivized, Bob will accrue 603 more rewards compared to the other 9 validators. 604 605 This is because Bob has the advantage of broadcasting its proposal early (1 606 second earlier than the others). But it also makes it possible for Bob to miss 607 a proposal from another validator and prevote `nil` due to him starting 608 `timeout_propose` earlier. I.e., if Bob's `timeout_commit` is too low comparing 609 to other validators, then he might miss some proposals and get slashed for 610 inactivity.