mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
config: share base config generator
This commit is contained in:
parent
ef5c59700d
commit
b9741f8d03
48
testing-framework/configs/src/topology/configs/base.rs
Normal file
48
testing-framework/configs/src/topology/configs/base.rs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
blend, bootstrap, bootstrap::SHORT_PROLONGED_BOOTSTRAP_PERIOD, consensus,
|
||||||
|
consensus::ConsensusParams, da, da::DaParams, network, network::NetworkParams,
|
||||||
|
wallet::WalletConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum BaseConfigError {
|
||||||
|
#[error(transparent)]
|
||||||
|
Da(#[from] da::DaConfigError),
|
||||||
|
#[error(transparent)]
|
||||||
|
Network(#[from] network::NetworkConfigError),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct BaseConfigs {
|
||||||
|
pub consensus_configs: Vec<consensus::GeneralConsensusConfig>,
|
||||||
|
pub bootstrap_configs: Vec<bootstrap::GeneralBootstrapConfig>,
|
||||||
|
pub da_configs: Vec<da::GeneralDaConfig>,
|
||||||
|
pub network_configs: Vec<network::GeneralNetworkConfig>,
|
||||||
|
pub blend_configs: Vec<blend::GeneralBlendConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build_base_configs(
|
||||||
|
ids: &[[u8; 32]],
|
||||||
|
consensus_params: &ConsensusParams,
|
||||||
|
da_params: &DaParams,
|
||||||
|
network_params: &NetworkParams,
|
||||||
|
wallet_config: &WalletConfig,
|
||||||
|
da_ports: &[u16],
|
||||||
|
blend_ports: &[u16],
|
||||||
|
) -> Result<BaseConfigs, BaseConfigError> {
|
||||||
|
Ok(BaseConfigs {
|
||||||
|
consensus_configs: consensus::create_consensus_configs(
|
||||||
|
ids,
|
||||||
|
consensus_params,
|
||||||
|
wallet_config,
|
||||||
|
),
|
||||||
|
bootstrap_configs: bootstrap::create_bootstrap_configs(
|
||||||
|
ids,
|
||||||
|
SHORT_PROLONGED_BOOTSTRAP_PERIOD,
|
||||||
|
),
|
||||||
|
da_configs: da::try_create_da_configs(ids, da_params, da_ports)?,
|
||||||
|
network_configs: network::create_network_configs(ids, network_params)?,
|
||||||
|
blend_configs: blend::create_blend_configs(ids, blend_ports),
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod base;
|
||||||
pub mod blend;
|
pub mod blend;
|
||||||
pub mod bootstrap;
|
pub mod bootstrap;
|
||||||
pub mod consensus;
|
pub mod consensus;
|
||||||
|
|||||||
@ -8,14 +8,10 @@ use nomos_da_network_core::swarm::DAConnectionPolicySettings;
|
|||||||
use testing_framework_config::topology::{
|
use testing_framework_config::topology::{
|
||||||
configs::{
|
configs::{
|
||||||
api::create_api_configs,
|
api::create_api_configs,
|
||||||
blend::create_blend_configs,
|
base::{BaseConfigs, build_base_configs},
|
||||||
bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs},
|
consensus::{ConsensusParams, ProviderInfo, create_genesis_tx_with_declarations},
|
||||||
consensus::{
|
da::DaParams,
|
||||||
ConsensusParams, ProviderInfo, create_consensus_configs,
|
network::{Libp2pNetworkLayout, NetworkParams},
|
||||||
create_genesis_tx_with_declarations,
|
|
||||||
},
|
|
||||||
da::{DaParams, try_create_da_configs},
|
|
||||||
network::{Libp2pNetworkLayout, NetworkParams, create_network_configs},
|
|
||||||
tracing::create_tracing_configs,
|
tracing::create_tracing_configs,
|
||||||
wallet::WalletConfig,
|
wallet::WalletConfig,
|
||||||
},
|
},
|
||||||
@ -264,14 +260,22 @@ impl TopologyBuilder {
|
|||||||
validate_generated_vectors(n_participants, &ids, &da_ports, &blend_ports)
|
validate_generated_vectors(n_participants, &ids, &da_ports, &blend_ports)
|
||||||
.expect("invalid generated topology inputs");
|
.expect("invalid generated topology inputs");
|
||||||
|
|
||||||
let mut consensus_configs =
|
let BaseConfigs {
|
||||||
create_consensus_configs(&ids, &config.consensus_params, &config.wallet_config);
|
mut consensus_configs,
|
||||||
let bootstrapping_config = create_bootstrap_configs(&ids, SHORT_PROLONGED_BOOTSTRAP_PERIOD);
|
bootstrap_configs: bootstrapping_config,
|
||||||
let da_configs = try_create_da_configs(&ids, &config.da_params, &da_ports)
|
da_configs,
|
||||||
.expect("failed to create DA configs");
|
network_configs,
|
||||||
let network_configs = create_network_configs(&ids, &config.network_params)
|
blend_configs,
|
||||||
.expect("failed to create network configs");
|
} = build_base_configs(
|
||||||
let blend_configs = create_blend_configs(&ids, &blend_ports);
|
&ids,
|
||||||
|
&config.consensus_params,
|
||||||
|
&config.da_params,
|
||||||
|
&config.network_params,
|
||||||
|
&config.wallet_config,
|
||||||
|
&da_ports,
|
||||||
|
&blend_ports,
|
||||||
|
)
|
||||||
|
.expect("failed to build base configs");
|
||||||
let api_configs = create_api_configs(&ids).expect("failed to create API configs");
|
let api_configs = create_api_configs(&ids).expect("failed to create API configs");
|
||||||
let tracing_configs = create_tracing_configs(&ids);
|
let tracing_configs = create_tracing_configs(&ids);
|
||||||
let time_config = default_time_config();
|
let time_config = default_time_config();
|
||||||
|
|||||||
@ -8,16 +8,10 @@ use rand::{Rng as _, thread_rng};
|
|||||||
use testing_framework_config::topology::configs::{
|
use testing_framework_config::topology::configs::{
|
||||||
GeneralConfig,
|
GeneralConfig,
|
||||||
api::GeneralApiConfig,
|
api::GeneralApiConfig,
|
||||||
blend,
|
base::{BaseConfigError, BaseConfigs, build_base_configs},
|
||||||
blend::create_blend_configs,
|
consensus::{ConsensusParams, create_genesis_tx_with_declarations},
|
||||||
bootstrap,
|
da::DaParams,
|
||||||
bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs},
|
network::NetworkParams,
|
||||||
consensus,
|
|
||||||
consensus::{ConsensusParams, create_consensus_configs, create_genesis_tx_with_declarations},
|
|
||||||
da,
|
|
||||||
da::{DaParams, try_create_da_configs},
|
|
||||||
network,
|
|
||||||
network::{NetworkParams, create_network_configs},
|
|
||||||
time::default_time_config,
|
time::default_time_config,
|
||||||
wallet::WalletConfig,
|
wallet::WalletConfig,
|
||||||
};
|
};
|
||||||
@ -65,9 +59,7 @@ pub enum NodeConfigBuildError {
|
|||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Providers(#[from] ProviderBuildError),
|
Providers(#[from] ProviderBuildError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Da(#[from] da::DaConfigError),
|
Base(#[from] BaseConfigError),
|
||||||
#[error(transparent)]
|
|
||||||
Network(#[from] network::NetworkConfigError),
|
|
||||||
#[error("failed to allocate an available UDP port")]
|
#[error("failed to allocate an available UDP port")]
|
||||||
PortAllocFailed,
|
PortAllocFailed,
|
||||||
#[error("failed to parse multiaddr '{value}': {message}")]
|
#[error("failed to parse multiaddr '{value}': {message}")]
|
||||||
@ -116,10 +108,11 @@ pub fn try_create_node_configs(
|
|||||||
network_configs,
|
network_configs,
|
||||||
blend_configs,
|
blend_configs,
|
||||||
} = build_base_configs(
|
} = build_base_configs(
|
||||||
|
&ids,
|
||||||
consensus_params,
|
consensus_params,
|
||||||
da_params,
|
da_params,
|
||||||
|
&NetworkParams::default(),
|
||||||
wallet_config,
|
wallet_config,
|
||||||
&ids,
|
|
||||||
&ports,
|
&ports,
|
||||||
&blend_ports,
|
&blend_ports,
|
||||||
)?;
|
)?;
|
||||||
@ -261,23 +254,6 @@ fn resolve_blend_ports(hosts: &[Host], blend_ports: Option<Vec<u16>>) -> Vec<u16
|
|||||||
blend_ports.unwrap_or_else(|| hosts.iter().map(|h| h.blend_port).collect())
|
blend_ports.unwrap_or_else(|| hosts.iter().map(|h| h.blend_port).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_base_configs(
|
|
||||||
consensus_params: &ConsensusParams,
|
|
||||||
da_params: &DaParams,
|
|
||||||
wallet_config: &WalletConfig,
|
|
||||||
ids: &[[u8; 32]],
|
|
||||||
da_ports: &[u16],
|
|
||||||
blend_ports: &[u16],
|
|
||||||
) -> Result<BaseConfigs, NodeConfigBuildError> {
|
|
||||||
Ok(BaseConfigs {
|
|
||||||
consensus_configs: create_consensus_configs(ids, consensus_params, wallet_config),
|
|
||||||
bootstrap_configs: create_bootstrap_configs(ids, SHORT_PROLONGED_BOOTSTRAP_PERIOD),
|
|
||||||
da_configs: try_create_da_configs(ids, da_params, da_ports)?,
|
|
||||||
network_configs: create_network_configs(ids, &NetworkParams::default())?,
|
|
||||||
blend_configs: create_blend_configs(ids, blend_ports),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_api_configs(hosts: &[Host]) -> Result<Vec<GeneralApiConfig>, NodeConfigBuildError> {
|
fn build_api_configs(hosts: &[Host]) -> Result<Vec<GeneralApiConfig>, NodeConfigBuildError> {
|
||||||
hosts
|
hosts
|
||||||
.iter()
|
.iter()
|
||||||
@ -314,11 +290,3 @@ fn build_peer_ids(ids: &[[u8; 32]]) -> Result<Vec<PeerId>, NodeConfigBuildError>
|
|||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BaseConfigs {
|
|
||||||
consensus_configs: Vec<consensus::GeneralConsensusConfig>,
|
|
||||||
bootstrap_configs: Vec<bootstrap::GeneralBootstrapConfig>,
|
|
||||||
da_configs: Vec<da::GeneralDaConfig>,
|
|
||||||
network_configs: Vec<network::GeneralNetworkConfig>,
|
|
||||||
blend_configs: Vec<blend::GeneralBlendConfig>,
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user