zombienet_configuration/lib.rs
1//! This crate is used to create type safe configuration for Zombienet SDK using nested builders.
2//!
3//!
4//! The main entry point of this crate is the [`NetworkConfigBuilder`] which is used to build a full network configuration
5//! but all inner builders are also exposed to allow more granular control over the configuration.
6//!
7//! **Note**: Not all options can be checked at compile time and some will be checked at runtime when spawning a
8//! network (e.g.: supported args for a specific node version).
9//!
10//! # Example
11//! ```
12//! use zombienet_configuration::NetworkConfigBuilder;
13//!
14//! let simple_configuration = NetworkConfigBuilder::new()
15//! .with_relaychain(|relaychain| {
16//! relaychain
17//! .with_chain("polkadot")
18//! .with_random_nominators_count(10)
19//! .with_default_resources(|resources| {
20//! resources
21//! .with_limit_cpu("1000m")
22//! .with_request_memory("1Gi")
23//! .with_request_cpu(100_000)
24//! })
25//! .with_validator(|node| node.with_name("node").with_command("command"))
26//! .with_validator(|node| node.with_name("node1").with_command("command"))
27//! })
28//! .with_parachain(|parachain| {
29//! parachain
30//! .with_id(1000)
31//! .with_chain("myparachain1")
32//! .with_initial_balance(100_000)
33//! .with_default_image("myimage:version")
34//! .with_collator(|collator| {
35//! collator
36//! .with_name("collator1")
37//! .with_command("command1")
38//! .validator(true)
39//! })
40//! })
41//! .with_parachain(|parachain| {
42//! parachain
43//! .with_id(2000)
44//! .with_chain("myparachain2")
45//! .with_initial_balance(50_0000)
46//! .with_collator(|collator| {
47//! collator
48//! .with_name("collator2")
49//! .with_command("command2")
50//! .validator(true)
51//! })
52//! })
53//! .with_hrmp_channel(|hrmp_channel1| {
54//! hrmp_channel1
55//! .with_sender(1)
56//! .with_recipient(2)
57//! .with_max_capacity(200)
58//! .with_max_message_size(500)
59//! })
60//! .with_hrmp_channel(|hrmp_channel2| {
61//! hrmp_channel2
62//! .with_sender(2)
63//! .with_recipient(1)
64//! .with_max_capacity(100)
65//! .with_max_message_size(250)
66//! })
67//! .with_global_settings(|global_settings| {
68//! global_settings
69//! .with_network_spawn_timeout(1200)
70//! .with_node_spawn_timeout(240)
71//! })
72//! .build();
73//!
74//! assert!(simple_configuration.is_ok())
75//! ```
76
77#![allow(clippy::expect_fun_call)]
78mod custom_process;
79mod global_settings;
80mod hrmp_channel;
81mod network;
82mod observability;
83mod parachain;
84mod relaychain;
85pub mod shared;
86mod utils;
87
88pub use custom_process::{CustomProcess, CustomProcessBuilder};
89pub use global_settings::{GlobalSettings, GlobalSettingsBuilder};
90pub use hrmp_channel::{HrmpChannelConfig, HrmpChannelConfigBuilder};
91pub use network::{NetworkConfig, NetworkConfigBuilder, WithRelaychain};
92pub use observability::{ObservabilityConfig, ObservabilityConfigBuilder};
93pub use parachain::{
94 states as para_states, ParachainConfig, ParachainConfigBuilder, RegistrationStrategy,
95};
96pub use relaychain::{RelaychainConfig, RelaychainConfigBuilder};
97// re-export shared
98pub use shared::{node::NodeConfig, types};