You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
14 KiB

6 years ago
limit number of /subscribe clients and queries per client (#3269) * limit number of /subscribe clients and queries per client Add the following config variables (under [rpc] section): * max_subscription_clients * max_subscriptions_per_client * timeout_broadcast_tx_commit Fixes #2826 new HTTPClient interface for subscriptions finalize HTTPClient events interface remove EventSubscriber fix data race ``` WARNING: DATA RACE Read at 0x00c000a36060 by goroutine 129: github.com/tendermint/tendermint/rpc/client.(*Local).Subscribe.func1() /go/src/github.com/tendermint/tendermint/rpc/client/localclient.go:168 +0x1f0 Previous write at 0x00c000a36060 by goroutine 132: github.com/tendermint/tendermint/rpc/client.(*Local).Subscribe() /go/src/github.com/tendermint/tendermint/rpc/client/localclient.go:191 +0x4e0 github.com/tendermint/tendermint/rpc/client.WaitForOneEvent() /go/src/github.com/tendermint/tendermint/rpc/client/helpers.go:64 +0x178 github.com/tendermint/tendermint/rpc/client_test.TestTxEventsSentWithBroadcastTxSync.func1() /go/src/github.com/tendermint/tendermint/rpc/client/event_test.go:139 +0x298 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Goroutine 129 (running) created at: github.com/tendermint/tendermint/rpc/client.(*Local).Subscribe() /go/src/github.com/tendermint/tendermint/rpc/client/localclient.go:164 +0x4b7 github.com/tendermint/tendermint/rpc/client.WaitForOneEvent() /go/src/github.com/tendermint/tendermint/rpc/client/helpers.go:64 +0x178 github.com/tendermint/tendermint/rpc/client_test.TestTxEventsSentWithBroadcastTxSync.func1() /go/src/github.com/tendermint/tendermint/rpc/client/event_test.go:139 +0x298 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Goroutine 132 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 github.com/tendermint/tendermint/rpc/client_test.TestTxEventsSentWithBroadcastTxSync() /go/src/github.com/tendermint/tendermint/rpc/client/event_test.go:119 +0x186 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 ================== ``` lite client works (tested manually) godoc comments httpclient: do not close the out channel use TimeoutBroadcastTxCommit no timeout for unsubscribe but 1s Local (5s HTTP) timeout for resubscribe format code change Subscribe#out cap to 1 and replace config vars with RPCConfig TimeoutBroadcastTxCommit can't be greater than rpcserver.WriteTimeout rpc: Context as first parameter to all functions reformat code fixes after my own review fixes after Ethan's review add test stubs fix config.toml * fixes after manual testing - rpc: do not recommend to use BroadcastTxCommit because it's slow and wastes Tendermint resources (pubsub) - rpc: better error in Subscribe and BroadcastTxCommit - HTTPClient: do not resubscribe if err = ErrAlreadySubscribed * fixes after Ismail's review * Update rpc/grpc/grpc_test.go Co-Authored-By: melekes <anton.kalyaev@gmail.com>
6 years ago
limit number of /subscribe clients and queries per client (#3269) * limit number of /subscribe clients and queries per client Add the following config variables (under [rpc] section): * max_subscription_clients * max_subscriptions_per_client * timeout_broadcast_tx_commit Fixes #2826 new HTTPClient interface for subscriptions finalize HTTPClient events interface remove EventSubscriber fix data race ``` WARNING: DATA RACE Read at 0x00c000a36060 by goroutine 129: github.com/tendermint/tendermint/rpc/client.(*Local).Subscribe.func1() /go/src/github.com/tendermint/tendermint/rpc/client/localclient.go:168 +0x1f0 Previous write at 0x00c000a36060 by goroutine 132: github.com/tendermint/tendermint/rpc/client.(*Local).Subscribe() /go/src/github.com/tendermint/tendermint/rpc/client/localclient.go:191 +0x4e0 github.com/tendermint/tendermint/rpc/client.WaitForOneEvent() /go/src/github.com/tendermint/tendermint/rpc/client/helpers.go:64 +0x178 github.com/tendermint/tendermint/rpc/client_test.TestTxEventsSentWithBroadcastTxSync.func1() /go/src/github.com/tendermint/tendermint/rpc/client/event_test.go:139 +0x298 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Goroutine 129 (running) created at: github.com/tendermint/tendermint/rpc/client.(*Local).Subscribe() /go/src/github.com/tendermint/tendermint/rpc/client/localclient.go:164 +0x4b7 github.com/tendermint/tendermint/rpc/client.WaitForOneEvent() /go/src/github.com/tendermint/tendermint/rpc/client/helpers.go:64 +0x178 github.com/tendermint/tendermint/rpc/client_test.TestTxEventsSentWithBroadcastTxSync.func1() /go/src/github.com/tendermint/tendermint/rpc/client/event_test.go:139 +0x298 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 Goroutine 132 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:878 +0x659 github.com/tendermint/tendermint/rpc/client_test.TestTxEventsSentWithBroadcastTxSync() /go/src/github.com/tendermint/tendermint/rpc/client/event_test.go:119 +0x186 testing.tRunner() /usr/local/go/src/testing/testing.go:827 +0x162 ================== ``` lite client works (tested manually) godoc comments httpclient: do not close the out channel use TimeoutBroadcastTxCommit no timeout for unsubscribe but 1s Local (5s HTTP) timeout for resubscribe format code change Subscribe#out cap to 1 and replace config vars with RPCConfig TimeoutBroadcastTxCommit can't be greater than rpcserver.WriteTimeout rpc: Context as first parameter to all functions reformat code fixes after my own review fixes after Ethan's review add test stubs fix config.toml * fixes after manual testing - rpc: do not recommend to use BroadcastTxCommit because it's slow and wastes Tendermint resources (pubsub) - rpc: better error in Subscribe and BroadcastTxCommit - HTTPClient: do not resubscribe if err = ErrAlreadySubscribed * fixes after Ismail's review * Update rpc/grpc/grpc_test.go Co-Authored-By: melekes <anton.kalyaev@gmail.com>
6 years ago
blockchain: Reorg reactor (#3561) * go routines in blockchain reactor * Added reference to the go routine diagram * Initial commit * cleanup * Undo testing_logger change, committed by mistake * Fix the test loggers * pulled some fsm code into pool.go * added pool tests * changes to the design added block requests under peer moved the request trigger in the reactor poolRoutine, triggered now by a ticker in general moved everything required for making block requests smarter in the poolRoutine added a simple map of heights to keep track of what will need to be requested next added a few more tests * send errors to FSM in a different channel than blocks send errors (RemovePeer) from switch on a different channel than the one receiving blocks renamed channels added more pool tests * more pool tests * lint errors * more tests * more tests * switch fast sync to new implementation * fixed data race in tests * cleanup * finished fsm tests * address golangci comments :) * address golangci comments :) * Added timeout on next block needed to advance * updating docs and cleanup * fix issue in test from previous cleanup * cleanup * Added termination scenarios, tests and more cleanup * small fixes to adr, comments and cleanup * Fix bug in sendRequest() If we tried to send a request to a peer not present in the switch, a missing continue statement caused the request to be blackholed in a peer that was removed and never retried. While this bug was manifesting, the reactor kept asking for other blocks that would be stored and never consumed. Added the number of unconsumed blocks in the math for requesting blocks ahead of current processing height so eventually there will be no more blocks requested until the already received ones are consumed. * remove bpPeer's didTimeout field * Use distinct err codes for peer timeout and FSM timeouts * Don't allow peers to update with lower height * review comments from Ethan and Zarko * some cleanup, renaming, comments * Move block execution in separate goroutine * Remove pool's numPending * review comments * fix lint, remove old blockchain reactor and duplicates in fsm tests * small reorg around peer after review comments * add the reactor spec * verify block only once * review comments * change to int for max number of pending requests * cleanup and godoc * Add configuration flag fast sync version * golangci fixes * fix config template * move both reactor versions under blockchain * cleanup, golint, renaming stuff * updated documentation, fixed more golint warnings * integrate with behavior package * sync with master * gofmt * add changelog_pending entry * move to improvments * suggestion to changelog entry
5 years ago
  1. # Configuration
  2. Tendermint Core can be configured via a TOML file in
  3. `$TMHOME/config/config.toml`. Some of these parameters can be overridden by
  4. command-line flags. For most users, the options in the `##### main base configuration options #####` are intended to be modified while
  5. config options further below are intended for advance power users.
  6. ## Options
  7. The default configuration file create by `tendermint init` has all
  8. the parameters set with their default values. It will look something
  9. like the file below, however, double check by inspecting the
  10. `config.toml` created with your version of `tendermint` installed:
  11. ```
  12. # This is a TOML config file.
  13. # For more information, see https://github.com/toml-lang/toml
  14. ##### main base config options #####
  15. # TCP or UNIX socket address of the ABCI application,
  16. # or the name of an ABCI application compiled in with the Tendermint binary
  17. proxy_app = "tcp://127.0.0.1:26658"
  18. # A custom human readable name for this node
  19. moniker = "anonymous"
  20. # If this node is many blocks behind the tip of the chain, FastSync
  21. # allows them to catchup quickly by downloading blocks in parallel
  22. # and verifying their commits
  23. fast_sync = true
  24. # Database backend: goleveldb | cleveldb | boltdb
  25. # * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
  26. # - pure go
  27. # - stable
  28. # * cleveldb (uses levigo wrapper)
  29. # - fast
  30. # - requires gcc
  31. # - use cleveldb build tag (go build -tags cleveldb)
  32. # * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
  33. # - EXPERIMENTAL
  34. # - may be faster is some use-cases (random reads - indexer)
  35. # - use boltdb build tag (go build -tags boltdb)
  36. db_backend = "goleveldb"
  37. # Database directory
  38. db_dir = "data"
  39. # Output level for logging, including package level options
  40. log_level = "main:info,state:info,*:error"
  41. # Output format: 'plain' (colored text) or 'json'
  42. log_format = "plain"
  43. ##### additional base config options #####
  44. # Path to the JSON file containing the initial validator set and other meta data
  45. genesis_file = "config/genesis.json"
  46. # Path to the JSON file containing the private key to use as a validator in the consensus protocol
  47. priv_validator_file = "config/priv_validator.json"
  48. # TCP or UNIX socket address for Tendermint to listen on for
  49. # connections from an external PrivValidator process
  50. priv_validator_laddr = ""
  51. # Path to the JSON file containing the private key to use for node authentication in the p2p protocol
  52. node_key_file = "config/node_key.json"
  53. # Mechanism to connect to the ABCI application: socket | grpc
  54. abci = "socket"
  55. # TCP or UNIX socket address for the profiling server to listen on
  56. prof_laddr = ""
  57. # If true, query the ABCI app on connecting to a new peer
  58. # so the app can decide if we should keep the connection or not
  59. filter_peers = false
  60. ##### advanced configuration options #####
  61. ##### rpc server configuration options #####
  62. [rpc]
  63. # TCP or UNIX socket address for the RPC server to listen on
  64. laddr = "tcp://0.0.0.0:26657"
  65. # A list of origins a cross-domain request can be executed from
  66. # Default value '[]' disables cors support
  67. # Use '["*"]' to allow any origin
  68. cors_allowed_origins = []
  69. # A list of methods the client is allowed to use with cross-domain requests
  70. cors_allowed_methods = ["HEAD", "GET", "POST"]
  71. # A list of non simple headers the client is allowed to use with cross-domain requests
  72. cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]
  73. # TCP or UNIX socket address for the gRPC server to listen on
  74. # NOTE: This server only supports /broadcast_tx_commit
  75. grpc_laddr = ""
  76. # Maximum number of simultaneous connections.
  77. # Does not include RPC (HTTP&WebSocket) connections. See max_open_connections
  78. # If you want to accept a larger number than the default, make sure
  79. # you increase your OS limits.
  80. # 0 - unlimited.
  81. # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
  82. # 1024 - 40 - 10 - 50 = 924 = ~900
  83. grpc_max_open_connections = 900
  84. # Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool
  85. unsafe = false
  86. # Maximum number of simultaneous connections (including WebSocket).
  87. # Does not include gRPC connections. See grpc_max_open_connections
  88. # If you want to accept a larger number than the default, make sure
  89. # you increase your OS limits.
  90. # 0 - unlimited.
  91. # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
  92. # 1024 - 40 - 10 - 50 = 924 = ~900
  93. max_open_connections = 900
  94. # Maximum number of unique clientIDs that can /subscribe
  95. # If you're using /broadcast_tx_commit, set to the estimated maximum number
  96. # of broadcast_tx_commit calls per block.
  97. max_subscription_clients = 100
  98. # Maximum number of unique queries a given client can /subscribe to
  99. # If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to
  100. # the estimated # maximum number of broadcast_tx_commit calls per block.
  101. max_subscriptions_per_client = 5
  102. # How long to wait for a tx to be committed during /broadcast_tx_commit.
  103. # WARNING: Using a value larger than 10s will result in increasing the
  104. # global HTTP write timeout, which applies to all connections and endpoints.
  105. # See https://github.com/tendermint/tendermint/issues/3435
  106. timeout_broadcast_tx_commit = "10s"
  107. # Maximum size of request body, in bytes
  108. max_body_bytes = {{ .RPC.MaxBodyBytes }}
  109. # Maximum size of request header, in bytes
  110. max_header_bytes = {{ .RPC.MaxHeaderBytes }}
  111. # The path to a file containing certificate that is used to create the HTTPS server.
  112. # Migth be either absolute path or path related to tendermint's config directory.
  113. # If the certificate is signed by a certificate authority,
  114. # the certFile should be the concatenation of the server's certificate, any intermediates,
  115. # and the CA's certificate.
  116. # NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
  117. tls_cert_file = ""
  118. # The path to a file containing matching private key that is used to create the HTTPS server.
  119. # Migth be either absolute path or path related to tendermint's config directory.
  120. # NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
  121. tls_key_file = ""
  122. ##### peer to peer configuration options #####
  123. [p2p]
  124. # Address to listen for incoming connections
  125. laddr = "tcp://0.0.0.0:26656"
  126. # Address to advertise to peers for them to dial
  127. # If empty, will use the same port as the laddr,
  128. # and will introspect on the listener or use UPnP
  129. # to figure out the address.
  130. external_address = ""
  131. # Comma separated list of seed nodes to connect to
  132. seeds = ""
  133. # Comma separated list of nodes to keep persistent connections to
  134. persistent_peers = ""
  135. # UPNP port forwarding
  136. upnp = false
  137. # Path to address book
  138. addr_book_file = "config/addrbook.json"
  139. # Set true for strict address routability rules
  140. # Set false for private or local networks
  141. addr_book_strict = true
  142. # Maximum number of inbound peers
  143. max_num_inbound_peers = 40
  144. # Maximum number of outbound peers to connect to, excluding persistent peers
  145. max_num_outbound_peers = 10
  146. # Time to wait before flushing messages out on the connection
  147. flush_throttle_timeout = "100ms"
  148. # Maximum size of a message packet payload, in bytes
  149. max_packet_msg_payload_size = 1024
  150. # Rate at which packets can be sent, in bytes/second
  151. send_rate = 5120000
  152. # Rate at which packets can be received, in bytes/second
  153. recv_rate = 5120000
  154. # Set true to enable the peer-exchange reactor
  155. pex = true
  156. # Seed mode, in which node constantly crawls the network and looks for
  157. # peers. If another node asks it for addresses, it responds and disconnects.
  158. #
  159. # Does not work if the peer-exchange reactor is disabled.
  160. seed_mode = false
  161. # Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
  162. private_peer_ids = ""
  163. # Toggle to disable guard against peers connecting from the same ip.
  164. allow_duplicate_ip = false
  165. # Peer connection configuration.
  166. handshake_timeout = "20s"
  167. dial_timeout = "3s"
  168. ##### mempool configuration options #####
  169. [mempool]
  170. recheck = true
  171. broadcast = true
  172. wal_dir = ""
  173. # Maximum number of transactions in the mempool
  174. size = 5000
  175. # Limit the total size of all txs in the mempool.
  176. # This only accounts for raw transactions (e.g. given 1MB transactions and
  177. # max_txs_bytes=5MB, mempool will only accept 5 transactions).
  178. max_txs_bytes = 1073741824
  179. # Size of the cache (used to filter transactions we saw earlier) in transactions
  180. cache_size = 10000
  181. # Maximum size of a single transaction.
  182. # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}.
  183. max_tx_bytes = 1048576
  184. ##### fast sync configuration options #####
  185. [fastsync]
  186. # Fast Sync version to use:
  187. # 1) "v0" (default) - the legacy fast sync implementation
  188. # 2) "v1" - refactor of v0 version for better testability
  189. version = "v0"
  190. ##### consensus configuration options #####
  191. [consensus]
  192. wal_file = "data/cs.wal/wal"
  193. timeout_propose = "3s"
  194. timeout_propose_delta = "500ms"
  195. timeout_prevote = "1s"
  196. timeout_prevote_delta = "500ms"
  197. timeout_precommit = "1s"
  198. timeout_precommit_delta = "500ms"
  199. timeout_commit = "1s"
  200. # Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
  201. skip_timeout_commit = false
  202. # EmptyBlocks mode and possible interval between empty blocks
  203. create_empty_blocks = true
  204. create_empty_blocks_interval = "0s"
  205. # Reactor sleep duration parameters
  206. peer_gossip_sleep_duration = "100ms"
  207. peer_query_maj23_sleep_duration = "2s"
  208. # Block time parameters. Corresponds to the minimum time increment between consecutive blocks.
  209. blocktime_iota = "1s"
  210. ##### transactions indexer configuration options #####
  211. [tx_index]
  212. # What indexer to use for transactions
  213. #
  214. # Options:
  215. # 1) "null"
  216. # 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
  217. indexer = "kv"
  218. # Comma-separated list of tags to index (by default the only tag is "tx.hash")
  219. #
  220. # You can also index transactions by height by adding "tx.height" tag here.
  221. #
  222. # It's recommended to index only a subset of tags due to possible memory
  223. # bloat. This is, of course, depends on the indexer's DB and the volume of
  224. # transactions.
  225. index_tags = ""
  226. # When set to true, tells indexer to index all tags (predefined tags:
  227. # "tx.hash", "tx.height" and all tags from DeliverTx responses).
  228. #
  229. # Note this may be not desirable (see the comment above). IndexTags has a
  230. # precedence over IndexAllTags (i.e. when given both, IndexTags will be
  231. # indexed).
  232. index_all_tags = false
  233. ##### instrumentation configuration options #####
  234. [instrumentation]
  235. # When true, Prometheus metrics are served under /metrics on
  236. # PrometheusListenAddr.
  237. # Check out the documentation for the list of available metrics.
  238. prometheus = false
  239. # Address to listen for Prometheus collector(s) connections
  240. prometheus_listen_addr = ":26660"
  241. # Maximum number of simultaneous connections.
  242. # If you want to accept a larger number than the default, make sure
  243. # you increase your OS limits.
  244. # 0 - unlimited.
  245. max_open_connections = 3
  246. # Instrumentation namespace
  247. namespace = "tendermint"
  248. ```
  249. ## Empty blocks VS no empty blocks
  250. **create_empty_blocks = true**
  251. If `create_empty_blocks` is set to `true` in your config, blocks will be
  252. created ~ every second (with default consensus parameters). You can regulate
  253. the delay between blocks by changing the `timeout_commit`. E.g. `timeout_commit = "10s"` should result in ~ 10 second blocks.
  254. **create_empty_blocks = false**
  255. In this setting, blocks are created when transactions received.
  256. Note after the block H, Tendermint creates something we call a "proof block"
  257. (only if the application hash changed) H+1. The reason for this is to support
  258. proofs. If you have a transaction in block H that changes the state to X, the
  259. new application hash will only be included in block H+1. If after your
  260. transaction is committed, you want to get a lite-client proof for the new state
  261. (X), you need the new block to be committed in order to do that because the new
  262. block has the new application hash for the state X. That's why we make a new
  263. (empty) block if the application hash changes. Otherwise, you won't be able to
  264. make a proof for the new state.
  265. Plus, if you set `create_empty_blocks_interval` to something other than the
  266. default (`0`), Tendermint will be creating empty blocks even in the absence of
  267. transactions every `create_empty_blocks_interval`. For instance, with
  268. `create_empty_blocks = false` and `create_empty_blocks_interval = "30s"`,
  269. Tendermint will only create blocks if there are transactions, or after waiting
  270. 30 seconds without receiving any transactions.
  271. ## Consensus timeouts explained
  272. There's a variety of information about timeouts in [Running in
  273. production](./running-in-production.md)
  274. You can also find more detailed technical explanation in the spec: [The latest
  275. gossip on BFT consensus](https://arxiv.org/abs/1807.04938).
  276. ```
  277. [consensus]
  278. ...
  279. timeout_propose = "3s"
  280. timeout_propose_delta = "500ms"
  281. timeout_prevote = "1s"
  282. timeout_prevote_delta = "500ms"
  283. timeout_precommit = "1s"
  284. timeout_precommit_delta = "500ms"
  285. timeout_commit = "1s"
  286. ```
  287. Note that in a successful round, the only timeout that we absolutely wait no
  288. matter what is `timeout_commit`.
  289. Here's a brief summary of the timeouts:
  290. - `timeout_propose` = how long we wait for a proposal block before prevoting
  291. nil
  292. - `timeout_propose_delta` = how much timeout_propose increases with each round
  293. - `timeout_prevote` = how long we wait after receiving +2/3 prevotes for
  294. anything (ie. not a single block or nil)
  295. - `timeout_prevote_delta` = how much the timeout_prevote increases with each
  296. round
  297. - `timeout_precommit` = how long we wait after receiving +2/3 precommits for
  298. anything (ie. not a single block or nil)
  299. - `timeout_precommit_delta` = how much the timeout_precommit increases with
  300. each round
  301. - `timeout_commit` = how long we wait after committing a block, before starting
  302. on the new height (this gives us a chance to receive some more precommits,
  303. even though we already have +2/3)