github.com/Finschia/ostracon@v1.1.5/config/toml.go (about) 1 package config 2 3 import ( 4 "bytes" 5 "fmt" 6 "os" 7 "path/filepath" 8 "strings" 9 "text/template" 10 11 tmos "github.com/Finschia/ostracon/libs/os" 12 ) 13 14 // DefaultDirPerm is the default permissions used when creating directories. 15 const DefaultDirPerm = 0o700 16 17 var configTemplate *template.Template 18 19 func init() { 20 var err error 21 tmpl := template.New("configFileTemplate").Funcs(template.FuncMap{ 22 "StringsJoin": strings.Join, 23 }) 24 if configTemplate, err = tmpl.Parse(defaultConfigTemplate); err != nil { 25 panic(err) 26 } 27 } 28 29 /****** these are for production settings ***********/ 30 31 // EnsureRoot creates the root, config, and data directories if they don't exist, 32 // and panics if it fails. 33 func EnsureRoot(rootDir string) { 34 if err := tmos.EnsureDir(rootDir, DefaultDirPerm); err != nil { 35 panic(err.Error()) 36 } 37 if err := tmos.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil { 38 panic(err.Error()) 39 } 40 if err := tmos.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil { 41 panic(err.Error()) 42 } 43 44 configFilePath := filepath.Join(rootDir, defaultConfigFilePath) 45 46 // Write default config file if missing. 47 if !tmos.FileExists(configFilePath) { 48 writeDefaultConfigFile(configFilePath) 49 } 50 } 51 52 // XXX: this func should probably be called by cmd/ostracon/commands/init.go 53 // alongside the writing of the genesis.json and priv_validator.json 54 func writeDefaultConfigFile(configFilePath string) { 55 WriteConfigFile(configFilePath, DefaultConfig()) 56 } 57 58 // WriteConfigFile renders config using the template and writes it to configFilePath. 59 func WriteConfigFile(configFilePath string, config *Config) { 60 var buffer bytes.Buffer 61 62 if err := configTemplate.Execute(&buffer, config); err != nil { 63 panic(err) 64 } 65 66 tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0o644) 67 } 68 69 // Note: any changes to the comments/variables/mapstructure 70 // must be reflected in the appropriate struct in config/config.go 71 const defaultConfigTemplate = `# This is a TOML config file. 72 # For more information, see https://github.com/toml-lang/toml 73 74 # NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or 75 # relative to the home directory (e.g. "data"). The home directory is 76 # "$HOME/.ostracon" by default, but could be changed via $OCHOME env variable 77 # or --home cmd flag. 78 79 ####################################################################### 80 ### Main Base Config Options ### 81 ####################################################################### 82 83 # TCP or UNIX socket address of the ABCI application, 84 # or the name of an ABCI application compiled in with the Ostracon binary 85 proxy_app = "{{ .BaseConfig.ProxyApp }}" 86 87 # A custom human readable name for this node 88 moniker = "{{ .BaseConfig.Moniker }}" 89 90 # If this node is many blocks behind the tip of the chain, FastSync 91 # allows them to catchup quickly by downloading blocks in parallel 92 # and verifying their commits 93 fast_sync = {{ .BaseConfig.FastSyncMode }} 94 95 # Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb 96 # * goleveldb (github.com/syndtr/goleveldb - most popular implementation) 97 # - pure go 98 # - stable 99 # * cleveldb (uses levigo wrapper) 100 # - fast 101 # - requires gcc 102 # - use cleveldb build tag (go build -tags cleveldb) 103 # * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) 104 # - EXPERIMENTAL 105 # - may be faster is some use-cases (random reads - indexer) 106 # - use boltdb build tag (go build -tags boltdb) 107 # * rocksdb (uses github.com/tecbot/gorocksdb) 108 # - EXPERIMENTAL 109 # - requires gcc 110 # - use rocksdb build tag (go build -tags rocksdb) 111 # * badgerdb (uses github.com/dgraph-io/badger) 112 # - EXPERIMENTAL 113 # - use badgerdb build tag (go build -tags badgerdb) 114 db_backend = "{{ .BaseConfig.DBBackend }}" 115 116 # Database directory 117 db_dir = "{{ js .BaseConfig.DBPath }}" 118 119 # Output level for logging, including package level options 120 log_level = "{{ .BaseConfig.LogLevel }}" 121 122 # Output format: 'plain' (colored text) or 'json' 123 log_format = "{{ .BaseConfig.LogFormat }}" 124 125 # LogPath is the file to write logs to(log dir + log filename) 126 # ex) /Users/user/.app/logs/app.log 127 # If left as an empty string, log file writing is disabled. 128 log_path = "{{ .BaseConfig.LogPath }}" 129 130 # LogMaxAge is the maximum number of days to retain old log files based on the 131 # timestamp encoded in their filename. Note that a day is defined as 24 132 # hours and may not exactly correspond to calendar days due to daylight 133 # savings, leap seconds, etc. The default is not to remove old log files 134 # based on age. 135 log_max_age = "{{ .BaseConfig.LogMaxAge }}" 136 137 # LogMaxSize is the maximum size in megabytes of the log file before it gets 138 # rotated. It defaults to 100 megabytes. 139 log_max_size = "{{ .BaseConfig.LogMaxSize }}" 140 141 # LogMaxBackups is the maximum number of old log files to retain. The default 142 # is to retain all old log files (though MaxAge may still cause them to get 143 # deleted.) 144 log_max_backups = "{{ .BaseConfig.LogMaxBackups }}" 145 146 ##### additional base config options ##### 147 148 # Path to the JSON file containing the initial validator set and other meta data 149 genesis_file = "{{ js .BaseConfig.Genesis }}" 150 151 # Path to the JSON file containing the private key to use as a validator in the consensus protocol 152 priv_validator_key_file = "{{ js .BaseConfig.PrivValidatorKey }}" 153 154 # Path to the JSON file containing the last sign state of a validator 155 priv_validator_state_file = "{{ js .BaseConfig.PrivValidatorState }}" 156 157 # TCP or UNIX socket address for Ostracon to listen on for 158 # connections from an external PrivValidator process 159 # If this value is set, key file(priv_validator_key.json) will not be generated. 160 # example) tcp://0.0.0.0:26659 161 priv_validator_laddr = "{{ .BaseConfig.PrivValidatorListenAddr }}" 162 163 # Validator's remote address to allow a connection 164 # List of addresses in TOML array format to allow 165 # ostracon only allows a connection from these listed addresses 166 # example) [ "127.0.0.1" ] 167 # example) [ "127.0.0.1", "192.168.1.2" ] 168 priv_validator_raddrs = [ "127.0.0.1" ] 169 170 # Path to the JSON file containing the private key to use for node authentication in the p2p protocol 171 node_key_file = "{{ js .BaseConfig.NodeKey }}" 172 173 # Mechanism to connect to the ABCI application: socket | grpc 174 abci = "{{ .BaseConfig.ABCI }}" 175 176 # If true, query the ABCI app on connecting to a new peer 177 # so the app can decide if we should keep the connection or not 178 filter_peers = {{ .BaseConfig.FilterPeers }} 179 180 181 ####################################################################### 182 ### Advanced Configuration Options ### 183 ####################################################################### 184 185 ####################################################### 186 ### RPC Server Configuration Options ### 187 ####################################################### 188 [rpc] 189 190 # TCP or UNIX socket address for the RPC server to listen on 191 laddr = "{{ .RPC.ListenAddress }}" 192 193 # A list of origins a cross-domain request can be executed from 194 # Default value '[]' disables cors support 195 # Use '["*"]' to allow any origin 196 cors_allowed_origins = [{{ range .RPC.CORSAllowedOrigins }}{{ printf "%q, " . }}{{end}}] 197 198 # A list of methods the client is allowed to use with cross-domain requests 199 cors_allowed_methods = [{{ range .RPC.CORSAllowedMethods }}{{ printf "%q, " . }}{{end}}] 200 201 # A list of non simple headers the client is allowed to use with cross-domain requests 202 cors_allowed_headers = [{{ range .RPC.CORSAllowedHeaders }}{{ printf "%q, " . }}{{end}}] 203 204 # TCP or UNIX socket address for the gRPC server to listen on 205 # NOTE: This server only supports /broadcast_tx_commit 206 grpc_laddr = "{{ .RPC.GRPCListenAddress }}" 207 208 # Maximum number of simultaneous connections. 209 # Does not include RPC (HTTP&WebSocket) connections. See max_open_connections 210 # If you want to accept a larger number than the default, make sure 211 # you increase your OS limits. 212 # 0 - unlimited. 213 # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} 214 # 1024 - 40 - 10 - 50 = 924 = ~900 215 grpc_max_open_connections = {{ .RPC.GRPCMaxOpenConnections }} 216 217 # Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool 218 unsafe = {{ .RPC.Unsafe }} 219 220 # Maximum number of simultaneous connections (including WebSocket). 221 # Does not include gRPC connections. See grpc_max_open_connections 222 # If you want to accept a larger number than the default, make sure 223 # you increase your OS limits. 224 # 0 - unlimited. 225 # Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} 226 # 1024 - 40 - 10 - 50 = 924 = ~900 227 max_open_connections = {{ .RPC.MaxOpenConnections }} 228 229 # mirrors http.Server#ReadTimeout 230 # ReadTimeout is the maximum duration for reading the entire 231 # request, including the body. 232 # Because ReadTimeout does not let Handlers make per-request 233 # decisions on each request body's acceptable deadline or 234 # upload rate, most users will prefer to use 235 # ReadHeaderTimeout. It is valid to use them both. 236 read_timeout = "{{ .RPC.ReadTimeout }}" 237 238 # mirrors http.Server#WriteTimeout 239 # WriteTimeout is the maximum duration before timing out 240 # writes of the response. It is reset whenever a new 241 # request's header is read. Like ReadTimeout, it does not 242 # let Handlers make decisions on a per-request basis. 243 write_timeout = "{{ .RPC.WriteTimeout }}" 244 245 # mirrors http.Server#IdleTimeout 246 # IdleTimeout is the maximum amount of time to wait for the 247 # next request when keep-alives are enabled. If IdleTimeout 248 # is zero, the value of ReadTimeout is used. If both are 249 # zero, there is no timeout. 250 idle_timeout = "{{ .RPC.IdleTimeout }}" 251 252 # Maximum number of unique clientIDs that can /subscribe 253 # If you're using /broadcast_tx_commit, set to the estimated maximum number 254 # of broadcast_tx_commit calls per block. 255 max_subscription_clients = {{ .RPC.MaxSubscriptionClients }} 256 257 # Maximum number of unique queries a given client can /subscribe to 258 # If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to 259 # the estimated # maximum number of broadcast_tx_commit calls per block. 260 max_subscriptions_per_client = {{ .RPC.MaxSubscriptionsPerClient }} 261 262 # Experimental parameter to specify the maximum number of events a node will 263 # buffer, per subscription, before returning an error and closing the 264 # subscription. Must be set to at least 100, but higher values will accommodate 265 # higher event throughput rates (and will use more memory). 266 experimental_subscription_buffer_size = {{ .RPC.SubscriptionBufferSize }} 267 268 # Experimental parameter to specify the maximum number of RPC responses that 269 # can be buffered per WebSocket client. If clients cannot read from the 270 # WebSocket endpoint fast enough, they will be disconnected, so increasing this 271 # parameter may reduce the chances of them being disconnected (but will cause 272 # the node to use more memory). 273 # 274 # Must be at least the same as "experimental_subscription_buffer_size", 275 # otherwise connections could be dropped unnecessarily. This value should 276 # ideally be somewhat higher than "experimental_subscription_buffer_size" to 277 # accommodate non-subscription-related RPC responses. 278 experimental_websocket_write_buffer_size = {{ .RPC.WebSocketWriteBufferSize }} 279 280 # If a WebSocket client cannot read fast enough, at present we may 281 # silently drop events instead of generating an error or disconnecting the 282 # client. 283 # 284 # Enabling this experimental parameter will cause the WebSocket connection to 285 # be closed instead if it cannot read fast enough, allowing for greater 286 # predictability in subscription behaviour. 287 experimental_close_on_slow_client = {{ .RPC.CloseOnSlowClient }} 288 289 # How long to wait for a tx to be committed during /broadcast_tx_commit. 290 # WARNING: Using a value larger than 'WriteTimeout' will result in increasing the 291 # global HTTP write timeout, which applies to all connections and endpoints. 292 # See https://github.com/tendermint/tendermint/issues/3435 293 timeout_broadcast_tx_commit = "{{ .RPC.TimeoutBroadcastTxCommit }}" 294 295 # Maximum size of request body, in bytes 296 max_body_bytes = {{ .RPC.MaxBodyBytes }} 297 298 # Maximum number of requests in a request body 299 max_batch_request_num = {{ .RPC.MaxBatchRequestNum }} 300 301 # Maximum size of request header, in bytes 302 max_header_bytes = {{ .RPC.MaxHeaderBytes }} 303 304 # The path to a file containing certificate that is used to create the HTTPS server. 305 # Might be either absolute path or path related to Ostracon's config directory. 306 # If the certificate is signed by a certificate authority, 307 # the certFile should be the concatenation of the server's certificate, any intermediates, 308 # and the CA's certificate. 309 # NOTE: both tls_cert_file and tls_key_file must be present for Ostracon to create HTTPS server. 310 # Otherwise, HTTP server is run. 311 tls_cert_file = "{{ .RPC.TLSCertFile }}" 312 313 # The path to a file containing matching private key that is used to create the HTTPS server. 314 # Might be either absolute path or path related to Ostracon's config directory. 315 # NOTE: both tls-cert-file and tls-key-file must be present for Ostracon to create HTTPS server. 316 # Otherwise, HTTP server is run. 317 tls_key_file = "{{ .RPC.TLSKeyFile }}" 318 319 # pprof listen address (https://golang.org/pkg/net/http/pprof) 320 pprof_laddr = "{{ .RPC.PprofListenAddress }}" 321 322 ####################################################### 323 ### P2P Configuration Options ### 324 ####################################################### 325 [p2p] 326 327 # Address to listen for incoming connections 328 laddr = "{{ .P2P.ListenAddress }}" 329 330 # Address to advertise to peers for them to dial 331 # If empty, will use the same port as the laddr, 332 # and will introspect on the listener or use UPnP 333 # to figure out the address. ip and port are required 334 # example: 159.89.10.97:26656 335 external_address = "{{ .P2P.ExternalAddress }}" 336 337 # Comma separated list of seed nodes to connect to 338 seeds = "{{ .P2P.Seeds }}" 339 340 # Comma separated list of nodes to keep persistent connections to 341 persistent_peers = "{{ .P2P.PersistentPeers }}" 342 343 # UPNP port forwarding 344 upnp = {{ .P2P.UPNP }} 345 346 # Path to address book 347 addr_book_file = "{{ js .P2P.AddrBook }}" 348 349 # Set true for strict address routability rules 350 # Set false for private or local networks 351 addr_book_strict = {{ .P2P.AddrBookStrict }} 352 353 # Maximum number of inbound peers 354 max_num_inbound_peers = {{ .P2P.MaxNumInboundPeers }} 355 356 # Maximum number of outbound peers to connect to, excluding persistent peers 357 max_num_outbound_peers = {{ .P2P.MaxNumOutboundPeers }} 358 359 # List of node IDs, to which a connection will be (re)established ignoring any existing limits 360 unconditional_peer_ids = "{{ .P2P.UnconditionalPeerIDs }}" 361 362 # Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) 363 persistent_peers_max_dial_period = "{{ .P2P.PersistentPeersMaxDialPeriod }}" 364 365 # Time to wait before flushing messages out on the connection 366 flush_throttle_timeout = "{{ .P2P.FlushThrottleTimeout }}" 367 368 # Maximum size of a message packet payload, in bytes 369 max_packet_msg_payload_size = {{ .P2P.MaxPacketMsgPayloadSize }} 370 371 # Rate at which packets can be sent, in bytes/second 372 send_rate = {{ .P2P.SendRate }} 373 374 # Rate at which packets can be received, in bytes/second 375 recv_rate = {{ .P2P.RecvRate }} 376 377 # Set true to enable the peer-exchange reactor 378 pex = {{ .P2P.PexReactor }} 379 380 # Seed mode, in which node constantly crawls the network and looks for 381 # peers. If another node asks it for addresses, it responds and disconnects. 382 # 383 # Does not work if the peer-exchange reactor is disabled. 384 seed_mode = {{ .P2P.SeedMode }} 385 386 # Comma separated list of peer IDs to keep private (will not be gossiped to other peers) 387 private_peer_ids = "{{ .P2P.PrivatePeerIDs }}" 388 389 # Toggle to disable guard against peers connecting from the same ip. 390 allow_duplicate_ip = {{ .P2P.AllowDuplicateIP }} 391 392 # Peer connection configuration. 393 handshake_timeout = "{{ .P2P.HandshakeTimeout }}" 394 dial_timeout = "{{ .P2P.DialTimeout }}" 395 396 # Sync/async of reactor's receive function 397 recv_async = {{ .P2P.RecvAsync }} 398 399 # Size of channel buffer of reactor 400 pex_recv_buf_size = {{ .P2P.PexRecvBufSize }} 401 mempool_recv_buf_size = {{ .P2P.MempoolRecvBufSize }} 402 evidence_recv_buf_size = {{ .P2P.EvidenceRecvBufSize }} 403 consensus_recv_buf_size = {{ .P2P.ConsensusRecvBufSize }} 404 blockchain_recv_buf_size = {{ .P2P.BlockchainRecvBufSize }} 405 statesync_recv_buf_size = {{ .P2P.StatesyncRecvBufSize }} 406 407 ####################################################### 408 ### Mempool Configuration Option ### 409 ####################################################### 410 [mempool] 411 412 # Mempool version to use: 413 # 1) "v0" - (default) FIFO mempool. 414 # 2) "v1" - prioritized mempool. 415 version = "{{ .Mempool.Version }}" 416 417 recheck = {{ .Mempool.Recheck }} 418 broadcast = {{ .Mempool.Broadcast }} 419 wal_dir = "{{ js .Mempool.WalPath }}" 420 421 # Maximum number of transactions in the mempool 422 size = {{ .Mempool.Size }} 423 424 # Limit the total size of all txs in the mempool. 425 # This only accounts for raw transactions (e.g. given 1MB transactions and 426 # max_txs_bytes=5MB, mempool will only accept 5 transactions). 427 max_txs_bytes = {{ .Mempool.MaxTxsBytes }} 428 429 # Size of the cache (used to filter transactions we saw earlier) in transactions 430 cache_size = {{ .Mempool.CacheSize }} 431 432 # Do not remove invalid transactions from the cache (default: false) 433 # Set to true if it's not possible for any invalid transaction to become valid 434 # again in the future. 435 keep-invalid-txs-in-cache = {{ .Mempool.KeepInvalidTxsInCache }} 436 437 # Maximum size of a single transaction. 438 # NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. 439 max_tx_bytes = {{ .Mempool.MaxTxBytes }} 440 441 # Maximum size of a batch of transactions to send to a peer 442 # Including space needed by encoding (one varint per transaction). 443 # XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 444 max_batch_bytes = {{ .Mempool.MaxBatchBytes }} 445 446 # ttl-duration, if non-zero, defines the maximum amount of time a transaction 447 # can exist for in the mempool. 448 # 449 # Note, if ttl-num-blocks is also defined, a transaction will be removed if it 450 # has existed in the mempool at least ttl-num-blocks number of blocks or if it's 451 # insertion time into the mempool is beyond ttl-duration. 452 ttl-duration = "{{ .Mempool.TTLDuration }}" 453 454 # ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction 455 # can exist for in the mempool. 456 # 457 # Note, if ttl-duration is also defined, a transaction will be removed if it 458 # has existed in the mempool at least ttl-num-blocks number of blocks or if 459 # it's insertion time into the mempool is beyond ttl-duration. 460 ttl-num-blocks = {{ .Mempool.TTLNumBlocks }} 461 462 ####################################################### 463 ### State Sync Configuration Options ### 464 ####################################################### 465 [statesync] 466 # State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine 467 # snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in 468 # the network to take and serve state machine snapshots. State sync is not attempted if the node 469 # has any local state (LastBlockHeight > 0). The node will have a truncated block history, 470 # starting from the height of the snapshot. 471 enable = {{ .StateSync.Enable }} 472 473 # RPC servers (comma-separated) for light client verification of the synced state machine and 474 # retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding 475 # header hash obtained from a trusted source, and a period during which validators can be trusted. 476 # 477 # For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 478 # weeks) during which they can be financially punished (slashed) for misbehavior. 479 rpc_servers = "{{ StringsJoin .StateSync.RPCServers "," }}" 480 trust_height = {{ .StateSync.TrustHeight }} 481 trust_hash = "{{ .StateSync.TrustHash }}" 482 trust_period = "{{ .StateSync.TrustPeriod }}" 483 484 # Time to spend discovering snapshots before initiating a restore. 485 discovery_time = "{{ .StateSync.DiscoveryTime }}" 486 487 # Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). 488 # Will create a new, randomly named directory within, and remove it when done. 489 temp_dir = "{{ .StateSync.TempDir }}" 490 491 # The timeout duration before re-requesting a chunk, possibly from a different 492 # peer (default: 1 minute). 493 chunk_request_timeout = "{{ .StateSync.ChunkRequestTimeout }}" 494 495 # The number of concurrent chunk fetchers to run (default: 1). 496 chunk_fetchers = "{{ .StateSync.ChunkFetchers }}" 497 498 ####################################################### 499 ### Fast Sync Configuration Connections ### 500 ####################################################### 501 [fastsync] 502 503 # Fast Sync version to use: 504 # 1) "v0" (default) - the legacy fast sync implementation 505 # 2) "v1" - refactor of v0 version for better testability 506 # 2) "v2" - complete redesign of v0, optimized for testability & readability 507 version = "{{ .FastSync.Version }}" 508 509 ####################################################### 510 ### Consensus Configuration Options ### 511 ####################################################### 512 [consensus] 513 514 wal_file = "{{ js .Consensus.WalPath }}" 515 516 # How long we wait for a proposal block before prevoting nil 517 timeout_propose = "{{ .Consensus.TimeoutPropose }}" 518 # How much timeout_propose increases with each round 519 timeout_propose_delta = "{{ .Consensus.TimeoutProposeDelta }}" 520 # How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) 521 timeout_prevote = "{{ .Consensus.TimeoutPrevote }}" 522 # How much the timeout_prevote increases with each round 523 timeout_prevote_delta = "{{ .Consensus.TimeoutPrevoteDelta }}" 524 # How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) 525 timeout_precommit = "{{ .Consensus.TimeoutPrecommit }}" 526 # How much the timeout_precommit increases with each round 527 timeout_precommit_delta = "{{ .Consensus.TimeoutPrecommitDelta }}" 528 # How long we wait after committing a block, before starting on the new 529 # height (this gives us a chance to receive some more precommits, even 530 # though we already have +2/3). 531 timeout_commit = "{{ .Consensus.TimeoutCommit }}" 532 533 # How many blocks to look back to check existence of the node's consensus votes before joining consensus 534 # When non-zero, the node will panic upon restart 535 # if the same consensus key was used to sign {double_sign_check_height} last blocks. 536 # So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. 537 double_sign_check_height = {{ .Consensus.DoubleSignCheckHeight }} 538 539 # Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) 540 skip_timeout_commit = {{ .Consensus.SkipTimeoutCommit }} 541 542 # EmptyBlocks mode and possible interval between empty blocks 543 create_empty_blocks = {{ .Consensus.CreateEmptyBlocks }} 544 create_empty_blocks_interval = "{{ .Consensus.CreateEmptyBlocksInterval }}" 545 546 # Max transactions per block. No limit if <= 0. 547 max_txs = {{ .Consensus.MaxTxs }} 548 549 # Reactor sleep duration parameters 550 peer_gossip_sleep_duration = "{{ .Consensus.PeerGossipSleepDuration }}" 551 peer_query_maj23_sleep_duration = "{{ .Consensus.PeerQueryMaj23SleepDuration }}" 552 553 ####################################################### 554 ### Storage Configuration Options ### 555 ####################################################### 556 [storage] 557 558 # Set to true to discard ABCI responses from the state store, which can save a 559 # considerable amount of disk space. Set to false to ensure ABCI responses are 560 # persisted. ABCI responses are required for /block_results RPC queries, and to 561 # reindex events in the command-line tool. 562 discard_abci_responses = {{ .Storage.DiscardABCIResponses}} 563 564 ####################################################### 565 ### Transaction Indexer Configuration Options ### 566 ####################################################### 567 [tx_index] 568 569 # What indexer to use for transactions 570 # 571 # The application will set which txs to index. In some cases a node operator will be able 572 # to decide which txs to index based on configuration set in the application. 573 # 574 # Options: 575 # 1) "null" 576 # 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). 577 # - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. 578 # 3) "psql" - the indexer services backed by PostgreSQL. 579 # When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. 580 indexer = "{{ .TxIndex.Indexer }}" 581 582 # The PostgreSQL connection configuration, the connection format: 583 # postgresql://<user>:<password>@<host>:<port>/<db>?<opts> 584 psql-conn = "{{ .TxIndex.PsqlConn }}" 585 586 ####################################################### 587 ### Instrumentation Configuration Options ### 588 ####################################################### 589 [instrumentation] 590 591 # When true, Prometheus metrics are served under /metrics on 592 # PrometheusListenAddr. 593 # Check out the documentation for the list of available metrics. 594 prometheus = {{ .Instrumentation.Prometheus }} 595 596 # Address to listen for Prometheus collector(s) connections 597 prometheus_listen_addr = "{{ .Instrumentation.PrometheusListenAddr }}" 598 599 # Maximum number of simultaneous connections. 600 # If you want to accept a larger number than the default, make sure 601 # you increase your OS limits. 602 # 0 - unlimited. 603 max_open_connections = {{ .Instrumentation.MaxOpenConnections }} 604 605 # Instrumentation namespace 606 namespace = "{{ .Instrumentation.Namespace }}" 607 ` 608 609 /****** these are for test settings ***********/ 610 611 func ResetTestRoot(testName string) *Config { 612 return ResetTestRootWithChainID(testName, "") 613 } 614 615 func ResetTestRootWithChainID(testName string, chainID string) *Config { 616 // create a unique, concurrency-safe test directory under os.TempDir() 617 rootDir, err := os.MkdirTemp("", fmt.Sprintf("%s-%s_", chainID, testName)) 618 if err != nil { 619 panic(err) 620 } 621 // ensure config and data subdirs are created 622 if err := tmos.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil { 623 panic(err) 624 } 625 if err := tmos.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil { 626 panic(err) 627 } 628 629 baseConfig := DefaultBaseConfig() 630 configFilePath := filepath.Join(rootDir, defaultConfigFilePath) 631 genesisFilePath := filepath.Join(rootDir, baseConfig.Genesis) 632 privKeyFilePath := filepath.Join(rootDir, baseConfig.PrivValidatorKey) 633 privStateFilePath := filepath.Join(rootDir, baseConfig.PrivValidatorState) 634 nodeKeyFilePath := filepath.Join(rootDir, baseConfig.NodeKey) 635 636 // Write default config file if missing. 637 if !tmos.FileExists(configFilePath) { 638 writeDefaultConfigFile(configFilePath) 639 } 640 if !tmos.FileExists(genesisFilePath) { 641 if chainID == "" { 642 chainID = "ostracon_test" 643 } 644 testGenesis := fmt.Sprintf(testGenesisFmt, chainID) 645 tmos.MustWriteFile(genesisFilePath, []byte(testGenesis), 0o644) 646 } 647 // we always overwrite the priv val 648 tmos.MustWriteFile(privKeyFilePath, []byte(testPrivValidatorKey), 0o644) 649 tmos.MustWriteFile(privStateFilePath, []byte(testPrivValidatorState), 0o644) 650 tmos.MustWriteFile(nodeKeyFilePath, []byte(testNodeKey), 0o644) 651 652 config := TestConfig().SetRoot(rootDir) 653 return config 654 } 655 656 var testGenesisFmt = `{ 657 "genesis_time": "2018-10-10T08:20:13.695936996Z", 658 "chain_id": "%s", 659 "initial_height": "1", 660 "consensus_params": { 661 "block": { 662 "max_bytes": "22020096", 663 "max_gas": "-1", 664 "time_iota_ms": "10" 665 }, 666 "evidence": { 667 "max_age_num_blocks": "100000", 668 "max_age_duration": "172800000000000", 669 "max_bytes": "1048576" 670 }, 671 "validator": { 672 "pub_key_types": [ 673 "ed25519" 674 ] 675 }, 676 "version": {} 677 }, 678 "validators": [ 679 { 680 "pub_key": { 681 "type": "tendermint/PubKeyEd25519", 682 "value":"AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE=" 683 }, 684 "power": "10", 685 "name": "" 686 } 687 ], 688 "app_hash": "" 689 }` 690 691 var testPrivValidatorKey = `{ 692 "address": "A3258DCBF45DCA0DF052981870F2D1441A36D145", 693 "pub_key": { 694 "type": "tendermint/PubKeyEd25519", 695 "value": "AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE=" 696 }, 697 "priv_key": { 698 "type": "tendermint/PrivKeyEd25519", 699 "value": "EVkqJO/jIXp3rkASXfh9YnyToYXRXhBr6g9cQVxPFnQBP/5povV4HTjvsy530kybxKHwEi85iU8YL0qQhSYVoQ==" 700 } 701 }` 702 703 var testNodeKey = `{ 704 "priv_key": { 705 "type": "tendermint/PrivKeyEd25519", 706 "value": "hICuZLlVwHdzz6pAQOKk07MFn3Hze1EwwTUUhEDIdti9a1cQLR5Co/lxAzeGcyPWS/LuEr7qbgHmDUJT/nxx+Q==" 707 } 708 }` 709 710 var testPrivValidatorState = `{ 711 "height": "0", 712 "round": 0, 713 "step": 0 714 }`