2018-06-20 17:35:30 -07:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2019-01-25 22:10:36 +09:00
|
|
|
"fmt"
|
2019-02-18 08:45:27 +01:00
|
|
|
"io/ioutil"
|
2018-06-20 17:35:30 -07:00
|
|
|
"path/filepath"
|
|
|
|
"text/template"
|
|
|
|
|
2018-07-01 22:36:49 -04:00
|
|
|
cmn "github.com/tendermint/tendermint/libs/common"
|
2018-06-20 17:35:30 -07:00
|
|
|
)
|
|
|
|
|
2019-02-18 08:45:27 +01:00
|
|
|
// DefaultDirPerm is the default permissions used when creating directories.
|
|
|
|
const DefaultDirPerm = 0700
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
var configTemplate *template.Template
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
var err error
|
|
|
|
if configTemplate, err = template.New("configFileTemplate").Parse(defaultConfigTemplate); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****** these are for production settings ***********/
|
|
|
|
|
|
|
|
// EnsureRoot creates the root, config, and data directories if they don't exist,
|
|
|
|
// and panics if it fails.
|
|
|
|
func EnsureRoot(rootDir string) {
|
2019-02-18 08:45:27 +01:00
|
|
|
if err := cmn.EnsureDir(rootDir, DefaultDirPerm); err != nil {
|
2019-04-26 06:23:43 -04:00
|
|
|
panic(err.Error())
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
2019-02-18 08:45:27 +01:00
|
|
|
if err := cmn.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil {
|
2019-04-26 06:23:43 -04:00
|
|
|
panic(err.Error())
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
2019-02-18 08:45:27 +01:00
|
|
|
if err := cmn.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil {
|
2019-04-26 06:23:43 -04:00
|
|
|
panic(err.Error())
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
configFilePath := filepath.Join(rootDir, defaultConfigFilePath)
|
|
|
|
|
|
|
|
// Write default config file if missing.
|
|
|
|
if !cmn.FileExists(configFilePath) {
|
|
|
|
writeDefaultConfigFile(configFilePath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX: this func should probably be called by cmd/tendermint/commands/init.go
|
|
|
|
// alongside the writing of the genesis.json and priv_validator.json
|
|
|
|
func writeDefaultConfigFile(configFilePath string) {
|
|
|
|
WriteConfigFile(configFilePath, DefaultConfig())
|
|
|
|
}
|
|
|
|
|
|
|
|
// WriteConfigFile renders config using the template and writes it to configFilePath.
|
|
|
|
func WriteConfigFile(configFilePath string, config *Config) {
|
|
|
|
var buffer bytes.Buffer
|
|
|
|
|
|
|
|
if err := configTemplate.Execute(&buffer, config); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
cmn.MustWriteFile(configFilePath, buffer.Bytes(), 0644)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: any changes to the comments/variables/mapstructure
|
|
|
|
// must be reflected in the appropriate struct in config/config.go
|
|
|
|
const defaultConfigTemplate = `# This is a TOML config file.
|
|
|
|
# For more information, see https://github.com/toml-lang/toml
|
|
|
|
|
2019-10-02 12:23:32 -07:00
|
|
|
# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or
|
|
|
|
# relative to the home directory (e.g. "data"). The home directory is
|
|
|
|
# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable
|
|
|
|
# or --home cmd flag.
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
##### main base config options #####
|
|
|
|
|
|
|
|
# TCP or UNIX socket address of the ABCI application,
|
|
|
|
# or the name of an ABCI application compiled in with the Tendermint binary
|
|
|
|
proxy_app = "{{ .BaseConfig.ProxyApp }}"
|
|
|
|
|
|
|
|
# A custom human readable name for this node
|
|
|
|
moniker = "{{ .BaseConfig.Moniker }}"
|
|
|
|
|
|
|
|
# If this node is many blocks behind the tip of the chain, FastSync
|
|
|
|
# allows them to catchup quickly by downloading blocks in parallel
|
|
|
|
# and verifying their commits
|
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
2019-07-23 10:58:52 +02:00
|
|
|
fast_sync = {{ .BaseConfig.FastSyncMode }}
|
2018-06-20 17:35:30 -07:00
|
|
|
|
2019-05-07 12:33:47 +04:00
|
|
|
# Database backend: goleveldb | cleveldb | boltdb
|
|
|
|
# * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
|
|
|
|
# - pure go
|
|
|
|
# - stable
|
|
|
|
# * cleveldb (uses levigo wrapper)
|
|
|
|
# - fast
|
|
|
|
# - requires gcc
|
|
|
|
# - use cleveldb build tag (go build -tags cleveldb)
|
|
|
|
# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
|
|
|
|
# - EXPERIMENTAL
|
|
|
|
# - may be faster is some use-cases (random reads - indexer)
|
|
|
|
# - use boltdb build tag (go build -tags boltdb)
|
2018-06-20 17:35:30 -07:00
|
|
|
db_backend = "{{ .BaseConfig.DBBackend }}"
|
|
|
|
|
|
|
|
# Database directory
|
2018-08-27 14:27:18 +01:00
|
|
|
db_dir = "{{ js .BaseConfig.DBPath }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
# Output level for logging, including package level options
|
|
|
|
log_level = "{{ .BaseConfig.LogLevel }}"
|
|
|
|
|
2018-11-16 03:05:06 +04:00
|
|
|
# Output format: 'plain' (colored text) or 'json'
|
|
|
|
log_format = "{{ .BaseConfig.LogFormat }}"
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
##### additional base config options #####
|
|
|
|
|
|
|
|
# Path to the JSON file containing the initial validator set and other meta data
|
|
|
|
genesis_file = "{{ js .BaseConfig.Genesis }}"
|
|
|
|
|
|
|
|
# Path to the JSON file containing the private key to use as a validator in the consensus protocol
|
2018-12-22 05:58:27 +08:00
|
|
|
priv_validator_key_file = "{{ js .BaseConfig.PrivValidatorKey }}"
|
|
|
|
|
|
|
|
# Path to the JSON file containing the last sign state of a validator
|
|
|
|
priv_validator_state_file = "{{ js .BaseConfig.PrivValidatorState }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
|
2018-08-01 16:20:59 +04:00
|
|
|
# TCP or UNIX socket address for Tendermint to listen on for
|
|
|
|
# connections from an external PrivValidator process
|
|
|
|
priv_validator_laddr = "{{ .BaseConfig.PrivValidatorListenAddr }}"
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
# Path to the JSON file containing the private key to use for node authentication in the p2p protocol
|
2018-09-26 14:04:44 +04:00
|
|
|
node_key_file = "{{ js .BaseConfig.NodeKey }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
# Mechanism to connect to the ABCI application: socket | grpc
|
|
|
|
abci = "{{ .BaseConfig.ABCI }}"
|
|
|
|
|
|
|
|
# TCP or UNIX socket address for the profiling server to listen on
|
|
|
|
prof_laddr = "{{ .BaseConfig.ProfListenAddress }}"
|
|
|
|
|
|
|
|
# If true, query the ABCI app on connecting to a new peer
|
|
|
|
# so the app can decide if we should keep the connection or not
|
|
|
|
filter_peers = {{ .BaseConfig.FilterPeers }}
|
|
|
|
|
|
|
|
##### advanced configuration options #####
|
|
|
|
|
|
|
|
##### rpc server configuration options #####
|
|
|
|
[rpc]
|
|
|
|
|
|
|
|
# TCP or UNIX socket address for the RPC server to listen on
|
|
|
|
laddr = "{{ .RPC.ListenAddress }}"
|
|
|
|
|
2018-11-14 15:47:41 +03:00
|
|
|
# A list of origins a cross-domain request can be executed from
|
|
|
|
# Default value '[]' disables cors support
|
|
|
|
# Use '["*"]' to allow any origin
|
2018-12-15 15:26:27 -05:00
|
|
|
cors_allowed_origins = [{{ range .RPC.CORSAllowedOrigins }}{{ printf "%q, " . }}{{end}}]
|
2018-11-14 15:47:41 +03:00
|
|
|
|
|
|
|
# A list of methods the client is allowed to use with cross-domain requests
|
2018-12-15 15:26:27 -05:00
|
|
|
cors_allowed_methods = [{{ range .RPC.CORSAllowedMethods }}{{ printf "%q, " . }}{{end}}]
|
2018-11-14 15:47:41 +03:00
|
|
|
|
|
|
|
# A list of non simple headers the client is allowed to use with cross-domain requests
|
2018-12-15 15:26:27 -05:00
|
|
|
cors_allowed_headers = [{{ range .RPC.CORSAllowedHeaders }}{{ printf "%q, " . }}{{end}}]
|
2018-11-14 15:47:41 +03:00
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
# TCP or UNIX socket address for the gRPC server to listen on
|
|
|
|
# NOTE: This server only supports /broadcast_tx_commit
|
|
|
|
grpc_laddr = "{{ .RPC.GRPCListenAddress }}"
|
|
|
|
|
2018-06-20 18:38:42 +04:00
|
|
|
# Maximum number of simultaneous connections.
|
|
|
|
# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections
|
2018-12-15 15:26:27 -05:00
|
|
|
# If you want to accept a larger number than the default, make sure
|
2018-06-20 18:38:42 +04:00
|
|
|
# you increase your OS limits.
|
|
|
|
# 0 - unlimited.
|
2018-08-15 02:25:56 +04:00
|
|
|
# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
|
|
|
|
# 1024 - 40 - 10 - 50 = 924 = ~900
|
2018-06-20 18:38:42 +04:00
|
|
|
grpc_max_open_connections = {{ .RPC.GRPCMaxOpenConnections }}
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool
|
|
|
|
unsafe = {{ .RPC.Unsafe }}
|
|
|
|
|
2018-06-20 18:38:42 +04:00
|
|
|
# Maximum number of simultaneous connections (including WebSocket).
|
|
|
|
# Does not include gRPC connections. See grpc_max_open_connections
|
2018-12-15 15:26:27 -05:00
|
|
|
# If you want to accept a larger number than the default, make sure
|
2018-06-20 18:38:42 +04:00
|
|
|
# you increase your OS limits.
|
|
|
|
# 0 - unlimited.
|
2018-08-15 02:25:56 +04:00
|
|
|
# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
|
|
|
|
# 1024 - 40 - 10 - 50 = 924 = ~900
|
2018-06-20 18:38:42 +04:00
|
|
|
max_open_connections = {{ .RPC.MaxOpenConnections }}
|
|
|
|
|
2019-03-11 22:45:58 +04:00
|
|
|
# Maximum number of unique clientIDs that can /subscribe
|
|
|
|
# If you're using /broadcast_tx_commit, set to the estimated maximum number
|
|
|
|
# of broadcast_tx_commit calls per block.
|
|
|
|
max_subscription_clients = {{ .RPC.MaxSubscriptionClients }}
|
|
|
|
|
|
|
|
# Maximum number of unique queries a given client can /subscribe to
|
|
|
|
# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to
|
|
|
|
# the estimated # maximum number of broadcast_tx_commit calls per block.
|
|
|
|
max_subscriptions_per_client = {{ .RPC.MaxSubscriptionsPerClient }}
|
|
|
|
|
|
|
|
# How long to wait for a tx to be committed during /broadcast_tx_commit.
|
2019-03-20 00:45:51 +01:00
|
|
|
# WARNING: Using a value larger than 10s will result in increasing the
|
|
|
|
# global HTTP write timeout, which applies to all connections and endpoints.
|
|
|
|
# See https://github.com/tendermint/tendermint/issues/3435
|
2019-03-11 22:45:58 +04:00
|
|
|
timeout_broadcast_tx_commit = "{{ .RPC.TimeoutBroadcastTxCommit }}"
|
|
|
|
|
2019-07-20 16:44:42 +09:00
|
|
|
# Maximum size of request body, in bytes
|
|
|
|
max_body_bytes = {{ .RPC.MaxBodyBytes }}
|
|
|
|
|
|
|
|
# Maximum size of request header, in bytes
|
|
|
|
max_header_bytes = {{ .RPC.MaxHeaderBytes }}
|
|
|
|
|
2019-07-01 12:48:54 +04:00
|
|
|
# The path to a file containing certificate that is used to create the HTTPS server.
|
|
|
|
# Migth be either absolute path or path related to tendermint's config directory.
|
2019-03-24 01:08:15 +08:00
|
|
|
# If the certificate is signed by a certificate authority,
|
|
|
|
# the certFile should be the concatenation of the server's certificate, any intermediates,
|
|
|
|
# and the CA's certificate.
|
|
|
|
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
|
|
|
tls_cert_file = "{{ .RPC.TLSCertFile }}"
|
|
|
|
|
2019-07-01 12:48:54 +04:00
|
|
|
# The path to a file containing matching private key that is used to create the HTTPS server.
|
|
|
|
# Migth be either absolute path or path related to tendermint's config directory.
|
2019-03-24 01:08:15 +08:00
|
|
|
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
|
|
|
tls_key_file = "{{ .RPC.TLSKeyFile }}"
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
##### peer to peer configuration options #####
|
|
|
|
[p2p]
|
|
|
|
|
|
|
|
# Address to listen for incoming connections
|
|
|
|
laddr = "{{ .P2P.ListenAddress }}"
|
|
|
|
|
2018-07-01 22:21:29 -04:00
|
|
|
# Address to advertise to peers for them to dial
|
|
|
|
# If empty, will use the same port as the laddr,
|
|
|
|
# and will introspect on the listener or use UPnP
|
|
|
|
# to figure out the address.
|
|
|
|
external_address = "{{ .P2P.ExternalAddress }}"
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
# Comma separated list of seed nodes to connect to
|
|
|
|
seeds = "{{ .P2P.Seeds }}"
|
|
|
|
|
|
|
|
# Comma separated list of nodes to keep persistent connections to
|
|
|
|
persistent_peers = "{{ .P2P.PersistentPeers }}"
|
|
|
|
|
2018-06-28 00:09:39 -07:00
|
|
|
# UPNP port forwarding
|
|
|
|
upnp = {{ .P2P.UPNP }}
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
# Path to address book
|
|
|
|
addr_book_file = "{{ js .P2P.AddrBook }}"
|
|
|
|
|
|
|
|
# Set true for strict address routability rules
|
2018-09-05 02:30:36 -04:00
|
|
|
# Set false for private or local networks
|
2018-06-20 17:35:30 -07:00
|
|
|
addr_book_strict = {{ .P2P.AddrBookStrict }}
|
|
|
|
|
2018-08-15 02:25:56 +04:00
|
|
|
# Maximum number of inbound peers
|
|
|
|
max_num_inbound_peers = {{ .P2P.MaxNumInboundPeers }}
|
|
|
|
|
|
|
|
# Maximum number of outbound peers to connect to, excluding persistent peers
|
|
|
|
max_num_outbound_peers = {{ .P2P.MaxNumOutboundPeers }}
|
2018-06-20 17:35:30 -07:00
|
|
|
|
2018-09-26 14:04:44 +04:00
|
|
|
# Time to wait before flushing messages out on the connection
|
|
|
|
flush_throttle_timeout = "{{ .P2P.FlushThrottleTimeout }}"
|
|
|
|
|
2018-06-29 12:17:26 +04:00
|
|
|
# Maximum size of a message packet payload, in bytes
|
|
|
|
max_packet_msg_payload_size = {{ .P2P.MaxPacketMsgPayloadSize }}
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
# Rate at which packets can be sent, in bytes/second
|
|
|
|
send_rate = {{ .P2P.SendRate }}
|
|
|
|
|
|
|
|
# Rate at which packets can be received, in bytes/second
|
|
|
|
recv_rate = {{ .P2P.RecvRate }}
|
|
|
|
|
|
|
|
# Set true to enable the peer-exchange reactor
|
|
|
|
pex = {{ .P2P.PexReactor }}
|
|
|
|
|
|
|
|
# Seed mode, in which node constantly crawls the network and looks for
|
|
|
|
# peers. If another node asks it for addresses, it responds and disconnects.
|
|
|
|
#
|
|
|
|
# Does not work if the peer-exchange reactor is disabled.
|
|
|
|
seed_mode = {{ .P2P.SeedMode }}
|
|
|
|
|
|
|
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
|
|
|
private_peer_ids = "{{ .P2P.PrivatePeerIDs }}"
|
|
|
|
|
2018-09-26 14:04:44 +04:00
|
|
|
# Toggle to disable guard against peers connecting from the same ip.
|
|
|
|
allow_duplicate_ip = {{ .P2P.AllowDuplicateIP }}
|
|
|
|
|
|
|
|
# Peer connection configuration.
|
|
|
|
handshake_timeout = "{{ .P2P.HandshakeTimeout }}"
|
|
|
|
dial_timeout = "{{ .P2P.DialTimeout }}"
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
##### mempool configuration options #####
|
|
|
|
[mempool]
|
|
|
|
|
|
|
|
recheck = {{ .Mempool.Recheck }}
|
|
|
|
broadcast = {{ .Mempool.Broadcast }}
|
|
|
|
wal_dir = "{{ js .Mempool.WalPath }}"
|
|
|
|
|
2019-02-23 19:32:31 +04:00
|
|
|
# Maximum number of transactions in the mempool
|
2018-06-20 17:35:30 -07:00
|
|
|
size = {{ .Mempool.Size }}
|
|
|
|
|
2019-02-23 19:32:31 +04:00
|
|
|
# Limit the total size of all txs in the mempool.
|
|
|
|
# This only accounts for raw transactions (e.g. given 1MB transactions and
|
|
|
|
# max_txs_bytes=5MB, mempool will only accept 5 transactions).
|
|
|
|
max_txs_bytes = {{ .Mempool.MaxTxsBytes }}
|
|
|
|
|
|
|
|
# Size of the cache (used to filter transactions we saw earlier) in transactions
|
2018-06-20 17:35:30 -07:00
|
|
|
cache_size = {{ .Mempool.CacheSize }}
|
|
|
|
|
2019-08-06 01:01:30 +09:00
|
|
|
# Maximum size of a single transaction.
|
|
|
|
# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}.
|
|
|
|
max_tx_bytes = {{ .Mempool.MaxTxBytes }}
|
2019-08-02 23:42:17 +04:00
|
|
|
|
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
2019-07-23 10:58:52 +02:00
|
|
|
##### fast sync configuration options #####
|
|
|
|
[fastsync]
|
|
|
|
|
|
|
|
# Fast Sync version to use:
|
|
|
|
# 1) "v0" (default) - the legacy fast sync implementation
|
|
|
|
# 2) "v1" - refactor of v0 version for better testability
|
|
|
|
version = "{{ .FastSync.Version }}"
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
##### consensus configuration options #####
|
|
|
|
[consensus]
|
|
|
|
|
|
|
|
wal_file = "{{ js .Consensus.WalPath }}"
|
|
|
|
|
2018-09-26 14:04:44 +04:00
|
|
|
timeout_propose = "{{ .Consensus.TimeoutPropose }}"
|
|
|
|
timeout_propose_delta = "{{ .Consensus.TimeoutProposeDelta }}"
|
|
|
|
timeout_prevote = "{{ .Consensus.TimeoutPrevote }}"
|
|
|
|
timeout_prevote_delta = "{{ .Consensus.TimeoutPrevoteDelta }}"
|
|
|
|
timeout_precommit = "{{ .Consensus.TimeoutPrecommit }}"
|
|
|
|
timeout_precommit_delta = "{{ .Consensus.TimeoutPrecommitDelta }}"
|
|
|
|
timeout_commit = "{{ .Consensus.TimeoutCommit }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
|
|
|
|
skip_timeout_commit = {{ .Consensus.SkipTimeoutCommit }}
|
|
|
|
|
2018-09-26 14:04:44 +04:00
|
|
|
# EmptyBlocks mode and possible interval between empty blocks
|
2018-06-20 17:35:30 -07:00
|
|
|
create_empty_blocks = {{ .Consensus.CreateEmptyBlocks }}
|
2018-09-26 14:04:44 +04:00
|
|
|
create_empty_blocks_interval = "{{ .Consensus.CreateEmptyBlocksInterval }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
|
2018-09-26 14:04:44 +04:00
|
|
|
# Reactor sleep duration parameters
|
|
|
|
peer_gossip_sleep_duration = "{{ .Consensus.PeerGossipSleepDuration }}"
|
|
|
|
peer_query_maj23_sleep_duration = "{{ .Consensus.PeerQueryMaj23SleepDuration }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
##### transactions indexer configuration options #####
|
|
|
|
[tx_index]
|
|
|
|
|
|
|
|
# What indexer to use for transactions
|
|
|
|
#
|
|
|
|
# Options:
|
2018-12-15 15:26:27 -05:00
|
|
|
# 1) "null"
|
|
|
|
# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
|
2018-06-20 17:35:30 -07:00
|
|
|
indexer = "{{ .TxIndex.Indexer }}"
|
|
|
|
|
2018-09-05 11:05:06 +04:00
|
|
|
# Comma-separated list of tags to index (by default the only tag is "tx.hash")
|
|
|
|
#
|
|
|
|
# You can also index transactions by height by adding "tx.height" tag here.
|
2018-06-20 17:35:30 -07:00
|
|
|
#
|
|
|
|
# It's recommended to index only a subset of tags due to possible memory
|
|
|
|
# bloat. This is, of course, depends on the indexer's DB and the volume of
|
|
|
|
# transactions.
|
|
|
|
index_tags = "{{ .TxIndex.IndexTags }}"
|
|
|
|
|
2018-09-05 11:05:06 +04:00
|
|
|
# When set to true, tells indexer to index all tags (predefined tags:
|
|
|
|
# "tx.hash", "tx.height" and all tags from DeliverTx responses).
|
|
|
|
#
|
|
|
|
# Note this may be not desirable (see the comment above). IndexTags has a
|
|
|
|
# precedence over IndexAllTags (i.e. when given both, IndexTags will be
|
|
|
|
# indexed).
|
2018-06-20 17:35:30 -07:00
|
|
|
index_all_tags = {{ .TxIndex.IndexAllTags }}
|
|
|
|
|
|
|
|
##### instrumentation configuration options #####
|
|
|
|
[instrumentation]
|
|
|
|
|
|
|
|
# When true, Prometheus metrics are served under /metrics on
|
|
|
|
# PrometheusListenAddr.
|
|
|
|
# Check out the documentation for the list of available metrics.
|
|
|
|
prometheus = {{ .Instrumentation.Prometheus }}
|
|
|
|
|
|
|
|
# Address to listen for Prometheus collector(s) connections
|
|
|
|
prometheus_listen_addr = "{{ .Instrumentation.PrometheusListenAddr }}"
|
2018-07-10 15:49:48 +04:00
|
|
|
|
|
|
|
# Maximum number of simultaneous connections.
|
2018-12-15 15:26:27 -05:00
|
|
|
# If you want to accept a larger number than the default, make sure
|
2018-07-10 15:49:48 +04:00
|
|
|
# you increase your OS limits.
|
|
|
|
# 0 - unlimited.
|
|
|
|
max_open_connections = {{ .Instrumentation.MaxOpenConnections }}
|
2018-09-25 04:14:38 -07:00
|
|
|
|
|
|
|
# Instrumentation namespace
|
|
|
|
namespace = "{{ .Instrumentation.Namespace }}"
|
2018-06-20 17:35:30 -07:00
|
|
|
`
|
|
|
|
|
|
|
|
/****** these are for test settings ***********/
|
|
|
|
|
|
|
|
func ResetTestRoot(testName string) *Config {
|
2019-01-25 22:10:36 +09:00
|
|
|
return ResetTestRootWithChainID(testName, "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResetTestRootWithChainID(testName string, chainID string) *Config {
|
2019-02-18 08:45:27 +01:00
|
|
|
// create a unique, concurrency-safe test directory under os.TempDir()
|
|
|
|
rootDir, err := ioutil.TempDir("", fmt.Sprintf("%s-%s_", chainID, testName))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
2019-02-18 08:45:27 +01:00
|
|
|
// ensure config and data subdirs are created
|
|
|
|
if err := cmn.EnsureDir(filepath.Join(rootDir, defaultConfigDir), DefaultDirPerm); err != nil {
|
|
|
|
panic(err)
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
2019-02-18 08:45:27 +01:00
|
|
|
if err := cmn.EnsureDir(filepath.Join(rootDir, defaultDataDir), DefaultDirPerm); err != nil {
|
|
|
|
panic(err)
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
baseConfig := DefaultBaseConfig()
|
|
|
|
configFilePath := filepath.Join(rootDir, defaultConfigFilePath)
|
|
|
|
genesisFilePath := filepath.Join(rootDir, baseConfig.Genesis)
|
2018-12-22 05:58:27 +08:00
|
|
|
privKeyFilePath := filepath.Join(rootDir, baseConfig.PrivValidatorKey)
|
|
|
|
privStateFilePath := filepath.Join(rootDir, baseConfig.PrivValidatorState)
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
// Write default config file if missing.
|
|
|
|
if !cmn.FileExists(configFilePath) {
|
|
|
|
writeDefaultConfigFile(configFilePath)
|
|
|
|
}
|
|
|
|
if !cmn.FileExists(genesisFilePath) {
|
2019-01-25 22:10:36 +09:00
|
|
|
if chainID == "" {
|
|
|
|
chainID = "tendermint_test"
|
|
|
|
}
|
|
|
|
testGenesis := fmt.Sprintf(testGenesisFmt, chainID)
|
2018-06-20 17:35:30 -07:00
|
|
|
cmn.MustWriteFile(genesisFilePath, []byte(testGenesis), 0644)
|
|
|
|
}
|
|
|
|
// we always overwrite the priv val
|
2018-12-22 05:58:27 +08:00
|
|
|
cmn.MustWriteFile(privKeyFilePath, []byte(testPrivValidatorKey), 0644)
|
|
|
|
cmn.MustWriteFile(privStateFilePath, []byte(testPrivValidatorState), 0644)
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
config := TestConfig().SetRoot(rootDir)
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
|
2019-01-25 22:10:36 +09:00
|
|
|
var testGenesisFmt = `{
|
2018-11-01 07:07:18 +01:00
|
|
|
"genesis_time": "2018-10-10T08:20:13.695936996Z",
|
2019-01-25 22:10:36 +09:00
|
|
|
"chain_id": "%s",
|
2018-06-20 17:35:30 -07:00
|
|
|
"validators": [
|
|
|
|
{
|
|
|
|
"pub_key": {
|
|
|
|
"type": "tendermint/PubKeyEd25519",
|
|
|
|
"value":"AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="
|
|
|
|
},
|
|
|
|
"power": "10",
|
|
|
|
"name": ""
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"app_hash": ""
|
|
|
|
}`
|
|
|
|
|
2018-12-22 05:58:27 +08:00
|
|
|
var testPrivValidatorKey = `{
|
2018-06-20 17:35:30 -07:00
|
|
|
"address": "A3258DCBF45DCA0DF052981870F2D1441A36D145",
|
|
|
|
"pub_key": {
|
|
|
|
"type": "tendermint/PubKeyEd25519",
|
|
|
|
"value": "AT/+aaL1eB0477Mud9JMm8Sh8BIvOYlPGC9KkIUmFaE="
|
|
|
|
},
|
|
|
|
"priv_key": {
|
|
|
|
"type": "tendermint/PrivKeyEd25519",
|
|
|
|
"value": "EVkqJO/jIXp3rkASXfh9YnyToYXRXhBr6g9cQVxPFnQBP/5povV4HTjvsy530kybxKHwEi85iU8YL0qQhSYVoQ=="
|
2018-12-22 05:58:27 +08:00
|
|
|
}
|
|
|
|
}`
|
|
|
|
|
|
|
|
var testPrivValidatorState = `{
|
|
|
|
"height": "0",
|
|
|
|
"round": "0",
|
|
|
|
"step": 0
|
2018-06-20 17:35:30 -07:00
|
|
|
}`
|