2025-12-09 06:30:18 +01:00
|
|
|
use std::{collections::HashSet, num::NonZeroUsize, path::PathBuf, time::Duration};
|
|
|
|
|
|
|
|
|
|
use chain_leader::LeaderConfig as ChainLeaderConfig;
|
|
|
|
|
use chain_network::{BootstrapConfig as ChainBootstrapConfig, OrphanConfig, SyncConfig};
|
|
|
|
|
use chain_service::StartingState;
|
2025-12-09 09:43:49 +01:00
|
|
|
use nomos_api::ApiServiceSettings;
|
|
|
|
|
use nomos_node::{
|
|
|
|
|
api::backend::AxumBackendSettings as NodeAxumBackendSettings,
|
|
|
|
|
config::{
|
|
|
|
|
cryptarchia::{
|
|
|
|
|
deployment::{
|
|
|
|
|
SdpConfig as DeploymentSdpConfig, Settings as CryptarchiaDeploymentSettings,
|
|
|
|
|
},
|
|
|
|
|
serde::{
|
2025-12-13 05:59:28 +01:00
|
|
|
Config as CryptarchiaConfig, NetworkConfig as CryptarchiaNetworkConfig,
|
2025-12-09 09:43:49 +01:00
|
|
|
ServiceConfig as CryptarchiaServiceConfig,
|
|
|
|
|
},
|
2025-12-09 06:30:18 +01:00
|
|
|
},
|
2025-12-09 09:43:49 +01:00
|
|
|
mempool::deployment::Settings as MempoolDeploymentSettings,
|
|
|
|
|
time::{deployment::Settings as TimeDeploymentSettings, serde::Config as TimeConfig},
|
2025-12-09 06:30:18 +01:00
|
|
|
},
|
|
|
|
|
};
|
2025-12-09 09:43:49 +01:00
|
|
|
use nomos_wallet::WalletServiceSettings;
|
2025-12-09 06:30:18 +01:00
|
|
|
|
2026-01-23 09:28:00 +02:00
|
|
|
use crate::{timeouts, topology::configs::GeneralConfig};
|
2025-12-09 06:30:18 +01:00
|
|
|
|
2025-12-15 22:29:36 +01:00
|
|
|
// Configuration constants
|
|
|
|
|
const CRYPTARCHIA_GOSSIPSUB_PROTOCOL: &str = "/cryptarchia/proto";
|
|
|
|
|
const MEMPOOL_PUBSUB_TOPIC: &str = "mantle";
|
|
|
|
|
const STATE_RECORDING_INTERVAL_SECS: u64 = 60;
|
|
|
|
|
const IBD_DOWNLOAD_DELAY_SECS: u64 = 10;
|
2025-12-18 22:14:55 +01:00
|
|
|
const MAX_ORPHAN_CACHE_SIZE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(5) };
|
2025-12-15 22:29:36 +01:00
|
|
|
const API_RATE_LIMIT_PER_SECOND: u64 = 10000;
|
|
|
|
|
const API_RATE_LIMIT_BURST: u32 = 10000;
|
|
|
|
|
const API_MAX_CONCURRENT_REQUESTS: usize = 1000;
|
|
|
|
|
|
2025-12-09 06:30:18 +01:00
|
|
|
pub(crate) fn cryptarchia_deployment(config: &GeneralConfig) -> CryptarchiaDeploymentSettings {
|
|
|
|
|
CryptarchiaDeploymentSettings {
|
|
|
|
|
epoch_config: config.consensus_config.ledger_config.epoch_config,
|
|
|
|
|
consensus_config: config.consensus_config.ledger_config.consensus_config,
|
|
|
|
|
sdp_config: DeploymentSdpConfig {
|
|
|
|
|
service_params: config
|
|
|
|
|
.consensus_config
|
|
|
|
|
.ledger_config
|
|
|
|
|
.sdp_config
|
|
|
|
|
.service_params
|
|
|
|
|
.clone(),
|
|
|
|
|
min_stake: config.consensus_config.ledger_config.sdp_config.min_stake,
|
|
|
|
|
},
|
2025-12-15 22:29:36 +01:00
|
|
|
gossipsub_protocol: CRYPTARCHIA_GOSSIPSUB_PROTOCOL.to_owned(),
|
2025-12-09 06:30:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn time_deployment(config: &GeneralConfig) -> TimeDeploymentSettings {
|
|
|
|
|
TimeDeploymentSettings {
|
|
|
|
|
slot_duration: config.time_config.slot_duration,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn mempool_deployment() -> MempoolDeploymentSettings {
|
|
|
|
|
MempoolDeploymentSettings {
|
2025-12-15 22:29:36 +01:00
|
|
|
pubsub_topic: MEMPOOL_PUBSUB_TOPIC.to_owned(),
|
2025-12-09 06:30:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn cryptarchia_config(config: &GeneralConfig) -> CryptarchiaConfig {
|
|
|
|
|
CryptarchiaConfig {
|
|
|
|
|
service: CryptarchiaServiceConfig {
|
|
|
|
|
starting_state: StartingState::Genesis {
|
|
|
|
|
genesis_tx: config.consensus_config.genesis_tx.clone(),
|
|
|
|
|
},
|
|
|
|
|
// Disable on-disk recovery in compose tests to avoid serde errors on
|
|
|
|
|
// non-string keys and keep services alive.
|
|
|
|
|
recovery_file: PathBuf::new(),
|
|
|
|
|
bootstrap: chain_service::BootstrapConfig {
|
|
|
|
|
prolonged_bootstrap_period: config.bootstrapping_config.prolonged_bootstrap_period,
|
|
|
|
|
force_bootstrap: false,
|
|
|
|
|
offline_grace_period: chain_service::OfflineGracePeriodConfig {
|
2025-12-09 17:45:10 +01:00
|
|
|
grace_period: timeouts::grace_period(),
|
2025-12-15 22:29:36 +01:00
|
|
|
state_recording_interval: Duration::from_secs(STATE_RECORDING_INTERVAL_SECS),
|
2025-12-09 06:30:18 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
network: CryptarchiaNetworkConfig {
|
|
|
|
|
bootstrap: ChainBootstrapConfig {
|
|
|
|
|
ibd: chain_network::IbdConfig {
|
|
|
|
|
peers: HashSet::new(),
|
2025-12-15 22:29:36 +01:00
|
|
|
delay_before_new_download: Duration::from_secs(IBD_DOWNLOAD_DELAY_SECS),
|
2025-12-09 06:30:18 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
sync: SyncConfig {
|
|
|
|
|
orphan: OrphanConfig {
|
2025-12-18 22:14:55 +01:00
|
|
|
max_orphan_cache_size: MAX_ORPHAN_CACHE_SIZE,
|
2025-12-09 06:30:18 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-12-13 05:59:28 +01:00
|
|
|
leader: ChainLeaderConfig {
|
|
|
|
|
pk: config.consensus_config.leader_config.pk,
|
|
|
|
|
sk: config.consensus_config.leader_config.sk.clone(),
|
2025-12-09 06:30:18 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-09 09:43:49 +01:00
|
|
|
|
|
|
|
|
pub(crate) fn time_config(config: &GeneralConfig) -> TimeConfig {
|
|
|
|
|
TimeConfig {
|
|
|
|
|
backend: nomos_time::backends::NtpTimeBackendSettings {
|
|
|
|
|
ntp_server: config.time_config.ntp_server.clone(),
|
|
|
|
|
ntp_client_settings: nomos_time::backends::ntp::async_client::NTPClientSettings {
|
|
|
|
|
timeout: config.time_config.timeout,
|
|
|
|
|
listening_interface: config.time_config.interface.clone(),
|
|
|
|
|
},
|
|
|
|
|
update_interval: config.time_config.update_interval,
|
|
|
|
|
},
|
|
|
|
|
chain_start_time: config.time_config.chain_start_time,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn mempool_config() -> nomos_node::config::mempool::serde::Config {
|
|
|
|
|
nomos_node::config::mempool::serde::Config {
|
|
|
|
|
// Disable mempool recovery for hermetic tests.
|
|
|
|
|
recovery_path: PathBuf::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn tracing_settings(config: &GeneralConfig) -> nomos_tracing_service::TracingSettings {
|
|
|
|
|
config.tracing_config.tracing_settings.clone()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn http_config(config: &GeneralConfig) -> ApiServiceSettings<NodeAxumBackendSettings> {
|
|
|
|
|
ApiServiceSettings {
|
|
|
|
|
backend_settings: NodeAxumBackendSettings {
|
|
|
|
|
address: config.api_config.address,
|
2025-12-15 22:29:36 +01:00
|
|
|
rate_limit_per_second: API_RATE_LIMIT_PER_SECOND,
|
|
|
|
|
rate_limit_burst: API_RATE_LIMIT_BURST,
|
|
|
|
|
max_concurrent_requests: API_MAX_CONCURRENT_REQUESTS,
|
2025-12-09 09:43:49 +01:00
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn testing_http_config(
|
|
|
|
|
config: &GeneralConfig,
|
|
|
|
|
) -> ApiServiceSettings<NodeAxumBackendSettings> {
|
|
|
|
|
ApiServiceSettings {
|
|
|
|
|
backend_settings: NodeAxumBackendSettings {
|
|
|
|
|
address: config.api_config.testing_http_address,
|
2025-12-15 22:29:36 +01:00
|
|
|
rate_limit_per_second: API_RATE_LIMIT_PER_SECOND,
|
|
|
|
|
rate_limit_burst: API_RATE_LIMIT_BURST,
|
|
|
|
|
max_concurrent_requests: API_MAX_CONCURRENT_REQUESTS,
|
2025-12-09 09:43:49 +01:00
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn wallet_settings(config: &GeneralConfig) -> WalletServiceSettings {
|
2026-01-22 05:57:59 +01:00
|
|
|
wallet_settings_with_leader(config, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn wallet_settings_with_leader(
|
|
|
|
|
config: &GeneralConfig,
|
|
|
|
|
include_leader: bool,
|
|
|
|
|
) -> WalletServiceSettings {
|
|
|
|
|
let mut keys = HashSet::new();
|
|
|
|
|
|
|
|
|
|
if include_leader {
|
|
|
|
|
keys.insert(config.consensus_config.leader_config.pk);
|
2025-12-09 09:43:49 +01:00
|
|
|
}
|
2026-01-22 05:57:59 +01:00
|
|
|
|
|
|
|
|
keys.extend(
|
|
|
|
|
config
|
|
|
|
|
.consensus_config
|
|
|
|
|
.wallet_accounts
|
|
|
|
|
.iter()
|
|
|
|
|
.map(crate::topology::configs::wallet::WalletAccount::public_key),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
WalletServiceSettings { known_keys: keys }
|
2025-12-09 09:43:49 +01:00
|
|
|
}
|