mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 05:13:09 +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 base;
|
||||
pub mod blend;
|
||||
pub mod bootstrap;
|
||||
pub mod consensus;
|
||||
|
||||
@ -8,14 +8,10 @@ use nomos_da_network_core::swarm::DAConnectionPolicySettings;
|
||||
use testing_framework_config::topology::{
|
||||
configs::{
|
||||
api::create_api_configs,
|
||||
blend::create_blend_configs,
|
||||
bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs},
|
||||
consensus::{
|
||||
ConsensusParams, ProviderInfo, create_consensus_configs,
|
||||
create_genesis_tx_with_declarations,
|
||||
},
|
||||
da::{DaParams, try_create_da_configs},
|
||||
network::{Libp2pNetworkLayout, NetworkParams, create_network_configs},
|
||||
base::{BaseConfigs, build_base_configs},
|
||||
consensus::{ConsensusParams, ProviderInfo, create_genesis_tx_with_declarations},
|
||||
da::DaParams,
|
||||
network::{Libp2pNetworkLayout, NetworkParams},
|
||||
tracing::create_tracing_configs,
|
||||
wallet::WalletConfig,
|
||||
},
|
||||
@ -264,14 +260,22 @@ impl TopologyBuilder {
|
||||
validate_generated_vectors(n_participants, &ids, &da_ports, &blend_ports)
|
||||
.expect("invalid generated topology inputs");
|
||||
|
||||
let mut consensus_configs =
|
||||
create_consensus_configs(&ids, &config.consensus_params, &config.wallet_config);
|
||||
let bootstrapping_config = create_bootstrap_configs(&ids, SHORT_PROLONGED_BOOTSTRAP_PERIOD);
|
||||
let da_configs = try_create_da_configs(&ids, &config.da_params, &da_ports)
|
||||
.expect("failed to create DA configs");
|
||||
let network_configs = create_network_configs(&ids, &config.network_params)
|
||||
.expect("failed to create network configs");
|
||||
let blend_configs = create_blend_configs(&ids, &blend_ports);
|
||||
let BaseConfigs {
|
||||
mut consensus_configs,
|
||||
bootstrap_configs: bootstrapping_config,
|
||||
da_configs,
|
||||
network_configs,
|
||||
blend_configs,
|
||||
} = build_base_configs(
|
||||
&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 tracing_configs = create_tracing_configs(&ids);
|
||||
let time_config = default_time_config();
|
||||
|
||||
@ -8,16 +8,10 @@ use rand::{Rng as _, thread_rng};
|
||||
use testing_framework_config::topology::configs::{
|
||||
GeneralConfig,
|
||||
api::GeneralApiConfig,
|
||||
blend,
|
||||
blend::create_blend_configs,
|
||||
bootstrap,
|
||||
bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs},
|
||||
consensus,
|
||||
consensus::{ConsensusParams, create_consensus_configs, create_genesis_tx_with_declarations},
|
||||
da,
|
||||
da::{DaParams, try_create_da_configs},
|
||||
network,
|
||||
network::{NetworkParams, create_network_configs},
|
||||
base::{BaseConfigError, BaseConfigs, build_base_configs},
|
||||
consensus::{ConsensusParams, create_genesis_tx_with_declarations},
|
||||
da::DaParams,
|
||||
network::NetworkParams,
|
||||
time::default_time_config,
|
||||
wallet::WalletConfig,
|
||||
};
|
||||
@ -65,9 +59,7 @@ pub enum NodeConfigBuildError {
|
||||
#[error(transparent)]
|
||||
Providers(#[from] ProviderBuildError),
|
||||
#[error(transparent)]
|
||||
Da(#[from] da::DaConfigError),
|
||||
#[error(transparent)]
|
||||
Network(#[from] network::NetworkConfigError),
|
||||
Base(#[from] BaseConfigError),
|
||||
#[error("failed to allocate an available UDP port")]
|
||||
PortAllocFailed,
|
||||
#[error("failed to parse multiaddr '{value}': {message}")]
|
||||
@ -116,10 +108,11 @@ pub fn try_create_node_configs(
|
||||
network_configs,
|
||||
blend_configs,
|
||||
} = build_base_configs(
|
||||
&ids,
|
||||
consensus_params,
|
||||
da_params,
|
||||
&NetworkParams::default(),
|
||||
wallet_config,
|
||||
&ids,
|
||||
&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())
|
||||
}
|
||||
|
||||
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> {
|
||||
hosts
|
||||
.iter()
|
||||
@ -314,11 +290,3 @@ fn build_peer_ids(ids: &[[u8; 32]]) -> Result<Vec<PeerId>, NodeConfigBuildError>
|
||||
})
|
||||
.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