config: move P2P options to a separate config section

And convert time-related settings to a Duration format along the way.
This commit is contained in:
Anna Shaleva 2022-12-06 22:35:37 +03:00
parent 9cf6cc61f4
commit 54c2aa8582
19 changed files with 340 additions and 192 deletions

View file

@ -113,10 +113,25 @@ array of "address:port:announcedPort" tuples in the `ApplicationConfiguration`'s
`Addresses` node config section. Deprecated `Address` and `Port` sections of `Addresses` node config section. Deprecated `Address` and `Port` sections of
`RPC`, `Prometheus`, `Pprof` subsections of the `ApplicationConfiguration` `RPC`, `Prometheus`, `Pprof` subsections of the `ApplicationConfiguration`
as far as the one of RPC server's `TLSConfig` are still available, but will be as far as the one of RPC server's `TLSConfig` are still available, but will be
removed, so please convert your node configuration file to use new `Addresses` removed, so please convert your node configuration file to use new `P2P`-level
section for the node services. Deprecated `Address`, `NodePort` and `AnnouncedPort` `Addresses` section for the node services. Deprecated `Address`, `NodePort` and
sections of `ApplicationConfiguration` will also be removed eventually, so please `AnnouncedPort` sections of `ApplicationConfiguration` will also be removed
update your node configuration file to use `Addresses` section for the P2P eventually, so please update your node configuration file to use `Addresses`
addresses configuration. section for the P2P addresses configuration.
Removal of these config sections is scheduled for May-June 2023 (~0.103.0 release). Removal of these config sections is scheduled for May-June 2023 (~0.103.0 release).
## P2P application settings configuration
Version 0.100.0 of NeoGo marks the following P2P application settings as
deprecated: `AttemptConnPeers`, `BroadcastFactor`, `DialTimeout`,
`ExtensiblePoolSize`, `MaxPeers`, `MinPeers`, `PingInterval`, `PingTimeout`,
`ProtoTickInterval`. These settings are moved to a separate `P2P` section of
`ApplicationConfiguration`. The `DialTimeout`, `PingInterval`, `PingTimeout`,
`ProtoTickInterval` settings are converted to more precise `Duration` format
(allowing for subsecond time). Please, update your node configuration (all you
need is to move specified settings under the `P2P` section and convert
time-related settings to `Duration` format).
Removal of deprecated P2P related application settings is scheduled for May-June
2023 (~0.103.0 release).

View file

@ -47,16 +47,17 @@ ApplicationConfiguration:
DataDirectoryPath: "./chains/mainnet.neofs" DataDirectoryPath: "./chains/mainnet.neofs"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/mainnet.bolt" # FilePath: "./chains/mainnet.bolt"
P2P:
Addresses: Addresses:
- ":40333" # in form of "[host]:[port][:announcedPort]" - ":40333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 100 MaxPeers: 100
AttemptConnPeers: 20 AttemptConnPeers: 20
MinPeers: 5 MinPeers: 5
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -59,16 +59,17 @@ ApplicationConfiguration:
DataDirectoryPath: "./chains/mainnet" DataDirectoryPath: "./chains/mainnet"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/mainnet.bolt" # FilePath: "./chains/mainnet.bolt"
P2P:
Addresses: Addresses:
- ":10333" # in form of "[host]:[port][:announcedPort]" - ":10333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 100 MaxPeers: 100
AttemptConnPeers: 20 AttemptConnPeers: 20
MinPeers: 10 MinPeers: 10
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -38,17 +38,17 @@ ApplicationConfiguration:
DataDirectoryPath: "/chains/four" DataDirectoryPath: "/chains/four"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/privnet.bolt" # FilePath: "./chains/privnet.bolt"
# Uncomment in order to set up custom address for node. P2P:
Addresses: Addresses:
- ":20336" # in form of "[host]:[port][:announcedPort]" - ":20336" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 3 MinPeers: 3
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -38,16 +38,17 @@ ApplicationConfiguration:
DataDirectoryPath: "/chains/one" DataDirectoryPath: "/chains/one"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/privnet.bolt" # FilePath: "./chains/privnet.bolt"
P2P:
Addresses: Addresses:
- ":20333" # in form of "[host]:[port][:announcedPort]" - ":20333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 3 MinPeers: 3
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -32,16 +32,17 @@ ApplicationConfiguration:
DataDirectoryPath: "/chains/single" DataDirectoryPath: "/chains/single"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/privnet.bolt" # FilePath: "./chains/privnet.bolt"
P2P:
Addresses: Addresses:
- ":20333" # in form of "[host]:[port][:announcedPort]" - ":20333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 0 MinPeers: 0
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -38,16 +38,17 @@ ApplicationConfiguration:
DataDirectoryPath: "/chains/three" DataDirectoryPath: "/chains/three"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/privnet.bolt" # FilePath: "./chains/privnet.bolt"
P2P:
Addresses: Addresses:
- ":20335" # in form of "[host]:[port][:announcedPort]" - ":20335" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 3 MinPeers: 3
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -38,16 +38,17 @@ ApplicationConfiguration:
DataDirectoryPath: "/chains/two" DataDirectoryPath: "/chains/two"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/privnet.bolt" # FilePath: "./chains/privnet.bolt"
P2P:
Addresses: Addresses:
- ":20334" # in form of "[host]:[port][:announcedPort]" - ":20334" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 3 MinPeers: 3
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -38,16 +38,17 @@ ApplicationConfiguration:
DataDirectoryPath: "./chains/privnet" DataDirectoryPath: "./chains/privnet"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/privnet.bolt" # FilePath: "./chains/privnet.bolt"
P2P:
Addresses: Addresses:
- ":20332" # in form of "[host]:[port][:announcedPort]" - ":20332" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 3 MinPeers: 3
Relay: true
P2PNotary: P2PNotary:
Enabled: false Enabled: false
UnlockWallet: UnlockWallet:

View file

@ -47,16 +47,17 @@ ApplicationConfiguration:
DataDirectoryPath: "./chains/testnet.neofs" DataDirectoryPath: "./chains/testnet.neofs"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/testnet.bolt" # FilePath: "./chains/testnet.bolt"
P2P:
Addresses: Addresses:
- ":50333" # in form of "[host]:[port][:announcedPort]" - ":50333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 100 MaxPeers: 100
AttemptConnPeers: 20 AttemptConnPeers: 20
MinPeers: 5 MinPeers: 5
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -62,16 +62,17 @@ ApplicationConfiguration:
DataDirectoryPath: "./chains/testnet" DataDirectoryPath: "./chains/testnet"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/testnet.bolt" # FilePath: "./chains/testnet.bolt"
P2P:
Addresses: Addresses:
- ":20333" # in form of "[host]:[port][:announcedPort]" - ":20333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 100 MaxPeers: 100
AttemptConnPeers: 20 AttemptConnPeers: 20
MinPeers: 10 MinPeers: 10
Relay: true
Oracle: Oracle:
Enabled: false Enabled: false
AllowedContentTypes: AllowedContentTypes:

View file

@ -33,16 +33,17 @@ ApplicationConfiguration:
# DataDirectoryPath: "./chains/unit_testnet" # DataDirectoryPath: "./chains/unit_testnet"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/unit_testnet.bolt" # FilePath: "./chains/unit_testnet.bolt"
P2P:
Addresses: Addresses:
- ":0" # in form of "[host]:[port][:announcedPort]" - ":0" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MinPeers: 0 MinPeers: 0
MaxPeers: 10 MaxPeers: 10
AttemptConnPeers: 5 AttemptConnPeers: 5
Relay: true
UnlockWallet: UnlockWallet:
Path: "../testdata/wallet1_solo.json" Path: "../testdata/wallet1_solo.json"
Password: "one" Password: "one"

View file

@ -42,16 +42,17 @@ ApplicationConfiguration:
# DataDirectoryPath: "./chains/unit_testnet" # DataDirectoryPath: "./chains/unit_testnet"
# BoltDBOptions: # BoltDBOptions:
# FilePath: "./chains/unit_testnet.bolt" # FilePath: "./chains/unit_testnet.bolt"
P2P:
Addresses: Addresses:
- ":20333" # in form of "[host]:[port][:announcedPort]" - ":20333" # in form of "[host]:[port][:announcedPort]"
Relay: true DialTimeout: 3s
DialTimeout: 3 ProtoTickInterval: 2s
ProtoTickInterval: 2 PingInterval: 30s
PingInterval: 30 PingTimeout: 90s
PingTimeout: 90
MaxPeers: 50 MaxPeers: 50
AttemptConnPeers: 5 AttemptConnPeers: 5
MinPeers: 0 MinPeers: 0
Relay: true
P2PNotary: P2PNotary:
Enabled: false Enabled: false
UnlockWallet: UnlockWallet:

View file

@ -18,29 +18,75 @@ node-related settings described in the table below.
| --- | --- | --- | --- | | --- | --- | --- | --- |
| Address | `string` | `0.0.0.0` | Node address that P2P protocol handler binds to. Warning: this field is deprecated, please, use `Addresses` instead. | | Address | `string` | `0.0.0.0` | Node address that P2P protocol handler binds to. Warning: this field is deprecated, please, use `Addresses` instead. |
| AnnouncedPort | `uint16` | Same as `NodePort` | Node port which should be used to announce node's port on P2P layer, it can differ from the `NodePort` the node is bound to (for example, if your node is behind NAT). Warning: this field is deprecated, please, use `Addresses` instead. | | AnnouncedPort | `uint16` | Same as `NodePort` | Node port which should be used to announce node's port on P2P layer, it can differ from the `NodePort` the node is bound to (for example, if your node is behind NAT). Warning: this field is deprecated, please, use `Addresses` instead. |
| Addresses | `[]string` | `["0.0.0.0:0"]`, which is any free port on all available addresses | List of the node addresses that P2P protocol handler binds to. Each address has the form of `[address]:[nodePort][:announcedPort]` where `address` is the address itself, `nodePort` is the actual P2P port node listens at; `announcedPort` is the node port which should be used to announce node's port on P2P layer, it can differ from the `nodePort` the node is bound to if specified (for example, if your node is behind NAT).| | AttemptConnPeers | `int` | `20` | Number of connection to try to establish when the connection count drops below the `MinPeers` value. Warning: this field is deprecated and moved to `P2P` section. |
| AttemptConnPeers | `int` | `20` | Number of connection to try to establish when the connection count drops below the `MinPeers` value.| | BroadcastFactor | `int` | `0` | Multiplier that is used to determine the number of optimal gossip fan-out peer number for broadcasted messages (0-100). By default it's zero, node uses the most optimized value depending on the estimated network size (`2.5×log(size)`), so the node may have 20 peers and calculate that it needs to broadcast messages to just 10 of them. With BroadcastFactor set to 100 it will always send messages to all peers, any value in-between 0 and 100 is used for weighted calculation, for example if it's 30 then 13 neighbors will be used in the previous case. Warning: this field is deprecated and moved to `P2P` section. |
| BroadcastFactor | `int` | `0` | Multiplier that is used to determine the number of optimal gossip fan-out peer number for broadcasted messages (0-100). By default it's zero, node uses the most optimized value depending on the estimated network size (`2.5×log(size)`), so the node may have 20 peers and calculate that it needs to broadcast messages to just 10 of them. With BroadcastFactor set to 100 it will always send messages to all peers, any value in-between 0 and 100 is used for weighted calculation, for example if it's 30 then 13 neighbors will be used in the previous case. |
| DBConfiguration | [DB Configuration](#DB-Configuration) | | Describes configuration for database. See the [DB Configuration](#DB-Configuration) section for details. | | DBConfiguration | [DB Configuration](#DB-Configuration) | | Describes configuration for database. See the [DB Configuration](#DB-Configuration) section for details. |
| DialTimeout | `int64` | `0` | Maximum duration a single dial may take in seconds. | | DialTimeout | `int64` | `0` | Maximum duration a single dial may take in seconds. Warning: this field is deprecated and moved to `P2P` section. |
| ExtensiblePoolSize | `int` | `20` | Maximum amount of the extensible payloads from a single sender stored in a local pool. | | ExtensiblePoolSize | `int` | `20` | Maximum amount of the extensible payloads from a single sender stored in a local pool. Warning: this field is deprecated and moved to `P2P` section. |
| LogLevel | `string` | "info" | Minimal logged messages level (can be "debug", "info", "warn", "error", "dpanic", "panic" or "fatal"). | | LogLevel | `string` | "info" | Minimal logged messages level (can be "debug", "info", "warn", "error", "dpanic", "panic" or "fatal"). |
| LogPath | `string` | "", so only console logging | File path where to store node logs. | | LogPath | `string` | "", so only console logging | File path where to store node logs. |
| MaxPeers | `int` | `100` | Maximum numbers of peers that can be connected to the server. | | MaxPeers | `int` | `100` | Maximum numbers of peers that can be connected to the server. Warning: this field is deprecated and moved to `P2P` section. |
| MinPeers | `int` | `5` | Minimum number of peers for normal operation; when the node has less than this number of peers it tries to connect with some new ones. | | MinPeers | `int` | `5` | Minimum number of peers for normal operation; when the node has less than this number of peers it tries to connect with some new ones. Warning: this field is deprecated and moved to `P2P` section. |
| NodePort | `uint16` | `0`, which is any free port | The actual node port it is bound to. Warning: this field is deprecated, please, use `Addresses` instead. | | NodePort | `uint16` | `0`, which is any free port | The actual node port it is bound to. Warning: this field is deprecated, please, use `Addresses` instead. |
| Oracle | [Oracle Configuration](#Oracle-Configuration) | | Oracle module configuration. See the [Oracle Configuration](#Oracle-Configuration) section for details. | | Oracle | [Oracle Configuration](#Oracle-Configuration) | | Oracle module configuration. See the [Oracle Configuration](#Oracle-Configuration) section for details. |
| P2P | [P2P Configuration](#P2P-Configuration) | | Configuration values for P2P network interaction. See the [P2P Configuration](#P2P-Configuration) section for details. |
| P2PNotary | [P2P Notary Configuration](#P2P-Notary-Configuration) | | P2P Notary module configuration. See the [P2P Notary Configuration](#P2P-Notary-Configuration) section for details. | | P2PNotary | [P2P Notary Configuration](#P2P-Notary-Configuration) | | P2P Notary module configuration. See the [P2P Notary Configuration](#P2P-Notary-Configuration) section for details. |
| PingInterval | `int64` | `30` | Interval in seconds used in pinging mechanism for syncing blocks. | | PingInterval | `int64` | `30` | Interval in seconds used in pinging mechanism for syncing blocks. Warning: this field is deprecated and moved to `P2P` section. |
| PingTimeout | `int64` | `90` | Time to wait for pong (response for sent ping request). | | PingTimeout | `int64` | `90` | Time to wait for pong (response for sent ping request). Warning: this field is deprecated and moved to `P2P` section. |
| Pprof | [Metrics Services Configuration](#Metrics-Services-Configuration) | | Configuration for pprof service (profiling statistics gathering). See the [Metrics Services Configuration](#Metrics-Services-Configuration) section for details. | | Pprof | [Metrics Services Configuration](#Metrics-Services-Configuration) | | Configuration for pprof service (profiling statistics gathering). See the [Metrics Services Configuration](#Metrics-Services-Configuration) section for details. |
| Prometheus | [Metrics Services Configuration](#Metrics-Services-Configuration) | | Configuration for Prometheus (monitoring system). See the [Metrics Services Configuration](#Metrics-Services-Configuration) section for details | | Prometheus | [Metrics Services Configuration](#Metrics-Services-Configuration) | | Configuration for Prometheus (monitoring system). See the [Metrics Services Configuration](#Metrics-Services-Configuration) section for details |
| ProtoTickInterval | `int64` | `5` | Duration in seconds between protocol ticks with each connected peer. | | ProtoTickInterval | `int64` | `5` | Duration in seconds between protocol ticks with each connected peer. Warning: this field is deprecated and moved to `P2P` section. |
| Relay | `bool` | `true` | Determines whether the server is forwarding its inventory. | | Relay | `bool` | `true` | Determines whether the server is forwarding its inventory. |
| RPC | [RPC Configuration](#RPC-Configuration) | | Describes [RPC subsystem](rpc.md) configuration. See the [RPC Configuration](#RPC-Configuration) for details. | | RPC | [RPC Configuration](#RPC-Configuration) | | Describes [RPC subsystem](rpc.md) configuration. See the [RPC Configuration](#RPC-Configuration) for details. |
| StateRoot | [State Root Configuration](#State-Root-Configuration) | | State root module configuration. See the [State Root Configuration](#State-Root-Configuration) section for details. | | StateRoot | [State Root Configuration](#State-Root-Configuration) | | State root module configuration. See the [State Root Configuration](#State-Root-Configuration) section for details. |
| UnlockWallet | [Unlock Wallet Configuration](#Unlock-Wallet-Configuration) | | Node wallet configuration used for consensus (dBFT) operation. See the [Unlock Wallet Configuration](#Unlock-Wallet-Configuration) section for details. | | UnlockWallet | [Unlock Wallet Configuration](#Unlock-Wallet-Configuration) | | Node wallet configuration used for consensus (dBFT) operation. See the [Unlock Wallet Configuration](#Unlock-Wallet-Configuration) section for details. |
### P2P Configuration
`P2P` section contains configuration for peer-to-peer node communications and has
the following format:
```
P2P:
Addresses:
- "0.0.0.0:0" # any free port on all available addresses (in form of "[host]:[port][:announcedPort]")
AttemptConnPeers: 20
BroadcastFactor: 0
DialTimeout: 0s
MaxPeers: 100
MinPeers: 5
PingInterval: 30s
PingTimeout: 90s
ProtoTickInterval: 5s
ExtensiblePoolSize: 20
```
where:
- `Addresses` (`[]string`) is the list of the node addresses that P2P protocol
handler binds to. Each address has the form of `[address]:[nodePort][:announcedPort]`
where `address` is the address itself, `nodePort` is the actual P2P port node listens at;
`announcedPort` is the node port which should be used to announce node's port on P2P layer,
it can differ from the `nodePort` the node is bound to if specified (for example, if your
node is behind NAT).
- `AttemptConnPeers` (`int`) is the number of connection to try to establish when the
connection count drops below the `MinPeers` value.
- `BroadcastFactor` (`int`) is the multiplier that is used to determine the number of
optimal gossip fan-out peer number for broadcasted messages (0-100). By default, it's
zero, node uses the most optimized value depending on the estimated network size
(`2.5×log(size)`), so the node may have 20 peers and calculate that it needs to broadcast
messages to just 10 of them. With BroadcastFactor set to 100 it will always send messages
to all peers, any value in-between 0 and 100 is used for weighted calculation, for example
if it's 30 then 13 neighbors will be used in the previous case.
- `DialTimeout` (`Duration`) is the maximum duration a single dial may take.
- `ExtensiblePoolSize` (`int`) is the maximum amount of the extensible payloads from a single
sender stored in a local pool.
- `MaxPeers` (`int`) is the maximum numbers of peers that can be connected to the server.
- `MinPeers` (`int`) is the minimum number of peers for normal operation; when the node has
less than this number of peers it tries to connect with some new ones.
- `PingInterval` (`Duration`) is the interval used in pinging mechanism for syncing
blocks.
- `PingTimeout` (`Duration`) is the time to wait for pong (response for sent ping request).
- `ProtoTickInterval` (`Duration`) is the duration between protocol ticks with each
connected peer.
### DB Configuration ### DB Configuration
`DBConfiguration` section describes configuration for node database and has `DBConfiguration` section describes configuration for node database and has

View file

@ -12,27 +12,35 @@ import (
// ApplicationConfiguration config specific to the node. // ApplicationConfiguration config specific to the node.
type ApplicationConfiguration struct { type ApplicationConfiguration struct {
// Deprecated: please, use Addresses instead, this field will be removed in future versions. // Deprecated: please, use Addresses field of P2P section instead, this field will be removed in future versions.
Address *string `yaml:"Address,omitempty"` Address *string `yaml:"Address,omitempty"`
// Addresses stores the node address list in the form of "[host]:[port][:announcedPort]". // Deprecated: please, use Addresses field of P2P section instead, this field will be removed in future versions.
Addresses []string `yaml:"Addresses"`
// Deprecated: please, use Addresses instead, this field will be removed in future versions.
AnnouncedNodePort *uint16 `yaml:"AnnouncedPort,omitempty"` AnnouncedNodePort *uint16 `yaml:"AnnouncedPort,omitempty"`
// Deprecated: this option is moved to the P2P section.
AttemptConnPeers int `yaml:"AttemptConnPeers"` AttemptConnPeers int `yaml:"AttemptConnPeers"`
// BroadcastFactor is the factor (0-100) controlling gossip fan-out number optimization. // BroadcastFactor is the factor (0-100) controlling gossip fan-out number optimization.
//
// Deprecated: this option is moved to the P2P section.
BroadcastFactor int `yaml:"BroadcastFactor"` BroadcastFactor int `yaml:"BroadcastFactor"`
DBConfiguration dbconfig.DBConfiguration `yaml:"DBConfiguration"` DBConfiguration dbconfig.DBConfiguration `yaml:"DBConfiguration"`
// Deprecated: this option is moved to the P2P section.
DialTimeout int64 `yaml:"DialTimeout"` DialTimeout int64 `yaml:"DialTimeout"`
LogLevel string `yaml:"LogLevel"` LogLevel string `yaml:"LogLevel"`
LogPath string `yaml:"LogPath"` LogPath string `yaml:"LogPath"`
// Deprecated: this option is moved to the P2P section.
MaxPeers int `yaml:"MaxPeers"` MaxPeers int `yaml:"MaxPeers"`
// Deprecated: this option is moved to the P2P section.
MinPeers int `yaml:"MinPeers"` MinPeers int `yaml:"MinPeers"`
// Deprecated: please, use Addresses instead, this field will be removed in future versions. // Deprecated: please, use Addresses field of P2P section instead, this field will be removed in future versions.
NodePort *uint16 `yaml:"NodePort,omitempty"` NodePort *uint16 `yaml:"NodePort,omitempty"`
P2P P2P `yaml:"P2P"`
// Deprecated: this option is moved to the P2P section.
PingInterval int64 `yaml:"PingInterval"` PingInterval int64 `yaml:"PingInterval"`
// Deprecated: this option is moved to the P2P section.
PingTimeout int64 `yaml:"PingTimeout"` PingTimeout int64 `yaml:"PingTimeout"`
Pprof BasicService `yaml:"Pprof"` Pprof BasicService `yaml:"Pprof"`
Prometheus BasicService `yaml:"Prometheus"` Prometheus BasicService `yaml:"Prometheus"`
// Deprecated: this option is moved to the P2P section.
ProtoTickInterval int64 `yaml:"ProtoTickInterval"` ProtoTickInterval int64 `yaml:"ProtoTickInterval"`
Relay bool `yaml:"Relay"` Relay bool `yaml:"Relay"`
RPC RPC `yaml:"RPC"` RPC RPC `yaml:"RPC"`
@ -41,6 +49,8 @@ type ApplicationConfiguration struct {
P2PNotary P2PNotary `yaml:"P2PNotary"` P2PNotary P2PNotary `yaml:"P2PNotary"`
StateRoot StateRoot `yaml:"StateRoot"` StateRoot StateRoot `yaml:"StateRoot"`
// ExtensiblePoolSize is the maximum amount of the extensible payloads from a single sender. // ExtensiblePoolSize is the maximum amount of the extensible payloads from a single sender.
//
// Deprecated: this option is moved to the P2P section.
ExtensiblePoolSize int `yaml:"ExtensiblePoolSize"` ExtensiblePoolSize int `yaml:"ExtensiblePoolSize"`
} }
@ -48,13 +58,13 @@ type ApplicationConfiguration struct {
// (Oracle, P2PNotary, Pprof, Prometheus, RPC, StateRoot and UnlockWallet sections) // (Oracle, P2PNotary, Pprof, Prometheus, RPC, StateRoot and UnlockWallet sections)
// and LogLevel field. // and LogLevel field.
func (a *ApplicationConfiguration) EqualsButServices(o *ApplicationConfiguration) bool { func (a *ApplicationConfiguration) EqualsButServices(o *ApplicationConfiguration) bool {
if len(a.Addresses) != len(o.Addresses) { if len(a.P2P.Addresses) != len(o.P2P.Addresses) {
return false return false
} }
aCp := make([]string, len(a.Addresses)) aCp := make([]string, len(a.P2P.Addresses))
oCp := make([]string, len(o.Addresses)) oCp := make([]string, len(o.P2P.Addresses))
copy(aCp, a.Addresses) copy(aCp, a.P2P.Addresses)
copy(oCp, o.Addresses) copy(oCp, o.P2P.Addresses)
sort.Strings(aCp) sort.Strings(aCp)
sort.Strings(oCp) sort.Strings(oCp)
for i := range aCp { for i := range aCp {
@ -62,20 +72,29 @@ func (a *ApplicationConfiguration) EqualsButServices(o *ApplicationConfiguration
return false return false
} }
} }
if a.Address != o.Address || if a.Address != o.Address || //nolint:staticcheck // SA1019: a.Address is deprecated
a.AnnouncedNodePort != o.AnnouncedNodePort || a.AnnouncedNodePort != o.AnnouncedNodePort || //nolint:staticcheck // SA1019: a.AnnouncedNodePort is deprecated
a.AttemptConnPeers != o.AttemptConnPeers || a.AttemptConnPeers != o.AttemptConnPeers || //nolint:staticcheck // SA1019: a.AttemptConnPeers is deprecated
a.BroadcastFactor != o.BroadcastFactor || a.P2P.AttemptConnPeers != o.P2P.AttemptConnPeers ||
a.BroadcastFactor != o.BroadcastFactor || //nolint:staticcheck // SA1019: a.BroadcastFactor is deprecated
a.P2P.BroadcastFactor != o.P2P.BroadcastFactor ||
a.DBConfiguration != o.DBConfiguration || a.DBConfiguration != o.DBConfiguration ||
a.DialTimeout != o.DialTimeout || a.DialTimeout != o.DialTimeout || //nolint:staticcheck // SA1019: a.DialTimeout is deprecated
a.ExtensiblePoolSize != o.ExtensiblePoolSize || a.P2P.DialTimeout != o.P2P.DialTimeout ||
a.ExtensiblePoolSize != o.ExtensiblePoolSize || //nolint:staticcheck // SA1019: a.ExtensiblePoolSize is deprecated
a.P2P.ExtensiblePoolSize != o.P2P.ExtensiblePoolSize ||
a.LogPath != o.LogPath || a.LogPath != o.LogPath ||
a.MaxPeers != o.MaxPeers || a.MaxPeers != o.MaxPeers || //nolint:staticcheck // SA1019: a.MaxPeers is deprecated
a.MinPeers != o.MinPeers || a.P2P.MaxPeers != o.P2P.MaxPeers ||
a.NodePort != o.NodePort || a.MinPeers != o.MinPeers || //nolint:staticcheck // SA1019: a.MinPeers is deprecated
a.PingInterval != o.PingInterval || a.P2P.MinPeers != o.P2P.MinPeers ||
a.PingTimeout != o.PingTimeout || a.NodePort != o.NodePort || //nolint:staticcheck // SA1019: a.NodePort is deprecated
a.ProtoTickInterval != o.ProtoTickInterval || a.PingInterval != o.PingInterval || //nolint:staticcheck // SA1019: a.PingInterval is deprecated
a.P2P.PingInterval != o.P2P.PingInterval ||
a.PingTimeout != o.PingTimeout || //nolint:staticcheck // SA1019: a.PingTimeout is deprecated
a.P2P.PingTimeout != o.P2P.PingTimeout ||
a.ProtoTickInterval != o.ProtoTickInterval || //nolint:staticcheck // SA1019: a.ProtoTickInterval is deprecated
a.P2P.ProtoTickInterval != o.P2P.ProtoTickInterval ||
a.Relay != o.Relay { a.Relay != o.Relay {
return false return false
} }
@ -93,25 +112,25 @@ type AnnounceableAddress struct {
// gathered from both deprecated Address / NodePort / AnnouncedNodePort and newly // gathered from both deprecated Address / NodePort / AnnouncedNodePort and newly
// created Addresses fields. // created Addresses fields.
func (a *ApplicationConfiguration) GetAddresses() ([]AnnounceableAddress, error) { func (a *ApplicationConfiguration) GetAddresses() ([]AnnounceableAddress, error) {
addrs := make([]AnnounceableAddress, 0, len(a.Addresses)+1) addrs := make([]AnnounceableAddress, 0, len(a.P2P.Addresses)+1)
if a.Address != nil || a.NodePort != nil || a.AnnouncedNodePort != nil { if a.Address != nil || a.NodePort != nil || a.AnnouncedNodePort != nil { //nolint:staticcheck // SA1019: a.Address is deprecated
var ( var (
host string host string
nodePort uint16 nodePort uint16
) )
if a.Address != nil { if a.Address != nil { //nolint:staticcheck // SA1019: a.Address is deprecated
host = *a.Address host = *a.Address //nolint:staticcheck // SA1019: a.Address is deprecated
} }
if a.NodePort != nil { if a.NodePort != nil { //nolint:staticcheck // SA1019: a.NodePort is deprecated
nodePort = *a.NodePort nodePort = *a.NodePort //nolint:staticcheck // SA1019: a.NodePort is deprecated
} }
addr := AnnounceableAddress{Address: net.JoinHostPort(host, strconv.Itoa(int(nodePort)))} addr := AnnounceableAddress{Address: net.JoinHostPort(host, strconv.Itoa(int(nodePort)))}
if a.AnnouncedNodePort != nil { if a.AnnouncedNodePort != nil { //nolint:staticcheck // SA1019: a.AnnouncedNodePort is deprecated
addr.AnnouncedPort = *a.AnnouncedNodePort addr.AnnouncedPort = *a.AnnouncedNodePort //nolint:staticcheck // SA1019: a.AnnouncedNodePort is deprecated
} }
addrs = append(addrs, addr) addrs = append(addrs, addr)
} }
for i, addrStr := range a.Addresses { for i, addrStr := range a.P2P.Addresses {
if len(addrStr) == 0 { if len(addrStr) == 0 {
return nil, fmt.Errorf("address #%d is empty", i) return nil, fmt.Errorf("address #%d is empty", i)
} }

View file

@ -80,7 +80,7 @@ func TestGetAddresses(t *testing.T) {
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Address: &addr1, NodePort: &port1, AnnouncedNodePort: &port2, Address: &addr1, NodePort: &port1, AnnouncedNodePort: &port2,
Addresses: []string{addr1, addr2 + ":3", addr3 + ":1:3"}, P2P: P2P{Addresses: []string{addr1, addr2 + ":3", addr3 + ":1:3"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: addr1 + ":1", AnnouncedPort: port2}, {Address: addr1 + ":1", AnnouncedPort: port2},
@ -92,7 +92,7 @@ func TestGetAddresses(t *testing.T) {
// Multi-addresses checks. // Multi-addresses checks.
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{addr1}, P2P: P2P{Addresses: []string{addr1}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: addr1}, {Address: addr1},
@ -100,7 +100,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{":1"}, P2P: P2P{Addresses: []string{":1"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: ":1"}, {Address: ":1"},
@ -108,7 +108,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{"::1"}, P2P: P2P{Addresses: []string{"::1"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: ":", AnnouncedPort: port1}, {Address: ":", AnnouncedPort: port1},
@ -116,7 +116,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{addr1 + ":1"}, P2P: P2P{Addresses: []string{addr1 + ":1"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: addr1 + ":1"}, {Address: addr1 + ":1"},
@ -124,7 +124,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{addr1 + "::1"}, P2P: P2P{Addresses: []string{addr1 + "::1"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: addr1 + ":", AnnouncedPort: port1}, {Address: addr1 + ":", AnnouncedPort: port1},
@ -132,7 +132,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{addr1 + ":1:2"}, P2P: P2P{Addresses: []string{addr1 + ":1:2"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: addr1 + ":1", AnnouncedPort: port2}, {Address: addr1 + ":1", AnnouncedPort: port2},
@ -140,7 +140,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{addr1 + ":1", addr2 + "::2"}, P2P: P2P{Addresses: []string{addr1 + ":1", addr2 + "::2"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: addr1 + ":1"}, {Address: addr1 + ":1"},
@ -149,7 +149,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{v6Plain0, v6Plain1, v6Plain2, v6Plain3, v6Plain4}, P2P: P2P{Addresses: []string{v6Plain0, v6Plain1, v6Plain2, v6Plain3, v6Plain4}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: v6Plain0}, {Address: v6Plain0},
@ -161,7 +161,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{"[3731:54:65fe:2::]:123", "[3731:54:65fe:2::]:123:124"}, P2P: P2P{Addresses: []string{"[3731:54:65fe:2::]:123", "[3731:54:65fe:2::]:123:124"}},
}, },
expected: []AnnounceableAddress{ expected: []AnnounceableAddress{
{Address: "[3731:54:65fe:2::]:123"}, {Address: "[3731:54:65fe:2::]:123"},
@ -170,7 +170,7 @@ func TestGetAddresses(t *testing.T) {
}, },
{ {
cfg: &ApplicationConfiguration{ cfg: &ApplicationConfiguration{
Addresses: []string{"127.0.0.1:QWER:123"}, P2P: P2P{Addresses: []string{"127.0.0.1:QWER:123"}},
}, },
shouldFail: true, shouldFail: true,
}, },

View file

@ -55,8 +55,10 @@ func LoadFile(configPath string) (Config, error) {
config := Config{ config := Config{
ApplicationConfiguration: ApplicationConfiguration{ ApplicationConfiguration: ApplicationConfiguration{
P2P: P2P{
PingInterval: 30, PingInterval: 30,
PingTimeout: 90, PingTimeout: 30,
},
RPC: RPC{ RPC: RPC{
MaxIteratorResultItems: DefaultMaxIteratorResultItems, MaxIteratorResultItems: DefaultMaxIteratorResultItems,
MaxFindResultItems: 100, MaxFindResultItems: 100,

19
pkg/config/p2p.go Normal file
View file

@ -0,0 +1,19 @@
package config
import "time"
// P2P holds P2P node settings.
type P2P struct {
// Addresses stores the node address list in the form of "[host]:[port][:announcedPort]".
Addresses []string `yaml:"Addresses"`
AttemptConnPeers int `yaml:"AttemptConnPeers"`
// BroadcastFactor is the factor (0-100) controlling gossip fan-out number optimization.
BroadcastFactor int `yaml:"BroadcastFactor"`
DialTimeout time.Duration `yaml:"DialTimeout"`
ExtensiblePoolSize int `yaml:"ExtensiblePoolSize"`
MaxPeers int `yaml:"MaxPeers"`
MinPeers int `yaml:"MinPeers"`
PingInterval time.Duration `yaml:"PingInterval"`
PingTimeout time.Duration `yaml:"PingTimeout"`
ProtoTickInterval time.Duration `yaml:"ProtoTickInterval"`
}

View file

@ -88,29 +88,65 @@ func NewServerConfig(cfg config.Config) (ServerConfig, error) {
if timePerBlock == 0 && protoConfig.SecondsPerBlock > 0 { //nolint:staticcheck // SA1019: protoConfig.SecondsPerBlock is deprecated if timePerBlock == 0 && protoConfig.SecondsPerBlock > 0 { //nolint:staticcheck // SA1019: protoConfig.SecondsPerBlock is deprecated
timePerBlock = time.Duration(protoConfig.SecondsPerBlock) * time.Second //nolint:staticcheck // SA1019: protoConfig.SecondsPerBlock is deprecated timePerBlock = time.Duration(protoConfig.SecondsPerBlock) * time.Second //nolint:staticcheck // SA1019: protoConfig.SecondsPerBlock is deprecated
} }
dialTimeout := appConfig.P2P.DialTimeout
if dialTimeout == 0 && appConfig.DialTimeout > 0 { //nolint:staticcheck // SA1019: appConfig.DialTimeout is deprecated
dialTimeout = time.Duration(appConfig.DialTimeout) * time.Second //nolint:staticcheck // SA1019: appConfig.DialTimeout is deprecated
}
protoTickInterval := appConfig.P2P.ProtoTickInterval
if protoTickInterval == 0 && appConfig.ProtoTickInterval > 0 { //nolint:staticcheck // SA1019: appConfig.ProtoTickInterval is deprecated
protoTickInterval = time.Duration(appConfig.ProtoTickInterval) * time.Second //nolint:staticcheck // SA1019: appConfig.ProtoTickInterval is deprecated
}
pingInterval := appConfig.P2P.PingInterval
if pingInterval == 0 && appConfig.PingInterval > 0 { //nolint:staticcheck // SA1019: appConfig.PingInterval is deprecated
pingInterval = time.Duration(appConfig.PingInterval) * time.Second //nolint:staticcheck // SA1019: appConfig.PingInterval is deprecated
}
pingTimeout := appConfig.P2P.PingTimeout
if pingTimeout == 0 && appConfig.PingTimeout > 0 { //nolint:staticcheck // SA1019: appConfig.PingTimeout is deprecated
pingTimeout = time.Duration(appConfig.PingTimeout) * time.Second //nolint:staticcheck // SA1019: appConfig.PingTimeout is deprecated
}
maxPeers := appConfig.P2P.MaxPeers
if maxPeers == 0 && appConfig.MaxPeers > 0 { //nolint:staticcheck // SA1019: appConfig.MaxPeers is deprecated
maxPeers = appConfig.MaxPeers //nolint:staticcheck // SA1019: appConfig.MaxPeers is deprecated
}
attemptConnPeers := appConfig.P2P.AttemptConnPeers
if attemptConnPeers == 0 && appConfig.AttemptConnPeers > 0 { //nolint:staticcheck // SA1019: appConfig.AttemptConnPeers is deprecated
attemptConnPeers = appConfig.AttemptConnPeers //nolint:staticcheck // SA1019: appConfig.AttemptConnPeers is deprecated
}
minPeers := appConfig.P2P.MinPeers
if minPeers == 0 && appConfig.MinPeers > 0 { //nolint:staticcheck // SA1019: appConfig.MinPeers is deprecated
minPeers = appConfig.MinPeers //nolint:staticcheck // SA1019: appConfig.MinPeers is deprecated
}
extPoolSize := appConfig.P2P.ExtensiblePoolSize
if extPoolSize == 0 && appConfig.ExtensiblePoolSize > 0 { //nolint:staticcheck // SA1019: appConfig.ExtensiblePoolSize is deprecated
extPoolSize = appConfig.ExtensiblePoolSize //nolint:staticcheck // SA1019: appConfig.ExtensiblePoolSize is deprecated
}
broadcastFactor := appConfig.P2P.BroadcastFactor
if broadcastFactor > 0 && appConfig.BroadcastFactor > 0 { //nolint:staticcheck // SA1019: appConfig.BroadcastFactor is deprecated
broadcastFactor = appConfig.BroadcastFactor //nolint:staticcheck // SA1019: appConfig.BroadcastFactor is deprecated
}
addrs, err := appConfig.GetAddresses() addrs, err := appConfig.GetAddresses()
if err != nil { if err != nil {
return ServerConfig{}, fmt.Errorf("failed to parse addresses: %w", err) return ServerConfig{}, fmt.Errorf("failed to parse addresses: %w", err)
} }
return ServerConfig{ c := ServerConfig{
UserAgent: cfg.GenerateUserAgent(), UserAgent: cfg.GenerateUserAgent(),
Addresses: addrs, Addresses: addrs,
Net: protoConfig.Magic, Net: protoConfig.Magic,
Relay: appConfig.Relay, Relay: appConfig.Relay,
Seeds: protoConfig.SeedList, Seeds: protoConfig.SeedList,
DialTimeout: time.Duration(appConfig.DialTimeout) * time.Second, DialTimeout: dialTimeout,
ProtoTickInterval: time.Duration(appConfig.ProtoTickInterval) * time.Second, ProtoTickInterval: protoTickInterval,
PingInterval: time.Duration(appConfig.PingInterval) * time.Second, PingInterval: pingInterval,
PingTimeout: time.Duration(appConfig.PingTimeout) * time.Second, PingTimeout: pingTimeout,
MaxPeers: appConfig.MaxPeers, MaxPeers: maxPeers,
AttemptConnPeers: appConfig.AttemptConnPeers, AttemptConnPeers: attemptConnPeers,
MinPeers: appConfig.MinPeers, MinPeers: minPeers,
TimePerBlock: timePerBlock, TimePerBlock: timePerBlock,
OracleCfg: appConfig.Oracle, OracleCfg: appConfig.Oracle,
P2PNotaryCfg: appConfig.P2PNotary, P2PNotaryCfg: appConfig.P2PNotary,
StateRootCfg: appConfig.StateRoot, StateRootCfg: appConfig.StateRoot,
ExtensiblePoolSize: appConfig.ExtensiblePoolSize, ExtensiblePoolSize: extPoolSize,
BroadcastFactor: appConfig.BroadcastFactor, BroadcastFactor: broadcastFactor,
}, nil }
return c, nil
} }