From d6f9f000431731b261c51943fa7d9a1c2b4d8a54 Mon Sep 17 00:00:00 2001 From: andrussal Date: Wed, 10 Dec 2025 09:26:11 +0100 Subject: [PATCH] Extract cfgsync KMS config helper --- testing-framework/tools/cfgsync/src/config.rs | 48 ++----------------- .../tools/cfgsync/src/config/kms.rs | 41 ++++++++++++++++ 2 files changed, 45 insertions(+), 44 deletions(-) create mode 100644 testing-framework/tools/cfgsync/src/config/kms.rs diff --git a/testing-framework/tools/cfgsync/src/config.rs b/testing-framework/tools/cfgsync/src/config.rs index 2c991ff..ba93be9 100644 --- a/testing-framework/tools/cfgsync/src/config.rs +++ b/testing-framework/tools/cfgsync/src/config.rs @@ -1,11 +1,5 @@ use std::{collections::HashMap, net::Ipv4Addr, str::FromStr as _}; -use groth16::fr_to_bytes; -use hex; -use key_management_system_service::{ - backend::preload::PreloadKMSBackendSettings, - keys::{Ed25519Key, Key, ZkKey}, -}; use nomos_core::mantle::GenesisTx as _; use nomos_libp2p::{Multiaddr, PeerId, ed25519}; use nomos_tracing_service::{LoggerLayer, MetricsLayer, TracingLayer, TracingSettings}; @@ -14,10 +8,10 @@ use rand::{Rng as _, thread_rng}; use testing_framework_config::topology::configs::{ GeneralConfig, api::GeneralApiConfig, - blend::{GeneralBlendConfig, create_blend_configs}, + blend::create_blend_configs, bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs}, consensus::{ConsensusParams, create_consensus_configs, create_genesis_tx_with_declarations}, - da::{DaParams, GeneralDaConfig, create_da_configs}, + da::{DaParams, create_da_configs}, network::{NetworkParams, create_network_configs}, time::default_time_config, tracing::GeneralTracingConfig, @@ -26,10 +20,11 @@ use testing_framework_config::topology::configs::{ pub use crate::host::{Host, HostKind, PortOverrides}; use crate::{ - config::{providers::create_providers, validation::validate_inputs}, + config::{kms::create_kms_configs, providers::create_providers, validation::validate_inputs}, host::sort_hosts, network::rewrite_initial_peers, }; +mod kms; mod providers; mod validation; @@ -221,41 +216,6 @@ fn update_tracing_identifier( } } -fn create_kms_configs( - blend_configs: &[GeneralBlendConfig], - da_configs: &[GeneralDaConfig], -) -> Vec { - da_configs - .iter() - .zip(blend_configs.iter()) - .map(|(da_conf, blend_conf)| PreloadKMSBackendSettings { - keys: [ - ( - hex::encode(blend_conf.signer.verifying_key().as_bytes()), - Key::Ed25519(Ed25519Key::new(blend_conf.signer.clone())), - ), - ( - hex::encode(fr_to_bytes( - &blend_conf.secret_zk_key.to_public_key().into_inner(), - )), - Key::Zk(ZkKey::new(blend_conf.secret_zk_key.clone())), - ), - ( - hex::encode(da_conf.signer.verifying_key().as_bytes()), - Key::Ed25519(Ed25519Key::new(da_conf.signer.clone())), - ), - ( - hex::encode(fr_to_bytes( - &da_conf.secret_zk_key.to_public_key().into_inner(), - )), - Key::Zk(ZkKey::new(da_conf.secret_zk_key.clone())), - ), - ] - .into(), - }) - .collect() -} - #[cfg(test)] mod cfgsync_tests { use std::{net::Ipv4Addr, num::NonZero, str::FromStr as _, time::Duration}; diff --git a/testing-framework/tools/cfgsync/src/config/kms.rs b/testing-framework/tools/cfgsync/src/config/kms.rs new file mode 100644 index 0000000..b5924f8 --- /dev/null +++ b/testing-framework/tools/cfgsync/src/config/kms.rs @@ -0,0 +1,41 @@ +use groth16::fr_to_bytes; +use key_management_system_service::{ + backend::preload::PreloadKMSBackendSettings, + keys::{Ed25519Key, Key, ZkKey}, +}; +use testing_framework_config::topology::configs::{blend::GeneralBlendConfig, da::GeneralDaConfig}; + +pub fn create_kms_configs( + blend_configs: &[GeneralBlendConfig], + da_configs: &[GeneralDaConfig], +) -> Vec { + da_configs + .iter() + .zip(blend_configs.iter()) + .map(|(da_conf, blend_conf)| PreloadKMSBackendSettings { + keys: [ + ( + hex::encode(blend_conf.signer.verifying_key().as_bytes()), + Key::Ed25519(Ed25519Key::new(blend_conf.signer.clone())), + ), + ( + hex::encode(fr_to_bytes( + &blend_conf.secret_zk_key.to_public_key().into_inner(), + )), + Key::Zk(ZkKey::new(blend_conf.secret_zk_key.clone())), + ), + ( + hex::encode(da_conf.signer.verifying_key().as_bytes()), + Key::Ed25519(Ed25519Key::new(da_conf.signer.clone())), + ), + ( + hex::encode(fr_to_bytes( + &da_conf.secret_zk_key.to_public_key().into_inner(), + )), + Key::Zk(ZkKey::new(da_conf.secret_zk_key.clone())), + ), + ] + .into(), + }) + .collect() +}