Skip to main content

Crate zombienet_configuration

Crate zombienet_configuration 

Source
Expand description

This crate is used to create type safe configuration for Zombienet SDK using nested builders.

The main entry point of this crate is the NetworkConfigBuilder which is used to build a full network configuration but all inner builders are also exposed to allow more granular control over the configuration.

Note: Not all options can be checked at compile time and some will be checked at runtime when spawning a network (e.g.: supported args for a specific node version).

§Example

use zombienet_configuration::NetworkConfigBuilder;

let simple_configuration = NetworkConfigBuilder::new()
    .with_relaychain(|relaychain| {
        relaychain
            .with_chain("polkadot")
            .with_random_nominators_count(10)
            .with_default_resources(|resources| {
                resources
                    .with_limit_cpu("1000m")
                    .with_request_memory("1Gi")
                    .with_request_cpu(100_000)
            })
            .with_validator(|node| node.with_name("node").with_command("command"))
            .with_validator(|node| node.with_name("node1").with_command("command"))
    })
    .with_parachain(|parachain| {
        parachain
            .with_id(1000)
            .with_chain("myparachain1")
            .with_initial_balance(100_000)
            .with_default_image("myimage:version")
            .with_collator(|collator| {
                collator
                    .with_name("collator1")
                    .with_command("command1")
                    .validator(true)
            })
    })
    .with_parachain(|parachain| {
        parachain
            .with_id(2000)
            .with_chain("myparachain2")
            .with_initial_balance(50_0000)
            .with_collator(|collator| {
                collator
                    .with_name("collator2")
                    .with_command("command2")
                    .validator(true)
            })
    })
    .with_hrmp_channel(|hrmp_channel1| {
        hrmp_channel1
            .with_sender(1)
            .with_recipient(2)
            .with_max_capacity(200)
            .with_max_message_size(500)
    })
    .with_hrmp_channel(|hrmp_channel2| {
        hrmp_channel2
            .with_sender(2)
            .with_recipient(1)
            .with_max_capacity(100)
            .with_max_message_size(250)
    })
    .with_global_settings(|global_settings| {
        global_settings
            .with_network_spawn_timeout(1200)
            .with_node_spawn_timeout(240)
    })
    .build();

assert!(simple_configuration.is_ok())

Re-exports§

pub use shared::node::NodeConfig;
pub use shared::types;
pub use shared::types::TransferedFile;
pub use json_patch;

Modules§

para_states
shared

Structs§

CustomProcess
A custom process to spawn next to the nodes: its command, args, env, injected_files, image (provider specific), named ports, resources (provider specific), and its lifecycle: ready_check, depends_on, one_shot and timeout.
CustomProcessBuilder
A custom process builder, used to build a CustomProcess declaratively with fields validation.
Dependency
Another custom process this one starts after. Written as a bare name ("postgres") or as { name = "init", condition = "..." }; without a condition the target’s natural one applies, see CustomProcess::natural_condition.
GlobalSettings
Global settings applied to an entire network.
GlobalSettingsBuilder
A global settings builder, used to build GlobalSettings declaratively with fields validation.
HrmpChannelConfig
HRMP channel configuration, with fine-grained configuration options.
HrmpChannelConfigBuilder
HRMP channel configuration builder, used to build an HrmpChannelConfig declaratively with fields validation.
JamAmount
An unsigned amount that also accepts "max" and numeric strings, so values above i64::MAX can be written in TOML.
JamBytes
Bytes, written as a 0x-prefixed hex string.
JamGenesisConfig
The genesis of a JAM chain built in process.
JamGenesisConfigBuilder
Builder for JamGenesisConfig.
JamGenesisPrivileges
Who holds the privileges at genesis. 0 is the bootstrap service.
JamGenesisService
A service as it exists at genesis.
JamGenesisServiceBuilder
Builder for JamGenesisService.
JamchainConfig
A JAM chain configuration
JamchainConfigBuilder
A relay chain configuration builder, used to build a JamchainConfig declaratively with fields validation.
NamedPort
A port a custom process listens on, by name.
NetworkConfig
A network configuration, composed of a relaychain (or a JAM chain), parachains and HRMP channels.
NetworkConfigBuilder
A network configuration builder, used to build a NetworkConfig declaratively with fields validation.
ObservabilityConfig
Configuration for the observability stack (Prometheus + Grafana)
ObservabilityConfigBuilder
Builder for ObservabilityConfig
ParachainConfig
A parachain configuration, composed of collators and fine-grained configuration options.
ParachainConfigBuilder
A parachain configuration builder, used to build a ParachainConfig declaratively with fields validation.
ProcessEnvVar
An environment variable of a custom process: a literal value, or on kubernetes a key of a Secret in the namespace, read by the pod itself.
ReadyCheck
How a custom process is known to be ready. tcp is a declared port name that must accept a connection; http is a declared port name and a path that must answer 2xx. On kubernetes the check is the pod’s readiness probe; elsewhere zombienet probes the port from where it runs. How long to wait is the process’s timeout.
RelaychainConfig
A relay chain configuration, composed of nodes and fine-grained configuration options.
RelaychainConfigBuilder
A relay chain configuration builder, used to build a RelaychainConfig declaratively with fields validation.

Enums§

Buildable
DependencyCondition
When a dependency counts as met, as docker-compose names them.
EnvValue
Where a ProcessEnvVar gets its value.
JamAuthorizer
An entry of a core’s authorization queue.
JamBalance
The starting balance of a service.
ReadyTarget
What a ReadyCheck probes, by declared port name.
RegistrationStrategy
The registration strategy that will be used for the parachain.

Constants§

JAM_BOOTSTRAP_SERVICE_ID
The id the bootstrap service is installed under.
MAX_TIMEOUT_SECS
The longest timeout accepted: a week, in seconds.

Type Aliases§

JamCoreIndex
Index of a JAM core.
JamServiceId
Id of a JAM service.