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.

188 lines
5.9 KiB

p2p: introduce peerConn to simplify peer creation (#1226) * expose AuthEnc in the P2P config if AuthEnc is true, dialed peers must have a node ID in the address and it must match the persistent pubkey from the secret handshake. Refs #1157 * fixes after my own review * fix docs * fix build failure ``` p2p/pex/pex_reactor_test.go:288:88: cannot use seed.NodeInfo().NetAddress() (type *p2p.NetAddress) as type string in array or slice literal ``` * p2p: introduce peerConn to simplify peer creation * Introduce `peerConn` containing the known fields of `peer` * `peer` only created in `sw.addPeer` once handshake is complete and NodeInfo is checked * Eliminates some mutable variables and makes the code flow better * Simplifies the `newXxxPeer` funcs * Use ID instead of PubKey where possible. * SetPubKeyFilter -> SetIDFilter * nodeInfo.Validate takes ID * remove peer.PubKey() * persistent node ids * fixes from review * test: use ip_plus_id.sh more * fix invalid memory panic during fast_sync test ``` 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: panic: runtime error: invalid memory address or nil pointer dereference 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x98dd3e] 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: goroutine 3432 [running]: 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.newOutboundPeerConn(0xc423fd1380, 0xc420933e00, 0x1, 0x1239a60, 0 xc420128c40, 0x2, 0x42caf6, 0xc42001f300, 0xc422831d98, 0xc4227951c0, ...) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #011/go/src/github.com/tendermint/tendermint/p2p/peer.go:123 +0x31e 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.(*Switch).addOutboundPeerWithConfig(0xc4200ad040, 0xc423fd1380, 0 xc420933e00, 0xc423f48801, 0x28, 0x2) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #011/go/src/github.com/tendermint/tendermint/p2p/switch.go:455 +0x12b 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.(*Switch).DialPeerWithAddress(0xc4200ad040, 0xc423fd1380, 0x1, 0x 0, 0x0) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #011/go/src/github.com/tendermint/tendermint/p2p/switch.go:371 +0xdc 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: github.com/tendermint/tendermint/p2p.(*Switch).reconnectToPeer(0xc4200ad040, 0x123e000, 0xc42007bb00) 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #011/go/src/github.com/tendermint/tendermint/p2p/switch.go:290 +0x25f 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: created by github.com/tendermint/tendermint/p2p.(*Switch).StopPeerForError 2018-02-21T06:30:05Z box887.localdomain docker/local_testnet_4[14907]: #011/go/src/github.com/tendermint/tendermint/p2p/switch.go:256 +0x1b7 ```
7 years ago
  1. Configuration
  2. =============
  3. Tendermint Core can be configured via a TOML file in
  4. ``$TMHOME/config/config.toml``. Some of these parameters can be overridden by
  5. command-line flags. For most users, the options in the ``##### main
  6. base configuration options #####`` are intended to be modified while
  7. config options further below are intended for advance power users.
  8. Config options
  9. ~~~~~~~~~~~~~~
  10. The default configuration file create by ``tendermint init`` has all
  11. the parameters set with their default values. It will look something
  12. like the file below, however, double check by inspecting the
  13. ``config.toml`` created with your version of ``tendermint`` installed:
  14. ::
  15. # This is a TOML config file.
  16. # For more information, see https://github.com/toml-lang/toml
  17. ##### main base config options #####
  18. # TCP or UNIX socket address of the ABCI application,
  19. # or the name of an ABCI application compiled in with the Tendermint binary
  20. proxy_app = "tcp://127.0.0.1:46658"
  21. # A custom human readable name for this node
  22. moniker = "anonymous"
  23. # If this node is many blocks behind the tip of the chain, FastSync
  24. # allows them to catchup quickly by downloading blocks in parallel
  25. # and verifying their commits
  26. fast_sync = true
  27. # Database backend: leveldb | memdb
  28. db_backend = "leveldb"
  29. # Database directory
  30. db_path = "data"
  31. # Output level for logging
  32. log_level = "state:info,*:error"
  33. ##### additional base config options #####
  34. # The ID of the chain to join (should be signed with every transaction and vote)
  35. chain_id = ""
  36. # Path to the JSON file containing the initial validator set and other meta data
  37. genesis_file = "genesis.json"
  38. # Path to the JSON file containing the private key to use as a validator in the consensus protocol
  39. priv_validator_file = "priv_validator.json"
  40. # Mechanism to connect to the ABCI application: socket | grpc
  41. abci = "socket"
  42. # TCP or UNIX socket address for the profiling server to listen on
  43. prof_laddr = ""
  44. # If true, query the ABCI app on connecting to a new peer
  45. # so the app can decide if we should keep the connection or not
  46. filter_peers = false
  47. ##### advanced configuration options #####
  48. ##### rpc server configuration options #####
  49. [rpc]
  50. # TCP or UNIX socket address for the RPC server to listen on
  51. laddr = "tcp://0.0.0.0:46657"
  52. # TCP or UNIX socket address for the gRPC server to listen on
  53. # NOTE: This server only supports /broadcast_tx_commit
  54. grpc_laddr = ""
  55. # Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool
  56. unsafe = false
  57. ##### peer to peer configuration options #####
  58. [p2p]
  59. # Address to listen for incoming connections
  60. laddr = "tcp://0.0.0.0:46656"
  61. # Comma separated list of seed nodes to connect to
  62. seeds = ""
  63. # Comma separated list of nodes to keep persistent connections to
  64. # Do not add private peers to this list if you don't want them advertised
  65. persistent_peers = ""
  66. # Path to address book
  67. addr_book_file = "addrbook.json"
  68. # Set true for strict address routability rules
  69. addr_book_strict = true
  70. # Time to wait before flushing messages out on the connection, in ms
  71. flush_throttle_timeout = 100
  72. # Maximum number of peers to connect to
  73. max_num_peers = 50
  74. # Maximum size of a message packet payload, in bytes
  75. max_msg_packet_payload_size = 1024
  76. # Rate at which packets can be sent, in bytes/second
  77. send_rate = 512000
  78. # Rate at which packets can be received, in bytes/second
  79. recv_rate = 512000
  80. # Set true to enable the peer-exchange reactor
  81. pex = true
  82. # Seed mode, in which node constantly crawls the network and looks for
  83. # peers. If another node asks it for addresses, it responds and disconnects.
  84. #
  85. # Does not work if the peer-exchange reactor is disabled.
  86. seed_mode = false
  87. # Authenticated encryption
  88. auth_enc = true
  89. # Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
  90. private_peer_ids = ""
  91. ##### mempool configuration options #####
  92. [mempool]
  93. recheck = true
  94. recheck_empty = true
  95. broadcast = true
  96. wal_dir = "data/mempool.wal"
  97. ##### consensus configuration options #####
  98. [consensus]
  99. wal_file = "data/cs.wal/wal"
  100. # All timeouts are in milliseconds
  101. timeout_propose = 3000
  102. timeout_propose_delta = 500
  103. timeout_prevote = 1000
  104. timeout_prevote_delta = 500
  105. timeout_precommit = 1000
  106. timeout_precommit_delta = 500
  107. timeout_commit = 1000
  108. # Make progress as soon as we have all the precommits (as if TimeoutCommit = 0)
  109. skip_timeout_commit = false
  110. # BlockSize
  111. max_block_size_txs = 10000
  112. max_block_size_bytes = 1
  113. # EmptyBlocks mode and possible interval between empty blocks in seconds
  114. create_empty_blocks = true
  115. create_empty_blocks_interval = 0
  116. # Reactor sleep duration parameters are in milliseconds
  117. peer_gossip_sleep_duration = 100
  118. peer_query_maj23_sleep_duration = 2000
  119. ##### transactions indexer configuration options #####
  120. [tx_index]
  121. # What indexer to use for transactions
  122. #
  123. # Options:
  124. # 1) "null" (default)
  125. # 2) "kv" - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
  126. indexer = "{{ .TxIndex.Indexer }}"
  127. # Comma-separated list of tags to index (by default the only tag is tx hash)
  128. #
  129. # It's recommended to index only a subset of tags due to possible memory
  130. # bloat. This is, of course, depends on the indexer's DB and the volume of
  131. # transactions.
  132. index_tags = "{{ .TxIndex.IndexTags }}"
  133. # When set to true, tells indexer to index all tags. Note this may be not
  134. # desirable (see the comment above). IndexTags has a precedence over
  135. # IndexAllTags (i.e. when given both, IndexTags will be indexed).
  136. index_all_tags = {{ .TxIndex.IndexAllTags }}