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.

670 lines
26 KiB

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
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
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. package config
  2. import (
  3. "bytes"
  4. "fmt"
  5. "io/ioutil"
  6. "os"
  7. "path/filepath"
  8. "strings"
  9. "text/template"
  10. tmos "github.com/tendermint/tendermint/libs/os"
  11. )
  12. // DefaultDirPerm is the default permissions used when creating directories.
  13. const DefaultDirPerm = 0700
  14. var configTemplate *template.Template
  15. func init() {
  16. var err error
  17. tmpl := template.New("configFileTemplate").Funcs(template.FuncMap{
  18. "StringsJoin": strings.Join,
  19. })
  20. if configTemplate, err = tmpl.Parse(defaultConfigTemplate); err != nil {
  21. panic(err)
  22. }
  23. }
  24. /****** these are for production settings ***********/
  25. // EnsureRoot creates the root, config, and data directories if they don't exist,
  26. // and panics if it fails.
  27. func EnsureRoot(rootDir string) {
  28. if err := tmos.EnsureDir(rootDir, DefaultDirPerm); err != nil {
  29. panic(err.Error())
  30. }
  31. if err := tmos.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil {
  32. panic(err.Error())
  33. }
  34. if err := tmos.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil {
  35. panic(err.Error())
  36. }
  37. }
  38. // WriteConfigFile renders config using the template and writes it to configFilePath.
  39. // This function is called by cmd/tendermint/commands/init.go
  40. func WriteConfigFile(rootDir string, config *Config) {
  41. var buffer bytes.Buffer
  42. if err := configTemplate.Execute(&buffer, config); err != nil {
  43. panic(err)
  44. }
  45. configFilePath := filepath.Join(rootDir, defaultConfigFilePath)
  46. mustWriteFile(configFilePath, buffer.Bytes(), 0644)
  47. }
  48. func writeDefaultConfigFileIfNone(rootDir string) {
  49. configFilePath := filepath.Join(rootDir, defaultConfigFilePath)
  50. if !tmos.FileExists(configFilePath) {
  51. WriteConfigFile(rootDir, DefaultConfig())
  52. }
  53. }
  54. // Note: any changes to the comments/variables/mapstructure
  55. // must be reflected in the appropriate struct in config/config.go
  56. const defaultConfigTemplate = `# This is a TOML config file.
  57. # For more information, see https://github.com/toml-lang/toml
  58. # NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or
  59. # relative to the home directory (e.g. "data"). The home directory is
  60. # "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable
  61. # or --home cmd flag.
  62. #######################################################################
  63. ### Main Base Config Options ###
  64. #######################################################################
  65. # TCP or UNIX socket address of the ABCI application,
  66. # or the name of an ABCI application compiled in with the Tendermint binary
  67. proxy-app = "{{ .BaseConfig.ProxyApp }}"
  68. # A custom human readable name for this node
  69. moniker = "{{ .BaseConfig.Moniker }}"
  70. # Mode of Node: full | validator | seed
  71. # * validator node
  72. # - all reactors
  73. # - with priv_validator_key.json, priv_validator_state.json
  74. # * full node
  75. # - all reactors
  76. # - No priv_validator_key.json, priv_validator_state.json
  77. # * seed node
  78. # - only P2P, PEX Reactor
  79. # - No priv_validator_key.json, priv_validator_state.json
  80. mode = "{{ .BaseConfig.Mode }}"
  81. # Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb
  82. # * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
  83. # - pure go
  84. # - stable
  85. # * cleveldb (uses levigo wrapper)
  86. # - fast
  87. # - requires gcc
  88. # - use cleveldb build tag (go build -tags cleveldb)
  89. # * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
  90. # - EXPERIMENTAL
  91. # - may be faster is some use-cases (random reads - indexer)
  92. # - use boltdb build tag (go build -tags boltdb)
  93. # * rocksdb (uses github.com/tecbot/gorocksdb)
  94. # - EXPERIMENTAL
  95. # - requires gcc
  96. # - use rocksdb build tag (go build -tags rocksdb)
  97. # * badgerdb (uses github.com/dgraph-io/badger)
  98. # - EXPERIMENTAL
  99. # - use badgerdb build tag (go build -tags badgerdb)
  100. db-backend = "{{ .BaseConfig.DBBackend }}"
  101. # Database directory
  102. db-dir = "{{ js .BaseConfig.DBPath }}"
  103. # Output level for logging, including package level options
  104. log-level = "{{ .BaseConfig.LogLevel }}"
  105. # Output format: 'plain' (colored text) or 'json'
  106. log-format = "{{ .BaseConfig.LogFormat }}"
  107. ##### additional base config options #####
  108. # Path to the JSON file containing the initial validator set and other meta data
  109. genesis-file = "{{ js .BaseConfig.Genesis }}"
  110. # Path to the JSON file containing the private key to use for node authentication in the p2p protocol
  111. node-key-file = "{{ js .BaseConfig.NodeKey }}"
  112. # Mechanism to connect to the ABCI application: socket | grpc
  113. abci = "{{ .BaseConfig.ABCI }}"
  114. # If true, query the ABCI app on connecting to a new peer
  115. # so the app can decide if we should keep the connection or not
  116. filter-peers = {{ .BaseConfig.FilterPeers }}
  117. #######################################################
  118. ### Priv Validator Configuration ###
  119. #######################################################
  120. [priv-validator]
  121. # Path to the JSON file containing the private key to use as a validator in the consensus protocol
  122. key-file = "{{ js .PrivValidator.Key }}"
  123. # Path to the JSON file containing the last sign state of a validator
  124. state-file = "{{ js .PrivValidator.State }}"
  125. # TCP or UNIX socket address for Tendermint to listen on for
  126. # connections from an external PrivValidator process
  127. # when the listenAddr is prefixed with grpc instead of tcp it will use the gRPC Client
  128. laddr = "{{ .PrivValidator.ListenAddr }}"
  129. # Path to the client certificate generated while creating needed files for secure connection.
  130. # If a remote validator address is provided but no certificate, the connection will be insecure
  131. client-certificate-file = "{{ js .PrivValidator.ClientCertificate }}"
  132. # Client key generated while creating certificates for secure connection
  133. client-key-file = "{{ js .PrivValidator.ClientKey }}"
  134. # Path to the Root Certificate Authority used to sign both client and server certificates
  135. root-ca-file = "{{ js .PrivValidator.RootCA }}"
  136. #######################################################################
  137. ### Advanced Configuration Options ###
  138. #######################################################################
  139. #######################################################
  140. ### RPC Server Configuration Options ###
  141. #######################################################
  142. [rpc]
  143. # TCP or UNIX socket address for the RPC server to listen on
  144. laddr = "{{ .RPC.ListenAddress }}"
  145. # A list of origins a cross-domain request can be executed from
  146. # Default value '[]' disables cors support
  147. # Use '["*"]' to allow any origin
  148. cors-allowed-origins = [{{ range .RPC.CORSAllowedOrigins }}{{ printf "%q, " . }}{{end}}]
  149. # A list of methods the client is allowed to use with cross-domain requests
  150. cors-allowed-methods = [{{ range .RPC.CORSAllowedMethods }}{{ printf "%q, " . }}{{end}}]
  151. # A list of non simple headers the client is allowed to use with cross-domain requests
  152. cors-allowed-headers = [{{ range .RPC.CORSAllowedHeaders }}{{ printf "%q, " . }}{{end}}]
  153. # TCP or UNIX socket address for the gRPC server to listen on
  154. # NOTE: This server only supports /broadcast_tx_commit
  155. # Deprecated gRPC in the RPC layer of Tendermint will be deprecated in 0.36.
  156. grpc-laddr = "{{ .RPC.GRPCListenAddress }}"
  157. # Maximum number of simultaneous connections.
  158. # Does not include RPC (HTTP&WebSocket) connections. See max-open-connections
  159. # If you want to accept a larger number than the default, make sure
  160. # you increase your OS limits.
  161. # 0 - unlimited.
  162. # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
  163. # 1024 - 40 - 10 - 50 = 924 = ~900
  164. # Deprecated gRPC in the RPC layer of Tendermint will be deprecated in 0.36.
  165. grpc-max-open-connections = {{ .RPC.GRPCMaxOpenConnections }}
  166. # Activate unsafe RPC commands like /dial-seeds and /unsafe-flush-mempool
  167. unsafe = {{ .RPC.Unsafe }}
  168. # Maximum number of simultaneous connections (including WebSocket).
  169. # Does not include gRPC connections. See grpc-max-open-connections
  170. # If you want to accept a larger number than the default, make sure
  171. # you increase your OS limits.
  172. # 0 - unlimited.
  173. # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
  174. # 1024 - 40 - 10 - 50 = 924 = ~900
  175. max-open-connections = {{ .RPC.MaxOpenConnections }}
  176. # Maximum number of unique clientIDs that can /subscribe
  177. # If you're using /broadcast_tx_commit, set to the estimated maximum number
  178. # of broadcast_tx_commit calls per block.
  179. max-subscription-clients = {{ .RPC.MaxSubscriptionClients }}
  180. # Maximum number of unique queries a given client can /subscribe to
  181. # If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to
  182. # the estimated # maximum number of broadcast_tx_commit calls per block.
  183. max-subscriptions-per-client = {{ .RPC.MaxSubscriptionsPerClient }}
  184. # How long to wait for a tx to be committed during /broadcast_tx_commit.
  185. # WARNING: Using a value larger than 10s will result in increasing the
  186. # global HTTP write timeout, which applies to all connections and endpoints.
  187. # See https://github.com/tendermint/tendermint/issues/3435
  188. timeout-broadcast-tx-commit = "{{ .RPC.TimeoutBroadcastTxCommit }}"
  189. # Maximum size of request body, in bytes
  190. max-body-bytes = {{ .RPC.MaxBodyBytes }}
  191. # Maximum size of request header, in bytes
  192. max-header-bytes = {{ .RPC.MaxHeaderBytes }}
  193. # The path to a file containing certificate that is used to create the HTTPS server.
  194. # Might be either absolute path or path related to Tendermint's config directory.
  195. # If the certificate is signed by a certificate authority,
  196. # the certFile should be the concatenation of the server's certificate, any intermediates,
  197. # and the CA's certificate.
  198. # NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server.
  199. # Otherwise, HTTP server is run.
  200. tls-cert-file = "{{ .RPC.TLSCertFile }}"
  201. # The path to a file containing matching private key that is used to create the HTTPS server.
  202. # Might be either absolute path or path related to Tendermint's config directory.
  203. # NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server.
  204. # Otherwise, HTTP server is run.
  205. tls-key-file = "{{ .RPC.TLSKeyFile }}"
  206. # pprof listen address (https://golang.org/pkg/net/http/pprof)
  207. pprof-laddr = "{{ .RPC.PprofListenAddress }}"
  208. #######################################################
  209. ### P2P Configuration Options ###
  210. #######################################################
  211. [p2p]
  212. # Enable the legacy p2p layer.
  213. use-legacy = {{ .P2P.UseLegacy }}
  214. # Select the p2p internal queue
  215. queue-type = "{{ .P2P.QueueType }}"
  216. # Address to listen for incoming connections
  217. laddr = "{{ .P2P.ListenAddress }}"
  218. # Address to advertise to peers for them to dial
  219. # If empty, will use the same port as the laddr,
  220. # and will introspect on the listener or use UPnP
  221. # to figure out the address. ip and port are required
  222. # example: 159.89.10.97:26656
  223. external-address = "{{ .P2P.ExternalAddress }}"
  224. # Comma separated list of seed nodes to connect to
  225. # We only use these if we cant connect to peers in the addrbook
  226. # NOTE: not used by the new PEX reactor. Please use BootstrapPeers instead.
  227. # TODO: Remove once p2p refactor is complete
  228. # ref: https:#github.com/tendermint/tendermint/issues/5670
  229. seeds = "{{ .P2P.Seeds }}"
  230. # Comma separated list of peers to be added to the peer store
  231. # on startup. Either BootstrapPeers or PersistentPeers are
  232. # needed for peer discovery
  233. bootstrap-peers = "{{ .P2P.BootstrapPeers }}"
  234. # Comma separated list of nodes to keep persistent connections to
  235. persistent-peers = "{{ .P2P.PersistentPeers }}"
  236. # UPNP port forwarding
  237. upnp = {{ .P2P.UPNP }}
  238. # Path to address book
  239. # TODO: Remove once p2p refactor is complete in favor of peer store.
  240. addr-book-file = "{{ js .P2P.AddrBook }}"
  241. # Set true for strict address routability rules
  242. # Set false for private or local networks
  243. addr-book-strict = {{ .P2P.AddrBookStrict }}
  244. # Maximum number of inbound peers
  245. #
  246. # TODO: Remove once p2p refactor is complete in favor of MaxConnections.
  247. # ref: https://github.com/tendermint/tendermint/issues/5670
  248. max-num-inbound-peers = {{ .P2P.MaxNumInboundPeers }}
  249. # Maximum number of outbound peers to connect to, excluding persistent peers
  250. #
  251. # TODO: Remove once p2p refactor is complete in favor of MaxConnections.
  252. # ref: https://github.com/tendermint/tendermint/issues/5670
  253. max-num-outbound-peers = {{ .P2P.MaxNumOutboundPeers }}
  254. # Maximum number of connections (inbound and outbound).
  255. max-connections = {{ .P2P.MaxConnections }}
  256. # Rate limits the number of incoming connection attempts per IP address.
  257. max-incoming-connection-attempts = {{ .P2P.MaxIncomingConnectionAttempts }}
  258. # List of node IDs, to which a connection will be (re)established ignoring any existing limits
  259. # TODO: Remove once p2p refactor is complete.
  260. # ref: https://github.com/tendermint/tendermint/issues/5670
  261. unconditional-peer-ids = "{{ .P2P.UnconditionalPeerIDs }}"
  262. # Maximum pause when redialing a persistent peer (if zero, exponential backoff is used)
  263. # TODO: Remove once p2p refactor is complete
  264. # ref: https:#github.com/tendermint/tendermint/issues/5670
  265. persistent-peers-max-dial-period = "{{ .P2P.PersistentPeersMaxDialPeriod }}"
  266. # Time to wait before flushing messages out on the connection
  267. # TODO: Remove once p2p refactor is complete
  268. # ref: https:#github.com/tendermint/tendermint/issues/5670
  269. flush-throttle-timeout = "{{ .P2P.FlushThrottleTimeout }}"
  270. # Maximum size of a message packet payload, in bytes
  271. # TODO: Remove once p2p refactor is complete
  272. # ref: https:#github.com/tendermint/tendermint/issues/5670
  273. max-packet-msg-payload-size = {{ .P2P.MaxPacketMsgPayloadSize }}
  274. # Rate at which packets can be sent, in bytes/second
  275. # TODO: Remove once p2p refactor is complete
  276. # ref: https:#github.com/tendermint/tendermint/issues/5670
  277. send-rate = {{ .P2P.SendRate }}
  278. # Rate at which packets can be received, in bytes/second
  279. # TODO: Remove once p2p refactor is complete
  280. # ref: https:#github.com/tendermint/tendermint/issues/5670
  281. recv-rate = {{ .P2P.RecvRate }}
  282. # Set true to enable the peer-exchange reactor
  283. pex = {{ .P2P.PexReactor }}
  284. # Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
  285. # Warning: IPs will be exposed at /net_info, for more information https://github.com/tendermint/tendermint/issues/3055
  286. private-peer-ids = "{{ .P2P.PrivatePeerIDs }}"
  287. # Toggle to disable guard against peers connecting from the same ip.
  288. allow-duplicate-ip = {{ .P2P.AllowDuplicateIP }}
  289. # Peer connection configuration.
  290. handshake-timeout = "{{ .P2P.HandshakeTimeout }}"
  291. dial-timeout = "{{ .P2P.DialTimeout }}"
  292. #######################################################
  293. ### Mempool Configuration Option ###
  294. #######################################################
  295. [mempool]
  296. # Mempool version to use:
  297. # 1) "v0" - The legacy non-prioritized mempool reactor.
  298. # 2) "v1" (default) - The prioritized mempool reactor.
  299. version = "{{ .Mempool.Version }}"
  300. recheck = {{ .Mempool.Recheck }}
  301. broadcast = {{ .Mempool.Broadcast }}
  302. # Maximum number of transactions in the mempool
  303. size = {{ .Mempool.Size }}
  304. # Limit the total size of all txs in the mempool.
  305. # This only accounts for raw transactions (e.g. given 1MB transactions and
  306. # max-txs-bytes=5MB, mempool will only accept 5 transactions).
  307. max-txs-bytes = {{ .Mempool.MaxTxsBytes }}
  308. # Size of the cache (used to filter transactions we saw earlier) in transactions
  309. cache-size = {{ .Mempool.CacheSize }}
  310. # Do not remove invalid transactions from the cache (default: false)
  311. # Set to true if it's not possible for any invalid transaction to become valid
  312. # again in the future.
  313. keep-invalid-txs-in-cache = {{ .Mempool.KeepInvalidTxsInCache }}
  314. # Maximum size of a single transaction.
  315. # NOTE: the max size of a tx transmitted over the network is {max-tx-bytes}.
  316. max-tx-bytes = {{ .Mempool.MaxTxBytes }}
  317. # Maximum size of a batch of transactions to send to a peer
  318. # Including space needed by encoding (one varint per transaction).
  319. # XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796
  320. max-batch-bytes = {{ .Mempool.MaxBatchBytes }}
  321. # ttl-duration, if non-zero, defines the maximum amount of time a transaction
  322. # can exist for in the mempool.
  323. #
  324. # Note, if ttl-num-blocks is also defined, a transaction will be removed if it
  325. # has existed in the mempool at least ttl-num-blocks number of blocks or if it's
  326. # insertion time into the mempool is beyond ttl-duration.
  327. ttl-duration = "{{ .Mempool.TTLDuration }}"
  328. # ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction
  329. # can exist for in the mempool.
  330. #
  331. # Note, if ttl-duration is also defined, a transaction will be removed if it
  332. # has existed in the mempool at least ttl-num-blocks number of blocks or if
  333. # it's insertion time into the mempool is beyond ttl-duration.
  334. ttl-num-blocks = {{ .Mempool.TTLNumBlocks }}
  335. #######################################################
  336. ### State Sync Configuration Options ###
  337. #######################################################
  338. [statesync]
  339. # State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine
  340. # snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in
  341. # the network to take and serve state machine snapshots. State sync is not attempted if the node
  342. # has any local state (LastBlockHeight > 0). The node will have a truncated block history,
  343. # starting from the height of the snapshot.
  344. enable = {{ .StateSync.Enable }}
  345. # State sync uses light client verification to verify state. This can be done either through the
  346. # P2P layer or RPC layer. Set this to true to use the P2P layer. If false (default), RPC layer
  347. # will be used.
  348. use-p2p = {{ .StateSync.UseP2P }}
  349. # If using RPC, at least two addresses need to be provided. They should be compatible with net.Dial,
  350. # for example: "host.example.com:2125"
  351. rpc-servers = "{{ StringsJoin .StateSync.RPCServers "," }}"
  352. # The hash and height of a trusted block. Must be within the trust-period.
  353. trust-height = {{ .StateSync.TrustHeight }}
  354. trust-hash = "{{ .StateSync.TrustHash }}"
  355. # The trust period should be set so that Tendermint can detect and gossip misbehavior before
  356. # it is considered expired. For chains based on the Cosmos SDK, one day less than the unbonding
  357. # period should suffice.
  358. trust-period = "{{ .StateSync.TrustPeriod }}"
  359. # Time to spend discovering snapshots before initiating a restore.
  360. discovery-time = "{{ .StateSync.DiscoveryTime }}"
  361. # Temporary directory for state sync snapshot chunks, defaults to os.TempDir().
  362. # The synchronizer will create a new, randomly named directory within this directory
  363. # and remove it when the sync is complete.
  364. temp-dir = "{{ .StateSync.TempDir }}"
  365. # The timeout duration before re-requesting a chunk, possibly from a different
  366. # peer (default: 15 seconds).
  367. chunk-request-timeout = "{{ .StateSync.ChunkRequestTimeout }}"
  368. # The number of concurrent chunk and block fetchers to run (default: 4).
  369. fetchers = "{{ .StateSync.Fetchers }}"
  370. #######################################################
  371. ### Block Sync Configuration Connections ###
  372. #######################################################
  373. [blocksync]
  374. # If this node is many blocks behind the tip of the chain, BlockSync
  375. # allows them to catchup quickly by downloading blocks in parallel
  376. # and verifying their commits
  377. enable = {{ .BlockSync.Enable }}
  378. # Block Sync version to use:
  379. # 1) "v0" (default) - the standard Block Sync implementation
  380. # 2) "v2" - DEPRECATED, please use v0
  381. version = "{{ .BlockSync.Version }}"
  382. #######################################################
  383. ### Consensus Configuration Options ###
  384. #######################################################
  385. [consensus]
  386. wal-file = "{{ js .Consensus.WalPath }}"
  387. # How long we wait for a proposal block before prevoting nil
  388. timeout-propose = "{{ .Consensus.TimeoutPropose }}"
  389. # How much timeout-propose increases with each round
  390. timeout-propose-delta = "{{ .Consensus.TimeoutProposeDelta }}"
  391. # How long we wait after receiving +2/3 prevotes for anything (ie. not a single block or nil)
  392. timeout-prevote = "{{ .Consensus.TimeoutPrevote }}"
  393. # How much the timeout-prevote increases with each round
  394. timeout-prevote-delta = "{{ .Consensus.TimeoutPrevoteDelta }}"
  395. # How long we wait after receiving +2/3 precommits for anything (ie. not a single block or nil)
  396. timeout-precommit = "{{ .Consensus.TimeoutPrecommit }}"
  397. # How much the timeout-precommit increases with each round
  398. timeout-precommit-delta = "{{ .Consensus.TimeoutPrecommitDelta }}"
  399. # How long we wait after committing a block, before starting on the new
  400. # height (this gives us a chance to receive some more precommits, even
  401. # though we already have +2/3).
  402. timeout-commit = "{{ .Consensus.TimeoutCommit }}"
  403. # How many blocks to look back to check existence of the node's consensus votes before joining consensus
  404. # When non-zero, the node will panic upon restart
  405. # if the same consensus key was used to sign {double-sign-check-height} last blocks.
  406. # So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic.
  407. double-sign-check-height = {{ .Consensus.DoubleSignCheckHeight }}
  408. # Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
  409. skip-timeout-commit = {{ .Consensus.SkipTimeoutCommit }}
  410. # EmptyBlocks mode and possible interval between empty blocks
  411. create-empty-blocks = {{ .Consensus.CreateEmptyBlocks }}
  412. create-empty-blocks-interval = "{{ .Consensus.CreateEmptyBlocksInterval }}"
  413. # Reactor sleep duration parameters
  414. peer-gossip-sleep-duration = "{{ .Consensus.PeerGossipSleepDuration }}"
  415. peer-query-maj23-sleep-duration = "{{ .Consensus.PeerQueryMaj23SleepDuration }}"
  416. #######################################################
  417. ### Transaction Indexer Configuration Options ###
  418. #######################################################
  419. [tx-index]
  420. # The backend database list to back the indexer.
  421. # If list contains "null" or "", meaning no indexer service will be used.
  422. #
  423. # The application will set which txs to index. In some cases a node operator will be able
  424. # to decide which txs to index based on configuration set in the application.
  425. #
  426. # Options:
  427. # 1) "null"
  428. # 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
  429. # 3) "psql" - the indexer services backed by PostgreSQL.
  430. # When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed.
  431. indexer = [{{ range $i, $e := .TxIndex.Indexer }}{{if $i}}, {{end}}{{ printf "%q" $e}}{{end}}]
  432. # The PostgreSQL connection configuration, the connection format:
  433. # postgresql://<user>:<password>@<host>:<port>/<db>?<opts>
  434. psql-conn = "{{ .TxIndex.PsqlConn }}"
  435. #######################################################
  436. ### Instrumentation Configuration Options ###
  437. #######################################################
  438. [instrumentation]
  439. # When true, Prometheus metrics are served under /metrics on
  440. # PrometheusListenAddr.
  441. # Check out the documentation for the list of available metrics.
  442. prometheus = {{ .Instrumentation.Prometheus }}
  443. # Address to listen for Prometheus collector(s) connections
  444. prometheus-listen-addr = "{{ .Instrumentation.PrometheusListenAddr }}"
  445. # Maximum number of simultaneous connections.
  446. # If you want to accept a larger number than the default, make sure
  447. # you increase your OS limits.
  448. # 0 - unlimited.
  449. max-open-connections = {{ .Instrumentation.MaxOpenConnections }}
  450. # Instrumentation namespace
  451. namespace = "{{ .Instrumentation.Namespace }}"
  452. `
  453. /****** these are for test settings ***********/
  454. func ResetTestRoot(testName string) *Config {
  455. return ResetTestRootWithChainID(testName, "")
  456. }
  457. func ResetTestRootWithChainID(testName string, chainID string) *Config {
  458. // create a unique, concurrency-safe test directory under os.TempDir()
  459. rootDir, err := ioutil.TempDir("", fmt.Sprintf("%s-%s_", chainID, testName))
  460. if err != nil {
  461. panic(err)
  462. }
  463. // ensure config and data subdirs are created
  464. if err := tmos.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil {
  465. panic(err)
  466. }
  467. if err := tmos.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil {
  468. panic(err)
  469. }
  470. conf := DefaultConfig()
  471. genesisFilePath := filepath.Join(rootDir, conf.Genesis)
  472. privKeyFilePath := filepath.Join(rootDir, conf.PrivValidator.Key)
  473. privStateFilePath := filepath.Join(rootDir, conf.PrivValidator.State)
  474. // Write default config file if missing.
  475. writeDefaultConfigFileIfNone(rootDir)
  476. if !tmos.FileExists(genesisFilePath) {
  477. if chainID == "" {
  478. chainID = "tendermint_test"
  479. }
  480. testGenesis := fmt.Sprintf(testGenesisFmt, chainID)
  481. mustWriteFile(genesisFilePath, []byte(testGenesis), 0644)
  482. }
  483. // we always overwrite the priv val
  484. mustWriteFile(privKeyFilePath, []byte(testPrivValidatorKey), 0644)
  485. mustWriteFile(privStateFilePath, []byte(testPrivValidatorState), 0644)
  486. config := TestConfig().SetRoot(rootDir)
  487. return config
  488. }
  489. func mustWriteFile(filePath string, contents []byte, mode os.FileMode) {
  490. if err := ioutil.WriteFile(filePath, contents, mode); err != nil {
  491. tmos.Exit(fmt.Sprintf("failed to write file: %v", err))
  492. }
  493. }
  494. var testGenesisFmt = `{
  495. "genesis_time": "2018-10-10T08:20:13.695936996Z",
  496. "chain_id": "%s",
  497. "initial_height": "1",
  498. "consensus_params": {
  499. "block": {
  500. "max_bytes": "22020096",
  501. "max_gas": "-1",
  502. "time_iota_ms": "10"
  503. },
  504. "evidence": {
  505. "max_age_num_blocks": "100000",
  506. "max_age_duration": "172800000000000",
  507. "max_bytes": "1048576"
  508. },
  509. "validator": {
  510. "pub_key_types": [
  511. "ed25519"
  512. ]
  513. },
  514. "version": {}
  515. },
  516. "validators": [
  517. {
  518. "pub_key": {
  519. "type": "tendermint/PubKeyEd25519",
  520. "value":"AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="
  521. },
  522. "power": "10",
  523. "name": ""
  524. }
  525. ],
  526. "app_hash": ""
  527. }`
  528. var testPrivValidatorKey = `{
  529. "address": "A3258DCBF45DCA0DF052981870F2D1441A36D145",
  530. "pub_key": {
  531. "type": "tendermint/PubKeyEd25519",
  532. "value": "AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="
  533. },
  534. "priv_key": {
  535. "type": "tendermint/PrivKeyEd25519",
  536. "value": "EVkqJO/jIXp3rkASXfh9YnyToYXRXhBr6g9cQVxPFnQBP/5povV4HTjvsy530kybxKHwEi85iU8YL0qQhSYVoQ=="
  537. }
  538. }`
  539. var testPrivValidatorState = `{
  540. "height": "0",
  541. "round": 0,
  542. "step": 0
  543. }`