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.

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