Skip to content

Commit dedf560

Browse files
authored
Merge branch 'main' into feature/ignore-checks-on-docs-changes
2 parents 3d8bf5d + f76ccf1 commit dedf560

File tree

15 files changed

+166
-140
lines changed

15 files changed

+166
-140
lines changed

nix/vit-servicing-station/operables.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
inherit package;
5656
args = {
5757
"--in-settings-file" = configFile;
58-
"--service-version" = "3.4";
58+
"--service-version" = "$VERSION";
59+
"--db-url" = "$DB_URL";
5960
};
6061
};
6162
};

src/jormungandr/jormungandr-lib/src/interfaces/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod secret;
66
pub use log::{Log, LogEntry, LogOutput};
77
pub use mempool::{LogMaxEntries, Mempool, PersistentLog, PoolMaxEntries};
88
pub use node::{
9-
Cors, CorsOrigin, JRpc, LayersConfig, NodeConfig, NodeId, P2p, Policy, PreferredListConfig,
10-
Rest, Tls, TopicsOfInterest, TrustedPeer,
9+
Bootstrap, Connection, Cors, CorsOrigin, JRpc, LayersConfig, NodeConfig, NodeId, P2p, Policy,
10+
PreferredListConfig, Rest, Tls, TopicsOfInterest, TrustedPeer,
1111
};
1212
pub use secret::{Bft, GenesisPraos, NodeSecret};

src/jormungandr/jormungandr-lib/src/interfaces/config/node.rs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,37 @@ impl Serialize for HttpMethod {
188188

189189
#[derive(Debug, Clone, Serialize, Deserialize)]
190190
pub struct P2p {
191-
/// The public address to which other peers may connect to
192-
pub public_address: Multiaddr,
191+
pub bootstrap: Bootstrap,
192+
193+
pub connection: Connection,
194+
195+
pub policy: Option<Policy>,
193196

194-
/// File with the secret key used to advertise and authenticate the node
195197
#[serde(skip_serializing_if = "Option::is_none")]
196-
pub node_key_file: Option<PathBuf>,
198+
pub layers: Option<LayersConfig>,
199+
}
197200

201+
/// Bootstrap contains meta data for initial startup
202+
#[derive(Debug, Clone, Serialize, Deserialize)]
203+
pub struct Bootstrap {
198204
/// the rendezvous points for the peer to connect to in order to initiate
199205
/// the p2p discovery from.
200206
pub trusted_peers: Vec<TrustedPeer>,
201207

208+
#[serde(skip_serializing_if = "Option::is_none")]
209+
pub max_bootstrap_attempts: Option<usize>,
210+
211+
/// File with the secret key used to advertise and authenticate the node
212+
#[serde(skip_serializing_if = "Option::is_none")]
213+
pub node_key_file: Option<PathBuf>,
214+
}
215+
216+
/// Miscellaneous network configuration
217+
#[derive(Debug, Clone, Serialize, Deserialize)]
218+
pub struct Connection {
219+
/// The public address to which other peers may connect to
220+
pub public_address: Multiaddr,
221+
202222
/// Listen address.
203223
#[serde(skip_serializing_if = "Option::is_none")]
204224
pub listen: Option<SocketAddr>,
@@ -209,21 +229,17 @@ pub struct P2p {
209229
#[serde(skip_serializing_if = "Option::is_none")]
210230
pub max_inbound_connections: Option<u32>,
211231

232+
/// Whether to allow non-public IP addresses in gossip
212233
pub allow_private_addresses: bool,
213234

235+
/// contains addrs of nodes which we can accept fragments from
214236
pub whitelist: Option<Vec<SocketAddr>>,
215237

216-
pub policy: Option<Policy>,
217-
218-
#[serde(skip_serializing_if = "Option::is_none")]
219-
pub layers: Option<LayersConfig>,
220-
238+
/// interval to start gossiping with new nodes, changing the value will affect the bandwidth.
221239
#[serde(skip_serializing_if = "Option::is_none")]
222240
pub gossip_interval: Option<Duration>,
223241

224-
#[serde(skip_serializing_if = "Option::is_none")]
225-
pub max_bootstrap_attempts: Option<usize>,
226-
242+
/// If no gossip has been received in the last interval, try to connect to nodes that were previously known to this node
227243
#[serde(skip_serializing_if = "Option::is_none")]
228244
pub network_stuck_check: Option<Duration>,
229245
}
@@ -234,6 +250,7 @@ pub struct TopicsOfInterest {
234250
pub blocks: String,
235251
}
236252

253+
/// policy module
237254
#[derive(Debug, Serialize, Deserialize, Clone)]
238255
pub struct Policy {
239256
#[serde(skip_serializing_if = "Option::is_none")]
@@ -242,6 +259,7 @@ pub struct Policy {
242259
pub quarantine_whitelist: Option<Vec<Multiaddr>>,
243260
}
244261

262+
/// Jörmungandr provides multiple additional layers to the poldercast default ones: the preferred list or the bottle in the sea.
245263
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
246264
#[serde(deny_unknown_fields)]
247265
pub struct LayersConfig {
@@ -308,7 +326,8 @@ pub struct NodeConfig {
308326

309327
impl P2p {
310328
pub fn get_listen_addr(&self) -> Option<SocketAddr> {
311-
self.listen
312-
.or_else(|| multiaddr_utils::to_tcp_socket_addr(&self.public_address))
329+
self.connection
330+
.listen
331+
.or_else(|| multiaddr_utils::to_tcp_socket_addr(&self.connection.public_address))
313332
}
314333
}

src/jormungandr/jormungandr/src/settings/start/config.rs

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,22 @@ pub struct ConfigLogSettings {
6666
#[derive(Debug, Clone, Deserialize, Default)]
6767
#[serde(deny_unknown_fields)]
6868
pub struct P2pConfig {
69-
/// The public address to which other peers may connect to
70-
pub public_address: Option<Multiaddr>,
69+
pub bootstrap: Bootstrap,
7170

72-
/// The socket address to listen on, if different from the public address.
73-
/// The format is "{ip_address}:{port}".
74-
/// The IP address can be specified as 0.0.0.0 or :: to listen on
75-
/// all network interfaces.
76-
pub listen: Option<Address>,
71+
pub connection: Connection,
72+
73+
/// setting for the policy
74+
#[serde(default)]
75+
pub policy: QuarantineConfig,
76+
77+
/// settings for the different custom layers
78+
#[serde(default)]
79+
pub layers: LayersConfig,
80+
}
7781

82+
#[derive(Debug, Clone, Deserialize, Default)]
83+
#[serde(deny_unknown_fields)]
84+
pub struct Bootstrap {
7885
/// File with the secret key used to advertise and authenticate the node
7986
#[serde(skip_serializing_if = "Option::is_none")]
8087
pub node_key_file: Option<PathBuf>,
@@ -83,6 +90,31 @@ pub struct P2pConfig {
8390
/// the p2p discovery from.
8491
pub trusted_peers: Option<Vec<TrustedPeer>>,
8592

93+
/// The number of times to retry bootstrapping from trusted peers. The default
94+
/// value of None will result in the bootstrap process retrying indefinitely. A
95+
/// value of zero will skip bootstrap all together -- even if trusted peers are
96+
/// defined. If the node fails to bootstrap from any of the trusted peers and the
97+
/// number of bootstrap retry attempts is exceeded, then the node will continue to
98+
/// run without completing the bootstrap process. This will allow the node to act
99+
/// as the first node in the p2p network (i.e. genesis node), or immediately begin
100+
/// gossip with the trusted peers if any are defined.
101+
#[serde(default)]
102+
pub max_bootstrap_attempts: Option<usize>,
103+
}
104+
105+
/// Start up connection configuration
106+
#[derive(Debug, Clone, Deserialize, Default)]
107+
#[serde(deny_unknown_fields)]
108+
pub struct Connection {
109+
/// The public address to which other peers may connect to
110+
pub public_address: Option<Multiaddr>,
111+
112+
/// The socket address to listen on, if different from the public address.
113+
/// The format is "{ip_address}:{port}".
114+
/// The IP address can be specified as 0.0.0.0 or :: to listen on
115+
/// all network interfaces.
116+
pub listen: Option<Address>,
117+
86118
/// Limit on the number of simultaneous connections.
87119
/// If not specified, an internal default limit is used.
88120
pub max_connections: Option<usize>,
@@ -99,16 +131,9 @@ pub struct P2pConfig {
99131
#[serde(default)]
100132
pub allow_private_addresses: bool,
101133

134+
/// contains addrs of nodes which we can accept fragments from
102135
pub whitelist: Option<Vec<SocketAddr>>,
103136

104-
/// setting for the policy
105-
#[serde(default)]
106-
pub policy: QuarantineConfig,
107-
108-
/// settings for the different custom layers
109-
#[serde(default)]
110-
pub layers: LayersConfig,
111-
112137
/// interval to start gossiping with new nodes, changing the value will
113138
/// affect the bandwidth. The more often the node will gossip the more
114139
/// bandwidth the node will need. The less often the node gossips the less
@@ -124,17 +149,6 @@ pub struct P2pConfig {
124149
/// The default value is 5 min.
125150
#[serde(default)]
126151
pub network_stuck_check: Option<Duration>,
127-
128-
/// The number of times to retry bootstrapping from trusted peers. The default
129-
/// value of None will result in the bootstrap process retrying indefinitely. A
130-
/// value of zero will skip bootstrap all together -- even if trusted peers are
131-
/// defined. If the node fails to bootstrap from any of the trusted peers and the
132-
/// number of bootstrap retry attempts is exceeded, then the node will continue to
133-
/// run without completing the bootstrap process. This will allow the node to act
134-
/// as the first node in the p2p network (i.e. genesis node), or immediately begin
135-
/// gossip with the trusted peers if any are defined.
136-
#[serde(default)]
137-
pub max_bootstrap_attempts: Option<usize>,
138152
}
139153

140154
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]

src/jormungandr/jormungandr/src/settings/start/mod.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,16 @@ fn generate_network(
260260
(config::P2pConfig::default(), Vec::new(), false, false)
261261
};
262262

263-
if p2p.trusted_peers.is_some() {
264-
if let Some(peers) = p2p.trusted_peers.as_mut() {
263+
if p2p.bootstrap.trusted_peers.is_some() {
264+
if let Some(peers) = p2p.bootstrap.trusted_peers.as_mut() {
265265
peers.extend(command_arguments.trusted_peer.clone())
266266
}
267267
} else if !command_arguments.trusted_peer.is_empty() {
268-
p2p.trusted_peers = Some(command_arguments.trusted_peer.clone())
268+
p2p.bootstrap.trusted_peers = Some(command_arguments.trusted_peer.clone())
269269
}
270270

271271
let trusted_peers = p2p
272+
.bootstrap
272273
.trusted_peers
273274
.as_ref()
274275
.map_or_else(Vec::new, |peers| resolve_trusted_peers(peers));
@@ -286,23 +287,21 @@ fn generate_network(
286287
.transpose()?
287288
.unwrap_or_default();
288289

289-
// TODO: do we want to check that we end up with a valid address?
290-
// Is it possible for a node to specify no public address?
291-
let config_addr = p2p.public_address;
290+
let config_addr = p2p.connection.public_address;
292291
let public_address = command_arguments
293292
.public_address
294293
.clone()
295294
.or(config_addr)
296295
.and_then(|addr| multiaddr::to_tcp_socket_addr(&addr));
297296

298-
let node_key = match p2p.node_key_file {
297+
let node_key = match p2p.bootstrap.node_key_file {
299298
Some(node_key_file) => {
300299
<SigningKey<Ed25519>>::from_bech32_str(&std::fs::read_to_string(&node_key_file)?)?
301300
}
302301
None => SigningKey::generate(rand::thread_rng()),
303302
};
304303

305-
let p2p_listen_address = p2p.listen.as_ref();
304+
let p2p_listen_address = p2p.connection.listen.as_ref();
306305
let listen_address = command_arguments
307306
.listen_address
308307
.as_ref()
@@ -321,23 +320,27 @@ fn generate_network(
321320
rings,
322321
},
323322
max_connections: p2p
323+
.connection
324324
.max_connections
325325
.unwrap_or(network::DEFAULT_MAX_CONNECTIONS),
326326
max_client_connections: p2p
327+
.connection
327328
.max_client_connections
328329
.unwrap_or(network::DEFAULT_MAX_CLIENT_CONNECTIONS),
329330
timeout: std::time::Duration::from_secs(15),
330-
allow_private_addresses: p2p.allow_private_addresses,
331-
whitelist: p2p.whitelist,
331+
allow_private_addresses: p2p.connection.allow_private_addresses,
332+
whitelist: p2p.connection.whitelist,
332333
gossip_interval: p2p
334+
.connection
333335
.gossip_interval
334336
.map(|d| d.into())
335337
.unwrap_or_else(|| std::time::Duration::from_secs(10)),
336338
network_stuck_check: p2p
339+
.connection
337340
.network_stuck_check
338341
.map(Into::into)
339342
.unwrap_or(crate::topology::DEFAULT_NETWORK_STUCK_INTERVAL),
340-
max_bootstrap_attempts: p2p.max_bootstrap_attempts,
343+
max_bootstrap_attempts: p2p.bootstrap.max_bootstrap_attempts,
341344
http_fetch_block0_service,
342345
bootstrap_from_trusted_peers,
343346
skip_bootstrap,

src/jormungandr/testing/hersir/src/builder/explorer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ pub fn generate_explorer(
1616
Ok(ExplorerConfiguration {
1717
explorer_port: get_available_port(),
1818
explorer_listen_address: "127.0.0.1".to_string(),
19-
node_address: settings.config.p2p.public_address.clone().to_http_addr(),
19+
node_address: settings
20+
.config
21+
.p2p
22+
.connection
23+
.public_address
24+
.clone()
25+
.to_http_addr(),
2026
logs_dir: Some(Path::new("C:\\work\\iohk\\logs.txt").to_path_buf()),
2127
storage_dir: None,
2228
params: explorer_template.to_explorer_params(),

src/jormungandr/testing/hersir/src/builder/settings/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ impl Settings {
178178
.to_public(),
179179
);
180180
trusted_peers.push(TrustedPeer {
181-
address: trusted_peer.config.p2p.public_address.clone(),
181+
address: trusted_peer.config.p2p.connection.public_address.clone(),
182182
id: Some(id),
183183
})
184184
}
185185

186186
node.config.skip_bootstrap = Some(trusted_peers.is_empty());
187187
node.config.bootstrap_from_trusted_peers = Some(!trusted_peers.is_empty());
188-
node.config.p2p.trusted_peers = trusted_peers;
188+
node.config.p2p.bootstrap.trusted_peers = trusted_peers;
189189
}
190190
}
191191

src/jormungandr/testing/hersir/src/config/spawn_params.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,31 +281,31 @@ impl SpawnParams {
281281
}
282282

283283
if let Some(public_address) = &self.public_address {
284-
node_config.p2p.public_address = public_address.clone();
284+
node_config.p2p.connection.public_address = public_address.clone();
285285
}
286286

287287
if let Some(max_inbound_connections) = &self.max_inbound_connections {
288-
node_config.p2p.max_inbound_connections = Some(*max_inbound_connections);
288+
node_config.p2p.connection.max_inbound_connections = Some(*max_inbound_connections);
289289
}
290290

291291
if let Some(allow_private_addresses) = &self.allow_private_addresses {
292-
node_config.p2p.allow_private_addresses = *allow_private_addresses;
292+
node_config.p2p.connection.allow_private_addresses = *allow_private_addresses;
293293
}
294294

295295
if let Some(whitelist) = &self.whitelist {
296-
node_config.p2p.whitelist = Some(whitelist.clone());
296+
node_config.p2p.connection.whitelist = Some(whitelist.clone());
297297
}
298298

299299
if let Some(max_connections) = &self.max_connections {
300-
node_config.p2p.max_connections = Some(*max_connections);
300+
node_config.p2p.connection.max_connections = Some(*max_connections);
301301
}
302302

303303
if let Some(listen_address_option) = &self.listen_address {
304-
node_config.p2p.listen = *listen_address_option;
304+
node_config.p2p.connection.listen = *listen_address_option;
305305
}
306306

307307
if let Some(trusted_peers) = &self.trusted_peers {
308-
node_config.p2p.trusted_peers = trusted_peers.clone();
308+
node_config.p2p.bootstrap.trusted_peers = trusted_peers.clone();
309309
}
310310

311311
if let Some(preferred_layer) = &self.preferred_layer {
@@ -328,19 +328,19 @@ impl SpawnParams {
328328
}
329329

330330
if let Some(node_key_file) = &self.node_key_file {
331-
node_config.p2p.node_key_file = Some(node_key_file.clone());
331+
node_config.p2p.bootstrap.node_key_file = Some(node_key_file.clone());
332332
}
333333

334334
if self.gossip_interval.is_some() {
335-
node_config.p2p.gossip_interval = self.gossip_interval;
335+
node_config.p2p.connection.gossip_interval = self.gossip_interval;
336336
}
337337

338338
if let Some(max_bootstrap_attempts) = self.max_bootstrap_attempts {
339-
node_config.p2p.max_bootstrap_attempts = Some(max_bootstrap_attempts);
339+
node_config.p2p.bootstrap.max_bootstrap_attempts = Some(max_bootstrap_attempts);
340340
}
341341

342342
if let Some(network_stuck_check) = self.network_stuck_check {
343-
node_config.p2p.network_stuck_check = Some(network_stuck_check);
343+
node_config.p2p.connection.network_stuck_check = Some(network_stuck_check);
344344
}
345345
node_config.mempool.as_mut().unwrap().persistent_log = self
346346
.persistent_fragment_log

src/jormungandr/testing/hersir/src/controller/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl Controller {
254254

255255
spawn_params.override_settings(&mut config);
256256

257-
for peer in config.p2p.trusted_peers.iter_mut() {
257+
for peer in config.p2p.bootstrap.trusted_peers.iter_mut() {
258258
peer.id = None;
259259
}
260260

0 commit comments

Comments
 (0)