|
|
@ -53,16 +53,14 @@ var ( |
|
|
|
defaultPrivValKeyName = "priv_validator_key.json" |
|
|
|
defaultPrivValStateName = "priv_validator_state.json" |
|
|
|
|
|
|
|
defaultNodeKeyName = "node_key.json" |
|
|
|
defaultAddrBookName = "addrbook.json" |
|
|
|
defaultNodeKeyName = "node_key.json" |
|
|
|
|
|
|
|
defaultConfigFilePath = filepath.Join(defaultConfigDir, defaultConfigFileName) |
|
|
|
defaultGenesisJSONPath = filepath.Join(defaultConfigDir, defaultGenesisJSONName) |
|
|
|
defaultPrivValKeyPath = filepath.Join(defaultConfigDir, defaultPrivValKeyName) |
|
|
|
defaultPrivValStatePath = filepath.Join(defaultDataDir, defaultPrivValStateName) |
|
|
|
|
|
|
|
defaultNodeKeyPath = filepath.Join(defaultConfigDir, defaultNodeKeyName) |
|
|
|
defaultAddrBookPath = filepath.Join(defaultConfigDir, defaultAddrBookName) |
|
|
|
defaultNodeKeyPath = filepath.Join(defaultConfigDir, defaultNodeKeyName) |
|
|
|
) |
|
|
|
|
|
|
|
// Config defines the top level configuration for a Tendermint node
|
|
|
@ -141,9 +139,6 @@ func (cfg *Config) ValidateBasic() error { |
|
|
|
if err := cfg.RPC.ValidateBasic(); err != nil { |
|
|
|
return fmt.Errorf("error in [rpc] section: %w", err) |
|
|
|
} |
|
|
|
if err := cfg.P2P.ValidateBasic(); err != nil { |
|
|
|
return fmt.Errorf("error in [p2p] section: %w", err) |
|
|
|
} |
|
|
|
if err := cfg.Mempool.ValidateBasic(); err != nil { |
|
|
|
return fmt.Errorf("error in [mempool] section: %w", err) |
|
|
|
} |
|
|
@ -646,25 +641,6 @@ type P2PConfig struct { //nolint: maligned |
|
|
|
// UPNP port forwarding
|
|
|
|
UPNP bool `mapstructure:"upnp"` |
|
|
|
|
|
|
|
// Path to address book
|
|
|
|
AddrBook string `mapstructure:"addr-book-file"` |
|
|
|
|
|
|
|
// Set true for strict address routability rules
|
|
|
|
// Set false for private or local networks
|
|
|
|
AddrBookStrict bool `mapstructure:"addr-book-strict"` |
|
|
|
|
|
|
|
// Maximum number of inbound peers
|
|
|
|
//
|
|
|
|
// TODO: Remove once p2p refactor is complete in favor of MaxConnections.
|
|
|
|
// ref: https://github.com/tendermint/tendermint/issues/5670
|
|
|
|
MaxNumInboundPeers int `mapstructure:"max-num-inbound-peers"` |
|
|
|
|
|
|
|
// Maximum number of outbound peers to connect to, excluding persistent peers.
|
|
|
|
//
|
|
|
|
// TODO: Remove once p2p refactor is complete in favor of MaxConnections.
|
|
|
|
// ref: https://github.com/tendermint/tendermint/issues/5670
|
|
|
|
MaxNumOutboundPeers int `mapstructure:"max-num-outbound-peers"` |
|
|
|
|
|
|
|
// MaxConnections defines the maximum number of connected peers (inbound and
|
|
|
|
// outbound).
|
|
|
|
MaxConnections uint16 `mapstructure:"max-connections"` |
|
|
@ -673,24 +649,6 @@ type P2PConfig struct { //nolint: maligned |
|
|
|
// attempts per IP address.
|
|
|
|
MaxIncomingConnectionAttempts uint `mapstructure:"max-incoming-connection-attempts"` |
|
|
|
|
|
|
|
// List of node IDs, to which a connection will be (re)established ignoring any existing limits
|
|
|
|
UnconditionalPeerIDs string `mapstructure:"unconditional-peer-ids"` |
|
|
|
|
|
|
|
// Maximum pause when redialing a persistent peer (if zero, exponential backoff is used)
|
|
|
|
PersistentPeersMaxDialPeriod time.Duration `mapstructure:"persistent-peers-max-dial-period"` |
|
|
|
|
|
|
|
// Time to wait before flushing messages out on the connection
|
|
|
|
FlushThrottleTimeout time.Duration `mapstructure:"flush-throttle-timeout"` |
|
|
|
|
|
|
|
// Maximum size of a message packet payload, in bytes
|
|
|
|
MaxPacketMsgPayloadSize int `mapstructure:"max-packet-msg-payload-size"` |
|
|
|
|
|
|
|
// Rate at which packets can be sent, in bytes/second
|
|
|
|
SendRate int64 `mapstructure:"send-rate"` |
|
|
|
|
|
|
|
// Rate at which packets can be received, in bytes/second
|
|
|
|
RecvRate int64 `mapstructure:"recv-rate"` |
|
|
|
|
|
|
|
// Set true to enable the peer-exchange reactor
|
|
|
|
PexReactor bool `mapstructure:"pex"` |
|
|
|
|
|
|
@ -721,28 +679,14 @@ func DefaultP2PConfig() *P2PConfig { |
|
|
|
ListenAddress: "tcp://0.0.0.0:26656", |
|
|
|
ExternalAddress: "", |
|
|
|
UPNP: false, |
|
|
|
AddrBook: defaultAddrBookPath, |
|
|
|
AddrBookStrict: true, |
|
|
|
MaxNumInboundPeers: 40, |
|
|
|
MaxNumOutboundPeers: 10, |
|
|
|
MaxConnections: 64, |
|
|
|
MaxIncomingConnectionAttempts: 100, |
|
|
|
PersistentPeersMaxDialPeriod: 0 * time.Second, |
|
|
|
FlushThrottleTimeout: 100 * time.Millisecond, |
|
|
|
// The MTU (Maximum Transmission Unit) for Ethernet is 1500 bytes.
|
|
|
|
// The IP header and the TCP header take up 20 bytes each at least (unless
|
|
|
|
// optional header fields are used) and thus the max for (non-Jumbo frame)
|
|
|
|
// Ethernet is 1500 - 20 -20 = 1460
|
|
|
|
// Source: https://stackoverflow.com/a/3074427/820520
|
|
|
|
MaxPacketMsgPayloadSize: 1400, |
|
|
|
SendRate: 5120000, // 5 mB/s
|
|
|
|
RecvRate: 5120000, // 5 mB/s
|
|
|
|
PexReactor: true, |
|
|
|
AllowDuplicateIP: false, |
|
|
|
HandshakeTimeout: 20 * time.Second, |
|
|
|
DialTimeout: 3 * time.Second, |
|
|
|
TestDialFail: false, |
|
|
|
QueueType: "priority", |
|
|
|
PexReactor: true, |
|
|
|
AllowDuplicateIP: false, |
|
|
|
HandshakeTimeout: 20 * time.Second, |
|
|
|
DialTimeout: 3 * time.Second, |
|
|
|
TestDialFail: false, |
|
|
|
QueueType: "priority", |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -750,43 +694,10 @@ func DefaultP2PConfig() *P2PConfig { |
|
|
|
func TestP2PConfig() *P2PConfig { |
|
|
|
cfg := DefaultP2PConfig() |
|
|
|
cfg.ListenAddress = "tcp://127.0.0.1:36656" |
|
|
|
cfg.FlushThrottleTimeout = 10 * time.Millisecond |
|
|
|
cfg.AllowDuplicateIP = true |
|
|
|
return cfg |
|
|
|
} |
|
|
|
|
|
|
|
// AddrBookFile returns the full path to the address book
|
|
|
|
func (cfg *P2PConfig) AddrBookFile() string { |
|
|
|
return rootify(cfg.AddrBook, cfg.RootDir) |
|
|
|
} |
|
|
|
|
|
|
|
// ValidateBasic performs basic validation (checking param bounds, etc.) and
|
|
|
|
// returns an error if any check fails.
|
|
|
|
func (cfg *P2PConfig) ValidateBasic() error { |
|
|
|
if cfg.MaxNumInboundPeers < 0 { |
|
|
|
return errors.New("max-num-inbound-peers can't be negative") |
|
|
|
} |
|
|
|
if cfg.MaxNumOutboundPeers < 0 { |
|
|
|
return errors.New("max-num-outbound-peers can't be negative") |
|
|
|
} |
|
|
|
if cfg.FlushThrottleTimeout < 0 { |
|
|
|
return errors.New("flush-throttle-timeout can't be negative") |
|
|
|
} |
|
|
|
if cfg.PersistentPeersMaxDialPeriod < 0 { |
|
|
|
return errors.New("persistent-peers-max-dial-period can't be negative") |
|
|
|
} |
|
|
|
if cfg.MaxPacketMsgPayloadSize < 0 { |
|
|
|
return errors.New("max-packet-msg-payload-size can't be negative") |
|
|
|
} |
|
|
|
if cfg.SendRate < 0 { |
|
|
|
return errors.New("send-rate can't be negative") |
|
|
|
} |
|
|
|
if cfg.RecvRate < 0 { |
|
|
|
return errors.New("recv-rate can't be negative") |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// MempoolConfig
|
|
|
|
|
|
|
|